[buildd-tools-devel] Bug#715020: [PATCH] bin/sbuild-createchroot: add an option to use qemu-debootstrap

Alberto Milone alberto.milone at canonical.com
Fri Jul 5 14:42:10 UTC 2013


When you call sbuild-createchroot with --use-qemu-debootstrap,
sbuild-createchroot will use qemu-debootstrap instead of the
standard debootstrap. This is particularly useful when
building for foreign architectures.

Signed-off-by: Alberto Milone <alberto.milone at canonical.com>
---
 bin/sbuild-createchroot |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/bin/sbuild-createchroot b/bin/sbuild-createchroot
index ba37f80..0ac7cbf 100755
--- a/bin/sbuild-createchroot
+++ b/bin/sbuild-createchroot
@@ -54,6 +54,9 @@ sub setup {
 	'KEEP_DEBOOTSTRAP_DIR'			=> {
 	    DEFAULT => 0
 	},
+	'USE_QEMU_DEBOOTSTRAP'			=> {
+	    DEFAULT => 0
+	},
 	'KEYRING'				=> {
 	    DEFAULT => undef
 	},
@@ -104,6 +107,9 @@ sub set_options {
 	"keep-debootstrap-dir" => sub {
 	    $self->set_conf('KEEP_DEBOOTSTRAP_DIR', 1)
 	},
+	"use-qemu-debootstrap" => sub {
+	    $self->set_conf('USE_QEMU_DEBOOTSTRAP', 1)
+	},
 	"exclude=s" => sub {
 	    $self->set_conf('EXCLUDE', $_[1]);
 	},
@@ -192,13 +198,25 @@ push @args, $conf->get('RESOLVE_DEPS') ?
 push @args, "$suite", "$target", "$mirror";
 push @args, "$script" if $script;
 
+# Set the path to debootstrap
+my $debootstrap = "/usr/sbin/debootstrap";
+
+# Run qemu-debootstrap instead of debootstrap
+if ($conf->get('USE_QEMU_DEBOOTSTRAP')) {
+    $debootstrap = "/usr/sbin/qemu-debootstrap";
+}
+
+# Get the name of the debootstrap binary
+my $debootstrap_bin = $debootstrap;
+$debootstrap_bin =~ s/^.*\///s;
+
 if ($conf->get('VERBOSE')) {
-    print "I: Running debootstrap " . join(' ', at args) . "\n";
+    print "I: Running $debootstrap_bin " . join(' ', at args) . "\n";
 }
 
 # Run debootstrap with specified options.
 if (!$conf->get('SETUP_ONLY')) {
-    !system("/usr/sbin/debootstrap", @args) or die "E: Error running debootstrap";
+    !system($debootstrap, @args) or die "E: Error running $debootstrap_bin";
 }
 
 # Set up minimal /etc/hosts.
-- 
1.7.9.5



More information about the Buildd-tools-devel mailing list