diff mbox

[1/7] Merge in BUILD/HOST ARCH bits that got lost

Message ID 1324299198-14640-1-git-send-email-wookey@wookware.org
State Accepted
Headers show

Commit Message

Wookey Dec. 19, 2011, 12:53 p.m. UTC
From: Wookey <wookey@wookware.org>

---
 bin/sbuild-createchroot |   19 +++++++++----------
 lib/Sbuild/Build.pm     |   30 ++++++++++++++++++------------
 lib/Sbuild/Utility.pm   |    2 +-
 3 files changed, 28 insertions(+), 23 deletions(-)
diff mbox

Patch

diff --git a/bin/sbuild-createchroot b/bin/sbuild-createchroot
index b8b82b7..c3c8d8a 100755
--- a/bin/sbuild-createchroot
+++ b/bin/sbuild-createchroot
@@ -90,7 +90,7 @@  sub set_options {
 
     $self->add_options(
 	"arch=s" => sub {
-	    $self->set_conf('ARCH', $_[1]);
+	    $self->set_conf('BUILD_ARCH', $_[1]);
 	},
 	"foreign" => sub {
 	    $self->set_conf('FOREIGN', 0);
@@ -177,7 +177,7 @@  if ($conf->get('VERBOSE')) {
     print "I: SCRIPT: $script\n" if (defined($script));
 }
 
-my @args = ("--arch=" . $conf->get('ARCH'),
+my @args = ("--arch=" . $conf->get('BUILD_ARCH'),
 	    "--variant=buildd");
 push @args, "--verbose" if $conf->get('VERBOSE');
 push @args, "--foreign" if $conf->get('FOREIGN');
@@ -250,11 +250,11 @@  dump_file("${target}/etc/apt/sources.list");
 print "I: Please add any additional APT sources to ${target}/etc/apt/sources.list\n";
 
 # Write out schroot chroot configuration.
-my $chrootname = "${suite}-" . $conf->get('ARCH') . "-sbuild";
+my $chrootname = "${suite}-" . $conf->get('BUILD_ARCH') . "-sbuild";
 
 # Determine the schroot chroot configuration to use.
 my $config_entry;
-my $arch = $conf->get('ARCH');
+my $arch = $conf->get('BUILD_ARCH');
 if ($conf->get('MAKE_SBUILD_TARBALL')) {
     my $tarball = $conf->get('MAKE_SBUILD_TARBALL');
 
@@ -298,18 +298,17 @@  if (-d "/etc/schroot/chroot.d") {
 
     my ($personality, $personality_message);
     # Detect whether personality might be needed.
-
-    if ($conf->get('ARCH') ne $conf->get('HOST_ARCH')) {
+    if ($conf->get('ARCH') ne $conf->get('BUILD_ARCH')) {
 	# Take care of the known case(s).
-	if ($conf->get('ARCH') eq 'i386' &&
-	    $conf->get('HOST_ARCH') eq 'amd64') {
+	if ($conf->get('BUILD_ARCH') eq 'i386' &&
+	    $conf->get('ARCH') eq 'amd64') {
 	    $personality='linux32';
 	    $personality_message =
 		"I: Added personality=$personality automatically (i386 on amd64).\n";
 	} else {
 	    $personality_message =
 		"W: The selected architecture and the current architecture do not match\n" .
-		"W: (" . $conf->get('ARCH') . " versus " . $conf->get('HOST_ARCH') . ").\n" .
+		"W: (" . $conf->get('BUILD_ARCH') . " versus " . $conf->get('ARCH') . ").\n" .
 		"I: You probably need to add a personality option (see schroot(1)).\n" .
 		"I: You may want to report your use case to the sbuild developers so that\n" .
 		"I: the appropriate option gets automatically added in the future.\n\n";
@@ -383,7 +382,7 @@  if ($conf->get('ARCH') eq $conf->get('HOST_ARCH')) {
     }
 } else {
     print "W: The selected architecture and the current architecture do not match\n";
-    print "W: (" . $conf->get('ARCH') . " versus " . $conf->get('HOST_ARCH') . ").\n";
+    print "W: (" . $conf->get('BUILD_ARCH') . " versus " . $conf->get('ARCH') . ").\n";
     print "W: Not automatically updating APT package lists.\n";
     print "I: Run \"apt-get update\" and \"apt-get dist-upgrade\" prior to use.\n";
     print "I: Run \"sbuild-checkpackages --set\" to set reference package list.\n";
diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm
index ff2240f..b7ab733 100644
--- a/lib/Sbuild/Build.pm
+++ b/lib/Sbuild/Build.pm
@@ -369,7 +369,7 @@  sub run_chroot_session {
 	my $session = $chroot_info->create('chroot',
 					   $self->get_conf('DISTRIBUTION'),
 					   $self->get_conf('CHROOT'),
-					   $self->get_conf('ARCH'));
+					   $self->get_conf('BUILD_ARCH'));
 
 	# Run pre build external commands
 	$self->check_abort();
@@ -388,12 +388,14 @@  sub run_chroot_session {
 
 	$self->check_abort();
 	my $chroot_arch =  $self->chroot_arch();
-	if ($self->get('Arch') ne $chroot_arch) {
-	    Sbuild::Exception::Build->throw(error => "Build architecture (" . $self->get('Arch') .
-					    ") is not the same as the chroot architecture (" .
-					    $chroot_arch . ")",
-					    info => "Please specify the correct architecture with --arch, or use a chroot of the correct architecture",
-					    failstage => "create-session");
+	if ($self->get_conf('BUILD_ARCH') ne $chroot_arch) {
+	    Sbuild::Exception::Build->throw(
+		error => "Requested build architecture (" .
+		$self->get_conf('BUILD_ARCH') .
+		") and chroot architecture (" . $chroot_arch .
+		") do not match.  Skipping build.",
+		info => "Please specify the correct architecture with --build-arch, or use a chroot of the correct architecture",
+		failstage => "create-session");
 	}
 
 	$self->set('Chroot Dir', $session->get('Location'));
@@ -984,14 +986,14 @@  sub fetch_source_files {
     } else {
 	my $valid_arch;
 	for my $a (split(/\s+/, $dscarchs)) {
-	    if (Dpkg::Arch::debarch_is($arch, $a)) {
+	    if (Dpkg::Arch::debarch_is($host_arch, $a)) {
 		$valid_arch = 1;
 		last;
 	    }
 	}
 	if ($dscarchs ne "any" && !($valid_arch) &&
 	    !($dscarchs eq "all" && $self->get_conf('BUILD_ARCH_ALL')) )  {
-	    my $msg = "$dsc: $arch not in arch list or does not match any arch wildcards: $dscarchs -- skipping\n";
+	    my $msg = "$dsc: $host_arch not in arch list or does not match any arch wildcards: $dscarchs -- skipping\n";
 	    $self->log($msg);
 	    Sbuild::Exception::Build->throw(error => "$dsc: $host_arch not in arch list or does not match any arch wildcards: $dscarchs -- skipping",
 					    status => "skipped",
@@ -1346,7 +1348,7 @@  sub build {
 		    " to version number; no source changes\n";
 	    }
 	    if ($self->get_conf('BIN_NMU')) {
-		print F "  * Binary-only non-maintainer upload for $arch; ",
+		print F "  * Binary-only non-maintainer upload for $host_arch; ",
 		    "no source changes.\n";
 		print F "  * ", join( "    ", split( "\n", $self->get_conf('BIN_NMU') )), "\n";
 	    }
@@ -1605,7 +1607,7 @@  sub build {
 	}
 
 	$self->log_subsection("Changes");
-	$changes = $self->get('Package_SVersion') . "_$arch.changes";
+	$changes = $self->get('Package_SVersion') . "_$host_arch.changes";
 	my @cfiles;
 	if (-r "$build_dir/$changes") {
 	    my(@do_dists, @saved_dists);
@@ -1659,7 +1661,7 @@  sub build {
 	my @debcfiles = @cfiles;
 	foreach (@debcfiles) {
 	    my $deb = "$build_dir/$_";
-	    next if $deb !~ /(\Q$arch\E|all)\.[\w\d.-]*$/;
+	    next if $deb !~ /(\Q$host_arch\E|all)\.[\w\d.-]*$/;
 
 	    $self->log_subsubsection("$_");
 	    if (!open( PIPE, "dpkg --info $deb 2>&1 |" )) {
@@ -2174,6 +2176,10 @@  sub open_build_log {
     my $hostname = $self->get_conf('HOSTNAME');
     $self->log("sbuild (Debian sbuild) $version ($release_date) on $hostname\n");
 
+    my $arch_string = $self->get_conf('BUILD_ARCH');
+    $arch_string = 'CROSS host=' . $self->get_conf('HOST_ARCH') .
+	'/build=' . $self->get_conf('BUILD_ARCH')
+	if ($self->get_conf('HOST_ARCH') ne $self->get_conf('BUILD_ARCH'));
     my $head1 = $self->get('Package') . ' ' . $self->get('Version') .
 	' (' . $arch_string . ') ';
     my $head2 = strftime("%d %b %Y %H:%M",
diff --git a/lib/Sbuild/Utility.pm b/lib/Sbuild/Utility.pm
index f75f703..63a94f1 100644
--- a/lib/Sbuild/Utility.pm
+++ b/lib/Sbuild/Utility.pm
@@ -97,7 +97,7 @@  sub setup ($$$) {
     $session = $chroot_info->create($namespace,
 				    $chroot,
 				    undef, # TODO: Add --chroot option
-				    $conf->get('ARCH'));
+				    $conf->get('BUILD_ARCH'));
 
     $session->set('Log Stream', \*STDOUT);