From: Ian Jackson Date: Sun, 13 Sep 2020 23:19:05 +0000 (+0100) Subject: Provide --no-cargo-lock-manip option X-Git-Tag: nailing-cargo/1.0.0~57 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=21f1732ad12380163db86dd5ba0ab0c7fb134fb2;p=nailing-cargo.git Provide --no-cargo-lock-manip option And clarify docs etc. Signed-off-by: Ian Jackson --- diff --git a/README.md b/README.md index bf80419..46086ed 100644 --- a/README.md +++ b/README.md @@ -385,11 +385,18 @@ Options commands that don't actually invoke cargo. Consider passingm `--no-lock` too. + * `--no-cargo-lock-manip` | `--cargo-lock-manip` (default): + Whether to manipulate `Cargo.lock`. For example, whether to copy + it to the build tree and back (in out of tree mode) and whether to + rename it from an alternative lockfile name, and put it back. + Overrides `-u` etc. + * `--no-lock` | `--lock` (default): Whether to take the nailing-cargo lock. Some kind of protection against concurrent operation is necessary to prevent multiple instances of nailing-cargo trashing each others' work, and possibly mangling - your `Cargo.toml`s. + your `Cargo.toml`s, `Cargo.lock`, etc., so `--no-lock` is dangerous + unless you take other measures against concurrent execution. * `-h` | `--help`: Print usage summary. diff --git a/nailing-cargo b/nailing-cargo index 722b6d8..5d92b03 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -29,7 +29,8 @@ options: --leave-nailed Leave the nailed Cargo.toml in place --just-linkfarm | --clean-linkfarm | --keep-linkfarm (default) --no-nail Do not nail, just run the command. - --no-lock Do not take the lock. + --no-cargo-lock-manip Do not manipulate Cargo.lock. + --no-lock Do not take the concurrency lock. -s Treat command as `cargo ` --subcommand-props=,... Override command props (see docs) @@ -93,6 +94,7 @@ our $just_linkfarm; our $leave_nailed; our $oot_clean; our $do_nail=1; +our $do_cargo_lock=1; our $do_lock=1; # @@ -320,6 +322,8 @@ sub consider_alt_cargo_lock () { # User should *either* have Cargo.lock in .gitignore, # or expect to commit Cargo.lock.example ($alt_cargo_lock) + return unless $do_cargo_lock; + $alt_cargo_lock = (cfg_uc @ck); my $force = 0; @@ -614,7 +618,7 @@ sub oot_massage_cmdline () { clean () { find -lname "$1/*" -print0 | xargs -0r rm --; }; clean; find "$1" -maxdepth 1 \! -name Cargo.lock -print0 | xargs -0r -I_ ln -sf -- _ .; END - $pre .= <<'ENDLK' if stat_exists 'Cargo.lock', 'working cargo lockfile'; + $pre .= <<'ENDLK' if $do_cargo_lock && stat_exists 'Cargo.lock', 'working cargo lockfile'; rm -f Cargo.lock; cp -- "$1"/Cargo.lock .; ENDLK @@ -728,6 +732,7 @@ sub makebackups () { } if (defined($alt_cargo_lock)) { + die 'internal error' unless $do_cargo_lock; if (@alt_cargo_lock_stat) { print STDERR "$self: using alt_cargo_lock `$alt_cargo_lock'..." if $verbose>=3; @@ -819,7 +824,7 @@ sub invoke () { } sub cargo_lock_update_after () { - if ($cargo_lock_update && !$just_linkfarm) { + if ($do_cargo_lock && $cargo_lock_update && !$just_linkfarm) { # avoids importing File::Copy and the error handling is about as good $!=0; $?=0; my $r= system qw(cp --), "$build_absdir/Cargo.lock", "Cargo.lock"; @@ -838,7 +843,7 @@ sub uninstall1 ($$) { sub unaltcargolock ($) { my ($enoentok) = @_; return unless $cleanup_cargo_lock; - die 'internal error!' unless defined $alt_cargo_lock; + die 'internal error!' unless $do_cargo_lock && defined $alt_cargo_lock; # we ignore $enoentok because we don't know if one was supposed to # have been created. @@ -948,6 +953,8 @@ sub parse_args () { $oot_clean = $1 eq 'clean'; } elsif (m{^--(no)?-nail$}) { $do_nail = !$1; + } elsif (m{^--(no)?-cargo-lock-manip$}) { + $do_cargo_lock = !$1; } elsif (m{^--(no)?-lock$}) { $do_lock = !$1; } elsif (m{^--leave-nailed$}) {