3 # nailing-cargo: wrapper to use unpublished local crates
5 # Copyright (C) 2019 Ian Jackson
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # ../nailing-cargo/nailing-cargo make
24 # ../nailing-cargo/nailing-cargo cargo build
25 # CARGO='../nailing-cargo/nailing-cargo cargo' make
28 # Why do we need this ?
30 # https://github.com/rust-lang/cargo/issues/6713
31 # https://stackoverflow.com/questions/33025887/how-to-use-a-local-unpublished-crate
32 # https://github.com/rust-lang/cargo/issues/1481
35 lock=${PWD%/*}/.nail.lock
36 if [ "x$NAILING_CARGO" != "x$lock" ]; then
38 exec with-lock-ex -w "$lock" "$0" "$@"
41 exec 203<../Cargo.nail
45 /^ *\[dependencies\]/,/^ \[/{
48 if test -e ../Cargo.nail-env; then
52 exec 204<../Cargo.nail
53 while read <&204 what where; do
54 if [ "x$what" = x- ]; then continue; fi
55 if [ "x$what" = 'x#' ]; then continue; fi
56 qwhere="${where//\//\\/}"
59 s/^'$what' *= *\(\".*\"\) *$/'$what' = { version = \1 }/;
60 s#^'$what' *= *{#'$what' = { path = "'"${PWD%/*}"'/'"${qwhere}"'", #;
61 /^'$what' *=/ s/version *= *\"[^"]*\"//;
62 /^'$what' *=/ s/, *\([,}]\)/\1/;
68 exec 204<../Cargo.nail
69 while read <&204 what where; do
70 if [ "x$what" = 'x#' ]; then continue; fi
73 sed <$wf >$wf.nailing~ "$sed"
76 exec 204<../Cargo.nail
77 while read <&204 what where; do
78 if [ "x$what" = 'x#' ]; then continue; fi
80 if ! test -e $wf.unnailed~; then
87 while read <&203 what where; do
88 if [ "x$what" = "x#" ]; then continue; fi
90 if test -e $wf.unnailed~; then
93 mv -f $wf.unnailed~ $wf
99 exec 204<../Cargo.nail
101 while read <&204 what where; do
102 if [ "x$what" = 'x#' ]; then continue; fi
104 printf >&2 ' %s' "$what"
105 if cmp -s $wf.nailed~ $wf.nailing~; then
106 mv -f $wf.nailed~ $wf
109 mv -f $wf.nailing~ $wf