* Improve architecture support in which_deb. Closes: #695244

+ Check all the architectures available in the archive if we're not
    specifically told which to use (e.g. on source builds)
  + If we fail to find packages/sources for the specified package, say
    so and bail out properly.
This commit is contained in:
Steve McIntyre 2012-12-06 17:36:28 +00:00
parent 44907c0720
commit 3e98cc6044
2 changed files with 50 additions and 12 deletions

5
debian/changelog vendored
View File

@ -22,6 +22,11 @@ debian-cd (3.1.11) UNRELEASED; urgency=low
release. The new code degrades gracefully if version info is not
available.
+ Add a dependency on libdpkg-perl for version comparison code.
* Improve architecture support in which_deb. Closes: #695244
+ Check all the architectures available in the archive if we're not
specifically told which to use (e.g. on source builds)
+ If we fail to find packages/sources for the specified package, say
so and bail out properly.
-- Steve McIntyre <93sam@debian.org> Wed, 26 Sep 2012 01:09:13 +0100

View File

@ -7,23 +7,15 @@
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);
my ($mirror, $codename, $pkg, $pth, $output, $result);
$mirror = shift;
$codename = shift;
$pkg = shift;
$output = shift;
$pth = "$mirror/dists/$codename";
$text_out = "";
my @components = qw(main);
push @components, 'contrib' if $ENV{CONTRIB};
@ -34,6 +26,39 @@ if (!defined ($output)) {
$output = "binary";
}
# Give preference to i386 and amd64, if specified
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};
}
# We seem to be building a source-only CD. Check for whatever binary
# arches exist in the archive; #695244
if (!@ARCHES) {
my %found_arches;
my $dh;
for my $component(@components) {
opendir ($dh, "$pth/$component");
if ($dh) {
while (my $entry = readdir $dh) {
$entry =~ /^binary-(.*)/ and $1 !~ /all/ and $found_arches{$1} = 1;
}
}
close $dh;
}
if ($found_arches{"i386"}) {
push @ARCHES, 'i386';
}
if ($found_arches{"amd64"}) {
push @ARCHES, 'amd64';
}
for my $arch (sort keys %found_arches) {
push @ARCHES, $arch;
}
}
sub grab_bin_info {
my $pth = shift;
my $arch = shift;
@ -118,7 +143,7 @@ if ($pkg eq "silo") {
if (length($pkgdata) > 2) {
if ($output eq "binary") {
$pkgdata =~ m/^Filename: (\S+)/m and $bin_deb = $1;
print "$bin_deb\n";
$text_out = "$bin_deb\n";
}
elsif ($output eq "source") {
$srcname = $pkg;
@ -128,7 +153,15 @@ if (length($pkgdata) > 2) {
my $dir;
$pkgdata =~ m/^Directory: (\S+)/m and $dir = $1;
# Explicitly use the md5 lines in the Sources stanza, hence the xdigit(32) here
while ($pkgdata =~ m/^ ([[:xdigit:]]{32}) (\d+) (\S+)/msg) { print "$dir/$3\n"; }
while ($pkgdata =~ m/^ ([[:xdigit:]]{32}) (\d+) (\S+)/msg) {
$text_out = $text_out . "$dir/$3\n";
}
}
}
}
if (length($text_out) < 2) {
die "which_deb: can't find $output file(s) for $pkg in $codename\n";
}
print $text_out;