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");
31 my ($package, $depends) = @_;
33 my @vdeps = split(",", $depends);
35 $i =~ qr,([0-9a-z-+.]+),;
38 $depends{$package} = $deps;
43 if (/^Package: ([0-9a-z-+.]+)/) {
45 push @packages, $package;
47 if (/^Depends: (.*)/) {
48 add_depends($package, $1);
50 if (/^Priority: (.*)/) {
51 $priority{$package} = $1;
53 if (/^Essential: yes/) {
54 $essential{$package} = "yes";
63 open(SOURCES, "<Sources");
71 my ($package, $binaries) = @_;
73 my @vbb = split(", ", $binaries);
75 $i =~ qr,([0-9a-z-+.]+),;
77 $csource{$i} = $package;
79 $binaries{$package} = $bb;
83 my ($package, $bdeps) = @_;
85 my @vbd = split(", ", $bdeps);
87 $i =~ qr,([0-9a-z-+.]+),;
90 $bdeps{$package} = $bd;
95 if (/^Package: ([0-9a-z-+.]+)/) {
97 push @packages, $package;
99 if (/^Binary: (.*)/) {
100 add_binaries($package, $1);
102 if (/^Build-Depends: (.*)/) {
103 add_bdeps($package, $1);
115 for my $i (keys %essential) {
118 push @visit, "build-essential";
122 next if grep /^$n$/, @pp;
124 my $source = $csource{$n};
125 if ($source and !grep /^$source$/, @vsource) {
126 push @vsource, $source;
127 for my $b (@{$bdeps{$source}}) {
128 if (!grep /^$b$/, @pp && !grep /^$b$/, @visit) {
133 my $l = $depends{$n};
135 if (!grep /^$d$/, @pp && !grep /^$d$/, @visit) {
143 $size{$i} = 0 if (!defined($size{$i}));
144 print "$size{$i} $i\n";
148 print "$tsize Total\n";