From: Ian Jackson Date: Sun, 3 May 2020 21:10:43 +0000 (+0100) Subject: nailing-cargo: Remainder converted to Perl..., runs, broken X-Git-Tag: nailing-cargo/1.0.0~239 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d200235d105006342861b5f5d89fc5ff812e5356;p=nailing-cargo.git nailing-cargo: Remainder converted to Perl..., runs, broken Signed-off-by: Ian Jackson --- diff --git a/nailing-cargo b/nailing-cargo index 4d3d0f7..95377fe 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -28,6 +28,7 @@ # https://stackoverflow.com/questions/33025887/how-to-use-a-local-unpublished-crate # https://github.com/rust-lang/cargo/issues/1481 +# Needs libtoml-perl #: Cargo.nail: # @@ -188,7 +189,7 @@ sub readorigs () { sub calculate () { foreach my $mf (keys %manifests) { - my $toml = $manifest{$mf}; + my $toml = $manifests{$mf}; foreach my $k (qw(dependencies build-dependencies dev-dependencies)) { my $deps = $toml->{$k}; next unless $deps; @@ -203,11 +204,13 @@ sub calculate () { my $nailing = "$mf.nailing~"; unlink $nailing or $!==ENOENT or die "$0: remove old $nailing: $!\n"; open N, '>', $nailing or die "$0: create new $nailing: $!\n"; - print N, to_toml($toml) or die "$0: write new $nailing: $!\n"; + print N to_toml($toml) or die "$0: write new $nailing: $!\n"; close N or die "$0: close new $nailing: $!\n"; } } +our $want_uninstall; + END { if ($want_uninstall) { local ($?); @@ -230,8 +233,14 @@ sub install () { my $nailing = "$mf.nailing~"; my $nailed = "$mf.nailed~"; my ($use, $rm); - my $diff = compare($nailing, $nailed); - die "$0: compare $nailing and $nailed: $!" if $diff<0; + my $diff; + if (open NN, '<', $nailed) { + $diff = compare($nailing, \*NN); + die "$0: compare $nailing and $nailed: $!" if $diff<0; + } else { + $!==ENOENT or die "$0: check previous $nailed: $!\n"; + $diff = 1; + } if ($diff) { $use = $nailing; $rm = $nailed; @@ -264,7 +273,7 @@ sub uninstall1 ($$) { my ($mf, $enoentok) = @_; my $unnailed = "$mf.unnailed"; rename $unnailed, $mf or ($enoentok && $!==ENOENT) - die "$0: rename $unnailed back to $mf: $!\n"; + or die "$0: rename $unnailed back to $mf: $!\n"; } sub uninstall () {