[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Small patch for list2cds (cleanup and modify output)



Hello

I'm currently using the debian-cd package to build my own CDs with a
slightli modified package list.  I'm using the output from list2cds to
generate reports like this, to make it easier to see which packages
are taking up the space on the CD.

    +size  cdsize pkgname
  -----------------------
     1447   71091 ntp
      631   72539 ntpdate
      929   73170 ssh
      639   74100 cfengine
     3343   74739 groff

With the current output from list2cds, this package list starts after
the "standard, required, important and base packages" are added on the
CD, because there is no output with size info while this is being
done.  The following patch changes this, and make the output more
consistent.  Please include in the next version of debian-cd.

Changes:

  - move setting of $include{pkg} into add_to_cd(), as it is done by
    all the callers of this function.
  - Pass package size into add_to_cd() for consistent output of this
    info, and move the += operation on $cd_size and $total_size into
    add_to_cd().
  - Output text every time a standard package is added.

Index: tools//list2cds
===================================================================
RCS file: /var/lib/cvs/skolelinux/src/debian-cd/tools/list2cds,v
retrieving revision 1.1.1.1
diff -u -3 -p -u -r1.1.1.1 list2cds
--- tools//list2cds	26 Aug 2001 11:45:50 -0000	1.1.1.1
+++ tools//list2cds	1 Dec 2001 11:31:46 -0000
@@ -143,10 +143,12 @@ while (defined($_ = <STATUS>)) {
                 next;
 	}
 	next if $excluded{$p};
-	$cd_size += $packages{$p}{"Size"};
-	$total_size += $packages{$p}{"Size"};
-	$included{$p} = 1;
-	add_to_cd (1, [ $p ]);
+
+	msg(2, "+ Trying to add $p...\n");
+
+	my $size = $packages{$p}{"Size"};
+
+	add_to_cd (1, $size, [ $p ]);
 }
 close STATUS;
 msg(0, "   Standard system already takes $cd_size bytes on the first CD.\n");
@@ -466,17 +468,7 @@ sub add_package {
 		unexclude ($cd);
 	}
 
-	msg(2, "  \$cd_size = $cd_size, \$size = $size\n");
-
-	$cd_size += $size;
-	$total_size += $size;
-
-	add_to_cd ($cd, \@dep);
-
-	# Mark the packages included
-	foreach (@dep) {
-		$included{$_} = $cd;
-	}
+	add_to_cd ($cd, $size, \@dep);
 }
 
 sub accepted {
@@ -633,7 +625,18 @@ sub check_list {
 # Add packages to the current CD number $cd
 sub add_to_cd {
 	my $cd = shift;
+	my $size = shift;
 	my $ref = shift;
+
+	msg(2, "  \$cd_size = $cd_size, \$size = $size\n");
+
+	$cd_size += $size;
+	$total_size += $size;
+
+	my $pkg;
+	for $pkg (@{$ref}) {
+	    $included{$p} = $cd;
+	}
 	$cds{$cd} = [] if not ref $cds{$cd};
 	msg(2, "  Adding @{$ref} to CD $cd ...\n");
 	push(@{$cds{$cd}}, @{$ref});


I also include the script I use to produce the summary reports:


#!/usr/bin/perl -w
#
# 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.

$logfile = ($ARGV[0] ||
            "/skolelinux/developer/local0/ftp/tmp/woody-i386/log.list2cds");

open(LOG, $logfile) || die "Unable to open $logfile";

my $pkg;
while (<LOG>) {
    chomp;
    $pkg = $1 if (/^\+ Trying to add (.+)\.\.\./);
    if (/  \$cd_size = (\d+), \$size = (\d+)/) {
        $cdsize{$pkg} = $1;
        $size{$pkg} = $2;
    }
    last if (/Limit for CD 2 is/);
}
close(LOG);

print "  +size  cdsize pkgname\n";
print "-----------------------\n";

for $pkg (sort { $cdsize{$a} <=> $cdsize{$b} } keys %size) {
    printf "%7d %7d %s\n", $size{$pkg} / 1024, $cdsize{$pkg} / 1024, $pkg;
}



Reply to: