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 "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 "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 $binary->{$p->{'binary'}} = { 'version' => $p->{'version'}, 'arch' => $p->{'arch'}} unless $binary->{$p->{'binary'}} and vercmp($binary->{$p->{'binary'}->{'version'}}, $p->{'version'}) < 0;
72 #next if $pas->{$p->{'binary'}} && pasignore($pas->{$p->{'binary'}}, $arch);
73 next if $p->{'arch'} eq 'all';
74 next unless $srcs->{$p->{'source'}};
75 $srcs->{$p->{'source'}}->{'compiled'} = 1;
76 next unless $srcs->{$p->{'source'}}->{'version'} eq $p->{'version'};
77 $srcs->{$p->{'source'}}->{'installed'} = 1;
78 next unless $p->{'binnmu'};
79 next if ($srcs->{$p->{'source'}}->{'binnmu'}) && ($srcs->{$p->{'source'}}->{'binnmu'} > $p->{'binnmu'});
80 $srcs->{$p->{'source'}}->{'binnmu'} = $p->{'binnmu'};
86 for my $k (keys %$srcs) {
87 if ($srcs->{$k}->{'installed'}) {
88 $srcs->{$k}->{'status'} = 'installed';
89 delete $srcs->{$k}->{'installed'};
90 } elsif ($srcs->{$k}->{'compiled'}) {
91 $srcs->{$k}->{'status'} = 'out-of-date';
93 $srcs->{$k}->{'status'} = 'uncompiled';
95 delete $srcs->{$k}->{'compiled'};
96 $srcs->{$k}->{'status'} = 'installed' if $srcs->{$k}->{'arch'} && $srcs->{$k}->{'arch'} eq 'all';
99 #$p ||= $pas->{'%'.$k};
100 #$srcs->{$k}->{'status'} = 'not-for-us' if pasignore($p, $arch);
101 if (pasignore($pas->{'%'.$k}, $arch)) {
102 $srcs->{$k}->{'status'} = 'not-for-us';
105 for my $bin (@{$srcs->{$k}->{'binary'}}) {
106 next if pasignore($pas->{$bin}, $arch);
107 next if $binary->{$bin} and $binary->{$bin}->{'arch'} eq 'all';
110 $srcs->{$k}->{'status'} = 'not-for-us';
112 $srcs->{'_binary'} = $binary;
121 if ($p && $p->{'mode'}) {
122 return 1 unless grep { $_ eq $arch } @{$p->{'arch'}};
124 if ($p && not $p->{'mode'}) {
125 return 1 if grep /^!$arch$/, @{$p->{'arch'}};