* Clean up calls to system().
This commit is contained in:
		
							parent
							
								
									76c9710091
								
							
						
					
					
						commit
						68ae953d8a
					
				
					 8 changed files with 26 additions and 26 deletions
				
			
		|  | @ -90,8 +90,7 @@ addToQueue $targetPath; | ||||||
| 
 | 
 | ||||||
| sub isValidPath { | sub isValidPath { | ||||||
|     my $p = shift; |     my $p = shift; | ||||||
|     system "@bindir@/nix-store --check-validity '$p' 2> /dev/null"; |     return system("@bindir@/nix-store --check-validity '$p' 2> /dev/null") == 0; | ||||||
|     return $? == 0; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| sub parseHash { | sub parseHash { | ||||||
|  | @ -231,8 +230,8 @@ while (scalar @path > 0) { | ||||||
|             # as a base to one or more patches.  So turn the base path |             # as a base to one or more patches.  So turn the base path | ||||||
|             # into a NAR archive, to which we can apply the patch. |             # into a NAR archive, to which we can apply the patch. | ||||||
|             print "  packing base path...\n"; |             print "  packing base path...\n"; | ||||||
|             system "@bindir@/nix-store --dump $v > $tmpNar"; |             system("@bindir@/nix-store --dump $v > $tmpNar") == 0 | ||||||
|             die "cannot dump `$v'" if ($? != 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 |         # Apply the patch to the NAR archive produced in step 1 (for | ||||||
|         # the already present path) or a later step (for patch sequences). |         # the already present path) or a later step (for patch sequences). | ||||||
|         print "  applying patch...\n"; |         print "  applying patch...\n"; | ||||||
|         system "@libexecdir@/bspatch $tmpNar $tmpNar2 $patchPath"; |         system("@libexecdir@/bspatch $tmpNar $tmpNar2 $patchPath") == 0 | ||||||
|         die "cannot apply patch `$patchPath' to $tmpNar" if ($? != 0); |             or die "cannot apply patch `$patchPath' to $tmpNar"; | ||||||
| 
 | 
 | ||||||
|         if ($curStep < $maxStep) { |         if ($curStep < $maxStep) { | ||||||
|             # The archive will be used as the base of the next patch. |             # 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 |             # This was the last patch.  Unpack the final NAR archive | ||||||
|             # into the target path. |             # into the target path. | ||||||
|             print "  unpacking patched archive...\n"; |             print "  unpacking patched archive...\n"; | ||||||
|             system "@bindir@/nix-store --restore $v < $tmpNar2"; |             system("@bindir@/nix-store --restore $v < $tmpNar2") == 0 | ||||||
|             die "cannot unpack $tmpNar2 into `$v'" if ($? != 0); |                 or die "cannot unpack $tmpNar2 into `$v'"; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -276,12 +275,13 @@ while (scalar @path > 0) { | ||||||
| 
 | 
 | ||||||
|         if ($curStep < $maxStep) { |         if ($curStep < $maxStep) { | ||||||
|             # The archive will be used a base to a patch. |             # 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 { |         } else { | ||||||
|             # Unpack the archive into the target path. |             # Unpack the archive into the target path. | ||||||
|             print "  unpacking archive...\n"; |             print "  unpacking archive...\n"; | ||||||
|             system "@bunzip2@ < '$narFilePath' | @bindir@/nix-store --restore '$v'"; |             system("@bunzip2@ < '$narFilePath' | @bindir@/nix-store --restore '$v'") == 0 | ||||||
|             die "cannot unpack `$narFilePath' into `$v'" if ($? != 0); |                 or die "cannot unpack `$narFilePath' into `$v'"; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -70,8 +70,8 @@ sub update { | ||||||
|     readChannels; |     readChannels; | ||||||
| 
 | 
 | ||||||
|     # Get rid of all the old substitutes. |     # Get rid of all the old substitutes. | ||||||
|     system "@bindir@/nix-store --clear-substitutes"; |     system("@bindir@/nix-store", "--clear-substitutes") == 0 | ||||||
|     die "cannot clear substitutes" if ($? != 0); |         or die "cannot clear substitutes"; | ||||||
| 
 | 
 | ||||||
|     # Remove all the old manifests. |     # Remove all the old manifests. | ||||||
|     for my $manifest (glob "$stateDir/manifests/*.nixmanifest") { |     for my $manifest (glob "$stateDir/manifests/*.nixmanifest") { | ||||||
|  | @ -81,8 +81,8 @@ sub update { | ||||||
|     # Pull cache manifests. |     # Pull cache manifests. | ||||||
|     foreach my $url (@channels) { |     foreach my $url (@channels) { | ||||||
|         print "pulling cache manifest from `$url'\n"; |         print "pulling cache manifest from `$url'\n"; | ||||||
|         system "@bindir@/nix-pull '$url'/MANIFEST"; |         system("@bindir@/nix-pull", "$url/MANIFEST") == 0 | ||||||
|         die "cannot pull cache manifest from `$url'" if ($? != 0); |             or die "cannot pull cache manifest from `$url'"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     # Create a Nix expression that fetches and unpacks the channel Nix |     # Create a Nix expression that fetches and unpacks the channel Nix | ||||||
|  | @ -122,8 +122,8 @@ sub update { | ||||||
|     unlink "$rootFile.tmp"; |     unlink "$rootFile.tmp"; | ||||||
| 
 | 
 | ||||||
|     # Make it the default Nix expression for `nix-env'. |     # Make it the default Nix expression for `nix-env'. | ||||||
|     system "@bindir@/nix-env --import '$outPath'"; |     system("@bindir@/nix-env", "--import", "$outPath") == 0 | ||||||
|     die "cannot pull set default Nix expression to `$outPath'" if ($? != 0); |          or die "cannot pull set default Nix expression to `$outPath'"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ if ($removeOld) { | ||||||
|         $name = $profilesDir . "/" . $name; |         $name = $profilesDir . "/" . $name; | ||||||
|         if (-l $name && (readlink($name) =~ /link/)) { |         if (-l $name && (readlink($name) =~ /link/)) { | ||||||
|             print STDERR "removing old generations of profile $name\n"; |             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"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |  | ||||||
|  | @ -68,7 +68,7 @@ if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) { | ||||||
| my $tmpDir; | my $tmpDir; | ||||||
| do { $tmpDir = tmpnam(); } | do { $tmpDir = tmpnam(); } | ||||||
| until mkdir $tmpDir, 0777; | 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 { | sub barf { | ||||||
|  | @ -83,7 +83,7 @@ sub barf { | ||||||
| my $pkgFile = $source; | my $pkgFile = $source; | ||||||
| if ($fromURL) { | if ($fromURL) { | ||||||
|     $pkgFile = "$tmpDir/tmp.nixpkg"; |     $pkgFile = "$tmpDir/tmp.nixpkg"; | ||||||
|     system ("@curl@", "--silent", $source, "-o", $pkgFile) == 0 |     system("@curl@", "--silent", $source, "-o", $pkgFile) == 0 | ||||||
|         or barf "curl failed: $?"; |         or barf "curl failed: $?"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -124,12 +124,12 @@ if ($interactive) { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| print "\nPulling manifests...\n"; | print "\nPulling manifests...\n"; | ||||||
| system ("@bindir@/nix-pull", $manifestURL) == 0 | system("@bindir@/nix-pull", $manifestURL) == 0 | ||||||
|     or barf "nix-pull failed: $?"; |     or barf "nix-pull failed: $?"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| print "\nInstalling package...\n"; | 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: $?"; |     or barf "nix-env failed: $?"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ $binDir = "@bindir@" unless defined $binDir; | ||||||
| my $tmpDir; | my $tmpDir; | ||||||
| do { $tmpDir = tmpnam(); } | do { $tmpDir = tmpnam(); } | ||||||
| until mkdir $tmpDir, 0777; | 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/contents", 0777 or die; | ||||||
| mkdir "$tmpDir/references", 0777 or die; | mkdir "$tmpDir/references", 0777 or die; | ||||||
| mkdir "$tmpDir/derivers", 0777 or die; | mkdir "$tmpDir/derivers", 0777 or die; | ||||||
|  |  | ||||||
|  | @ -56,7 +56,7 @@ sub processURL { | ||||||
|      |      | ||||||
|     my $finalPath = "$stateDir/manifests/$baseName-$hash.nixmanifest"; |     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"; |         or die "cannot move `$manifest' to `$finalPath"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -227,7 +227,7 @@ writeManifest $manifest, \%narFiles, \%patches; | ||||||
| sub copyFile { | sub copyFile { | ||||||
|     my $src = shift; |     my $src = shift; | ||||||
|     my $dst = 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"; |     rename("$dst.tmp", "$dst") or die "cannot rename file"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ $binDir = "@bindir@" unless defined $binDir; | ||||||
| my $tmpDir; | my $tmpDir; | ||||||
| do { $tmpDir = tmpnam(); } | do { $tmpDir = tmpnam(); } | ||||||
| until mkdir $tmpDir, 0777; | 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. | # Unpack the NAR archive on standard input. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue