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

Bug#514237: debian-cd: Support non-i386 mirrors, and support D-I modules in non-main



Package: debian-cd
Version: 3.1.0-nymgy1
Severity: wishlist
Tags: patch

This patch adds two features to debian-cd, filed as a single bug/patch, per
Steve McIntyre's suggestion on the mailing list:
 1) It no longer requires the existence of the i386 architecture in the
    mirror to build non-i386 CD images.
 2) It no longer requires that all D-I modules (udebs) exist in the 'main'
    component

I have tested this patch to work when building the following combinations of
CDs from a mirror with binary-i386, binary-amd64, and source archs:
binary-i386
binary-i386 + source
binary-amd64
binary-amd64 + source
binary-i386 + binary-amd64
binary-i386 + binary-amd64 + source
source

I have also tested it to build the following CDs from a mirror with only
binary-amd64 and source archs:
binary-amd64
binary-amd64 + source
source

I have not tested with any other architectures, or CD combinations but I
beleive this patch should work with any architecture(s).


*** /home/jonhall/non-i386.patch
Index: debian-cd/tools/update_tasks
===================================================================
--- debian-cd/tools/update_tasks	(revision 7407)
+++ debian-cd/tools/update_tasks	(revision 7487)
@@ -1,5 +1,6 @@
 #!/bin/sh
 set -e
+ARCHES="alpha arm armel hppa hurd-i386 i386 ia64 mips mipsel powerpc s390 sparc amd64"
 
 if [ -z "$CODENAME" ]; then
     echo "update_tasks: codename not specified" >&2
@@ -149,10 +150,14 @@
     }' | sort -s -n -k1 | cut -d: -f2 >> $file
 }
 
-# We need to gunzip a copy of the appropriate Packages.gz file
-# Assume i386, use the $CODENAME main Packages file
+# We need to gunzip a copy of the appropriate Packages.gz file(s)
+# Find an arch that exists in our mirror...
+for arch in $ARCHES; do
+    if [ -e $MIRROR/dists/$CODENAME/main/binary-$arch ]; then break; fi
+done
 TMP_PKG=$TDIR/Packages
