1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 01:51:47 +02:00

Use proper quotes everywhere

This commit is contained in:
Eelco Dolstra 2014-08-20 17:00:17 +02:00
parent 373fad75e1
commit 11849a320e
54 changed files with 548 additions and 543 deletions

View file

@ -202,7 +202,7 @@ REQ: while (1) {
};
last REQ unless $@;
print STDERR "$@";
warn "unable to open SSH connection to `$hostName', trying other available machines...\n";
warn "unable to open SSH connection to $hostName, trying other available machines...\n";
$from = undef;
$to = undef;
$machine->{enabled} = 0;
@ -251,7 +251,7 @@ close UPLOADLOCK;
# Perform the build.
print STDERR "building `$drvPath' on `$hostName'\n";
print STDERR "building $drvPath on $hostName\n";
writeInt(6, $to) or die; # == cmdBuildPaths
writeStrings([$drvPath], $to);
writeInt($maxSilentTime, $to);
@ -259,7 +259,7 @@ writeInt($buildTimeout, $to);
my $res = readInt($from);
if ($res != 0) {
my $msg = readString($from);
print STDERR "error: $msg on `$hostName'\n";
print STDERR "error: $msg on $hostName\n";
exit $res;
}

View file

@ -1,5 +1,6 @@
#! @perl@ -w @perlFlags@
use utf8;
use strict;
use File::Basename;
use IO::Handle;
@ -57,16 +58,16 @@ if ($ARGV[0] eq "--query") {
$ENV{"NIX_DB_DIR"} = "$store/var/nix/db";
my $deriver = `$binDir/nix-store --query --deriver $storePath`;
die "cannot query deriver of `$storePath'" if $? != 0;
die "cannot query deriver of $storePath" if $? != 0;
chomp $deriver;
$deriver = "" if $deriver eq "unknown-deriver";
my @references = split "\n",
`$binDir/nix-store --query --references $storePath`;
die "cannot query references of `$storePath'" if $? != 0;
die "cannot query references of $storePath" if $? != 0;
my $narSize = `$binDir/nix-store --query --size $storePath`;
die "cannot query size of `$storePath'" if $? != 0;
die "cannot query size of $storePath" if $? != 0;
chomp $narSize;
print "$storePath\n";
@ -80,7 +81,7 @@ if ($ARGV[0] eq "--query") {
print "\n";
}
else { die "unknown command `$cmd'"; }
else { die "unknown command $cmd"; }
}
}
@ -91,9 +92,9 @@ elsif ($ARGV[0] eq "--substitute") {
my $destPath = $ARGV[2];
my ($store, $sourcePath) = findStorePath $storePath;
die unless $store;
print STDERR "\n*** Copying `$storePath' from `$sourcePath'\n\n";
print STDERR "\n*** Copying $storePath from $sourcePath\n\n";
system("$binDir/nix-store --dump $sourcePath | $binDir/nix-store --restore $destPath") == 0
or die "cannot copy `$sourcePath' to `$storePath'";
or die "cannot copy $sourcePath to $storePath";
print "\n"; # no hash to verify
}

View file

