X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FWB%2FQD.pm;h=8391fc3066d05f3547c35d01e78524b71f564b25;hb=4572e2d58812a9c5f422a8c2e2401c441d528bb7;hp=f02378dfa89e8db5f208d35923cff3ef011195de;hpb=3d6d4dff99af12ffe90c3b7da9b13c5346039cb9;p=wannabuild.git diff --git a/lib/WB/QD.pm b/lib/WB/QD.pm index f02378d..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,20 @@ 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) { - print "SRC: $s\n"; my $S = new IO::Uncompress::AnyInflate($s) || return "WB::QD::SRC can't open $s"; while(<$S>) { my $p={}; @@ -42,15 +43,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; @@ -61,14 +65,15 @@ sub readsourcebins { 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'; @@ -95,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};