mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
* Make unpacking of patch sequences much faster by not doing redundant
unpacking and repacking of intermediate paths.
This commit is contained in:
parent
456f3251d2
commit
cbc8d083ac
2 changed files with 38 additions and 16 deletions
6
NEWS
6
NEWS
|
@ -1,3 +1,9 @@
|
||||||
|
Version 0.9
|
||||||
|
|
||||||
|
* Unpacking of patch sequences is much faster now by not doing
|
||||||
|
redundant unpacking and repacking of intermediate paths.
|
||||||
|
|
||||||
|
|
||||||
Version 0.8 (April 11, 2005)
|
Version 0.8 (April 11, 2005)
|
||||||
|
|
||||||
NOTE: the hashing scheme in Nix 0.8 changed (as detailed below). As a
|
NOTE: the hashing scheme in Nix 0.8 changed (as detailed below). As a
|
||||||
|
|
|
@ -207,11 +207,19 @@ while (scalar @path > 0) {
|
||||||
my $v = $edge->{end};
|
my $v = $edge->{end};
|
||||||
|
|
||||||
print "\n*** Step $curStep/$maxStep: ";
|
print "\n*** Step $curStep/$maxStep: ";
|
||||||
$curStep++;
|
|
||||||
|
|
||||||
if ($edge->{type} eq "present") {
|
if ($edge->{type} eq "present") {
|
||||||
print "using already present path `$v'\n";
|
print "using already present path `$v'\n";
|
||||||
print LOGFILE "$$ present $v\n";
|
print LOGFILE "$$ present $v\n";
|
||||||
|
|
||||||
|
if ($curStep < $maxStep) {
|
||||||
|
# Since this is not the last step, the path will be used
|
||||||
|
# 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 > /tmp/nar";
|
||||||
|
die "cannot dump `$v'" if ($? != 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($edge->{type} eq "patch") {
|
elsif ($edge->{type} eq "patch") {
|
||||||
|
@ -224,22 +232,23 @@ while (scalar @path > 0) {
|
||||||
print " downloading patch...\n";
|
print " downloading patch...\n";
|
||||||
my $patchPath = downloadFile "$patch->{url}", "$patch->{hash}";
|
my $patchPath = downloadFile "$patch->{url}", "$patch->{hash}";
|
||||||
|
|
||||||
# Turn the base path into a NAR archive, to which we can
|
# Apply the patch to the NAR archive produced in step 1 (for
|
||||||
# actually apply the patch.
|
# the already present path) or a later step (for patch sequences).
|
||||||
print " packing base path...\n";
|
|
||||||
system "@bindir@/nix-store --dump $patch->{basePath} > /tmp/nar";
|
|
||||||
die "cannot dump `$patch->{basePath}'" if ($? != 0);
|
|
||||||
|
|
||||||
# Apply the patch.
|
|
||||||
print " applying patch...\n";
|
print " applying patch...\n";
|
||||||
system "@libexecdir@/bspatch /tmp/nar /tmp/nar2 $patchPath";
|
system "@libexecdir@/bspatch /tmp/nar /tmp/nar2 $patchPath";
|
||||||
die "cannot apply patch `$patchPath' to /tmp/nar" if ($? != 0);
|
die "cannot apply patch `$patchPath' to /tmp/nar" if ($? != 0);
|
||||||
|
|
||||||
# Unpack the resulting NAR archive into the target path.
|
if ($curStep < $maxStep) {
|
||||||
|
# The archive will be used as the base of the next patch.
|
||||||
|
rename "/tmp/nar2", "/tmp/nar" or die "cannot rename NAR archive: $!";
|
||||||
|
} else {
|
||||||
|
# This was the last patch. Unpack the final NAR archive
|
||||||
|
# into the target path.
|
||||||
print " unpacking patched archive...\n";
|
print " unpacking patched archive...\n";
|
||||||
system "@bindir@/nix-store --restore $v < /tmp/nar2";
|
system "@bindir@/nix-store --restore $v < /tmp/nar2";
|
||||||
die "cannot unpack /tmp/nar2 into `$v'" if ($? != 0);
|
die "cannot unpack /tmp/nar2 into `$v'" if ($? != 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
elsif ($edge->{type} eq "narfile") {
|
elsif ($edge->{type} eq "narfile") {
|
||||||
my $narFile = $edge->{info};
|
my $narFile = $edge->{info};
|
||||||
|
@ -251,6 +260,10 @@ while (scalar @path > 0) {
|
||||||
print " downloading archive...\n";
|
print " downloading archive...\n";
|
||||||
my $narFilePath = downloadFile "$narFile->{url}", "$narFile->{hash}";
|
my $narFilePath = downloadFile "$narFile->{url}", "$narFile->{hash}";
|
||||||
|
|
||||||
|
if ($curStep < $maxStep) {
|
||||||
|
# The archive will be used a base to a patch.
|
||||||
|
system "@bunzip2@ < '$narFilePath' > /tmp/nar";
|
||||||
|
} 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'";
|
||||||
|
@ -258,6 +271,9 @@ while (scalar @path > 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$curStep++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print LOGFILE "$$ success\n";
|
print LOGFILE "$$ success\n";
|
||||||
close LOGFILE;
|
close LOGFILE;
|
||||||
|
|
Loading…
Reference in a new issue