@ -134,7 +134,7 @@ sub initCache {
# Open/create the database.
$dbh = DBI->connect("dbi:SQLite:dbname=$dbPath", "", "")
or die "cannot open database `$dbPath'";
or die "cannot open database $dbPath";
$dbh->{RaiseError} = 1;
$dbh->{PrintError} = 0;
@ -544,7 +544,7 @@ sub downloadBinary {
print STDERR "\n*** Downloading $url ", ($requireSignedBinaryCaches ? "(signed by $info->{signedBy}) " : ""), "to $storePath...\n";
checkURL $url;
if (system("$Nix::Config::curl --fail --location --insecure --connect-timeout $curlConnectTimeout '$url' $decompressor | $Nix::Config::binDir/nix-store --restore $destPath") != 0) {
warn "download of `$url' failed" . ($! ? ": $!" : "") . "\n";
warn "download of $url failed" . ($! ? ": $!" : "") . "\n";
next;
}
@ -590,7 +590,7 @@ if ($ARGV[0] eq "--query") {
print "\n";
}
else { die "unknown command `$cmd'"; }
else { die "unknown command $cmd"; }
flush STDOUT;
}

View file

@ -1,5 +1,6 @@
#! @perl@ -w @perlFlags@
use utf8;
use strict;
use Nix::Config;
use Nix::Manifest;
@ -228,7 +229,7 @@ if ($ARGV[0] eq "--query") {
print "\n";
}
else { die "unknown command `$cmd'"; }
else { die "unknown command $cmd"; }
}
exit 0;
@ -257,7 +258,7 @@ open LOGFILE, ">>$logFile" or die "cannot open log file $logFile";
my $date = strftime ("%F %H:%M:%S UTC", gmtime (time));
print LOGFILE "$$ get $targetPath $date\n";
print STDERR "\n*** Trying to download/patch `$targetPath'\n";
print STDERR "\n*** Trying to download/patch $targetPath\n";
# Compute the shortest path.
@ -286,7 +287,7 @@ while (scalar @path > 0) {
print STDERR "\n*** Step $curStep/$maxStep: ";
if ($edge->{type} eq "present") {
print STDERR "using already present path `$v'\n";
print STDERR "using already present path $v\n";
print LOGFILE "$$ present $v\n";
if ($curStep < $maxStep) {
@ -295,13 +296,13 @@ while (scalar @path > 0) {
# into a NAR archive, to which we can apply the patch.
print STDERR " packing base path...\n";
system("$Nix::Config::binDir/nix-store --dump $v > $tmpNar") == 0
or die "cannot dump `$v'";
or die "cannot dump $v";
}
}
elsif ($edge->{type} eq "patch") {
my $patch = $edge->{info};
print STDERR "applying patch `$patch->{url}' to `$u' to create `$v'\n";
print STDERR "applying patch $patch->{url} to $u to create $v\n";
print LOGFILE "$$ patch $patch->{url} $patch->{size} $patch->{baseHash} $u $v\n";
@ -310,13 +311,13 @@ while (scalar @path > 0) {
my $patchPath = "$tmpDir/patch";
checkURL $patch->{url};
system("$curl '$patch->{url}' -o $patchPath") == 0
or die "cannot download patch `$patch->{url}'\n";
or die "cannot download patch $patch->{url}\n";
# Apply the patch to the NAR archive produced in step 1 (for
# the already present path) or a later step (for patch sequences).
print STDERR " applying patch...\n";
system("$Nix::Config::libexecDir/nix/bspatch $tmpNar $tmpNar2 $patchPath") == 0
or die "cannot apply patch `$patchPath' to $tmpNar\n";
or die "cannot apply patch $patchPath to $tmpNar\n";
if ($curStep < $maxStep) {
# The archive will be used as the base of the next patch.
@ -326,7 +327,7 @@ while (scalar @path > 0) {
# into the target path.
print STDERR " unpacking patched archive...\n";
system("$Nix::Config::binDir/nix-store --restore $destPath < $tmpNar2") == 0
or die "cannot unpack $tmpNar2 to `$v'\n";
or die "cannot unpack $tmpNar2 to $v\n";
}
$finalNarHash = $patch->{narHash};
@ -334,7 +335,7 @@ while (scalar @path > 0) {
elsif ($edge->{type} eq "narfile") {
my $narFile = $edge->{info};
print STDERR "downloading `$narFile->{url}' to `$v'\n";
print STDERR "downloading $narFile->{url} to $v\n";
my $size = $narFile->{size} || -1;
print LOGFILE "$$ narfile $narFile->{url} $size $v\n";
@ -345,16 +346,16 @@ while (scalar @path > 0) {
$narFile->{compressionType} eq "bzip2" ? "| $Nix::Config::bzip2 -d" :
$narFile->{compressionType} eq "xz" ? "| $Nix::Config::xz -d" :
$narFile->{compressionType} eq "none" ? "" :
die "unknown compression type `$narFile->{compressionType}'";
die "unknown compression type $narFile->{compressionType}";
if ($curStep < $maxStep) {
# The archive will be used a base to a patch.
system("$curl '$narFile->{url}' $decompressor > $tmpNar") == 0
or die "cannot download and unpack `$narFile->{url}' to `$v'\n";
or die "cannot download and unpack $narFile->{url} to $v\n";
} else {
# Unpack the archive to the target path.
system("$curl '$narFile->{url}' $decompressor | $Nix::Config::binDir/nix-store --restore '$destPath'") == 0
or die "cannot download and unpack `$narFile->{url}' to `$v'\n";
or die "cannot download and unpack $narFile->{url} to $v\n";
}
$finalNarHash = $narFile->{narHash};

View file

@ -24,15 +24,15 @@ echo "performing a single-user installation of Nix..." >&2
if ! [ -e $dest ]; then
cmd="mkdir -m 0755 $dest && chown $USER $dest"
echo "directory $dest does not exist; creating it by running \`$cmd' using sudo" >&2
echo "directory $dest does not exist; creating it by running $cmd using sudo" >&2
if ! sudo sh -c "$cmd"; then
echo "$0: please manually run \`$cmd' as root to create $dest" >&2
echo "$0: please manually run $cmd as root to create $dest" >&2
exit 1
fi
fi
if ! [ -w $dest ]; then
echo "$0: directory $dest exists, but is not writable by you; please run \`chown -R $USER $dest' as root" >&2
echo "$0: directory $dest exists, but is not writable by you; please run chown -R $USER $dest as root" >&2
exit 1
fi

View file

@ -55,37 +55,37 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
elsif ($arg eq "--drv-link") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$drvLink = $ARGV[$n];
}
elsif ($arg eq "--out-link" || $arg eq "-o") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$outLink = $ARGV[$n];
}
elsif ($arg eq "--attr" || $arg eq "-A" || $arg eq "-I") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
push @instArgs, ($arg, $ARGV[$n]);
}
elsif ($arg eq "--arg" || $arg eq "--argstr") {
die "$0: `$arg' requires two arguments\n" unless $n + 2 < scalar @ARGV;
die "$0: $arg requires two arguments\n" unless $n + 2 < scalar @ARGV;
push @instArgs, ($arg, $ARGV[$n + 1], $ARGV[$n + 2]);
$n += 2;
}
elsif ($arg eq "--log-type") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
push @instArgs, ($arg, $ARGV[$n]);
push @buildArgs, ($arg, $ARGV[$n]);
}
elsif ($arg eq "--option") {
die "$0: `$arg' requires two arguments\n" unless $n + 2 < scalar @ARGV;
die "$0: $arg requires two arguments\n" unless $n + 2 < scalar @ARGV;
push @instArgs, ($arg, $ARGV[$n + 1], $ARGV[$n + 2]);
push @buildArgs, ($arg, $ARGV[$n + 1], $ARGV[$n + 2]);
$n += 2;
@ -93,7 +93,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
elsif ($arg eq "--max-jobs" || $arg eq "-j" || $arg eq "--max-silent-time" || $arg eq "--log-type" || $arg eq "--cores" || $arg eq "--timeout" || $arg eq '--add-root') {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
push @buildArgs, ($arg, $ARGV[$n]);
}
@ -131,13 +131,13 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
elsif ($arg eq "--command") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$envCommand = "$ARGV[$n]\nexit $!";
}
elsif ($arg eq "--exclude") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
push @envExclude, $ARGV[$n];
}
@ -195,7 +195,7 @@ foreach my $expr (@exprs) {
die "$0: a single derivation is required\n" if scalar @drvPaths != 1;
my $drvPath = $drvPaths[0];
$drvPath = (split '!',$drvPath)[0];
$drvPath = readlink $drvPath or die "cannot read symlink `$drvPath'" if -l $drvPath;
$drvPath = readlink $drvPath or die "cannot read symlink $drvPath" if -l $drvPath;
my $drv = derivationFromPath($drvPath);
# Build or fetch all dependencies of the derivation.
@ -257,7 +257,7 @@ foreach my $expr (@exprs) {
} else {
$p = $drvPath;
}
my $target = readlink $p or die "cannot read symlink `$p'";
my $target = readlink $p or die "cannot read symlink $p";
print STDERR "derivation is $target\n" if $verbose;
if ($target eq $prevDrvPath) {
push @drvPaths2, (pop @drvPaths2) . "," . $output;
@ -280,7 +280,7 @@ foreach my $expr (@exprs) {
next if $dryRun;
foreach my $outPath (@outPaths) {
my $target = readlink $outPath or die "cannot read symlink `$outPath'";
my $target = readlink $outPath or die "cannot read symlink $outPath";
print "$target\n";
}
}

View file

@ -32,7 +32,7 @@ my %channels;
# Reads the list of channels.
sub readChannels {
return if (!-f $channelsList);
open CHANNELS, "<$channelsList" or die "cannot open `$channelsList': $!";
open CHANNELS, "<$channelsList" or die "cannot open $channelsList: $!";
while (<CHANNELS>) {
chomp;
next if /^\s*\#/;
@ -47,7 +47,7 @@ sub readChannels {
# Writes the list of channels.
sub writeChannels {
open CHANNELS, ">$channelsList" or die "cannot open `$channelsList': $!";
open CHANNELS, ">$channelsList" or die "cannot open $channelsList: $!";
foreach my $name (keys %channels) {
print CHANNELS "$channels{$name} $name\n";
}
@ -74,7 +74,7 @@ sub removeChannel {
writeChannels;
system("$Nix::Config::binDir/nix-env --profile '$profile' -e '$name'") == 0
or die "cannot remove channel `$name'\n";
or die "cannot remove channel $name\n";
}
@ -97,7 +97,7 @@ sub update {
# consistency if the redirection is changed between
# downloading the manifest and the tarball.
my $headers = `$Nix::Config::curl --silent --head '$url'`;
die "$0: unable to check `$url'\n" if $? != 0;
die "$0: unable to check $url\n" if $? != 0;
$headers =~ s/\r//g;
$url = $1 if $headers =~ /^Location:\s*(.*)\s*$/m;
@ -115,19 +115,19 @@ sub update {
if ($getManifest) {
# No binary cache, so pull the channel manifest.
mkdir $manifestDir, 0755 unless -e $manifestDir;
die "$0: you do not have write permission to `$manifestDir'!\n" unless -W $manifestDir;
die "$0: you do not have write permission to $manifestDir!\n" unless -W $manifestDir;
$ENV{'NIX_ORIG_URL'} = $origUrl;
system("$Nix::Config::binDir/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
or die "cannot pull manifest from `$url'\n";
or die "cannot pull manifest from $url\n";
}
# Download the channel tarball.
my $fullURL = "$url/nixexprs.tar.xz";
system("$Nix::Config::curl --fail --silent --head '$fullURL' > /dev/null") == 0 or
$fullURL = "$url/nixexprs.tar.bz2";
print STDERR "downloading Nix expressions from `$fullURL'...\n";
print STDERR "downloading Nix expressions from $fullURL...\n";
my ($hash, $path) = `PRINT_PATH=1 QUIET=1 $Nix::Config::binDir/nix-prefetch-url '$fullURL'`;
die "cannot fetch `$fullURL'\n" if $? != 0;
die "cannot fetch $fullURL\n" if $? != 0;
chomp $path;
# If the URL contains a version number, append it to the name
@ -148,10 +148,10 @@ sub update {
# Make the channels appear in nix-env.
unlink $nixDefExpr if -l $nixDefExpr; # old-skool ~/.nix-defexpr
mkdir $nixDefExpr or die "cannot create directory `$nixDefExpr'" if !-e $nixDefExpr;
mkdir $nixDefExpr or die "cannot create directory $nixDefExpr" if !-e $nixDefExpr;
my $channelLink = "$nixDefExpr/channels";
unlink $channelLink; # !!! not atomic
symlink($profile, $channelLink) or die "cannot symlink `$channelLink' to `$profile'";
symlink($profile, $channelLink) or die "cannot symlink $channelLink to $profile";
}
@ -162,7 +162,7 @@ while (scalar @ARGV) {
my $arg = shift @ARGV;
if ($arg eq "--add") {
die "$0: `--add' requires one or two arguments\n" if scalar @ARGV < 1 || scalar @ARGV > 2;
die "$0: --add requires one or two arguments\n" if scalar @ARGV < 1 || scalar @ARGV > 2;
my $url = shift @ARGV;
my $name = shift @ARGV;
unless (defined $name) {
@ -175,13 +175,13 @@ while (scalar @ARGV) {
}
if ($arg eq "--remove") {
die "$0: `--remove' requires one argument\n" if scalar @ARGV != 1;
die "$0: --remove requires one argument\n" if scalar @ARGV != 1;
removeChannel(shift @ARGV);
last;
}
if ($arg eq "--list") {
die "$0: `--list' requires one argument\n" if scalar @ARGV != 0;
die "$0: --list requires one argument\n" if scalar @ARGV != 0;
readChannels;
foreach my $name (keys %channels) {
print "$name $channels{$name}\n";
@ -204,6 +204,6 @@ while (scalar @ARGV) {
}
else {
die "unknown argument `$arg'; try `--help'\n";
die "unknown argument $arg; try --help\n";
}
}

View file

@ -38,7 +38,7 @@ while (@ARGV) {
$sign = 1;
}
elsif ($arg eq "--gzip" || $arg eq "--bzip2" || $arg eq "--xz") {
warn "$0: `$arg' is not implemented\n" if $arg ne "--gzip";
warn "$0: $arg is not implemented\n" if $arg ne "--gzip";
push @globalSshOpts, "-C";
}
elsif ($arg eq "--from") {
@ -51,7 +51,7 @@ while (@ARGV) {
$includeOutputs = 1;
}
elsif ($arg eq "--show-progress") {
warn "$0: `$arg' is not implemented\n";
warn "$0: $arg is not implemented\n";
}
elsif ($arg eq "--dry-run") {
$dryRun = 1;

View file

@ -23,7 +23,7 @@ while (scalar @args) {
}
elsif ($arg eq "--profile" || $arg eq "-p") {
my $profile = shift @args;
die "$0: `--profile' requires an argument\n" if !defined $profile;
die "$0: --profile requires an argument\n" if !defined $profile;
push @extraNixEnvArgs, "-p", $profile;
}
elsif ($arg eq "--non-interactive") {
@ -45,7 +45,7 @@ if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) {
foreach my $term ("xterm", "konsole", "gnome-terminal", "xterm") {
exec($term, "-e", "$Nix::Config::binDir/nix-install-package", @ARGV);
}
die "cannot execute `xterm'";
die "cannot execute xterm";
}
@ -70,7 +70,7 @@ if ($fromURL) {
# Read and parse the package file.
open PKGFILE, "<$pkgFile" or barf "cannot open `$pkgFile': $!";
open PKGFILE, "<$pkgFile" or barf "cannot open $pkgFile: $!";
my $contents = <PKGFILE>;
close PKGFILE;
@ -92,12 +92,12 @@ my $drvPath = $5;
my $outPath = $6;
my $binaryCacheURL = $8;
barf "invalid package version `$version'" unless $version eq "NIXPKG1";
barf "invalid package version $version" unless $version eq "NIXPKG1";
if ($interactive) {
# Ask confirmation.
print "Do you want to install `$drvName' (Y/N)? ";
print "Do you want to install $drvName (Y/N)? ";
my $reply = <STDIN>;
chomp $reply;
exit if $reply ne "y" && $reply ne "Y";

View file

@ -17,9 +17,9 @@ while ($arg = shift) {
exec "man nix-prefetch-url" or die;
} elsif ($arg eq "--type") {
$hashType = shift;
die "$0: `$arg' requires an argument\n" unless defined $hashType;
die "$0: $arg requires an argument\n" unless defined $hashType;
} elsif (substr($arg, 0, 1) eq "-") {
die "$0: unknown flag `$arg'\n";
die "$0: unknown flag $arg\n";
} else {
push @args, $arg;
}

View file

@ -13,7 +13,7 @@ umask 0022;
# Create the manifests directory if it doesn't exist.
if (! -e $manifestDir) {
mkdir $manifestDir, 0755 or die "cannot create directory `$manifestDir'";
mkdir $manifestDir, 0755 or die "cannot create directory $manifestDir";
}
@ -21,7 +21,7 @@ if (! -e $manifestDir) {
my $gcRootsDir = "$Nix::Config::stateDir/gcroots";
my $manifestDirLink = "$gcRootsDir/manifests";
if (! -l $manifestDirLink) {
symlink($manifestDir, $manifestDirLink) or die "cannot create symlink `$manifestDirLink'";
symlink($manifestDir, $manifestDirLink) or die "cannot create symlink $manifestDirLink";
}
@ -32,7 +32,7 @@ sub downloadFile {
$ENV{"PRINT_PATH"} = 1;
$ENV{"QUIET"} = 1;
my ($dummy, $path) = `$Nix::Config::binDir/nix-prefetch-url '$url'`;
die "cannot fetch `$url'" if $? != 0;
die "cannot fetch $url" if $? != 0;
die "nix-prefetch-url did not return a path" unless defined $path;
chomp $path;
return $path;
@ -49,13 +49,13 @@ sub processURL {
# First see if a bzipped manifest is available.
if (system("$Nix::Config::curl --fail --silent --location --head '$url'.bz2 > /dev/null") == 0) {
print "fetching list of Nix archives at `$url.bz2'...\n";
print "fetching list of Nix archives at $url.bz2...\n";
$manifest = downloadFile "$url.bz2";
}
# Otherwise, just get the uncompressed manifest.
else {
print "fetching list of Nix archives at `$url'...\n";
print "fetching list of Nix archives at $url...\n";
$manifest = downloadFile $url;
}
@ -65,11 +65,11 @@ sub processURL {
}
my $hash = `$Nix::Config::binDir/nix-hash --flat '$manifest'`
or die "cannot hash `$manifest'";
or die "cannot hash $manifest";
chomp $hash;
my $urlFile = "$manifestDir/$baseName-$hash.url";
open URL, ">$urlFile" or die "cannot create `$urlFile'";
open URL, ">$urlFile" or die "cannot create $urlFile";
print URL $origUrl;
close URL;
@ -78,7 +78,7 @@ sub processURL {
unlink $finalPath if -e $finalPath;
symlink("$manifest", "$finalPath")
or die "cannot link `$finalPath to `$manifest'";
or die "cannot link $finalPath to $manifest";
deleteOldManifests($origUrl, $urlFile);
}

View file

@ -41,33 +41,33 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
$force = 1;
} elsif ($arg eq "--dest") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$destDir = $ARGV[$n];
mkpath($destDir, 0, 0755);
} elsif ($arg eq "--manifest") {
$writeManifest = 1;
} elsif ($arg eq "--manifest-path") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$manifestPath = $ARGV[$n];
$writeManifest = 1;
mkpath(dirname($manifestPath), 0, 0755);
} elsif ($arg eq "--url-prefix") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$archivesURL = $ARGV[$n];
} elsif ($arg eq "--link") {
$link = 1;
} elsif ($arg eq "--key") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$privateKeyFile = $ARGV[$n];
} elsif ($arg eq "--key-name") {
$n++;
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$keyName = $ARGV[$n];
} elsif (substr($arg, 0, 1) eq "-") {
die "$0: unknown flag `$arg'\n";
die "$0: unknown flag $arg\n";
} else {
push @roots, $arg;
}
@ -108,7 +108,7 @@ foreach my $storePath (@storePaths) {
my $pathHash = substr(basename($storePath), 0, 32);
my $narInfoFile = "$destDir/$pathHash.narinfo";
if (-e $narInfoFile) {
my $narInfo = parseNARInfo($storePath, readFile($narInfoFile), 0, $narInfoFile) or die "cannot read `$narInfoFile'\n";
my $narInfo = parseNARInfo($storePath, readFile($narInfoFile), 0, $narInfoFile) or die "cannot read $narInfoFile\n";
my $narFile = "$destDir/$narInfo->{url}";
if (-e $narFile) {
print STDERR "skipping existing $storePath\n";
@ -197,7 +197,7 @@ for (my $n = 0; $n < scalar @storePaths2; $n++) {
system("$Nix::Config::binDir/nix-store --dump $storePath > $nar") == 0
or die "cannot dump $storePath\n";
$narHash = `$Nix::Config::binDir/nix-hash --type sha256 --base32 --flat $nar`;
die "cannot hash `$nar'" if $? != 0;
die "cannot hash $nar" if $? != 0;
chomp $narHash;
$narHash = "sha256:$narHash";
$narSize = stat("$nar")->size;