]> git.donarmstrong.com Git - wannabuild.git/blobdiff - lib/WB/QD.pm
WB::QD: handle case when arch=all-packages becomes arch=any (plus testcase)
[wannabuild.git] / lib / WB / QD.pm
index 25d2fb0234e3f7e0db684ed6dee4b8e81619614c..5f84d5ebe065b12a7b6cb6ac65e2afa82b16d6b1 100644 (file)
@@ -2,7 +2,12 @@ package WB::QD;
 
 use strict;
 use IO::Uncompress::AnyInflate qw(anyinflate);
-use Dpkg::Version qw(vercmp);
+use Dpkg::Version (); # import nothing
+if ( defined $Dpkg::Version::VERSION ) {
+    *vercmp = \&Dpkg::Version::version_compare;
+} else {
+    *vercmp = \&Dpkg::Version::vercmp;
+}
 use Dpkg::Arch qw(debarch_is);
 use Data::Dumper;
 
@@ -15,15 +20,15 @@ sub readsourcebins {
 
     my $pas = {};
     local($/) = "\n";
-    open(PAS, '<', $pasfile);
-    while(<PAS>) {
+    open(my $pasf, '<', $pasfile);
+    while(<$pasf>) {
         chomp;
         s,\s*#.*,,;
         next unless $_;
         my ($p, $c) = split(/:\s*/);
         $pas->{$p} = { arch => [ split(/\s+/, $c) ], mode => substr($c, 0, 1) ne '!' };
     }
-    close PAS;
+    close $pasf;
 
     my $srcs = {};
     local($/) = ""; # read in paragraph mode
@@ -52,8 +57,9 @@ sub readsourcebins {
             if ($srcs->{$p->{'name'}}) {
                 next if (vercmp($srcs->{$p->{'name'}}->{'version'}, $p->{'version'}) > 0);
             }
-            my @a = split(/,? /, $p->{'binary'}) if $p->{'binary'};
-            $p->{'binary'} = \@a;
+            if ($p->{'binary'}) {
+                $p->{'binary'} = [ split(/,? /, $p->{'binary'}) ];
+            }
             $srcs->{$p->{'name'}} = $p;
         }
         close $S;
@@ -71,6 +77,8 @@ sub readsourcebins {
             /^Source:\s*(\S+)$/mi and $p->{'source'} = $1;
             /^Source:\s*(\S+)\s+\((\S+)\)$/mi and $p->{'source'} = $1 and $p->{'version'} = $2;
 
+            # consider packages as non-existant if it's all but outdated
+            next if $p->{'arch'} eq 'all' && $srcs->{$p->{'source'}} && $srcs->{$p->{'source'}}->{'version'} && vercmp($srcs->{$p->{'source'}}->{'version'}, $p->{'version'}) > 0;
             next unless $p->{'arch'} eq 'all' || $p->{'arch'} eq ${arch};
             $binary->{$p->{'binary'}} = { 'version' => $p->{'version'}, 'arch' => $p->{'arch'}} unless $binary->{$p->{'binary'}} and vercmp($binary->{$p->{'binary'}}->{'version'}, $p->{'version'}) < 0;