-zcat $MIRROR/dists/$CODENAME/main/binary-i386/Packages.gz > $TMP_PKG
+zcat $MIRROR/dists/$CODENAME/main/binary-$arch/Packages.gz > $TMP_PKG
+[ -n "$LOCAL" ] && zcat $MIRROR/dists/$CODENAME/local/binary-$arch/Packages.gz >> $TMP_PKG
 
 # Now grab the appropriate tasksel package
 TASKSEL_DEB=$MIRROR/`mawk '
Index: debian-cd/tools/make_disc_trees.pl
===================================================================
--- debian-cd/tools/make_disc_trees.pl	(revision 7407)
+++ debian-cd/tools/make_disc_trees.pl	(revision 7487)
@@ -735,7 +735,7 @@
     }	
 
     $pdir = "$dir/dists/$codename/$dist";
-    if ($section eq "debian-installer") {
+    if ($section and $section eq "debian-installer") {
         $pdir = "$dir/dists/$codename/$dist/debian-installer";
     }
     return $pdir;
Index: debian-cd/tools/generate_di_list
===================================================================
--- debian-cd/tools/generate_di_list	(revision 7407)
+++ debian-cd/tools/generate_di_list	(revision 7487)
@@ -24,32 +24,38 @@
 EOF
 
 my @common_excludes = read_exclude("exclude-udebs");
-
+my $mirror_path = "$ENV{MIRROR}/dists/$ENV{DI_CODENAME}";
+opendir COMP, $mirror_path;
+my @components = grep { -d "$mirror_path/$_" and $_ !~ /^\./ } readdir COMP;
+close COMP;
 foreach my $arch (@ARCHES) {
-	my $packagefile="$ENV{MIRROR}/dists/$ENV{DI_CODENAME}/main/debian-installer/binary-$arch/Packages.gz";
-	unless (-f $packagefile) {
-		print "Missing package file for arch $arch.\n";
-		next;
-	}
 	(my $cpparch = $arch) =~ s/-/_/g;
-	print OUT "#ifdef ARCH_$cpparch\n";
-	my @exclude = @common_excludes;
-	push @exclude, read_exclude("exclude-udebs-$arch")
-		if -e exclude_path("exclude-udebs-$arch");
-UDEB:	foreach my $udeb (map { chomp; $_ } `zcat $packagefile | awk '/^Package:/ {print \$2}'`) {
-		foreach my $pattern (@exclude) {
-			if ($udeb =~ /^$pattern$/) {
-				next UDEB;
-			}
+	my $output = '';
+	for my $component ( @components ) {
+		my $packagefile="$mirror_path/$component/debian-installer/binary-$arch/Packages.gz";
+		unless ( -f $packagefile ) {
+			print "Missing package file for $component/$arch.\n";
+			next;
 		}
-		print OUT "$udeb\n";
+		my @exclude = @common_excludes;
+		push @exclude, read_exclude("exclude-udebs-$arch")
+			if -e exclude_path("exclude-udebs-$arch");
+		foreach my $udeb (map { chomp; $_ } `zcat $packagefile | awk '/^Package:/ {print \$2}'`) {
+			$output .= "$udeb\n" unless grep { $udeb =~ /^${_}$/ } @exclude;
+		}
 	}
+	next unless $output;
+	print OUT "#ifdef ARCH_$cpparch\n";
+	print OUT $output;
 	print OUT "#endif /* ARCH_$cpparch */\n";
 }
 
 sub read_exclude {
 	my $file=exclude_path(shift);
-	open (IN, "<$file") || warn "failed to read exclude file $file";
+	unless ( open (IN, "<$file") ) {
+	   warn "failed to read exclude file $file";
+	   return;
+	}
 	my @ret;
 	while (<IN>) {
 		chomp;
Index: debian-cd/tools/which_deb
===================================================================
--- debian-cd/tools/which_deb	(revision 7407)
+++ debian-cd/tools/which_deb	(revision 7487)
@@ -6,6 +6,9 @@
 # the archive to meet a requirement in the debian-cd build
 
 use strict;
+use List::Util qw{first};
+my @ARCHES=qw{alpha arm armel hppa hurd-i386 i386 ia64 mips mipsel
+              powerpc s390 sparc amd64};
 
 my ($mirror, $codename, $pkg, $pth, $output);
 
@@ -13,8 +16,14 @@
 $codename = shift;
 $pkg = shift;
 $output = shift;
-$pth = "$mirror/dists/$codename/main";
+$pth = "$mirror/dists/$codename/";
+opendir COMP, $pth;
+my @components = grep { -d "$pth/$_" and $_ !~ /^\./ } readdir COMP;
+close COMP;
 
+die "No components present in $pth\n"
+    unless @components;
+
 if (!defined ($output)) {
     $output = "binary";
 }
@@ -26,24 +35,26 @@
     my $old_split = $/;
     my $match;
     my $result = "";
-    
-    my $pgz = "$pth/binary-$arch/Packages.gz";
 
-    $/ = ''; # Browse by paragraph    
+    $/ = ''; # Browse by paragraph
 
-    if (-e $pgz) {
-        open(PFILE, "zcat $pgz |") or
-            die "Failed to read Packages file $pgz";
+    for my $component ( @components ) {
+        my $pgz = "$pth/$component/binary-$arch/Packages.gz";
 
-        while (defined($match = <PFILE>)) {
-            if (($match =~ /^Package: \Q$pkgname\E$/m)) {
-                $result = $match;
-                close PFILE;
-                return $result;
+        if (-e $pgz) {
+            open(PFILE, "zcat $pgz |") or
+                die "Failed to read Packages file $pgz";
+
+            while (defined($match = <PFILE>)) {
+                if (($match =~ /^Package: \Q$pkgname\E$/m)) {
+                    $result = $match;
+                    close PFILE;
+                    return $result;
+                }
             }
+            # Fell through
+            close PFILE;
         }
-        # Fell through
-        close PFILE;
     }
     return "";
 }
@@ -54,24 +65,26 @@
     my $old_split = $/;
     my $match;
     my $result = "";
-    
-    my $pgz = "$pth/source/Sources.gz";
 
-    $/ = ''; # Browse by paragraph    
+    $/ = ''; # Browse by paragraph
 
-    if (-e $pgz) {
-        open(PFILE, "zcat $pgz |") or
-            die "Failed to read Sources file $pgz";
+    for my $component ( @components ) {
+        my $pgz = "$pth/$component/source/Sources.gz";
 
-        while (defined($match = <PFILE>)) {
-            if (($match =~ /^Package: \Q$pkgname\E$/m)) {
-                $result = $match;
-                close PFILE;
-                return $result;
+        if (-e $pgz) {
+            open(PFILE, "zcat $pgz |") or
+                die "Failed to read Sources file $pgz";
+
+            while (defined($match = <PFILE>)) {
+                if (($match =~ /^Package: \Q$pkgname\E$/m)) {
+                    $result = $match;
+                    close PFILE;
+                    return $result;
+                }
             }
+            # Fell through
+            close PFILE;
         }
-        # Fell through
-        close PFILE;
     }
     return "";
 }
@@ -81,20 +94,23 @@
 my $srcname = "";
 
 if ($pkg eq "debootstrap") {
-    $pkgdata = grab_bin_info($pth, "i386", $pkg);
+    first { $pkgdata = grab_bin_info($pth, $_, $pkg) } @ARCHES;
 
 } elsif ($pkg eq "silo") {
     $pkgdata = grab_bin_info($pth, "sparc", $pkg);
 
 } elsif ($pkg eq "syslinux") {
-    $pkgdata = grab_bin_info($pth, "i386", "syslinux-common");
-    if (length($pkgdata) < 3) {        
-        $pkgdata = grab_bin_info($pth, "i386", "syslinux");
+    first { $pkgdata = grab_bin_info($pth, $_, "syslinux-common") } @ARCHES;
+    if (length($pkgdata) < 3) {
+        first { $pkgdata = grab_bin_info($pth, $_, "syslinux") } @ARCHES;
     }
 } elsif ($pkg eq "yaboot") {
     $pkgdata = grab_bin_info($pth, "powerpc", $pkg);
 }
 
+die "Could not locate $pkg\n"
+    unless $pkgdata;
+
 if (length($pkgdata) > 2) {
     if ($output eq "binary") {
         $pkgdata =~ m/^Filename: (\S+)/m and $bin_deb = $1;


-- System Information:
Debian Release: 5.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages debian-cd depends on:
ii  apt                     0.7.20           Advanced front-end for dpkg
ii  bc                      1.06.94-3        The GNU bc arbitrary precision cal
ii  cpp                     4:4.3.2-2        The GNU C preprocessor (cpp)
ii  curl                    7.18.2-8         Get a file from an HTTP, HTTPS or 
ii  dctrl-tools [grep-dctrl 2.13.1           Command-line tools to process Debi
ii  genisoimage             9:1.1.9-1        Creates ISO-9660 CD-ROM filesystem
ii  libcompress-zlib-perl   2.012-1          Perl module for creation and manip
ii  lynx                    2.8.7dev9-2.1    Text-mode WWW Browser (transitiona
ii  lynx-cur                2.8.7dev9-2.1    Text-mode WWW Browser with NLS sup
ii  make                    3.81-5           The GNU version of the "make" util
ii  perl [libdigest-md5-per 5.10.0-19        Larry Wall's Practical Extraction 
ii  tofrodos                1.7.8.debian.1-1 Converts DOS <-> Unix text files, 

Versions of packages debian-cd recommends:
ii  hfsutils                   3.2.6-11      Tools for reading and writing Maci
ii  netpbm                     2:10.0-12     Graphics conversion tools
ii  syslinux-common            2:3.71+dfsg-5 Kernel loader which uses a FAT, ex

debian-cd suggests no packages.

-- no debconf information



Reply to: