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

Updated non-free patch



Much cleaned up and no longer causes a significant slow-down because
I'm using a better algorithm. Source is now done too, and the
"EXTRANONFREE" option is plumbed into CONF.sh.

If nobody objects strenuously I'd like to put this into CVS tonight.

-- 
Steve McIntyre, Cambridge, UK.                   stevem@chiark.greenend.org.uk
  Getting a SCSI chain working is perfectly simple if you remember that there
  must be exactly three terminations: one on one end of the cable, one on the
  far end, and the goat, terminated over the SCSI chain with a silver-handled
  knife whilst burning *black* candles. --- Anthony DeBoer
Index: CONF.sh
===================================================================
RCS file: /cvs/debian-boot/debian-cd/CONF.sh,v
retrieving revision 1.6
diff -u -r1.6 CONF.sh
--- CONF.sh	2000/05/18 22:49:00	1.6
+++ CONF.sh	2000/06/06 07:16:47
@@ -46,6 +46,10 @@
 # Do I want to have NONFREE
 # export NONFREE=1
 
+# And if I do - specify this to move non-free binaries and sources off
+# onto separate CDs.
+export EXTRANONFREE=1
+
 # If you have a $MIRROR/dists/$CODENAME/local/binary-$ARCH dir with 
 # local packages that you want to put on the CD set then
 # uncomment the following line 
Index: tools/cds2src
===================================================================
RCS file: /cvs/debian-boot/debian-cd/tools/cds2src,v
retrieving revision 1.4
diff -u -r1.4 cds2src
--- tools/cds2src	2000/04/03 22:05:07	1.4
+++ tools/cds2src	2000/06/06 07:16:59
@@ -23,6 +23,8 @@
 my $adir = "$ENV{'APTTMP'}/$ENV{'CODENAME'}-$ENV{'ARCH'}";
 my $sdir = "$ENV{'TDIR'}/$ENV{'CODENAME'}-src";
 my $verbose = $ENV{'VERBOSE'} || 0;
+my $extranonfree = $ENV{'EXTRANONFREE'} || 0;
+my $doing_nonfree = 0;
 
 my $mirror = $ENV{'MIRROR'};
 my $codename = $ENV{'CODENAME'};
@@ -83,10 +85,18 @@
 	next if not m/^Package: (\S+)\s*$/m;
 	$p = $1;
 	$included{$p} = 0;
-        $sources{$p}{"Package"} = $p;
+	$sources{$p}{"Package"} = $p;
+	$sources{$p}{"nonfree"} = 0;		    
+	$sources{$p}{"nonus"} = 0;		    
 	foreach $re (qw/Binary Version Section Directory/) {
-		(m/^$re: (.*?)\s*$/m and $sources{$p}{$re} = $1)
-		|| msg(1, "Header field '$re' missing for source '$p'\n");
+	    (m/^$re: (.*?)\s*$/m and $sources{$p}{$re} = $1)
+	        || msg(1, "Header field '$re' missing for source '$p'\n");
+	    if (m/\/non-free\//mgc) {
+	        $sources{$p}{"nonfree"} = 1;
+	    }
+	    if (m/\/non-US\//mgc) {
+	        $sources{$p}{"nonus"} = 1;
+	    }
 	}
 	foreach $bin (split (/,\s+/, $sources{$p}{"Binary"})) {
 		$bin2src{$bin} = $p;
@@ -102,7 +112,7 @@
 		push @{$sources{$p}{"Files"}}, [ $file, $size ];
 	}
 	if (not @{$sources{$p}{"Files"}}) {
-		msg(0, "ERROR: Source package $p has no files ...\n");
+	    msg(0, "ERROR: Source package $p has no files ...\n");
 	}
 }
 
@@ -150,6 +160,23 @@
 
 }
 
