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 exactly once, using the\n";
13 print STDERR "one with the highest version number.\n";
15 print STDERR "Since it only looks at Package: and Version:, it works with Sources files\n";
16 print STDERR "as well\n";
23 local($/) = ""; # read in paragraph mode
25 my( $version, $name );
26 /^Package:\s*(\S+)$/mi and $name = $1;
27 /^Version:\s*(\S+)$/mi and $version = $1;
28 if (!defined $name or !defined $version) {
29 warn "Stanza without Package or Version\n";
33 if ((!exists $version{$name}) or version_less($version{name},$version)) {
34 $version{$name} = $version;
39 foreach (values %data) {
40 s/\n*$/\n\n/;# always one empty line to separate stanzas