X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FWB%2FQD.pm;h=83527bc5f9775010f7cdfd7654621d12a954566b;hb=246b04b67089feb618f0bcd5bb47fe9573ab1978;hp=d5cefb328ea9388ec4c774ac0249a67e5c8e36e7;hpb=ee46693fa80dcafcc98db9adeca3d74e039be8b7;p=wannabuild.git diff --git a/lib/WB/QD.pm b/lib/WB/QD.pm index d5cefb3..83527bc 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 @@ -41,16 +47,17 @@ sub readsourcebins { /^Build-Conflicts:\s*(.*)$/mi and $p->{'conflicts'} = $1; 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 - delete $p->{'arch'}; + foreach my $tarch (split(/\s+/, $p->{'arch'})) { + $p->{'for-us'} = 1 if debarch_is($arch, $tarch); + } # 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; @@ -68,15 +75,29 @@ 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 + # arch:all and ver(binary) < ver(source) => skip + next if $p->{'arch'} eq 'all' && $srcs->{$p->{'source'}} && $srcs->{$p->{'source'}}->{'version'} && vercmp($srcs->{$p->{'source'}}->{'version'}, $p->{'version'}) > 0; + # not for the current architecture or arch:all => skip 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; + # register the binary if there isn't a newer one in the hash yet + $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); + + # only continue if it's arch-specific... next if $p->{'arch'} eq 'all'; + + # annotate the source package if present, continue otherwise next unless $srcs->{$p->{'source'}}; + $srcs->{$p->{'source'}}->{'compiled'} = 1; + + # TODO: ??? next unless $srcs->{$p->{'source'}}->{'version'} eq $p->{'version'}; $srcs->{$p->{'source'}}->{'installed'} = 1; + next unless $p->{'binnmu'}; next if ($srcs->{$p->{'source'}}->{'binnmu'}) && ($srcs->{$p->{'source'}}->{'binnmu'} > $p->{'binnmu'}); $srcs->{$p->{'source'}}->{'binnmu'} = $p->{'binnmu'}; @@ -96,20 +117,35 @@ 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'} = 'arch-not-in-arch-list'; + } + delete $srcs->{$k}->{'for-us'}; - #my $p = $pas->{$k}; - #$p ||= $pas->{'%'.$k}; - #$srcs->{$k}->{'status'} = 'not-for-us' if pasignore($p, $arch); + if ($srcs->{$k}->{'arch'} eq 'all') { + $srcs->{$k}->{'status'} = 'arch-all-only'; + delete $srcs->{$k}->{'arch'}; + next; + } + delete $srcs->{$k}->{'arch'}; + if (pasignore($pas->{'%'.$k}, $arch)) { - $srcs->{$k}->{'status'} = 'not-for-us'; + $srcs->{$k}->{'status'} = 'packages-arch-specific'; next; } for my $bin (@{$srcs->{$k}->{'binary'}}) { + $srcs->{$k}->{'pas'} = 1 if pasignore($pas->{$bin}, $arch); next if pasignore($pas->{$bin}, $arch); next if $binary->{$bin} and $binary->{$bin}->{'arch'} eq 'all'; next SRCS; } - $srcs->{$k}->{'status'} = 'not-for-us'; + if ($srcs->{$k}->{'pas'}) { + $srcs->{$k}->{'status'} = 'packages-arch-specific'; + } else { + $srcs->{$k}->{'status'} = 'overwritten-by-arch-all'; + } + delete $srcs->{$k}->{'pas'}; } $srcs->{'_binary'} = $binary; local($/) = "\n";