From e9d8bd0896ea36068072bdde4e96dee8d322fc8f Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Thu, 11 Apr 2013 19:47:05 +0200 Subject: [PATCH] xt-install-image: Don't bail out if only cdebootstrap is installed There was a duplicated check on debootstrap being installed and only one has been expanded when cdebootstrap support was added. So xen-tools bailed out if debootstrap wasn't installed even if it had been instructed to use cdebootstrap instead. This also adds support for cdebootstrap-static. Additionally xt-install-image dispatcher has been extended to hand array refs of command paths instead of just single command paths. Thanks to Elmar Heeb for reporting this issue! --- bin/xt-install-image | 60 ++++++++++++++++++++++++++++---------------- debian/changelog | 2 ++ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/bin/xt-install-image b/bin/xt-install-image index 2cb29b8..7f1d687 100755 --- a/bin/xt-install-image +++ b/bin/xt-install-image @@ -133,13 +133,19 @@ my $RELEASE = '4.4~dev'; # needDirectory Defined if we need an install-source directory specified. # # +my $debootstrap_cmd; my %dispatch = ( "copy" => { sub => \&do_copy, needBinary => "/bin/cp", needDirectory => 1, }, "debootstrap" => { sub => \&do_debootstrap, - needBinary => "/usr/sbin/debootstrap", + needBinary => ["/usr/sbin/debootstrap", "/usr/bin/cdebootstrap", "/usr/bin/cdebootstrap-static"], + var => \$debootstrap_cmd, + }, + "cdebootstrap" => { sub => \&do_debootstrap, + needBinary => ["/usr/sbin/cdebootstrap", "/usr/bin/cdebootstrap-static"], + var => \$debootstrap_cmd, }, "rinse" => { sub => \&do_rinse, needBinary => "/usr/sbin/rinse", @@ -210,13 +216,35 @@ if ( defined( $CONFIG{ 'install-method' } ) && # # Do we need to test for a binary. - if ( ( $installer->{ 'needBinary' } ) && - ( !-x $installer->{ 'needBinary' } ) ) - { - print - "The following required binary for the installation was not found\n"; - print "\t" . $installer->{ 'needBinary' } . "\n"; - exit 1; + if ( $installer->{ 'needBinary' } ) { + if ( 'ARRAY' eq ref $installer->{ 'needBinary' } ) { + unless (ref $installer->{ 'var' }) { + die "Assertion: If dispatch->->needBinary is an array ref, dispatch->->var must exist"; + } + + foreach my $binary (@{$installer->{ 'needBinary' }}) { + if (-x $binary) { + ${$installer->{ 'var' }} = $binary; + last; + } + } + + unless ( ${$installer->{ 'var' }} ) { + print + "One of the following binaries are required for the installation, but none was found\n"; + print "\t" . join(', ', @{$installer->{ 'needBinary' }}) . "\n"; + exit 1; + } + } + else + { + if ( !-x $installer->{ 'needBinary' } ) { + print + "The following required binary for the installation was not found\n"; + print "\t" . $installer->{ 'needBinary' } . "\n"; + exit 1; + } + } } # Do we need a directory specified as the installation source? @@ -572,21 +600,9 @@ sub do_debootstrap # The command is a little configurable - mostly to allow you # to use cdebootstrap. # - my $cmd = $CONFIG{ 'debootstrap-cmd' }; + my $cmd = $CONFIG{ 'debootstrap-cmd' } || $debootstrap_cmd; + print "Using $cmd as debootstrap command\n"; my $cachedir = $CONFIG{ 'cachedir' }; - if ( !$cmd ) - { - if (-x '/usr/sbin/debootstrap') { - $cmd = '/usr/sbin/debootstrap'; - } elsif (-x '/usr/sbin/cdebootstrap') { - $cmd = '/usr/sbin/cdebootstrap'; - } else { - print STDERR "Found neither debootstrap nor cdebootstrap and no --debootstrap-cmd given\n"; - exit 1; - } - print "Using $cmd as debootstrap command\n"; - } - # # Cache from host -> new installation if we've got caching diff --git a/debian/changelog b/debian/changelog index 761357d..7b5e574 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ xen-tools (4.4~dev-1) UNRELEASED; urgency=low - Preliminary support for Debian Jessie and Ubuntu Raring - Preliminary support for xl toolstack - xen-create-image: Consistently use runCommand() instead of system() + - xt-install-image: Don't bail out if only cdebootstrap is installed + but not debootstrap (Thanks Elmar Heeb!) - Makefile accepts DESTDIR=… - Move examples from debian/examples to examples. - Uses File::Which, added (build-) dependency on libfile-which-perl -- 2.39.5