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 for my $i (@packages) {
132 if (defined($priority{$i}) and ($priority{$i} eq "required" ||
133 $priority{$i} eq "standard" || $priority{$i} eq "important")) {
137 push @visit, "build-essential";
141 next if grep /^\Q$n\E$/, @pp;
143 my $source = $csource{$n};
144 if ($source and !grep /^\Q$source\E$/, @vsource) {
145 push @vsource, $source;
146 for my $b (@{$bdeps{$source}}) {
147 if (!grep /^\Q$b\E$/, @pp && !grep /^\Q$b\E$/, @visit) {
152 my $l = $depends{$n};
154 if (!grep /^\Q$d\E$/, @pp && !grep /^\Q$d\E$/, @visit) {
163 $size{$i} = 0 if (!defined($size{$i}));
164 print "$size{$i} $i\n";
168 for my $i (@vsource) {
169 $ssize{$i} = 0 if (!defined($ssize{$i}));
170 print "$ssize{$i} S:$i\n";
171 $tsize += $ssize{$i};
174 print "$tsize Total\n";