#!/bin/bash set -e # CARGO='../nailing-cargo/nailing-cargo cargo' make && make check CARGO='../nailing-cargo/nailing-cargo cargo' # Why do we need this ? # # https://stackoverflow.com/questions/33025887/how-to-use-a-local-unpublished-crate # https://github.com/rust-lang/cargo/issues/1481 lock=${PWD%/*}/.nail.lock if [ "x$NAILING_CARGO" != "x$lock" ]; then NAILING_CARGO=$lock \ exec with-lock-ex -w "$lock" "$0" "$@" fi exec 203<../Cargo.nail f=Cargo.toml sed=' /^ *\[dependencies\]/,/^ \[/{ ' exec 204<../Cargo.nail while read <&204 what where; do if [ "x$what" = x- ]; then continue; fi if [ "x$what" = 'x#' ]; then continue; fi qwhere="${where//\//\\/}" sed+=' s/^'$what' *= *\(\".*\"\) *$/'$what' = { version = \1 }/; s/^'$what' *= *{/'$what' = { path = "..\/'"${qwhere}"'", /; /^'$what' *=/ s/version *= *\"[^"]*\"//; /^'$what' *=/ s/, *\([,}]\)/\1/; ' done sed+='} ' exec 204<../Cargo.nail while read <&204 what where; do if [ "x$what" = 'x#' ]; then continue; fi wf=../$where/$f rm -f $wf.nailing~ sed <$wf >$wf.nailing~ "$sed" done exec 204<../Cargo.nail while read <&204 what where; do if [ "x$what" = 'x#' ]; then continue; fi wf=../$where/$f if ! test -e $wf.unnailed~; then ln $wf $wf.unnailed~ fi done trap ' set +e while read <&203 what where; do if [ "x$what" = "x#" ]; then continue; fi wf=../$where/$f if test -e $wf.unnailed~; then rm -f $wf.nailed~ ln $wf $wf.nailed~ mv -f $wf.unnailed~ $wf fi done echo >&2 'Unnailed' ' EXIT exec 204<../Cargo.nail printf >&2 'Nailing' while read <&204 what where; do if [ "x$what" = 'x#' ]; then continue; fi wf=../$where/$f printf >&2 ' %s' "$what" if cmp -s $wf.nailed~ $wf.nailing~; then mv -f $wf.nailed~ $wf rm -f $wf.nailing else mv -f $wf.nailing~ $wf rm -f $wf.nailed fi done echo >&2 "$@"