From: Ian Jackson Date: Sat, 12 Sep 2020 11:32:18 +0000 (+0100) Subject: Provide --no-lock option X-Git-Tag: nailing-cargo/1.0.0~59 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=bd7ad5914e7c2dbbd15c92691e6234242b707b2e;p=nailing-cargo.git Provide --no-lock option This will have a more common sane use case in a moment... Signed-off-by: Ian Jackson --- diff --git a/README.md b/README.md index 4798d40..fbba698 100644 --- a/README.md +++ b/README.md @@ -379,6 +379,12 @@ Options `.Cargo.toml.nailed~`, so you only need this if you want to run cargo by hand or something. + * `--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. + * `-h` | `--help`: Print usage summary. * `--man` | `--manual`: Format this manual into html using `pandoc` diff --git a/nailing-cargo b/nailing-cargo index cf13b6d..b2f1f8c 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -28,6 +28,7 @@ options: --man --manual Display complete manual (in w3m) --leave-nailed Leave the nailed Cargo.toml in place --just-linkfarm | --clean-linkfarm | --keep-linkfarm (default) + --no-lock Do not take the lock. -s Treat command as `cargo ` --subcommand-props=,... Override command props (see docs) @@ -90,6 +91,7 @@ our $online; our $just_linkfarm; our $leave_nailed; our $oot_clean; +our $do_lock=1; # our %subcmd_props = ( @@ -177,6 +179,8 @@ sub same_file ($$) { } sub takelock () { + return unless $do_lock; + for (;;) { open LOCK, ">", $lockfile or die "$self: open/create $lockfile: $!\n"; flock LOCK, LOCK_EX or die "$self: lock $lockfile: $!\n"; @@ -496,6 +500,8 @@ sub calculate () { print STDERR "$self: package $p in $packagemap{$p}[0]\n" if $verbose>=2; } foreach my $mf (keys %manifests) { + die "internal error" if $do_nail; # belt and braces + my ($toml, $mf_org_subdir) = @{ $manifests{$mf} }; foreach my $deps (get_dependency_tables $toml) { next unless $deps; @@ -934,6 +940,8 @@ sub parse_args () { $cargo_lock_update= 1; } elsif (m{^--(clean|keep)-linkfarm$}) { $oot_clean = $1 eq 'clean'; + } elsif (m{^--(no)?-lock$}) { + $do_lock = !$1; } elsif (m{^--leave-nailed$}) { $leave_nailed = 1; } elsif (s{^--subcommand-props=}{}) {