4 use IO::Uncompress::AnyInflate qw(anyinflate);
5 use Dpkg::Version qw(vercmp);
17 open(PAS, '<', $pasfile);
22 my ($p, $c) = split(/:\s*/);
23 $pas->{$p} = { arch => [ split(/\s+/, $c) ], mode => substr($c, 0, 1) ne '!' };
28 local($/) = ""; # read in paragraph mode
30 foreach my $s (@$SRC) {
31 my $S = new IO::Uncompress::AnyInflate($s) || return "WB::QD::SRC can't open $s";
34 /^Package:\s*(\S+)$/mi and $p->{'name'} = $1;
35 /^Version:\s*(\S+)$/mi and $p->{'version'} = $1;
36 /^Binary:\s*(.*)$/mi and $p->{'binary'} = $1;
37 /^Architecture:\s*(.+)$/mi and $p->{'arch'} = $1;
38 /^Priority:\s*(\S+)$/mi and $p->{'priority'} = $1;
39 /^Section:\s*(\S+)$/mi and $p->{'section'} = $1;
40 /^Build-Depends:\s*(.*)$/mi and $p->{'depends'} = $1;
41 /^Build-Conflicts:\s*(.*)$/mi and $p->{'conflicts'} = $1;
43 next unless $p->{'name'} and $p->{'version'};
44 next if $p->{'arch'} eq 'all';
45 # TODO: respect the architecture - or not / we already respect it via P-a-s
48 # ignore if package already exists with higher version
49 if ($srcs->{$p->{'name'}}) {
50 next if (vercmp($srcs->{$p->{'name'}}->{'version'}, $p->{'version'}) > 0);
52 my @a = split(/,? /, $p->{'binary'}) if $p->{'binary'};
54 $srcs->{$p->{'name'}} = $p;
59 foreach my $p (@$BIN) {
60 my $P = new IO::Uncompress::AnyInflate($p) || return "WB::QD::PKGS can't open $p";
63 /^Version:\s*(\S+)$/mi and $p->{'version'} = $1;
64 /^Version:\s*(\S+)\+b([0-9]+)$/mi and $p->{'version'} = $1 and $p->{'binnmu'} = $2;
65 /^Architecture:\s*(\S+)$/mi and $p->{'arch'} = $1;
66 /^Package:\s*(\S+)$/mi and $p->{'binary'} = $1;
67 /^Package:\s*(\S+)$/mi and $p->{'source'} = $1;
68 /^Source:\s*(\S+)$/mi and $p->{'source'} = $1;
69 /^Source:\s*(\S+)\s+\((\S+)\)$/mi and $p->{'source'} = $1 and $p->{'version'} = $2;
71 next unless $p->{'arch'} eq 'all' || $p->{'arch'} eq ${arch};
72 $binary->{$p->{'binary'}} = { 'version' => $p->{'version'}, 'arch' => $p->{'arch'}} unless $binary->{$p->{'binary'}} and vercmp($binary->{$p->{'binary'}}->{'version'}, $p->{'version'}) < 0;
74 #next if $pas->{$p->{'binary'}} && pasignore($pas->{$p->{'binary'}}, $arch);
75 next if $p->{'arch'} eq 'all';
76 next unless $srcs->{$p->{'source'}};
77 $srcs->{$p->{'source'}}->{'compiled'} = 1;
78 next unless $srcs->{$p->{'source'}}->{'version'} eq $p->{'version'};
79 $srcs->{$p->{'source'}}->{'installed'} = 1;
80 next unless $p->{'binnmu'};
81 next if ($srcs->{$p->{'source'}}->{'binnmu'}) && ($srcs->{$p->{'source'}}->{'binnmu'} > $p->{'binnmu'});
82 $srcs->{$p->{'source'}}->{'binnmu'} = $p->{'binnmu'};
88 for my $k (keys %$srcs) {
89 if ($srcs->{$k}->{'installed'}) {
90 $srcs->{$k}->{'status'} = 'installed';
91 delete $srcs->{$k}->{'installed'};
92 } elsif ($srcs->{$k}->{'compiled'}) {
93 $srcs->{$k}->{'status'} = 'out-of-date';
95 $srcs->{$k}->{'status'} = 'uncompiled';
97 delete $srcs->{$k}->{'compiled'};
98 $srcs->{$k}->{'status'} = 'installed' if $srcs->{$k}->{'arch'} && $srcs->{$k}->{'arch'} eq 'all';
101 #$p ||= $pas->{'%'.$k};
102 #$srcs->{$k}->{'status'} = 'not-for-us' if pasignore($p, $arch);
103 if (pasignore($pas->{'%'.$k}, $arch)) {
104 $srcs->{$k}->{'status'} = 'not-for-us';
107 for my $bin (@{$srcs->{$k}->{'binary'}}) {
108 next if pasignore($pas->{$bin}, $arch);
109 next if $binary->{$bin} and $binary->{$bin}->{'arch'} eq 'all';
112 $srcs->{$k}->{'status'} = 'not-for-us';
114 $srcs->{'_binary'} = $binary;
123 if ($p && $p->{'mode'}) {
124 return 1 unless grep { $_ eq $arch } @{$p->{'arch'}};
126 if ($p && not $p->{'mode'}) {
127 return 1 if grep /^!$arch$/, @{$p->{'arch'}};