X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FWB%2FQD.pm;h=8391fc3066d05f3547c35d01e78524b71f564b25;hb=4572e2d58812a9c5f422a8c2e2401c441d528bb;hp=75dc9e8679b651ed6fd3e5d982351d0bb414dbcd;hpb=15410f04a42f2314ac2c8c2c6cea83d1d179b857;p=wannabuild.git diff --git a/lib/WB/QD.pm b/lib/WB/QD.pm index 75dc9e8..8391fc3 100644 --- a/lib/WB/QD.pm +++ b/lib/WB/QD.pm @@ -3,6 +3,8 @@ package WB::QD; use strict; use IO::Uncompress::AnyInflate qw(anyinflate); use Dpkg::Version qw(vercmp); +use Dpkg::Arch qw(debarch_is); +use Data::Dumper; sub readsourcebins { my $arch = shift; @@ -13,21 +15,21 @@ sub readsourcebins { my $pas = {}; local($/) = "\n"; - open(PAS, '<', $pasfile); - while() { + open(my $pas, '<', $pasfile); + while(<$pas>) { 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 $pas; my $srcs = {}; local($/) = ""; # read in paragraph mode foreach my $s (@$SRC) { - my $S = new IO::Uncompress::AnyInflate($s) || return "can't open $s"; + my $S = new IO::Uncompress::AnyInflate($s) || return "WB::QD::SRC can't open $s"; while(<$S>) { my $p={}; /^Package:\s*(\S+)$/mi and $p->{'name'} = $1; @@ -41,33 +43,37 @@ 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; } foreach my $p (@$BIN) { - my $P = new IO::Uncompress::AnyInflate($p) || return "can't open $p"; + my $P = new IO::Uncompress::AnyInflate($p) || return "WB::QD::PKGS can't open $p"; while(<$P>) { my $p; /^Version:\s*(\S+)$/mi and $p->{'version'} = $1; + /^Version:\s*(\S+)\+b([0-9]+)$/mi and $p->{'version'} = $1 and $p->{'binnmu'} = $2; /^Architecture:\s*(\S+)$/mi and $p->{'arch'} = $1; /^Package:\s*(\S+)$/mi and $p->{'binary'} = $1; /^Package:\s*(\S+)$/mi and $p->{'source'} = $1; /^Source:\s*(\S+)$/mi and $p->{'source'} = $1; /^Source:\s*(\S+)\s+\((\S+)\)$/mi and $p->{'source'} = $1 and $p->{'version'} = $2; - $p->{'version'} =~ /(\S+)\+b([0-9]+)/ and $p->{'version'} = $1 and $p->{'binnmu'} = $2; - $binary->{$p->{'binary'}} = { 'version' => $p->{'version'}, 'arch' => $p->{'arch'}} unless $binary->{$p->{'binary'}} and vercmp($binary->{$p->{'binary'}->{'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; #next if $pas->{$p->{'binary'}} && pasignore($pas->{$p->{'binary'}}, $arch); next if $p->{'arch'} eq 'all'; @@ -94,6 +100,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};