# 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:
#
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;
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 ($?);
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;
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 () {