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

Bug#514237: New patch to address some issues



This new patch, I believe, addresses most of the issues that have been brought up with my initial patch, and one or two others:

* It eliminates the hard-coded list of arches in which_deb, update_tasks, and generate_di_lists, in favor of the ARCHES environment variable, and falls back to (i386, amd64) when the ARCHES variable is unavailable, or when building a source-only CD
* update_tasks uses which_deb to determine a valid/existing arch
* It does not address the issue of running update_tasks independently for each arch; I'm afraid I don't fully understand how update_tasks is used well enough to make this change at the current time * which_deb and generate_di_list now build the @components array explicitly, based on whether CONTRIB, NONFREE, and LOCAL variables are set, rather than just looking for directory names that exist under the pool/ directory--this in response to some comments Frans made in relation to another forum thread. * which_deb now needs to be able to look up 'coreutils', which I allowed by creating a fall-through mode, effectively making which_deb work for any existing deb--I hope this approach is sane



Index: tools/update_tasks
===================================================================
--- tools/update_tasks    (revision 7407)
+++ tools/update_tasks    (revision 7522)
@@ -149,10 +149,15 @@
    }' | 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
+# Look for the coreutils package (which should exist in all archs, and is
+# a non -all package) to determine a valid arch for the rest of this
+# script
+arch=$(which_deb $MIRROR $CODENAME coreutils binary | sed -e "s/\.deb//" -e "s/.*_//")
+
+# We need to gunzip a copy of the appropriate Packages.gz file(s)
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: tools/make_disc_trees.pl
===================================================================
--- tools/make_disc_trees.pl    (revision 7407)
+++ tools/make_disc_trees.pl    (revision 7522)
@@ -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: tools/generate_di_list
===================================================================
--- tools/generate_di_list    (revision 7407)
+++ tools/generate_di_list    (revision 7522)
@@ -5,9 +5,19 @@
die "Missing \$MIRROR variable" unless $ENV{MIRROR};
die "Missing \$DI_CODENAME variable" unless $ENV{DI_CODENAME};
die "Missing \$BASEDIR variable" unless $ENV{BASEDIR};
+die "Missing \$ARCHES variable" unless $ENV{ARCHES};

-my @ARCHES=qw{alpha arm armel hppa hurd-i386 i386 ia64 mips mipsel
-              powerpc s390 sparc amd64};
+# Early exit if we're building a source-only CD
+exit 0 if $ENV{ARCHES} =~ /^\s*source\s*$/;
+
+my @ARCHES;
+if ( $ENV{ARCHES} ) {
+    push @ARCHES, 'i386' if $ENV{ARCHES} =~ /i386/;
+    push @ARCHES, 'amd64' if $ENV{ARCHES} =~ /amd64/;
+    push @ARCHES, grep { !/source|i386|amd64/ } split /\s+/, $ENV{ARCHES};
+}
+@ARCHES = qw{i386 amd64} unless @ARCHES;
+
my $DATE=`date`;
chomp $DATE;
open(OUT, ">debian-installer") || die "write: $!";
@@ -24,32 +34,42 @@
EOF

my @common_excludes = read_exclude("exclude-udebs");
-
+my $mirror_path = "$ENV{MIRROR}/dists/$ENV{DI_CODENAME}";
+my @components = qw(main);
+push @components, 'contrib' if $ENV{CONTRIB};
+push @components, 'non-free' if $ENV{NONFREE};
+push @components, 'local' if $ENV{LOCAL};
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";
+        if ( $component eq 'local' and $ENV{LOCALDEBS} ) {
+ $packagefile="$ENV{LOCALDEBS}/dists/$ENV{DI_CODENAME}/local/debian-installer/binary-$arch/Packages.gz";
        }
-        print OUT "$udeb\n";
+        unless ( -f $packagefile ) {
+            print "Missing package file for $arch/$component.\n";
+            next;
+        }
+        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: tools/which_deb
===================================================================
--- tools/which_deb    (revision 7407)
+++ tools/which_deb    (revision 7522)
@@ -6,6 +6,16 @@
# the archive to meet a requirement in the debian-cd build

use strict;
+use List::Util qw{first};
+# Give prefernce to i386 and amd64, if specified, or if building a
+# source-only CD.
+my @ARCHES;
+if ( $ENV{ARCHES} ) {
+    push @ARCHES, 'i386' if $ENV{ARCHES} =~ /i386/;
+    push @ARCHES, 'amd64' if $ENV{ARCHES} =~ /amd64/;
+    push @ARCHES, grep { !/source|i386|amd64/ } split /\s+/, $ENV{ARCHES};
+}
+@ARCHES = qw{i386 amd64} unless @ARCHES;

my ($mirror, $codename, $pkg, $pth, $output);

@@ -13,8 +23,13 @@
$codename = shift;
$pkg = shift;
$output = shift;
-$pth = "$mirror/dists/$codename/main";
+$pth = "$mirror/dists/$codename/";

+my @components = qw(main);
+push @components, 'contrib' if $ENV{CONTRIB};
+push @components, 'non-free' if $ENV{NONFREE};
+push @components, 'local' if $ENV{LOCAL};
+
if (!defined ($output)) {
    $output = "binary";
}
@@ -26,24 +41,29 @@
    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";
+        if ( $component eq 'local' and $ENV{LOCALDEBS} ) {
+ $pgz = "$ENV{LOCALDEBS}/dists/$codename/local/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 +74,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 "";
}
@@ -80,21 +102,23 @@
my $pkgdata = "";
my $srcname = "";

-if ($pkg eq "debootstrap") {
-    $pkgdata = grab_bin_info($pth, "i386", $pkg);
-
-} elsif ($pkg eq "silo") {
+if ($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);
+} else { # Fallthrough for all other packages
+    first { $pkgdata = grab_bin_info($pth, $_, $pkg) } @ARCHES;
}

+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;


--
Inbound and outbound email scanned for spam and viruses by the

DoubleCheck Email Manager: http://www.doublecheckemail.com



Reply to: