From 009aaa975da342fdeaeb7932b95eac0e632e56cb Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Wed, 29 Jul 2009 16:01:26 +0200 Subject: [PATCH] bin/keep-latest: Consider architecture field MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Since keep-latest is written to merge incoming’s Packages file, which contains various arches, into a regular one, one must not remove packages just because there is a newer version on an other architecture. --- bin/keep-latest | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/keep-latest b/bin/keep-latest index eabcc10..c66c41b 100755 --- a/bin/keep-latest +++ b/bin/keep-latest @@ -9,11 +9,11 @@ if (!@ARGV) { print STDERR "Usage: $0 Packages1 Packages2 ..\n"; print STDERR "\n"; print STDERR "This perl scripts reads the Packages files given on the command line and\n"; - print STDERR "outputs a Packages file which contians each package exactly once, using the\n"; - print STDERR "one with the highest version number.\n"; + print STDERR "outputs a Packages file which contians each package/architecture pair at most\n"; + print STDERR "once, using the one with the highest version number.\n"; print STDERR ""; - print STDERR "Since it only looks at Package: and Version:, it works with Sources files\n"; - print STDERR "as well\n"; + print STDERR "Since it only looks at Package:, Version: and Architecture:, it works with\n"; + print STDERR "Sources files as well\n"; exit 1; } @@ -22,17 +22,20 @@ my %data; local($/) = ""; # read in paragraph mode while (<>) { - my( $version, $name ); + my( $version, $name, $architecture ); + $architecture="none"; # better to keep an entry too much than to delete an entry /^Package:\s*(\S+)$/mi and $name = $1; /^Version:\s*(\S+)$/mi and $version = $1; + /^Architecture:\s*(\S+)$/mi and $architecture = $1; if (!defined $name or !defined $version) { warn "Stanza without Package or Version\n"; next; } + my $key = $name."_".$architecture; - if ((!exists $version{$name}) or version_less($version{name},$version)) { - $version{$name} = $version; - $data{$name} = $_; + if ((!exists $version{$key}) or version_less($version{$key},$version)) { + $version{$key} = $version; + $data{$key} = $_; } } -- 2.39.5