* 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.
This commit is contained in:
Eelco Dolstra 2005-02-28 14:12:06 +00:00
parent 8376fff151
commit 2c4302dd7a
2 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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