diff mbox

[04/17] Resolve comflicts from merging initial cross-support

Message ID 1323885273-23505-4-git-send-email-wookey@linaro.org
State Accepted
Headers show

Commit Message

Wookey Dec. 14, 2011, 5:54 p.m. UTC
From: Wookey <wookey@wookware.org>

---
 bin/sbuild-createchroot |   19 +++++++++----------
 lib/Sbuild/Build.pm     |   36 +++++++++++++++++++++++++-----------
 lib/Sbuild/Utility.pm   |    2 +-
 3 files changed, 35 insertions(+), 22 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 b6784b3..1eb099f 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();
@@ -396,6 +396,16 @@  sub run_chroot_session {
 					    failstage => "create-session");
 	}
 
+	my $chroot_arch = $self->chroot_arch();
+	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.",
+		failstage => "create-session");
+	}
+
 	$self->set('Chroot Dir', $session->get('Location'));
 	# TODO: Don't hack the build location in; add a means to customise
 	# the chroot directly.  i.e. allow changing of /build location.
@@ -974,14 +984,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",
@@ -990,7 +1000,7 @@  sub fetch_source_files {
 	}
     }
 
-    debug("Arch check ok ($arch included in $dscarchs)\n");
+    debug("Arch check ok ($host_arch included in $dscarchs)\n");
 
     $self->set('Build Depends', $build_depends);
     $self->set('Build Depends Indep', $build_depends_indep);
@@ -1334,7 +1344,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";
 	    }
@@ -1593,7 +1603,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);
@@ -1647,7 +1657,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 |" )) {
@@ -2042,7 +2052,7 @@  sub open_build_log {
 
     my $filename = $self->get_conf('LOG_DIR') . '/' .
 	$self->get('Package_SVersion') . '-' .
-	$self->get('Arch') .
+	$self->get_conf('HOST_ARCH') .
 	"-$date";
 
     open($saved_stdout, ">&STDOUT") or warn "Can't redirect stdout\n";
@@ -2079,7 +2089,7 @@  sub open_build_log {
 		$self->log_symlink($filename,
 				   $self->get_conf('BUILD_DIR') . '/' .
 				   $self->get('Package_SVersion') . '_' .
-				   $self->get('Arch') . '.build');
+				   $self->get_conf('HOST_ARCH') . '.build');
 	    }
 	}
 
@@ -2162,6 +2172,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",
@@ -2226,8 +2240,8 @@  sub close_build_log {
 
     my $subject = "Log for " . $self->get_status() .
 	" build of " . $self->get('Package_Version');
-    if ($self->get('Arch')) {
-	$subject .= " on " . $self->get('Arch');
+    if ($self->get_conf('HOST_ARCH')) {
+	$subject .= " on " . $self->get_conf('HOST_ARCH');
     }
     if ($self->get_conf('ARCHIVE')) {
 	$subject .= " (" . $self->get_conf('ARCHIVE') . "/" . $self->get_conf('DISTRIBUTION') . ")";
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);