Author: eelco
Date: 2010-06-23 21:11:33 +0000 (Wed, 23 Jun 2010)
New Revision: 22401

You can view the changes in this commit at:
   https://svn.nixos.org/viewvc/nix?rev=22401&view=rev

Modified:
   nix/trunk/scripts/generate-patches.pl.in

Log:
* Ignore packages that don't have a version.
* Work on a manifest instead of a channel directory.


Changes:

Modified: nix/trunk/scripts/generate-patches.pl.in
===================================================================
--- nix/trunk/scripts/generate-patches.pl.in    2010-06-23 14:35:18 UTC (rev 
22400)
+++ nix/trunk/scripts/generate-patches.pl.in    2010-06-23 21:11:33 UTC (rev 
22401)
@@ -20,11 +20,11 @@
 
 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 %dstLocalPaths;
 my %dstPatches;
 
-readManifest "$srcDir/MANIFEST",
+readManifest "$srcManifest",
     \%srcNarFiles, \%srcLocalPaths, \%srcPatches;
 
-readManifest "$dstDir/MANIFEST",
+readManifest "$dstManifest",
     \%dstNarFiles, \%dstLocalPaths, \%dstPatches;
 
 
@@ -55,8 +55,7 @@
     
     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
@@ -85,6 +84,7 @@
     $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 @@
     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 @@
     # this path.
 
     (my $name, my $version) = getNameVersion $p;
+    next unless defined $name && defined $version;
 
     my @closest = ();
     my $closestVersion;
@@ -222,6 +223,8 @@
 
     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 @@
             # 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";
@@ -404,5 +407,5 @@
 
 
 # Rewrite the manifest of the destination (with the new patches).
-writeManifest "$dstDir/MANIFEST",
+writeManifest "${dstManifest}",
     \%dstNarFiles, \%dstPatches;

_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to