6 use lib '/org/wanna-build/bin';
7 use WannaBuild; # for version compare
10 print STDERR "Usage: $0 arch Packages1 Packages2 ..\n";
12 print STDERR "This perl scripts reads the Packages files given on the command line and\n";
13 print STDERR "outputs a Packages file which contians each package at most\n";
14 print STDERR "once, using the one with the highest version number.\n";
16 print STDERR "Since it only looks at Package:, Version: and Architecture:, it works with\n";
17 print STDERR "Sources files as well\n";
19 print STDERR "It throws out any package not arch \"all\" or the given architecture.\n";
20 print STDERR "Pass \"source\" to keep all entries.\n";
28 my $arch = shift @ARGV;
30 local($/) = ""; # read in paragraph mode
32 my( $version, $name, $architecture );
33 $architecture="none"; # better to keep an entry too much than to delete an entry
34 /^Package:\s*(\S+)$/mi and $name = $1;
35 /^Version:\s*(\S+)$/mi and $version = $1;
36 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
37 if (!defined $name or !defined $version) {
38 warn "Stanza without Package or Version\n";
41 if ($arch ne "source" && defined $architecture && $architecture ne "all" && $architecture ne $arch) {
46 if ((!exists $version{$key}) or version_less($version{$key},$version)) {
47 $version{$key} = $version;
52 foreach (values %data) {
53 s/\n*$/\n\n/;# always one empty line to separate stanzas