From 68ae953d8a492061bcda7c4d7bf2f5b9432f791c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 25 Sep 2006 10:44:27 +0000 Subject: [PATCH] * Clean up calls to system(). --- scripts/download-using-manifests.pl.in | 22 +++++++++++----------- scripts/nix-channel.in | 12 ++++++------ scripts/nix-collect-garbage.in | 2 +- scripts/nix-install-package.in | 8 ++++---- scripts/nix-pack-closure.in | 2 +- scripts/nix-pull.in | 2 +- scripts/nix-push.in | 2 +- scripts/nix-unpack-closure.in | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/scripts/download-using-manifests.pl.in b/scripts/download-using-manifests.pl.in index 382eb7c3ae..5dd5b817af 100644 --- a/scripts/download-using-manifests.pl.in +++ b/scripts/download-using-manifests.pl.in @@ -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'"; } } diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index 63a56616b1..19b012922b 100644 --- a/scripts/nix-channel.in +++ b/scripts/nix-channel.in @@ -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'"; } diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in index 81975d2d3c..f1ea09b8ee 100644 --- a/scripts/nix-collect-garbage.in +++ b/scripts/nix-collect-garbage.in @@ -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"); } } diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in index 4f5b0087fe..35f6d68248 100644 --- a/scripts/nix-install-package.in +++ b/scripts/nix-install-package.in @@ -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: $?"; diff --git a/scripts/nix-pack-closure.in b/scripts/nix-pack-closure.in index a29f120215..ebf7164075 100644 --- a/scripts/nix-pack-closure.in +++ b/scripts/nix-pack-closure.in @@ -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; diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in index 67a7838f19..0af036f6f3 100644 --- a/scripts/nix-pull.in +++ b/scripts/nix-pull.in @@ -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"; } diff --git a/scripts/nix-push.in b/scripts/nix-push.in index f11cd1f46f..02b1dec482 100644 --- a/scripts/nix-push.in +++ b/scripts/nix-push.in @@ -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"; } diff --git a/scripts/nix-unpack-closure.in b/scripts/nix-unpack-closure.in index 01e8ee30d2..20fdef7594 100644 --- a/scripts/nix-unpack-closure.in +++ b/scripts/nix-unpack-closure.in @@ -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.