forked from lix-project/lix
* Clean up calls to system().
This commit is contained in:
parent
76c9710091
commit
68ae953d8a
|
@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue