diff options
-rw-r--r-- | perl/lib/Nix/Manifest.pm | 18 | ||||
-rw-r--r-- | scripts/download-from-binary-cache.pl.in | 2 | ||||
-rwxr-xr-x | scripts/download-using-manifests.pl.in | 20 | ||||
-rwxr-xr-x | scripts/nix-push.in | 1 | ||||
-rw-r--r-- | src/libstore/globals.hh | 1 |
5 files changed, 28 insertions, 14 deletions
diff --git a/perl/lib/Nix/Manifest.pm b/perl/lib/Nix/Manifest.pm index 7a7263c5a5b1..50f7777e4459 100644 --- a/perl/lib/Nix/Manifest.pm +++ b/perl/lib/Nix/Manifest.pm @@ -68,7 +68,7 @@ sub readManifest_ { my $manifestVersion = 2; my ($storePath, $url, $hash, $size, $basePath, $baseHash, $patchType); - my ($narHash, $narSize, $references, $deriver, $copyFrom, $system); + my ($narHash, $narSize, $references, $deriver, $copyFrom, $system, $compressionType); while (<MANIFEST>) { chomp; @@ -93,6 +93,7 @@ sub readManifest_ { undef $system; $references = ""; $deriver = ""; + $compressionType = "bzip2"; } } else { @@ -107,6 +108,7 @@ sub readManifest_ { , references => $references , deriver => $deriver , system => $system + , compressionType => $compressionType }); } @@ -125,6 +127,7 @@ sub readManifest_ { elsif (/^\s*CopyFrom:\s*(\/\S+)\s*$/) { $copyFrom = $1; } elsif (/^\s*Hash:\s*(\S+)\s*$/) { $hash = $1; } elsif (/^\s*URL:\s*(\S+)\s*$/) { $url = $1; } + elsif (/^\s*Compression:\s*(\S+)\s*$/) { $compressionType = $1; } elsif (/^\s*Size:\s*(\d+)\s*$/) { $size = $1; } elsif (/^\s*BasePath:\s*(\/\S+)\s*$/) { $basePath = $1; } elsif (/^\s*BaseHash:\s*(\S+)\s*$/) { $baseHash = $1; } @@ -172,6 +175,7 @@ sub writeManifest { print MANIFEST "{\n"; print MANIFEST " StorePath: $storePath\n"; print MANIFEST " NarURL: $narFile->{url}\n"; + print MANIFEST " Compression: $narFile->{compressionType}\n"; print MANIFEST " Hash: $narFile->{hash}\n" if defined $narFile->{hash}; print MANIFEST " Size: $narFile->{size}\n" if defined $narFile->{size}; print MANIFEST " NarHash: $narFile->{narHash}\n"; @@ -225,7 +229,8 @@ sub updateManifestDB { mkpath($manifestDir); - my $dbPath = "$manifestDir/cache.sqlite"; + unlink "$manifestDir/cache.sqlite"; # remove obsolete cache + my $dbPath = "$manifestDir/cache-v2.sqlite"; # Open/create the database. our $dbh = DBI->connect("dbi:SQLite:dbname=$dbPath", "", "") @@ -252,6 +257,7 @@ EOF manifest integer not null, storePath text not null, url text not null, + compressionType text not null, hash text, size integer, narHash text, @@ -292,8 +298,8 @@ EOF flock(MAINLOCK, LOCK_EX) or die; our $insertNAR = $dbh->prepare( - "insert into NARs(manifest, storePath, url, hash, size, narHash, " . - "narSize, refs, deriver, system) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") or die; + "insert into NARs(manifest, storePath, url, compressionType, hash, size, narHash, " . + "narSize, refs, deriver, system) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") or die; our $insertPatch = $dbh->prepare( "insert into Patches(manifest, storePath, basePath, baseHash, url, hash, " . @@ -327,8 +333,8 @@ EOF sub addNARToDB { my ($storePath, $narFile) = @_; $insertNAR->execute( - $id, $storePath, $narFile->{url}, $narFile->{hash}, $narFile->{size}, - $narFile->{narHash}, $narFile->{narSize}, $narFile->{references}, + $id, $storePath, $narFile->{url}, $narFile->{compressionType}, $narFile->{hash}, + $narFile->{size}, $narFile->{narHash}, $narFile->{narSize}, $narFile->{references}, $narFile->{deriver}, $narFile->{system}); }; diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in index f49f246613a0..751623eebf2e 100644 --- a/scripts/download-from-binary-cache.pl.in +++ b/scripts/download-from-binary-cache.pl.in @@ -508,7 +508,7 @@ sub downloadBinary { next; } my $url = "$cache->{url}/$info->{url}"; # FIXME: handle non-relative URLs - print STDERR "\n*** Downloading ‘$url’ into ‘$storePath’...\n"; + print STDERR "\n*** Downloading ‘$url’ to ‘$storePath’...\n"; Nix::Utils::checkURL $url; if (system("$Nix::Config::curl --fail --location --insecure '$url' | $decompressor | $Nix::Config::binDir/nix-store --restore $storePath") != 0) { die "download of `$info->{url}' failed" . ($! ? ": $!" : "") . "\n" unless $? == 0; diff --git a/scripts/download-using-manifests.pl.in b/scripts/download-using-manifests.pl.in index 24f7c98e0cb9..8f66a292e361 100755 --- a/scripts/download-using-manifests.pl.in +++ b/scripts/download-using-manifests.pl.in @@ -325,7 +325,7 @@ while (scalar @path > 0) { # into the target path. print STDERR " unpacking patched archive...\n"; system("$Nix::Config::binDir/nix-store --restore $v < $tmpNar2") == 0 - or die "cannot unpack $tmpNar2 into `$v'\n"; + or die "cannot unpack $tmpNar2 to `$v'\n"; } $finalNarHash = $patch->{narHash}; @@ -333,20 +333,26 @@ while (scalar @path > 0) { elsif ($edge->{type} eq "narfile") { my $narFile = $edge->{info}; - print STDERR "downloading `$narFile->{url}' into `$v'\n"; + print STDERR "downloading `$narFile->{url}' to `$v'\n"; my $size = $narFile->{size} || -1; print LOGFILE "$$ narfile $narFile->{url} $size $v\n"; Nix::Utils::checkURL $narFile->{url}; + + my $decompressor = + $narFile->{compressionType} eq "bzip2" ? "$Nix::Config::bzip2 -d" : + $narFile->{compressionType} eq "xz" ? "$Nix::Config::xz -d" : + die "unknown compression type `$narFile->{compressionType}'"; + if ($curStep < $maxStep) { # The archive will be used a base to a patch. - system("$curl '$narFile->{url}' | $Nix::Config::bzip2 -d > $tmpNar") == 0 - or die "cannot download and unpack `$narFile->{url}' into `$v'\n"; + system("$curl '$narFile->{url}' | $decompressor > $tmpNar") == 0 + or die "cannot download and unpack `$narFile->{url}' to `$v'\n"; } else { - # Unpack the archive into the target path. - system("$curl '$narFile->{url}' | $Nix::Config::bzip2 -d | $Nix::Config::binDir/nix-store --restore '$v'") == 0 - or die "cannot download and unpack `$narFile->{url}' into `$v'\n"; + # Unpack the archive to the target path. + system("$curl '$narFile->{url}' | $decompressor | $Nix::Config::binDir/nix-store --restore '$v'") == 0 + or die "cannot download and unpack `$narFile->{url}' to `$v'\n"; } $finalNarHash = $narFile->{narHash}; diff --git a/scripts/nix-push.in b/scripts/nix-push.in index 1edd8e77314b..00d03c3c1f0c 100755 --- a/scripts/nix-push.in +++ b/scripts/nix-push.in @@ -227,6 +227,7 @@ for (my $n = 0; $n < scalar @storePaths; $n++) { { url => "$archivesURL/$narName" , hash => "sha256:$compressedHash" , size => $compressedSize + , compressionType => $compressionType , narHash => "$narHash" , narSize => $narSize , references => join(" ", @{$refs}) diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 1fb196db2924..d25ee6adca30 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -3,6 +3,7 @@ #include "types.hh" #include <map> +#include <sys/types.h> namespace nix { |