diff mbox

[4/7] Add dpkg_setup function for setting dpkg multiarch cross-comfig

Message ID 1324299198-14640-4-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 |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/lib/Sbuild/ResolverBase.pm b/lib/Sbuild/ResolverBase.pm
index 4756304..3bae921 100644
--- a/lib/Sbuild/ResolverBase.pm
+++ b/lib/Sbuild/ResolverBase.pm
@@ -70,6 +70,9 @@  sub setup {
     my $session = $self->get('Session');
     my $chroot_dir = $session->get('Location');
 
+    #Set up dpkg config
+    $self->setup_dpkg();
+    
     my $aptconf = "/var/lib/sbuild/apt.conf";
     $self->set('APT Conf', $aptconf);
 
@@ -84,7 +87,11 @@  sub setup {
 	    print $F "APT::Get::AllowUnauthenticated true;\n";
 	}
 	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('Split')) {
 	    print $F "Dir \"$chroot_dir\";\n";
 	}
@@ -124,6 +131,18 @@  sub setup {
     $self->cleanup_apt_archive();
 }
 
+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";
+	}
+}
+
 sub cleanup {
     my $self = shift;