From 2c4302dd7a437c3153d6de704fb5ddec004ea308 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 28 Feb 2005 14:12:06 +0000 Subject: [PATCH] * Added a disambiguation heuristic: if two components have the same name but differ to much in sice (by more than a factor of 3), then never generate a patch. --- scripts/Makefile.am | 2 +- scripts/generate-patches.pl.in | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 20e42e74c5..8f42095b40 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -2,7 +2,7 @@ bin_SCRIPTS = nix-collect-garbage \ nix-pull nix-push nix-prefetch-url \ nix-install-package nix-channel nix-build -noinst_SCRIPTS = nix-profile.sh +noinst_SCRIPTS = nix-profile.sh generate-patches.pl nix-pull nix-push: readmanifest.pm download-using-manifests.pl diff --git a/scripts/generate-patches.pl.in b/scripts/generate-patches.pl.in index ef4ddcda4a..87334b5fcb 100755 --- a/scripts/generate-patches.pl.in +++ b/scripts/generate-patches.pl.in @@ -134,11 +134,11 @@ print "creating patches...\n"; foreach my $p (keys %dstOutPaths) { # If exactly the same path already exists in the source, skip it. - next if defined $srcOutPaths{$p}; +# !!! next if defined $srcOutPaths{$p}; -# print " $p\n"; + print " $p\n"; - # If not, then we should find the path in the source that is + # If not, then we should find the paths in the source that are # `most' likely to be present on a system that wants to install # this path. @@ -153,6 +153,22 @@ foreach my $p (keys %dstOutPaths) { foreach my $q (keys %srcOutPaths) { (my $name2, my $version2) = getNameVersion $q; if ($name eq $name2) { + + # If the sizes differ to much, then skip. This + # disambiguates between, e.g., a real component and a + # wrapper component (cf. Firefox in Nixpkgs). + my $srcSize = @{$srcNarFiles{$q}}[0]->{size}; + my $dstSize = @{$dstNarFiles{$p}}[0]->{size}; + my $ratio = $srcSize / $dstSize; + $ratio = 1 / $ratio if $ratio < 1; + print " $srcSize $dstSize $ratio $q\n"; + + if ($ratio >= 3) { + print " SKIPPING $q due to size ratio $ratio\n"; + } + + # If there are multiple matching names, include the ones + # with the closest version numbers. my $dist = versionDiff $version, $version2; if ($dist > $minDist) { $minDist = $dist; @@ -174,6 +190,8 @@ foreach my $p (keys %dstOutPaths) { # Generate a patch between $closest and $p. print " $p <- $closest\n"; + next; + # If the patch already exists, skip it. if (containsPatch(\%srcPatches, $p, $closest) || containsPatch(\%dstPatches, $p, $closest)) @@ -242,6 +260,8 @@ foreach my $p (keys %dstOutPaths) { } } +exit 0; # !!! + # Add in any potentially useful patches in the source (namely, those # patches that produce either paths in the destination or paths that