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");
72 my ($package, $binaries) = @_;
74 my @vbb = split(", ", $binaries);
76 $i =~ qr,([0-9a-z-+.]+),;
78 $csource{$i} = $package;
80 $binaries{$package} = $bb;
84 my ($package, $bdeps) = @_;
86 my @vbd = split(", ", $bdeps);
88 $i =~ qr,([0-9a-z-+.]+),;
91 $bdeps{$package} = $bd;
97 if (/^Package: ([0-9a-z-+.]+)/) {
99 push @packages, $package;
101 if (/^Binary: (.*)/) {
102 add_binaries($package, $1);
104 if (/^Build-Depends: (.*)/) {
105 add_bdeps($package, $1);
108 if (/^ [a-f0-9]+ ([0-9]+)/) {
109 $ssize{$package} += $1;
116 $ssize{$package} = 0;
128 for my $i (keys %essential) {
131 push @visit, "build-essential";
135 next if grep /^$n$/, @pp;
137 my $source = $csource{$n};
138 if ($source and !grep /^$source$/, @vsource) {
139 push @vsource, $source;
140 for my $b (@{$bdeps{$source}}) {
141 if (!grep /^$b$/, @pp && !grep /^$b$/, @visit) {
146 my $l = $depends{$n};
148 if (!grep /^$d$/, @pp && !grep /^$d$/, @visit) {
157 $size{$i} = 0 if (!defined($size{$i}));
158 print "$size{$i} $i\n";
162 for my $i (@vsource) {
163 $ssize{$i} = 0 if (!defined($ssize{$i}));
164 print "$ssize{$i} S:$i\n";
165 $tsize += $ssize{$i};
168 print "$tsize Total\n";