* Clean up calls to system().

This commit is contained in:
Eelco Dolstra 2006-09-25 10:44:27 +00:00
parent 76c9710091
commit 68ae953d8a
8 changed files with 26 additions and 26 deletions

View file

@ -90,8 +90,7 @@ addToQueue $targetPath;
sub isValidPath {
my $p = shift;
system "@bindir@/nix-store --check-validity '$p' 2> /dev/null";
return $? == 0;
return system("@bindir@/nix-store --check-validity '$p' 2> /dev/null") == 0;
}
sub parseHash {
@ -231,8 +230,8 @@ while (scalar @path > 0) {
# as a base to one or more patches. So turn the base path
# into a NAR archive, to which we can apply the patch.
print " packing base path...\n";
system "@bindir@/nix-store --dump $v > $tmpNar";
die "cannot dump `$v'" if ($? != 0);
system("@bindir@/nix-store --dump $v > $tmpNar") == 0
or die "cannot dump `$v'";
}
}
@ -249,8 +248,8 @@ while (scalar @path > 0) {
# Apply the patch to the NAR archive produced in step 1 (for
# the already present path) or a later step (for patch sequences).
print " applying patch...\n";
system "@libexecdir@/bspatch $tmpNar $tmpNar2 $patchPath";
die "cannot apply patch `$patchPath' to $tmpNar" if ($? != 0);
system("@libexecdir@/bspatch $tmpNar $tmpNar2 $patchPath") == 0
or die "cannot apply patch `$patchPath' to $tmpNar";
if ($curStep < $maxStep) {
# The archive will be used as the base of the next patch.
@ -259,8 +258,8 @@ while (scalar @path > 0) {
# This was the last patch. Unpack the final NAR archive
# into the target path.
print " unpacking patched archive...\n";
system "@bindir@/nix-store --restore $v < $tmpNar2";
die "cannot unpack $tmpNar2 into `$v'" if ($? != 0);
system("@bindir@/nix-store --restore $v < $tmpNar2") == 0
or die "cannot unpack $tmpNar2 into `$v'";
}
}
@ -276,12 +275,13 @@ while (scalar @path > 0) {
if ($curStep < $maxStep) {
# The archive will be used a base to a patch.
system "@bunzip2@ < '$narFilePath' > $tmpNar";
system("@bunzip2@ < '$narFilePath' > $tmpNar") == 0
or die "cannot unpack `$narFilePath' into `$v'";
} else {
# Unpack the archive into the target path.
print " unpacking archive...\n";
system "@bunzip2@ < '$narFilePath' | @bindir@/nix-store --restore '$v'";
die "cannot unpack `$narFilePath' into `$v'" if ($? != 0);
system("@bunzip2@ < '$narFilePath' | @bindir@/nix-store --restore '$v'") == 0
or die "cannot unpack `$narFilePath' into `$v'";
}
}

View file

@ -70,8 +70,8 @@ sub update {
readChannels;
# Get rid of all the old substitutes.
system "@bindir@/nix-store --clear-substitutes";
die "cannot clear substitutes" if ($? != 0);
system("@bindir@/nix-store", "--clear-substitutes") == 0
or die "cannot clear substitutes";
# Remove all the old manifests.
for my $manifest (glob "$stateDir/manifests/*.nixmanifest") {
@ -81,8 +81,8 @@ sub update {
# Pull cache manifests.
foreach my $url (@channels) {
print "pulling cache manifest from `$url'\n";
system "@bindir@/nix-pull '$url'/MANIFEST";
die "cannot pull cache manifest from `$url'" if ($? != 0);
system("@bindir@/nix-pull", "$url/MANIFEST") == 0
or die "cannot pull cache manifest from `$url'";
}
# Create a Nix expression that fetches and unpacks the channel Nix
@ -122,8 +122,8 @@ sub update {
unlink "$rootFile.tmp";
# Make it the default Nix expression for `nix-env'.
system "@bindir@/nix-env --import '$outPath'";
die "cannot pull set default Nix expression to `$outPath'" if ($? != 0);
system("@bindir@/nix-env", "--import", "$outPath") == 0
or die "cannot pull set default Nix expression to `$outPath'";
}

View file

@ -29,7 +29,7 @@ if ($removeOld) {
$name = $profilesDir . "/" . $name;
if (-l $name && (readlink($name) =~ /link/)) {
print STDERR "removing old generations of profile $name\n";
system "@bindir@/nix-env", "-p", $name, "--delete-generations", "old";
system("@bindir@/nix-env", "-p", $name, "--delete-generations", "old");
}
}

View file

@ -68,7 +68,7 @@ if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) {
my $tmpDir;
do { $tmpDir = tmpnam(); }
until mkdir $tmpDir, 0777;
END { if (defined $tmpDir) { my $x = $?; system ("@coreutils@/rm", "-rf", $tmpDir); $? = $x; } }
END { if (defined $tmpDir) { my $x = $?; system("@coreutils@/rm", "-rf", $tmpDir); $? = $x; } }
sub barf {
@ -83,7 +83,7 @@ sub barf {
my $pkgFile = $source;
if ($fromURL) {
$pkgFile = "$tmpDir/tmp.nixpkg";
system ("@curl@", "--silent", $source, "-o", $pkgFile) == 0
system("@curl@", "--silent", $source, "-o", $pkgFile) == 0
or barf "curl failed: $?";
}
@ -124,12 +124,12 @@ if ($interactive) {
print "\nPulling manifests...\n";
system ("@bindir@/nix-pull", $manifestURL) == 0
system("@bindir@/nix-pull", $manifestURL) == 0
or barf "nix-pull failed: $?";
print "\nInstalling package...\n";
system ("@bindir@/nix-env", "--install", $outPath, @extraNixEnvArgs) == 0
system("@bindir@/nix-env", "--install", $outPath, @extraNixEnvArgs) == 0
or barf "nix-env failed: $?";

View file

@ -17,7 +17,7 @@ $binDir = "@bindir@" unless defined $binDir;
my $tmpDir;
do { $tmpDir = tmpnam(); }
until mkdir $tmpDir, 0777;
END { my $x = $?; system ("@coreutils@/rm", "-rf", $tmpDir); $? = $x; }
END { my $x = $?; system("@coreutils@/rm", "-rf", $tmpDir); $? = $x; }
mkdir "$tmpDir/contents", 0777 or die;
mkdir "$tmpDir/references", 0777 or die;
mkdir "$tmpDir/derivers", 0777 or die;

View file

@ -56,7 +56,7 @@ sub processURL {
my $finalPath = "$stateDir/manifests/$baseName-$hash.nixmanifest";
system("mv -f '$manifest' '$finalPath'") == 0
system ("@coreutils@/mv", "-f", "$manifest", "$finalPath") == 0
or die "cannot move `$manifest' to `$finalPath";
}

View file

@ -227,7 +227,7 @@ writeManifest $manifest, \%narFiles, \%patches;
sub copyFile {
my $src = shift;
my $dst = shift;
system("cp '$src' '$dst.tmp'") == 0 or die "cannot copy file";
system("@coreutils@/cp", $src, "$dst.tmp") == 0 or die "cannot copy file";
rename("$dst.tmp", "$dst") or die "cannot rename file";
}

View file

@ -15,7 +15,7 @@ $binDir = "@bindir@" unless defined $binDir;
my $tmpDir;
do { $tmpDir = tmpnam(); }
until mkdir $tmpDir, 0777;
END { my $x = $?; system ("@coreutils@/rm", "-rf", $tmpDir); $? = $x; }
END { my $x = $?; system("@coreutils@/rm", "-rf", $tmpDir); $? = $x; }
# Unpack the NAR archive on standard input.