From fa77aa4826b69e450954bb98dd5b72d58a6d102a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 3 May 2020 22:47:57 +0100 Subject: [PATCH] nailing-cargo: Bugfixes etc. Signed-off-by: Ian Jackson --- nailing-cargo | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/nailing-cargo b/nailing-cargo index db7b72a..92bd8ce 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -52,6 +52,7 @@ $worksphere =~ s{/[^/]+}{} or die "$self: cwd \`$worksphere' unsupported!\n"; our $lockfile = "../.nailing-cargo-sphere.lock"; our @configs; +our ($verbose,$noact,$dump); sub read_or_enoent ($) { my ($fn) = @_; @@ -125,6 +126,11 @@ sub readnail () { # old non-toml syntax $toml =~ s{^[ \t]*([-_0-9a-z]+)[ \t]+(\S+)[ \t]*$}{$1 = \"$2\"}mig) { $toml =~ s{^}{[packages\]\n}; + my @sd; + $toml =~ s{^[ \t]*\-[ \t]*\=[ \t]*(\"[-_0-9a-z]+\"\n?)$}{ + push @sd, $1; ''; + }mige; + $toml = "subdirs = [\n".(join '', map { "$_\n" } @sd)."]\n".$toml; $transformed = 1; } my $e; @@ -145,6 +151,7 @@ our %packagemap; sub read_manifest ($) { my ($subdir) = @_; my $manifest = "../$subdir/Cargo.toml"; + print STDERR "$self: reading $manifest...\n" if $verbose>=3; if (defined $manifests{$manifest}) { print STDERR "$self: warning: $subdir: specified more than once!\n"; @@ -171,7 +178,7 @@ sub readorigs () { my $gotpackage = read_manifest($subdir) // ''; if ($gotpackage ne $p) { print STDERR - "$self: warning: honouring Cargo.nail [packages.$subdir]=$p even though $subdir contains package $gotpackage!\n"; + "$self: warning: honouring Cargo.nail packages.$subdir=$p even though $subdir contains package $gotpackage!\n"; } die if defined $packagemap{$p}; $packagemap{$p} = $subdir; @@ -230,7 +237,7 @@ sub makebackups () { sub install () { foreach my $mf (keys %manifests) { my $nailing = "$mf.nailing~"; - my $nailed = "$mf.nailed~"; + my $nailed = "$mf.nailed~"; $nailed =~ s{/([^/]+)$}{/.$1} or die; my ($use, $rm); my $diff; if (open NN, '<', $nailed) { @@ -249,6 +256,7 @@ sub install () { } rename $use, $mf or die "$self: install nailed $use: $!\n"; unlink $rm or $!==ENOENT or die "$self: remove old $rm: $!\n"; + print STDERR "Nailed $mf\n" if $verbose>=2; } } @@ -283,13 +291,38 @@ sub uninstall () { while (@ARGV && $ARGV[0] =~ m/^-/) { $_ = shift @ARGV; - last if m/^--$/; + last if m{^--$}; + if (m{^-[^-]}) { + while (m{^-.}) { + if (s{^-v}{-}) { + $verbose++; + } elsif (s{^-n}{-}) { + $noact++; + } elsif (s{^-D}{-}) { + $dump++; + } else { + die "$self: unknown short option(s) $_\n"; + } + } + } else { + die "$self: unknown long option $_\n"; + } } takelock(); readnail(); readorigs(); calculate(); + +if ($dump) { + eval ' + use Data::Dumper; + print STDERR Dumper(\%manifests, \%packagemap); + ' or die $@; +} + +exit 0 if $noact; + $want_uninstall = 1; makebackups(); install(); -- 2.30.2