6 use WannaBuild; # for version compare
9 print STDERR "Usage: $0 Packages1 Packages2 ..\n";
11 print STDERR "This perl scripts reads the Packages files given on the command line and\n";
12 print STDERR "outputs a Packages file which contians each package/architecture pair at most\n";
13 print STDERR "once, using the one with the highest version number.\n";
15 print STDERR "Since it only looks at Package:, Version: and Architecture:, it works with\n";
16 print STDERR "Sources files as well\n";
23 local($/) = ""; # read in paragraph mode
25 my( $version, $name, $architecture );
26 $architecture="none"; # better to keep an entry too much than to delete an entry
27 /^Package:\s*(\S+)$/mi and $name = $1;
28 /^Version:\s*(\S+)$/mi and $version = $1;
29 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
30 if (!defined $name or !defined $version) {
31 warn "Stanza without Package or Version\n";
34 my $key = $name."_".$architecture;
36 if ((!exists $version{$key}) or version_less($version{$key},$version)) {
37 $version{$key} = $version;
42 foreach (values %data) {
43 s/\n*$/\n\n/;# always one empty line to separate stanzas