X-Git-Url: https://git.donarmstrong.com/?p=wannabuild.git;a=blobdiff_plain;f=lib%2FWB%2FQD.pm;h=48ae97902b84e661ff9631f39b171e83af94afbd;hp=d5cefb328ea9388ec4c774ac0249a67e5c8e36e7;hb=53d790e962438849e04d9c9e0169d03253fc8bef;hpb=eb5070e2cad4a201ff88083826d9db670ca571fd diff --git a/lib/WB/QD.pm b/lib/WB/QD.pm index d5cefb3..48ae979 100644 --- a/lib/WB/QD.pm +++ b/lib/WB/QD.pm @@ -2,7 +2,13 @@ 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; sub readsourcebins { @@ -14,15 +20,15 @@ sub readsourcebins { my $pas = {}; local($/) = "\n"; - open(PAS, '<', $pasfile); - while() { + 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 @@ -42,15 +48,18 @@ sub readsourcebins { next unless $p->{'name'} and $p->{'version'}; next if $p->{'arch'} eq 'all'; - # TODO: respect the architecture - or not / we already respect it via P-a-s + foreach my $tarch (split(/\s+/, $p->{'arch'})) { + $p->{'for-us'} = 1 if debarch_is($arch, $tarch); + } delete $p->{'arch'}; # ignore if package already exists with higher version 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; @@ -96,6 +105,11 @@ sub readsourcebins { } delete $srcs->{$k}->{'compiled'}; $srcs->{$k}->{'status'} = 'installed' if $srcs->{$k}->{'arch'} && $srcs->{$k}->{'arch'} eq 'all'; + + if (!$srcs->{$k}->{'for-us'} && $srcs->{$k}->{'status'} ne 'installed') { + $srcs->{$k}->{'status'} = 'auto-not-for-us'; + } + delete $srcs->{$k}->{'for-us'}; #my $p = $pas->{$k}; #$p ||= $pas->{'%'.$k};