+# And now add the non-free sources to separate non-free CDs
+if ($nonfree and $extranonfree) {
+    $doing_nonfree=1;
+    $cd++;
+    $cd_size = 0;
+    # New limit
+    $limit = $ENV{"SRCSIZELIMIT$cd"} || $deflimit;
+    msg(0, "Limit for non-free CD $cd is $limit.\n");
+    foreach $p (sort { ($sources{$a}{"Section"} cmp $sources{$b}{"Section"})
+                       || ($a cmp $b) }
+                grep { not $included{$_} } keys %sources) 
+    {
+	add_src ($p);
+    }
+}
+msg(0, "Non-free source CD $cd filled with $cd_size bytes ...\n");
+
 # Now write the lists down
 foreach (keys %cds) {
         my $count = 0;
@@ -173,8 +200,12 @@
 	$size = 0;
 	msg(2, "+ Trying to add $src ...\n");
 	foreach (@{$sources{$src}{"Files"}}) {
-		$size += $_->[1];
-		push @files, $_->[0];
+	    if(!$doing_nonfree and $extranonfree and $sources{$src}{"nonfree"}) {
+	        msg(3, "Ignoring non-free source file $_->[0]\n");
+	        return;
+	    }
+	    $size += $_->[1];
+	    push @files, $_->[0];
 	}
 	if ($cd_size + $size > $limit) {
 		msg(0, "Source CD $cd filled with $cd_size bytes ...",
Index: tools/list2cds
===================================================================
RCS file: /cvs/debian-boot/debian-cd/tools/list2cds,v
retrieving revision 1.5
diff -u -r1.5 list2cds
--- tools/list2cds	2000/05/01 04:59:01	1.5
+++ tools/list2cds	2000/06/06 07:17:04
@@ -24,6 +24,8 @@
 my $adir = "$ENV{'APTTMP'}/$ENV{'CODENAME'}-$ENV{'ARCH'}";
 my $dir = "$ENV{'TDIR'}/$ENV{'CODENAME'}-$ENV{'ARCH'}";
 my $verbose = $ENV{'VERBOSE'} || 0;
+my $extranonfree = $ENV{'EXTRANONFREE'} || 0;
+my $doing_nonfree = 0;
 
 $| = 1; # Autoflush for debugging
 
@@ -62,9 +64,17 @@
 	$p = $1;
 	$included{$p} = 0;
 	$packages{$p}{"Package"} = $p;
+	$packages{$p}{"nonfree"} = 0;
+	$packages{$p}{"nonus"} = 0;
 	foreach $re (qw(Version Priority Section Filename Size MD5sum)) {
 		(m/^$re: (\S+)\s*$/m and $packages{$p}{$re} = $1)
 		|| msg(1, "Header field '$re' missing for package '$p'.\n");
+		if (m/\/non-free\//mgc) {
+		    $packages{$p}{"nonfree"} = 1;
+		}
+		if (m/\/non-US\//mgc) {
+		    $packages{$p}{"nonus"} = 1;
+		}
 	}
 	$packages{$p}{"Depends"} = [];
 	$packages{$p}{"Suggests"} = [];
@@ -210,6 +220,23 @@
 }
 msg(0, "CD $cd will only be filled with $cd_size bytes ...\n");
 
+# And now add the non-free packages to separate non-free CDs
+if ($nonfree and $extranonfree) {
+    my $p;
+    $doing_nonfree=1;
+    $cd++;
+    $cd_size = 0;
+    # New limit
+    $limit = $ENV{"SIZELIMIT$cd"} || $deflimit;
+    msg(0, "Limit for non-free CD $cd is $limit.\n");
+    foreach $p (sort { ($packages{$a}{"Section"} cmp $packages{$b}{"Section"})
+		       || ($a cmp $b) }
+	      grep { not ($included{$_} or $excluded{$_}) } keys %packages) {
+        add_package ($p, 0);
+    }
+}
+msg(0, "CD $cd will only be filled with $cd_size bytes ...\n");
+
 # Remove old files
 foreach (glob("$dir/*.packages")) {
 	unlink $_;
@@ -349,6 +376,7 @@
 sub add_package {
 	my $p = shift;
 	my $add_rec = shift; # Do we look for recommends/suggests
+	my $q;
 	
 	msg(2, "+ Trying to add $p...\n");
 	if ($included{$p}) {
@@ -388,30 +416,33 @@
 		msg(3, "  \@dep after checklist2 = @dep\n");
 	}
 	
-	# All packages are ok, now check for the size issue
-	$size = get_size (\@dep);
-
-	# Creation of a new CD when needed
-	if ($cd_size + $size > $limit) {
-		msg(0, "CD $cd filled with $cd_size bytes ... ",
-		       "(limit was $limit)\n");
-		$cd++;
-		$cd_size = 0;
-		# New limit
-		$limit = $ENV{"SIZELIMIT$cd"} || $deflimit;
-		msg(2, "Limit for CD $cd is $limit.\n");
-	}
-
-	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;
+	foreach $q (@dep) {
+	    if (!$doing_nonfree and $extranonfree and $packages{$q}{"nonfree"}) {
+	        msg(3, "Ignoring non-free reference to '$q'\n");
+	    } else {
+	        # All packages are ok, now check for the size issue
+	        $size = get_size ([$q]);
+
+	        # Creation of a new CD when needed
+	        if ($cd_size + $size > $limit) {
+		  msg(0, "CD $cd filled with $cd_size bytes ... ",
+		      "(limit was $limit)\n");
+		  $cd++;
+		  $cd_size = 0;
+		  # New limit
+		  $limit = $ENV{"SIZELIMIT$cd"} || $deflimit;
+		  msg(2, "Limit for CD $cd is $limit.\n");
+	        }
+	        
+	        msg(2, "  \$cd_size = $cd_size, \$size = $size\n");
+	        
+	        $cd_size += $size;
+	        $total_size += $size;
+
+	        add_to_cd ($cd, [$q]);
+	        $included{$q} = $cd;
+	    }
 	}
 }
 

Reply to: