diff mbox

[6/7] Add setup-dpkg fn to set dpkg foreign-architecture Add apt-config option to set apt to use $HOST package files

Message ID 1324299198-14640-6-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>

---
 lib/Sbuild/ResolverBase.pm |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/lib/Sbuild/ResolverBase.pm b/lib/Sbuild/ResolverBase.pm
index 3bae921..963e194 100644
--- a/lib/Sbuild/ResolverBase.pm
+++ b/lib/Sbuild/ResolverBase.pm
@@ -88,9 +88,9 @@  sub setup {
 	}
 	print $F "APT::Install-Recommends false;\n";
     
-    if ($self->get('Host_Arch') ne $self->get('Build_Arch')) {
-		print $F "APT::Architecture=".$self->get('Host_Arch');
-		print STDOUT "Adding APT::Architecture".$self->get('Host_Arch')."to the apt config";
+    if ($self->get_conf('HOST_ARCH') ne $self->get_conf('BUILD_ARCH')) {
+		print $F "APT::Architecture=".$self->get_conf('HOST_ARCH');
+		$self->log("Adding APT::Architecture" . $self->get_conf('HOST_ARCH') . " to the apt config\n");
 	}
 	if ($self->get('Split')) {
 	    print $F "Dir \"$chroot_dir\";\n";
@@ -133,13 +133,19 @@  sub setup {
 
 sub setup_dpkg {
 	my $self = shift;
-	
-	#if cross-building we need to set the correct foreign-arch
-	if ($self->get('Host_Arch') ne $self->get('Build_Arch')) {
-		open (my $F, '>/etc/dpkg/dpkg.cfg.d/sbuild');
-		print $F "foreign-architecture ".$self->get('Host_Arch');
-		close ($F);
-		print "Setting dpkg foreign-architecutre";
+
+    my $session = $self->get('Session');
+
+	#if cross-building set the correct foreign-arch
+	if ($self->get_conf('HOST_ARCH') ne $self->get_conf('BUILD_ARCH')) {
+        
+		$session->run_command(
+        { COMMAND => ['echo', 'foreign-architecture ' . $self->get_conf('HOST_ARCH'), '>', '/etc/dpkg/dpk.cfg.d/sbuild'],
+          USER => 'root' });
+        # We should get this much nicer interface with new dpkg upload.
+        # { COMMAND => ['dpkg', '--add-foreign-architecture ', $self->get_conf('HOST_ARCH')],
+        #   USER => 'root' });
+		$self->log("Setting dpkg foreign-architecture\n");
 	}
 }