X-Git-Url: https://git.donarmstrong.com/?p=wannabuild.git;a=blobdiff_plain;f=lib%2FWB%2FQD.pm;h=48ae97902b84e661ff9631f39b171e83af94afbd;hp=f02378dfa89e8db5f208d35923cff3ef011195de;hb=53d790e962438849e04d9c9e0169d03253fc8bef;hpb=3d6d4dff99af12ffe90c3b7da9b13c5346039cb9 diff --git a/lib/WB/QD.pm b/lib/WB/QD.pm index f02378d..48ae979 100644 --- a/lib/WB/QD.pm +++ b/lib/WB/QD.pm @@ -2,7 +2,14 @@ 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 { my $arch = shift; @@ -13,21 +20,20 @@ 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 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 +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; @@ -61,14 +70,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 +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};