diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/generate-patches.pl.in | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/scripts/generate-patches.pl.in b/scripts/generate-patches.pl.in index 148b7d81f..dba647350 100755 --- a/scripts/generate-patches.pl.in +++ b/scripts/generate-patches.pl.in @@ -20,11 +20,11 @@ die unless scalar @ARGV == 5; my $hashAlgo = "sha256"; -my $cacheDir = $ARGV[0]; +my $narDir = $ARGV[0]; my $patchesDir = $ARGV[1]; my $patchesURL = $ARGV[2]; -my $srcDir = $ARGV[3]; -my $dstDir = $ARGV[4]; +my $srcManifest = $ARGV[3]; +my $dstManifest = $ARGV[4]; my $tmpDir = tempdir("nix-generate-patches.XXXXXX", CLEANUP => 1, TMPDIR => 1) or die "cannot create a temporary directory"; @@ -41,10 +41,10 @@ my %dstNarFiles; my %dstLocalPaths; my %dstPatches; -readManifest "$srcDir/MANIFEST", +readManifest "$srcManifest", \%srcNarFiles, \%srcLocalPaths, \%srcPatches; -readManifest "$dstDir/MANIFEST", +readManifest "$dstManifest", \%dstNarFiles, \%dstLocalPaths, \%dstPatches; @@ -55,8 +55,7 @@ sub findOutputPaths { foreach my $p (keys %{$narFiles}) { - # Ignore store expressions. - next if ($p =~ /\.store$/); + # Ignore derivations. next if ($p =~ /\.drv$/); # Ignore builders (too much ambiguity -- they're all called @@ -65,7 +64,7 @@ sub findOutputPaths { next if ($p =~ /\.patch$/); # Don't bother including tar files etc. - next if ($p =~ /\.tar\.(gz|bz2)$/ || $p =~ /\.zip$/ || $p =~ /\.bin$/); + next if ($p =~ /\.tar$/ || $p =~ /\.tar\.(gz|bz2|Z|lzma|xz)$/ || $p =~ /\.zip$/ || $p =~ /\.bin$/ || $p =~ /\.tgz$/ || $p =~ /\.rpm$/ || $p =~ /cvs-export$/ || $p =~ /fetchhg$/); $outPaths{$p} = 1; } @@ -85,6 +84,7 @@ sub getNameVersion { $p =~ /\/[0-9a-z]+((?:-[a-zA-Z][^\/-]*)+)([^\/]*)$/; my $name = $1; my $version = $2; + return undef unless defined $name && defined $version; $name =~ s/^-//; $version =~ s/^-//; return ($name, $version); @@ -112,14 +112,14 @@ sub getNarBz2 { my $storePath = shift; my $narFileList = $$narFiles{$storePath}; - die "missing store expression $storePath" unless defined $narFileList; + die "missing path $storePath" unless defined $narFileList; my $narFile = @{$narFileList}[0]; die unless defined $narFile; $narFile->{url} =~ /\/([^\/]+)$/; die unless defined $1; - return "$cacheDir/$1"; + return "$narDir/$1"; } @@ -213,6 +213,7 @@ foreach my $p (keys %dstOutPaths) { # this path. (my $name, my $version) = getNameVersion $p; + next unless defined $name && defined $version; my @closest = (); my $closestVersion; @@ -222,6 +223,8 @@ foreach my $p (keys %dstOutPaths) { foreach my $q (keys %srcOutPaths) { (my $name2, my $version2) = getNameVersion $q; + next unless defined $name2 && defined $version2; + if ($name eq $name2) { # If the sizes differ too much, then skip. This @@ -241,11 +244,11 @@ foreach my $p (keys %dstOutPaths) { # If the numbers of weighted uses differ too much, then # skip. This disambiguates between, e.g., the bootstrap # GCC and the final GCC in Nixpkgs. - my $srcUses = computeUses \%srcNarFiles, $q; - my $dstUses = computeUses \%dstNarFiles, $p; - $ratio = $srcUses / $dstUses; - $ratio = 1 / $ratio if $ratio < 1; - print " USE $srcUses $dstUses $ratio $q\n"; +# my $srcUses = computeUses \%srcNarFiles, $q; +# my $dstUses = computeUses \%dstNarFiles, $p; +# $ratio = $srcUses / $dstUses; +# $ratio = 1 / $ratio if $ratio < 1; +# print " USE $srcUses $dstUses $ratio $q\n"; # if ($ratio >= 2) { # print " SKIPPING $q due to use ratio $ratio ($srcUses $dstUses)\n"; @@ -288,6 +291,11 @@ foreach my $p (keys %dstOutPaths) { my $srcNarBz2 = getNarBz2 \%srcNarFiles, $closest; my $dstNarBz2 = getNarBz2 \%dstNarFiles, $p; + if (! -f $srcNarBz2) { + warn "patch source archive $srcNarBz2 is missing\n"; + next; + } + system("@bunzip2@ < $srcNarBz2 > $tmpDir/A") == 0 or die "cannot unpack $srcNarBz2"; @@ -404,5 +412,5 @@ do { # Rewrite the manifest of the destination (with the new patches). -writeManifest "$dstDir/MANIFEST", +writeManifest "${dstManifest}", \%dstNarFiles, \%dstPatches; |