From: Wichert Akkerman Date: Sun, 10 Sep 2000 21:40:30 +0000 (+0000) Subject: scripts/dpkg-scanpackages.pl: modify to use most recent version X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5aa096a7f107e2d59f963dea6dcb77355b015960;p=dpkg scripts/dpkg-scanpackages.pl: modify to use most recent version of a package of multiple versions are found --- diff --git a/ChangeLog b/ChangeLog index e8367055..02a10f66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Sep 10 23:31:02 CEST 2000 Wichert Akkerman + + * scripts/dpkg-scanpackages.pl: modify to use most recent version + of a package of multiple versions are found + Sat Sep 9 21:17:37 CEST 2000 Wichert Akkerman * debian/control: add dependency on binutils for dpkg-dev (needed for diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl index 853c7d5d..56bb37f4 100755 --- a/scripts/dpkg-scanpackages.pl +++ b/scripts/dpkg-scanpackages.pl @@ -35,6 +35,14 @@ $#ARGV == 1 || $#ARGV == 2 -d $binarydir or die "Binary dir $binarydir not found\n"; -e $override or die "Override file $override not found\n"; +sub vercmp { + ($a,$b)=@_; + return $vercache{$a,$b} if defined($varcache{$a,$b}); + system("dpkg --compare-versions $a le $b"); + $varcache{$a,$a}=$?; + return $?; +} + # The extra slash causes symlinks to be followed. open(F,"find $binarydir/ -follow -name '*.deb' -print |") or die "Couldn't open pipe to find: $!\n"; @@ -72,10 +80,20 @@ while () { $p= $tv{'Package'}; delete $tv{'Package'}; if (defined($p1{$p})) { - print(STDERR " ! Package $p (filename $fn) is repeat;\n". - " ignored that one and using data from $pfilename{$p} !\n") - || die $!; - next; + if (&vercmp($tv{'Version'}, $pv{$p,'Version'})) { + print(STDERR " ! Package $p (filename $fn) is repeat but newer version;\n". + " used that one and ignored data from $pfilename{$p} !\n") + || die $!; + delete $p1{$p}; + for $k (keys %k1) { + delete $pv{$p,$k}; + } + } else { + print(STDERR " ! Package $p (filename $fn) is repeat;\n". + " ignored that one and using data from $pfilename{$p} !\n") + || die $!; + next; + } } print(STDERR " ! Package $p (filename $fn) has Filename field!\n") || die $! if defined($tv{'Filename'});