3 # Copyright 2014 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 open(PACKAGES, "<Packages");
30 my ($package, $depends) = @_;
32 my @vdeps = split(",", $depends);
34 $i =~ qr,([0-9a-z-+.]+),;
37 $depends{$package} = $deps;
42 if (/^Package: ([0-9a-z-+.]+)/) {
44 push @packages, $package;
46 if (/^Depends: (.*)/) {
47 add_depends($package, $1);
49 if (/^Priority: (.*)/) {
50 $priority{$package} = $1;
52 if (/^Essential: yes/) {
53 $essential{$package} = "yes";
59 open(SOURCES, "<Sources");
67 my ($package, $binaries) = @_;
69 my @vbb = split(", ", $binaries);
71 $i =~ qr,([0-9a-z-+.]+),;
73 $csource{$i} = $package;
75 $binaries{$package} = $bb;
79 my ($package, $bdeps) = @_;
81 my @vbd = split(", ", $bdeps);
83 $i =~ qr,([0-9a-z-+.]+),;
86 $bdeps{$package} = $bd;
91 if (/^Package: ([0-9a-z-+.]+)/) {
93 push @packages, $package;
95 if (/^Binary: (.*)/) {
96 add_binaries($package, $1);
98 if (/^Build-Depends: (.*)/) {
99 add_bdeps($package, $1);
111 for my $i (keys %essential) {
114 push @visit, "build-essential";
118 next if grep /^$n$/, @pp;
120 my $source = $csource{$n};
121 if ($source and !grep /^$source$/, @vsource) {
122 push @vsource, $source;
123 for my $b (@{$bdeps{$source}}) {
124 if (!grep /^$b$/, @pp && !grep /^$b$/, @visit) {
129 my $l = $depends{$n};
131 if (!grep /^$d$/, @pp && !grep /^$d$/, @visit) {