4 use IO::Uncompress::AnyInflate qw(anyinflate);
5 use Dpkg::Version (); # import nothing
6 if ( defined $Dpkg::Version::VERSION ) {
7 *vercmp = \&Dpkg::Version::version_compare;
9 *vercmp = \&Dpkg::Version::vercmp;
11 use Dpkg::Arch qw(debarch_is);
23 open(my $pasf, '<', $pasfile);
28 my ($p, $c) = split(/:\s*/);
29 $pas->{$p} = { arch => [ split(/\s+/, $c) ], mode => substr($c, 0, 1) ne '!' };
34 local($/) = ""; # read in paragraph mode
36 foreach my $s (@$SRC) {
37 my $S = new IO::Uncompress::AnyInflate($s) || return "WB::QD::SRC can't open $s";
40 /^Package:\s*(\S+)$/mi and $p->{'name'} = $1;
41 /^Version:\s*(\S+)$/mi and $p->{'version'} = $1;
42 /^Binary:\s*(.*)$/mi and $p->{'binary'} = $1;
43 /^Architecture:\s*(.+)$/mi and $p->{'arch'} = $1;
44 /^Priority:\s*(\S+)$/mi and $p->{'priority'} = $1;
45 /^Section:\s*(\S+)$/mi and $p->{'section'} = $1;
46 /^Build-Depends:\s*(.*)$/mi and $p->{'depends'} = $1;
47 /^Build-Conflicts:\s*(.*)$/mi and $p->{'conflicts'} = $1;
49 next unless $p->{'name'} and $p->{'version'};
50 next if $p->{'arch'} eq 'all';
51 foreach my $tarch (split(/\s+/, $p->{'arch'})) {
52 $p->{'for-us'} = 1 if debarch_is($arch, $tarch);
56 # ignore if package already exists with higher version
57 if ($srcs->{$p->{'name'}}) {
58 next if (vercmp($srcs->{$p->{'name'}}->{'version'}, $p->{'version'}) > 0);
61 $p->{'binary'} = [ split(/,? /, $p->{'binary'}) ];
63 $srcs->{$p->{'name'}} = $p;
68 foreach my $p (@$BIN) {
69 my $P = new IO::Uncompress::AnyInflate($p) || return "WB::QD::PKGS can't open $p";
72 /^Version:\s*(\S+)$/mi and $p->{'version'} = $1;
73 /^Version:\s*(\S+)\+b([0-9]+)$/mi and $p->{'version'} = $1 and $p->{'binnmu'} = $2;
74 /^Architecture:\s*(\S+)$/mi and $p->{'arch'} = $1;
75 /^Package:\s*(\S+)$/mi and $p->{'binary'} = $1;
76 /^Package:\s*(\S+)$/mi and $p->{'source'} = $1;
77 /^Source:\s*(\S+)$/mi and $p->{'source'} = $1;
78 /^Source:\s*(\S+)\s+\((\S+)\)$/mi and $p->{'source'} = $1 and $p->{'version'} = $2;
80 # consider packages as non-existant if it's all but outdated
81 next if $p->{'arch'} eq 'all' && $srcs->{$p->{'source'}} && $srcs->{$p->{'source'}}->{'version'} && vercmp($srcs->{$p->{'source'}}->{'version'}, $p->{'version'}) > 0;
82 next unless $p->{'arch'} eq 'all' || $p->{'arch'} eq ${arch};
83 $binary->{$p->{'binary'}} = { 'version' => $p->{'version'}, 'arch' => $p->{'arch'}} unless $binary->{$p->{'binary'}} and vercmp($binary->{$p->{'binary'}}->{'version'}, $p->{'version'}) < 0;
85 #next if $pas->{$p->{'binary'}} && pasignore($pas->{$p->{'binary'}}, $arch);
86 next if $p->{'arch'} eq 'all';
87 next unless $srcs->{$p->{'source'}};
88 $srcs->{$p->{'source'}}->{'compiled'} = 1;
89 next unless $srcs->{$p->{'source'}}->{'version'} eq $p->{'version'};
90 $srcs->{$p->{'source'}}->{'installed'} = 1;
91 next unless $p->{'binnmu'};
92 next if ($srcs->{$p->{'source'}}->{'binnmu'}) && ($srcs->{$p->{'source'}}->{'binnmu'} > $p->{'binnmu'});
93 $srcs->{$p->{'source'}}->{'binnmu'} = $p->{'binnmu'};
99 for my $k (keys %$srcs) {
100 if ($srcs->{$k}->{'installed'}) {
101 $srcs->{$k}->{'status'} = 'installed';
102 delete $srcs->{$k}->{'installed'};
103 } elsif ($srcs->{$k}->{'compiled'}) {
104 $srcs->{$k}->{'status'} = 'out-of-date';
106 $srcs->{$k}->{'status'} = 'uncompiled';
108 delete $srcs->{$k}->{'compiled'};
109 $srcs->{$k}->{'status'} = 'installed' if $srcs->{$k}->{'arch'} && $srcs->{$k}->{'arch'} eq 'all';
111 if (!$srcs->{$k}->{'for-us'} && $srcs->{$k}->{'status'} ne 'installed') {
112 $srcs->{$k}->{'status'} = 'auto-not-for-us';
114 delete $srcs->{$k}->{'for-us'};
117 #$p ||= $pas->{'%'.$k};
118 #$srcs->{$k}->{'status'} = 'not-for-us' if pasignore($p, $arch);
119 if (pasignore($pas->{'%'.$k}, $arch)) {
120 $srcs->{$k}->{'status'} = 'not-for-us';
123 for my $bin (@{$srcs->{$k}->{'binary'}}) {
124 $srcs->{$k}->{'pas'} = 1 if pasignore($pas->{$bin}, $arch);
125 next if pasignore($pas->{$bin}, $arch);
126 next if $binary->{$bin} and $binary->{$bin}->{'arch'} eq 'all';
129 if ($srcs->{$k}->{'pas'}) {
130 $srcs->{$k}->{'status'} = 'not-for-us';
131 $srcs->{$k}->{'notes'} = 'packages-arch-specific';
133 $srcs->{$k}->{'status'} = 'auto-not-for-us';
134 $srcs->{$k}->{'notes'} = 'overwritten-by-arch-all';
136 delete $srcs->{$k}->{'pas'};
138 $srcs->{'_binary'} = $binary;
147 if ($p && $p->{'mode'}) {
148 return 1 unless grep { $_ eq $arch } @{$p->{'arch'}};
150 if ($p && not $p->{'mode'}) {
151 return 1 if grep /^!$arch$/, @{$p->{'arch'}};