+ my $fh;
+ if ($file =~ /.gz$/) {
+ open($fh, '-|', 'gzip', '-d', '-c', $file)
+ or die("Can't open pipe from gzip: $!");
+ } else {
+ open($fh, '<', $file)
+ or die("Can't open $file: $!");
+ }
+
+ local($/) = ""; # read in paragraph mode
+ while (<$fh>) {
+ 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;
+ }
+ if ($arch ne "source" && defined $architecture && $architecture ne "all" && $architecture ne $arch) {
+ next;
+ }
+ my $key = $name;