4 use IO::Uncompress::AnyInflate qw(anyinflate);
5 use Dpkg::Version qw(vercmp);
16 open(PAS, '<', $pasfile);
21 my ($p, $c) = split(/:\s*/);
22 $pas->{$p} = { arch => [ split(/\s+/, $c) ], mode => substr($c, 0, 1) ne '!' };
27 local($/) = ""; # read in paragraph mode
29 foreach my $s (@$SRC) {
30 my $S = new IO::Uncompress::AnyInflate($s) || return "WB::QD::SRC can't open $s";
33 /^Package:\s*(\S+)$/mi and $p->{'name'} = $1;
34 /^Version:\s*(\S+)$/mi and $p->{'version'} = $1;
35 /^Binary:\s*(.*)$/mi and $p->{'binary'} = $1;
36 /^Architecture:\s*(.+)$/mi and $p->{'arch'} = $1;
37 /^Priority:\s*(\S+)$/mi and $p->{'priority'} = $1;
38 /^Section:\s*(\S+)$/mi and $p->{'section'} = $1;
39 /^Build-Depends:\s*(.*)$/mi and $p->{'depends'} = $1;
40 /^Build-Conflicts:\s*(.*)$/mi and $p->{'conflicts'} = $1;
42 next unless $p->{'name'} and $p->{'version'};
43 next if $p->{'arch'} eq 'all';
44 # TODO: respect the architecture - or not / we already respect it via P-a-s
47 # ignore if package already exists with higher version
48 if ($srcs->{$p->{'name'}}) {
49 next if (vercmp($srcs->{$p->{'name'}}->{'version'}, $p->{'version'}) > 0);
51 my @a = split(/,? /, $p->{'binary'}) if $p->{'binary'};
53 $srcs->{$p->{'name'}} = $p;
58 foreach my $p (@$BIN) {
59 my $P = new IO::Uncompress::AnyInflate($p) || return "WB::QD::PKGS can't open $p";
62 /^Version:\s*(\S+)$/mi and $p->{'version'} = $1;
63 /^Architecture:\s*(\S+)$/mi and $p->{'arch'} = $1;
64 /^Package:\s*(\S+)$/mi and $p->{'binary'} = $1;
65 /^Package:\s*(\S+)$/mi and $p->{'source'} = $1;
66 /^Source:\s*(\S+)$/mi and $p->{'source'} = $1;
67 /^Source:\s*(\S+)\s+\((\S+)\)$/mi and $p->{'source'} = $1 and $p->{'version'} = $2;
68 $p->{'version'} =~ /(\S+)\+b([0-9]+)/ and $p->{'version'} = $1 and $p->{'binnmu'} = $2;
70 next unless $p->{'arch'} eq 'all' || $p->{'arch'} eq ${arch};
71 $binary->{$p->{'binary'}} = { 'version' => $p->{'version'}, 'arch' => $p->{'arch'}} unless $binary->{$p->{'binary'}} and vercmp($binary->{$p->{'binary'}}->{'version'}, $p->{'version'}) < 0;
73 #next if $pas->{$p->{'binary'}} && pasignore($pas->{$p->{'binary'}}, $arch);
74 next if $p->{'arch'} eq 'all';
75 next unless $srcs->{$p->{'source'}};
76 $srcs->{$p->{'source'}}->{'compiled'} = 1;
77 next unless $srcs->{$p->{'source'}}->{'version'} eq $p->{'version'};
78 $srcs->{$p->{'source'}}->{'installed'} = 1;
79 next unless $p->{'binnmu'};
80 next if ($srcs->{$p->{'source'}}->{'binnmu'}) && ($srcs->{$p->{'source'}}->{'binnmu'} > $p->{'binnmu'});
81 $srcs->{$p->{'source'}}->{'binnmu'} = $p->{'binnmu'};
87 for my $k (keys %$srcs) {
88 if ($srcs->{$k}->{'installed'}) {
89 $srcs->{$k}->{'status'} = 'installed';
90 delete $srcs->{$k}->{'installed'};
91 } elsif ($srcs->{$k}->{'compiled'}) {
92 $srcs->{$k}->{'status'} = 'out-of-date';
94 $srcs->{$k}->{'status'} = 'uncompiled';
96 delete $srcs->{$k}->{'compiled'};
97 $srcs->{$k}->{'status'} = 'installed' if $srcs->{$k}->{'arch'} && $srcs->{$k}->{'arch'} eq 'all';
100 #$p ||= $pas->{'%'.$k};
101 #$srcs->{$k}->{'status'} = 'not-for-us' if pasignore($p, $arch);
102 if (pasignore($pas->{'%'.$k}, $arch)) {
103 $srcs->{$k}->{'status'} = 'not-for-us';
106 for my $bin (@{$srcs->{$k}->{'binary'}}) {
107 next if pasignore($pas->{$bin}, $arch);
108 next if $binary->{$bin} and $binary->{$bin}->{'arch'} eq 'all';
111 $srcs->{$k}->{'status'} = 'not-for-us';
113 $srcs->{'_binary'} = $binary;
122 if ($p && $p->{'mode'}) {
123 return 1 unless grep { $_ eq $arch } @{$p->{'arch'}};
125 if ($p && not $p->{'mode'}) {
126 return 1 if grep /^!$arch$/, @{$p->{'arch'}};