Control: tags -1 patch

On 2023-07-11 11:45:25 +0200, Vincent Lefevre wrote:
> IMHO, for architecture "all", either only the Packages file that
> corresponds to the main architecture of the machine should be
> considered, or the latest version between the various packages
> should be chosen. In the current case, these two strategies are
> equivalent, but there may be cases where a foreign architecture
> may have a more recent version.
> 
> Ideally, the same rule as apt should be chosen. I think that it
> chooses the latest version, as in the past, IIRC, I was offered the
> choice to upgrade the "Architecture: all" packages when available
> for the foreign architecture only.

I note that there is a version comparison in sub parse_file:

                if (!defined $packages->{$package->{$PACKAGE}} or
                    !defined 
$packages->{$package->{$PACKAGE}}{$package->{$ARCH}}{$VERS} or
                    
$vs->compare($packages->{$package->{$PACKAGE}}{$package->{$ARCH}}{$VERS},
                         $package->{$VERS}) < 0) {
                    $package->{$RELEASE} = $release;
                    $packages->{$package->{$PACKAGE}}{$package->{$ARCH}} = 
$package;
                }

So, if I understand correctly, if a Packages file contains several
versions of a package, the most recent one will be chosen. But such
a comparison is absent when these versions are in different Packages
files. I've attached a patch to add this comparison. Now, if I do

# ./apt-show-versions -i

with the patched version:

cventin:~> apt-show-versions -a libreoffice-common
libreoffice-common:all 4:7.5.4-4 install ok installed
libreoffice-common:all 4:7.4.5-3     stable       ftp.debian.org
No stable-updates version
libreoffice-common:all 4:7.4.5-3     testing      ftp.debian.org
libreoffice-common:all 4:7.5.4-4     unstable     ftp.debian.org
libreoffice-common:all 4:7.5.5~rc1-2 experimental ftp.debian.org
libreoffice-common:all/unstable 4:7.5.4-4 uptodate

cventin:~> apt-show-versions -a libreoffice
libreoffice:amd64 4:7.5.4-4 install ok installed
libreoffice:amd64 4:7.4.5-3     stable       ftp.debian.org
No stable-updates version
libreoffice:amd64 4:7.4.5-3     testing      ftp.debian.org
libreoffice:amd64 4:7.5.4-4     unstable     ftp.debian.org
libreoffice:amd64 4:7.5.5~rc1-2 experimental ftp.debian.org
libreoffice:amd64/unstable 4:7.5.4-4 uptodate
libreoffice:i386 4:7.4.5-3     stable       ftp.debian.org
No stable-updates version
libreoffice:i386 4:7.4.5-3     testing      ftp.debian.org
libreoffice:i386 4:7.4.5-3     unstable     ftp.debian.org
libreoffice:i386 4:7.5.5~rc1-2 experimental ftp.debian.org
libreoffice:i386 not installed

This seems correct.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
--- apt-show-versions~	2022-10-15 09:52:39.000000000 +0000
+++ apt-show-versions	2023-07-11 10:10:03.205293265 +0000
@@ -267,7 +267,10 @@
         my ($href, $release) = &parse_file ($_);
         foreach my $pkg (keys %$href) {
 	    foreach my $arch (keys %{$href->{$pkg}}) {
-                $apackages->{$pkg}{$arch}{$release} = $href->{$pkg}{$arch};
+                $apackages->{$pkg}{$arch}{$release} = $href->{$pkg}{$arch} if
+                  (!defined $apackages->{$pkg}{$arch}{$release} ||
+                   $vs->compare($apackages->{$pkg}{$arch}{$release}{$VERS},
+                                $href->{$pkg}{$arch}{$VERS}) < 0);
             }
 	}
     }

Reply via email to