chiark / gitweb /
Provide --no-cargo-lock-manip option
[nailing-cargo.git] / nailing-cargo
index 722b6d803c7035f3190710f63163e96dab8919fe..5d92b037117ee430e2c03b23cfda3e2da4010c27 100755 (executable)
@@ -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<subcommand>                  Treat command as `cargo <subcommand>`
   --subcommand-props=<prop>,...   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$}) {