From f2732f971282346d0667f584f83fbbb310a85ceb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 12 Sep 2020 12:46:17 +0100 Subject: [PATCH] Provide --no-nail option Signed-off-by: Ian Jackson --- README.md | 6 ++++++ nailing-cargo | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fbba698..bf80419 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-nail` | `--nail` (default): Whether to actually nail - ie, + whether to actually modify any `Cargo.toml`s while running the + command. This can be useful, e.g., in out-of-tree mode with + commands that don't actually invoke cargo. Consider passingm + `--no-lock` too. + * `--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 diff --git a/nailing-cargo b/nailing-cargo index b2f1f8c..722b6d8 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-nail Do not nail, just run the command. --no-lock Do not take the lock. -s Treat command as `cargo ` @@ -91,6 +92,7 @@ our $online; our $just_linkfarm; our $leave_nailed; our $oot_clean; +our $do_nail=1; our $do_lock=1; # @@ -465,6 +467,10 @@ sub queue_referenced_path ($$$) { } sub readorigs () { + # We (and our callees) populate %packagemap and %manifest, so if we + # don't run, they remain empty and nothing is nailed. + return unless $do_nail; + foreach my $p (keys %{ $nail->{packages} }) { my $v = $nail->{packages}{$p}; my $subdir = ref($v) ? $v->{subdir} : $v; @@ -500,7 +506,7 @@ 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 + die "internal error" unless $do_nail; # belt and braces my ($toml, $mf_org_subdir) = @{ $manifests{$mf} }; foreach my $deps (get_dependency_tables $toml) { @@ -790,7 +796,7 @@ sub install () { print STDERR "$self: nailed $mf\n" if $verbose>=3; } - if (@our_unfound_stab) { + if (@our_unfound_stab && $do_nail) { print STDERR "$self: *WARNING* cwd is not in Cargo.nail thbough it has Cargo.toml!\n"; } @@ -940,6 +946,8 @@ sub parse_args () { $cargo_lock_update= 1; } elsif (m{^--(clean|keep)-linkfarm$}) { $oot_clean = $1 eq 'clean'; + } elsif (m{^--(no)?-nail$}) { + $do_nail = !$1; } elsif (m{^--(no)?-lock$}) { $do_lock = !$1; } elsif (m{^--leave-nailed$}) { @@ -1030,7 +1038,7 @@ install(); printf STDERR "$self: nailed (%s manifests, %s packages)%s\n", (scalar keys %manifests), (scalar keys %packagemap), (defined($alt_cargo_lock) and ", using `$alt_cargo_lock'") - if $verbose; + if $verbose && $do_nail; print STDERR "$self: invoking: @display_cmd\n" if $verbose; my $estatus = invoke(); @@ -1040,6 +1048,7 @@ cargo_lock_update_after(); uninstall() unless $leave_nailed; $want_uninstall = 0; -print STDERR "$self: unnailed. status $estatus.\n" if $verbose; +print STDERR "$self: ".($do_nail ? "unnailed" : "finished") + .". status $estatus.\n" if $verbose; exit $estatus; -- 2.30.2