diff mbox

[1/3] Use apt-get -a $arch build-dep $package when cross-building instead of dummy package.

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

Commit Message

Wookey Dec. 21, 2011, 10:41 p.m. UTC
From: Wookey <wookey@wookware.org>

---
 lib/Sbuild/Build.pm |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm
index ccc4d04..0ef5004 100644
--- a/lib/Sbuild/Build.pm
+++ b/lib/Sbuild/Build.pm
@@ -664,20 +664,35 @@  sub run_fetch_install_packages {
 				    join(", ", @{$self->get_conf('MANUAL_CONFLICTS_ARCH')}),
 				    join(", ", @{$self->get_conf('MANUAL_CONFLICTS_INDEP')}));
 
-	$resolver->add_dependencies($self->get('Package'),
-				    $self->get('Build Depends'),
-				    $self->get('Build Depends Arch'),
-				    $self->get('Build Depends Indep'),
-				    $self->get('Build Conflicts'),
-				    $self->get('Build Conflicts Arch'),
-				    $self->get('Build Conflicts Indep'));
-
-	$self->check_abort();
-	if (!$resolver->install_deps($self->get('Package'),
-				     'ESSENTIAL', 'GCC_SNAPSHOT', 'MANUAL',
-				     $self->get('Package'))) {
-	    Sbuild::Exception::Build->throw(error => "Package build dependencies not satisfied; skipping",
-					    failstage => "install-deps");
+	if ($self->get_conf('HOST_ARCH') eq $self->get_conf('BUILD_ARCH')) {
+	# for native building make and install dummy-deps package
+		$resolver->add_dependencies($self->get('Package'),
+						$self->get('Build Depends'),
+						$self->get('Build Depends Arch'),
+						$self->get('Build Depends Indep'),
+						$self->get('Build Conflicts'),
+						$self->get('Build Conflicts Arch'),
+						$self->get('Build Conflicts Indep'));
+
+		$self->check_abort();
+		if (!$resolver->install_deps($self->get('Package'),
+						'ESSENTIAL', 'GCC_SNAPSHOT', 'MANUAL',
+						$self->get('Package'))) {
+			Sbuild::Exception::Build->throw(error => "Package build dependencies not satisfied; skipping",
+							failstage => "install-deps");
+						}
+	} else { # cross-building
+		# install cross-deps. Hacked for now - need to generate dummy package
+		$self->log('Cross-deps: Running apt-get -a ' . $self->get('Host_Arch') . ' build-dep ' . $self->get('Package') . "\n");
+		$resolver->run_apt_command(
+			{ COMMAND => [$self->get_conf('APT_GET'),  '-a ' . $self->get('Host_Arch'), 'build-dep', $self->get('Package')],
+			ENV => {'DEBIAN_FRONTEND' => 'noninteractive'},
+			USER => 'root',
+			DIR => '/' });
+		if ($?) {
+			$self->log("Failed to get cross build-deps:\n");
+			return 1;
+		}
 	}
 	$self->set('Install End Time', time);