From 10ad73303cfda6958be69c1c28d38139edeca058 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 15 Aug 2006 21:11:32 +0000 Subject: [PATCH] 2006-08-15 21:11:31 by steve Allow command line to override the installation method, or type. This means resetting any other mutually exclusive options. This applies only to: --dir + --lvm --rpmstrap + --debootstrap + --copy + --tar. --- bin/xen-create-image | 108 ++++++++++++++++++++++++++++++++++++++----- debian/changelog | 3 ++ 2 files changed, 100 insertions(+), 11 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index c5b8f68..6dbaef7 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -435,7 +435,7 @@ Install an X11 server, using VNC and XDM -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.63 2006-08-15 18:04:14 steve Exp $ + $Id: xen-create-image,v 1.64 2006-08-15 21:11:31 steve Exp $ =cut @@ -478,6 +478,7 @@ my %CONFIG; my $MOUNT_POINT = undef; + # # Release number. # @@ -805,6 +806,20 @@ sub parseCommandLineArguments my $MANUAL = 0; my $VERSION = 0; + # + # We record the installation method here because we want + # to ensure that we allow the method supplied upon the command line + # to overwrite the one we might have ready read from the configuration + # file. + # + my %install; + $install{'debootstrap'} = 0; + $install{'rpmstrap'} = 0; + $install{'copy'} = undef; + $install{'tar'} = undef; + $install{'dir'} = undef; + $install{'lvm'} = undef; + # # Parse options. # @@ -819,11 +834,11 @@ sub parseCommandLineArguments "memory=s", \$CONFIG{'memory'}, # Locations - "dir=s", \$CONFIG{'dir'}, + "dir=s", \$install{'dir'}, "kernel=s", \$CONFIG{'kernel'}, "initrd=s", \$CONFIG{'initrd'}, "mirror=s", \$CONFIG{'mirror'}, - "lvm=s", \$CONFIG{'lvm'}, + "lvm=s", \$install{'lvm'}, # Networking options "dhcp", \$CONFIG{'dhcp'}, @@ -833,11 +848,14 @@ sub parseCommandLineArguments "netmask=s", \$CONFIG{'netmask'}, "p2p=s", \$CONFIG{'p2p'}, - # Exclusive - "copy=s", \$CONFIG{'copy'}, - "debootstrap", \$CONFIG{'debootstrap'}, - "rpmstrap", \$CONFIG{'rpmstrap'}, - "tar=s", \$CONFIG{'tar'}, + # Exclusive + # + # NOTE: We set the local variable here, not the global. + # + "copy=s", \$install{'copy'}, + "debootstrap", \$install{'debootstrap'}, + "rpmstrap", \$install{'rpmstrap'}, + "tar=s", \$install{'tar'}, # Misc. options "accounts", \$CONFIG{'accounts'}, @@ -864,7 +882,7 @@ sub parseCommandLineArguments if ( $VERSION ) { - my $REVISION = '$Revision: 1.63 $'; + my $REVISION = '$Revision: 1.64 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { @@ -875,6 +893,72 @@ sub parseCommandLineArguments exit; } + + # + # If we have had one of the local installation methods specified, + # and *only* one of them the we'll reset the global option(s) which + # came from the configuration file. + # + # Count the number which wer supplied + # + my $count = 0; + foreach my $key ( qw/debootstrap rpmstrap copy tar/ ) + { + if ( $install{$key} ) + { + $count += 1; + } + } + + # + # If we had exactly one specified then we can proceed. + # + if ( $count == 1 ) + { + foreach my $key ( qw/debootstrap rpmstrap copy tar/ ) + { + $CONFIG{$key} = $install{$key}; + } + } + elsif ( $count > 1 ) + { + print < 1 ) { print < Mon, 14 Aug 2006 22:34:59 +0000