2006-08-06 10:54:44 +00:00
|
|
|
#!/usr/bin/perl
|
2004-06-29 22:02:53 +00:00
|
|
|
#
|
|
|
|
# Author: Petter Reinholdtsen <pere@hungry.com>
|
|
|
|
# Date: 2001-11-20
|
|
|
|
#
|
|
|
|
# Parse logfile from Debian debian-cd build, and report how much each package
|
|
|
|
# added to the CD size.
|
|
|
|
|
2006-08-06 10:54:44 +00:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
2006-08-06 11:14:18 +00:00
|
|
|
use Text::Format; # From debian package libtext-format-perl
|
|
|
|
use Getopt::Std;
|
|
|
|
|
|
|
|
my %opts;
|
2006-08-10 11:17:02 +00:00
|
|
|
getopts('cm:t', \%opts);
|
2006-08-06 10:54:44 +00:00
|
|
|
|
|
|
|
my $logfile = ($ARGV[0] ||
|
2006-09-26 16:35:20 +00:00
|
|
|
"$ENV{TDIR}/$ENV{CODENAME}-$ENV{ARCH}/log.list2cds");
|
2006-08-06 10:54:44 +00:00
|
|
|
my $cdlimit = ($ARGV[1] || 1) + 1;
|
2004-06-29 22:02:53 +00:00
|
|
|
|
|
|
|
open(LOG, $logfile) || die "Unable to open $logfile";
|
|
|
|
|
2006-08-06 11:14:18 +00:00
|
|
|
|
|
|
|
my $text = Text::Format->new(leftMargin => 16,
|
|
|
|
rightMargin => 0,
|
|
|
|
firstIndent => 0);
|
2006-08-10 11:17:02 +00:00
|
|
|
my $markerstep = $opts{m} || 0;
|
2004-06-29 22:02:53 +00:00
|
|
|
my $pkg;
|
2006-08-06 10:54:44 +00:00
|
|
|
my @order;
|
|
|
|
my %cdsize;
|
|
|
|
my %size;
|
2006-08-06 11:14:18 +00:00
|
|
|
my %deps;
|
2006-09-02 10:57:48 +00:00
|
|
|
my $curcd = 1;
|
2006-08-06 10:54:44 +00:00
|
|
|
my $curcdsize;
|
|
|
|
my $cursize;
|
2006-08-10 11:17:02 +00:00
|
|
|
my @excluded;
|
|
|
|
my $nextmarker = $markerstep;
|
2004-06-29 22:02:53 +00:00
|
|
|
while (<LOG>) {
|
|
|
|
chomp;
|
2006-08-10 11:17:02 +00:00
|
|
|
if (/^\+ Trying to add (.+)\.\.\./) {
|
|
|
|
}
|
|
|
|
if (/^ (.+) has been refused because of user choice/) {
|
|
|
|
push @excluded, $1;
|
|
|
|
}
|
|
|
|
if (/^Can\'t add (.+) \.\.\. one of the package needed has been refused/) {
|
|
|
|
my $txt = "REJECT $1 (" . join(" ", @excluded). ")";
|
|
|
|
$size{$txt} = 0;
|
|
|
|
$cdsize{$txt} = $curcdsize;
|
|
|
|
push(@order, $txt);
|
|
|
|
@excluded = ();
|
|
|
|
}
|
2004-06-29 22:02:53 +00:00
|
|
|
if (/ \$cd_size = (\d+), \$size = (\d+)/) {
|
2006-08-06 10:54:44 +00:00
|
|
|
$curcdsize = $1;
|
|
|
|
$cursize = $2;
|
2006-08-10 11:17:02 +00:00
|
|
|
if ($markerstep) {
|
|
|
|
while ($curcdsize > $nextmarker) {
|
2006-09-02 10:57:48 +00:00
|
|
|
my $txt = sprintf("<=============== CD $curcd fill level passing %d KiB",
|
2006-08-10 11:17:02 +00:00
|
|
|
$nextmarker / 1024);
|
|
|
|
$size{$txt} = 0;
|
|
|
|
$cdsize{$txt} = $curcdsize;
|
|
|
|
push(@order, $txt);
|
|
|
|
$nextmarker += $markerstep;
|
|
|
|
}
|
|
|
|
}
|
2006-08-06 10:54:44 +00:00
|
|
|
}
|
2006-08-07 08:54:56 +00:00
|
|
|
if (/^ Adding (.+) to CD \d+/) {
|
|
|
|
my ($pkg, $deplist) = split(/\s+/, $1, 2);
|
2006-08-06 10:54:44 +00:00
|
|
|
$cdsize{$pkg} = $curcdsize;
|
|
|
|
$size{$pkg} = $cursize;
|
|
|
|
push @order, $pkg;
|
2006-08-07 08:54:56 +00:00
|
|
|
$deps{$pkg} = $deplist;
|
2006-08-06 10:54:44 +00:00
|
|
|
}
|
|
|
|
if (/Limit for CD (.+) is/) {
|
2006-08-10 11:17:02 +00:00
|
|
|
last if $cdlimit == $1;
|
2006-09-02 10:57:48 +00:00
|
|
|
$curcd = $1;
|
2006-08-06 10:54:44 +00:00
|
|
|
my $txt = "<=============== start of CD $1";
|
|
|
|
$size{$txt} = 0;
|
|
|
|
$cdsize{$txt} = 0;
|
|
|
|
push @order, $txt;
|
2006-08-10 11:17:02 +00:00
|
|
|
$nextmarker = $markerstep;
|
2004-06-29 22:02:53 +00:00
|
|
|
}
|
|
|
|
# Add delimiter
|
|
|
|
if (/Standard system already takes (.\d+)/) {
|
2006-08-06 10:54:44 +00:00
|
|
|
my $txt = "<=============== end of standard pkgs";
|
|
|
|
$size{$txt} = 0;
|
|
|
|
$cdsize{$txt} = $1;
|
|
|
|
push @order, $txt;
|
2004-06-29 22:02:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close(LOG);
|
|
|
|
|
2006-08-10 11:17:02 +00:00
|
|
|
if ($opts{'c'}) {
|
|
|
|
print " +size cdsize pkgname\n";
|
|
|
|
} else {
|
|
|
|
print " +size pkgname\n";
|
|
|
|
$text->leftMargin(8);
|
|
|
|
}
|
2004-06-29 22:02:53 +00:00
|
|
|
print "-----------------------\n";
|
|
|
|
|
2006-08-06 10:54:44 +00:00
|
|
|
for $pkg (@order) {
|
2006-08-10 11:17:02 +00:00
|
|
|
if ($opts{'c'}) {
|
|
|
|
printf "%7d %7d %s\n", $size{$pkg} / 1024, $cdsize{$pkg} / 1024, $pkg;
|
|
|
|
} else {
|
|
|
|
printf "%7d %s\n", $size{$pkg} / 1024, $pkg;
|
|
|
|
}
|
2006-08-06 11:14:18 +00:00
|
|
|
print $text->format($deps{$pkg}) if ($opts{'t'} && $deps{$pkg});
|
2004-06-29 22:02:53 +00:00
|
|
|
}
|