]> xenbits.xensource.com Git - people/dariof/xen-tools.git/commitdiff
xt-install-image: Don't bail out if only cdebootstrap is installed
authorAxel Beckert <abe@deuxchevaux.org>
Thu, 11 Apr 2013 17:47:05 +0000 (19:47 +0200)
committerAxel Beckert <abe@deuxchevaux.org>
Thu, 11 Apr 2013 17:47:05 +0000 (19:47 +0200)
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
debian/changelog

index 2cb29b859d70b7f295b3b8726b59357fd96f513b..7f1d687007b1de2864297a7927db09bb677f0a78 100755 (executable)
@@ -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
index 761357d538d56adc1fc12ef60b26f056a8457315..7b5e5745b68392c1c41d568759358f98ea20f154 100644 (file)
@@ -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