1
0
mirror of synced 2026-04-13 23:23:41 +00:00

2007-02-23 15:37:05 by steve

Installation methods are now updated so that I can add in the
 image server method for use @Bytemark.
This commit is contained in:
steve
2007-02-23 15:37:06 +00:00
parent 0687f4477d
commit 9cb33aa9b9
5 changed files with 196 additions and 287 deletions

View File

@@ -82,40 +82,21 @@ xen-create-image - Easily create new Xen instances with networking and OpenSSH.
Installation options:
--arch Pass the given architecture to debootstrap or rpmstrap.
This argument is ignored if you install with a different
installation type.
--arch Pass the given architecture to debootstrap or rpmstrap.
This argument is ignored if you install with a different
installation type.
--copy Install a new image by copying a directory recursively,
this is assumed to be a previously installed system.
This is much faster than installing from scratch.
--dist Specify the distribution you wish to install.
--copy-cmd This allows you to specify the command actually used for
installation when using "--copy"
NOTE: This option is *only* valid in the configuration file.
--install-method Specify the installation method to use.
--dist Specify the distribution you wish to install.
--install-source Specify the source path to use when installing via
a copy or tarball installation.
--debootstrap Use debootstrap to install the guest system.
--dist should be used to specify a distribution debootstrap
understands.
--mirror Setup the mirror to use when installing via debootstrap.
--mirror Setup the mirror to use when installing via debootstrap.
--rpmstrap Use rpmstrap to install the guest distribution.
--dist should be used to specify a distribution rpmstrap
understands.
--tar Install the new image by untarring the specified file.
Similar to --copy this is signficantly faster than
installing via rpmstrap or debootstrap.
--tar-cmd This allows you to specify the command actually used for
installation when using "--tar".
NOTE: This option is *only* valid in the configuration file.
--template Specify which template file to use when creating the
Xen configuration file.
--template Specify which template file to use when creating the
Xen configuration file.
@@ -268,12 +249,9 @@ Create a configuration file in /etc/xen so that xm can create the new image.
netmask = 255.255.255.0
#
# Installation options.
# Installation method, one of "copy", "debootstrap", "rpmstrap", "tar".
#
# copy = /path/to/pristine/image
debootstrap = 1
# rpmstrap = 1
# tar = /path/to/img.tar
install-method = debootstrap
=for example end
@@ -420,7 +398,7 @@ Create a configuration file in /etc/xen so that xm can create the new image.
xen-create-image --size=2Gb --swap=128Mb --dhcp \
--lvm=myvolumegroup --hostname=vm01.my.flat \
--tar=/path/to/tar.file.tar
--install-method=tar --install-source=/path/to/tar.file.tar
The advantage of the tarfile approach is that you'll not need to
keep a disk image mounted if you were to use the --copy argument
@@ -428,7 +406,7 @@ Create a configuration file in /etc/xen so that xm can create the new image.
xen-create-image --size=2Gb --swap=128Mb --dhcp \
--lvm=myvolumegroup --hostname=vm01.my.flat \
--copy=/path/to/copy/from
--install-method=copy --install-source=/path/to/copy/from
=cut
@@ -520,7 +498,7 @@ Install an X11 server, using VNC and XDM
--
http://www.steve.org.uk/
$Id: xen-create-image,v 1.125 2007-02-22 19:39:02 steve Exp $
$Id: xen-create-image,v 1.126 2007-02-23 15:37:05 steve Exp $
=cut
@@ -702,6 +680,7 @@ else
{
# Can't happen we didn't get an installation type.
logprint( "Error: No recognised installation type.\n" );
logprint( "Please specify either a directory, lvm, or evms volume to use.\n");
exit;
}
@@ -937,12 +916,9 @@ sub setupDefaultOptions
$CONFIG{'roledir'} = '/etc/xen-tools/role.d';
#
# Installation methods
# Installation method defaults to "debootstrap".
#
$CONFIG{'rpmstrap'} = 0;
$CONFIG{'debootstrap'} = 0;
$CONFIG{'copy'} = '';
$CONFIG{'tar'} = '';
$CONFIG{'install-method'} = 'debootstrap';
#
# The program to run to create a filesystem.
@@ -1058,11 +1034,7 @@ sub parseCommandLineArguments
# file.
#
my %install;
$install{'debootstrap'} = 0;
$install{'rpmstrap'} = 0;
$install{'evms'} = undef;
$install{'copy'} = undef;
$install{'tar'} = undef;
$install{'dir'} = undef;
$install{'lvm'} = undef;
@@ -1101,12 +1073,11 @@ sub parseCommandLineArguments
#
# NOTE: We set the local variable here, not the global.
#
"copy=s", \$install{'copy'},
"copy-cmd=s", \$CONFIG{'copy-cmd'}, # NOP - IGNORED.
"debootstrap", \$install{'debootstrap'},
"rpmstrap", \$install{'rpmstrap'},
"tar=s", \$install{'tar'},
"tar-cmd=s", \$CONFIG{'tar-cmd'}, # NOP - IGNORED.
"copy=s", \$install{'copy'},
"copy-cmd=s", \$CONFIG{'copy-cmd'}, # NOP - IGNORED.
"install-method=s", \$CONFIG{'install-method'},
"install-source=s", \$CONFIG{'install-source'},
"tar-cmd=s", \$CONFIG{'tar-cmd'}, # NOP - IGNORED.
# Misc. options
"accounts", \$CONFIG{'accounts'},
@@ -1139,7 +1110,7 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.125 $';
my $REVISION = '$Revision: 1.126 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
@@ -1151,99 +1122,8 @@ sub parseCommandLineArguments
#
# 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 )
{
my $err =<<E_O_ERROR;
Please specify an installation method using only *one* of the following
command line options:
--debootstrap = Install the system using the deboostrap command.
--rpmstrap = Install the system using the rpmstrap command.
--copy /path = Install by copying the specified directory recursively.
--tar file.tar = Install by untarring the given file.
(You could specify one of these options as the default in the configuration
file /etc/xen-tools/xen-tools.conf.)
E_O_ERROR
logprint( $err );
exit;
}
else
{
#
# count == 0;
#
# That means that the method should be supplied in the configuration
# file.
#
# If it isn't we'll abort here.
#
$count = 0;
foreach my $key ( qw/debootstrap rpmstrap copy tar/ )
{
if ( $CONFIG{$key} )
{
$count += 1;
}
}
if ( $count < 1 )
{
my $err =<<E_O_ERROR;
Please specify an installation method using only *one* of the following
command line options:
--debootstrap = Install the system using the deboostrap command.
--rpmstrap = Install the system using the rpmstrap command.
--copy /path = Install by copying the specified directory recursively.
--tar file.tar = Install by untarring the given file.
(You could specify one of these options as the default in the configuration
file /etc/xen-tools/xen-tools.conf.)
E_O_ERROR
logprint( $err );
exit;
}
}
#
# Now do a similar thing so that the command line setting of
# '--lvm', '--evms' and '--dir=x' override anything in the
# configuration file.
# Now make ensure that the command line setting of '--lvm', '--evms'
# and '--dir=x' override anything specified in the configuration file.
#
if ( $install{'dir'} )
{
@@ -1266,6 +1146,8 @@ E_O_ERROR
}
=begin doc
Make sure this script is being run by a user with UID 0.
@@ -1381,39 +1263,63 @@ E_OR
$CONFIG{'image'} = "full" if ( $CONFIG{'lvm'} ||
$CONFIG{'evms'} );
#
# Make sure we have one, and only one, installation method.
# Make sure that our installation method is specified.
#
my $count = 0;
foreach my $key ( qw/debootstrap rpmstrap copy tar/ )
my $valid = 0;
if ( defined( $CONFIG{'install-method'} ) )
{
if ( $CONFIG{$key} )
foreach my $recognised ( qw/ copy debootstrap rpmstrap tar / )
{
$count += 1;
$valid = 1 if ( lc($CONFIG{'install-method'}) eq lc($recognised) );
}
#
# If we have "copy" or "tar" make sure we have a source.
#
if ( lc($CONFIG{'install-method'}) eq "copy" )
{
# not defined.
$valid = 0 if (!defined( $CONFIG{'install-source'} ) );
# defined but not a directory.
$valid = 0 if (defined( $CONFIG{'install-source'} ) &&
(! -d $CONFIG{'install-source'} ) )
}
if ( lc($CONFIG{'install-method'}) eq "tar" )
{
# not defined.
$valid = 0 if (!defined( $CONFIG{'install-source'} ) );
# defined but not a file.
$valid = 0 if (defined( $CONFIG{'install-source'} ) &&
(! -e $CONFIG{'install-source'} ) )
}
}
if ( $count != 1 )
else
{
my $err =<<E_O_ERROR;
Please specify an installation method using one of the following
command line options:
--debootstrap = Install the system using the deboostrap command.
--rpmstrap = Install the system using the rpmstrap command.
--copy /path = Install by copying the specified directory recursively.
--tar file.tar = Install by untarring the given file.
(You could specify one of these options as the default in the configuration
file /etc/xen-tools/xen-tools.conf.)
E_O_ERROR
logprint( $err );
exit;
$valid = 1;
}
if ( !$valid )
{
print <<EOF;
Please specify the installation method to use.
For example:
--install-method=copy --install-source=/some/path
--install-method=debootstrap
--install-method=rpmstrap
--install-method=tar --install-source=/some/file.tar
EOF
exit;
}
#
# Make sure that any specified template file exists.
#
@@ -2267,9 +2173,6 @@ sub mountImage
Install the system, by invoking the xt-install-image script.
The script will be given the appropriate arguments from our environment.
This means that it will be given one of "--debootstrap", "--rpmstrap",
"--tar", and "--copy". There will also be other options passed on
as appropriate.
=end doc
@@ -2282,43 +2185,28 @@ sub installSystem
#
# Basic command
#
my $cmd = "xt-install-image --hostname=$CONFIG{'hostname'} --location=$MOUNT_POINT --dist=$CONFIG{'dist'}";
my $cmd = "xt-install-image --hostname=$CONFIG{'hostname'} --location=$MOUNT_POINT --dist=$CONFIG{'dist'} --install-method=$CONFIG{'install-method'}";
#
# Add on the install source if required.
#
$cmd .= " --install-source=$CONFIG{'install-source'}" if ( defined( $CONFIG{'install-source'} ) );
#
# Do we have a per-image configuration file?
#
$cmd .= " --config=$CONFIG{'config'}" if ( defined( $CONFIG{'config'} ) );
#
# Add on the mirror, if defined
#
$cmd .= " --mirror=$CONFIG{'mirror'}" if ( defined( $CONFIG{'mirror'} ) );
#
# Add on the current cache setting
#
$cmd .= " --cache=$CONFIG{'cache'}" if length( $CONFIG{'cache'} );
#
# Installation method
#
if ( $CONFIG{'copy'} )
{
$cmd .= " --copy=$CONFIG{'copy'}";
logprint( "copy from $CONFIG{'copy'}\n" );
}
if ( $CONFIG{'debootstrap'} )
{
$cmd .= " --debootstrap";
$cmd .= " --mirror=$CONFIG{'mirror'}";
logprint( "debootstrap mirror $CONFIG{'mirror'}\n" );
}
if ( $CONFIG{'rpmstrap'} )
{
$cmd .= " --rpmstrap";
logprint( "rpmstrap\n");
}
if ( $CONFIG{'tar'} )
{
$cmd .= " --tar=$CONFIG{'tar'}";
logprint( "tarfile $CONFIG{'tar'}\n" );
}
#
# Propogate --verbose
@@ -2337,6 +2225,13 @@ sub installSystem
}
#
# Show the user what they are installing
#
logprint( "Installation method: $CONFIG{'install-method'}\n" );
logprint( "(Source: $CONFIG{'install-source'})\n" ) if defined( $CONFIG{'install-source'} );
#
# Run the command.
#

View File

@@ -11,28 +11,26 @@ xt-install-image - Install a fresh copy of GNU/Linux into a directory
xt-install-image [options]
Help Options:
--help Show this scripts help information.
--manual Read this scripts manual.
--version Show the version number and exit.
--help Show this scripts help information.
--manual Read this scripts manual.
--version Show the version number and exit.
Debugging Options:
--verbose Be verbose in our execution.
--verbose Be verbose in our execution.
Mandatory Options:
--location The location to use for the new installation
--dist The name of the distribution which has been installed.
--location The location to use for the new installation
--dist The name of the distribution which has been installed.
Misc Options:
--arch Pass the given arch setting to debootstrap or rpmstrap.
--config Read the specified config file in addition to the global
configuration file.
--mirror The mirror to use when installing with 'debootstrap'.
--arch Pass the given arch setting to debootstrap or rpmstrap.
--config Read the specified config file in addition to the global
configuration file.
--mirror The mirror to use when installing with 'debootstrap'.
Installation Options:
--tar Untar the given file.
--debootstrap Install a new system via the debootstrap tool
--rpmstrap Install a new system via the rpmstrap.
--copy Copy the given directory recursively.
--install-method Specify the installation method to use.
--install-soruce Specify the installation source to use.
All other options from xen-create-image will be passed as environmental
variables.
@@ -59,17 +57,17 @@ xt-install-image - Install a fresh copy of GNU/Linux into a directory
=over 8
=item B<--debootstrap>
=item B<debootstrap>
Install the distribution specified by the B<--dist> argument using the debootstrap. If you use this option you must specify a mirror with B<--mirror>.
=item B<--copy>
Copy the given directory recursively. This local directory is assumed to contain a complete installation.
=item B<copy>
Copy the given directory recursively. This local directory is assumed to contain a complete installation. Specify the directory to copy with the B<--install-source> argument.
=item B<--rpmstrap>
=item B<rpmstrap>
Install the distribution specified by B<--dist> using the rpmstrap command.
=item B<--tar>
Untar a .tar file into the new installation location. This tarfile is assumed to contain a complete archived system.
=item B<tar>
Untar a .tar file into the new installation location. This tarfile is assumed to contain a complete archived system. Specify the directory to copy with the B<--install-source> argument.
=back
@@ -82,7 +80,7 @@ Untar a .tar file into the new installation location. This tarfile is assumed t
--
http://www.steve.org.uk/
$Id: xt-install-image,v 1.44 2006-12-26 00:55:58 steve Exp $
$Id: xt-install-image,v 1.45 2007-02-23 15:37:05 steve Exp $
=cut
@@ -159,7 +157,7 @@ checkArguments();
#
# Simplest cases first.
#
if ( $CONFIG{'copy'} )
if ( lc($CONFIG{'install-method'}) eq "copy" )
{
#
# Make sure we have the cp binary present.
@@ -183,7 +181,7 @@ if ( $CONFIG{'copy'} )
#
# Expand the source and the destination.
#
$cmd =~ s/\$src/$CONFIG{'copy'}/g;
$cmd =~ s/\$src/$CONFIG{'install-source'}/g;
$cmd =~ s/\$dest/$CONFIG{'location'}/g;
#
@@ -192,7 +190,7 @@ if ( $CONFIG{'copy'} )
runCommand( $cmd );
}
elsif ( $CONFIG{'tar'} )
elsif ( lc($CONFIG{'install-method'}) eq "tar" )
{
#
# Make sure we have the tar binary present.
@@ -216,14 +214,14 @@ elsif ( $CONFIG{'tar'} )
#
# Expand the tarfile.
#
$cmd =~ s/\$src/$CONFIG{'tar'}/g;
$cmd =~ s/\$src/$CONFIG{'install-source'}/g;
#
# Run a command to copy an installed system into the new root.
#
runCommand( "cd $CONFIG{'location'} && $cmd" );
}
elsif ( $CONFIG{'debootstrap'} )
elsif ( lc($CONFIG{'install-method'}) eq "debootstrap" )
{
#
# Make sure we have the debootstrap binary present.
@@ -236,7 +234,7 @@ elsif ( $CONFIG{'debootstrap'} )
installDebootstrapImage();
}
elsif ( $CONFIG{'rpmstrap'} )
elsif ( lc($CONFIG{'install-method'}) eq "rpmstrap" )
{
#
# Make sure we have the rpmstrap binary present.
@@ -374,11 +372,9 @@ sub parseCommandLineArguments
"dist=s", \$CONFIG{'dist'},
"hostname=s", \$CONFIG{'hostname'},
# Exclusive.
"tar=s", \$CONFIG{'tar'},
"copy=s", \$CONFIG{'copy'},
"rpmstrap", \$CONFIG{'rpmstrap'},
"debootstrap", \$CONFIG{'debootstrap'},
# Installation method
"install-method=s", \$CONFIG{'install-method'},
"install-source=s", \$CONFIG{'install-source'},
# Misc
"arch=s", \$CONFIG{'arch'},
@@ -399,7 +395,7 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.44 $';
my $REVISION = '$Revision: 1.45 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
@@ -478,54 +474,55 @@ E_OR
exit 1;
}
##
# Now check the mutually distinct arguments
##
my $count = 0;
foreach my $key ( qw(copy debootstrap rpmstrap tar ) )
my $valid = 0;
if ( defined( $CONFIG{'install-method'} ) )
{
if ( defined( $CONFIG{$key} ) )
foreach my $recognised ( qw/ copy debootstrap rpmstrap tar / )
{
$count += 1;
$valid = 1 if ( lc($CONFIG{'install-method'}) eq lc($recognised) );
}
#
# If we have "copy" or "tar" make sure we have a source.
#
if ( lc($CONFIG{'install-method'}) eq "copy" )
{
# not defined.
$valid = 0 if (!defined( $CONFIG{'install-source'} ) );
# defined but not a directory.
$valid = 0 if (defined( $CONFIG{'install-source'} ) &&
(! -d $CONFIG{'install-source'} ) )
}
if ( lc($CONFIG{'install-method'}) eq "tar" )
{
# not defined.
$valid = 0 if (!defined( $CONFIG{'install-source'} ) );
# defined but not a file.
$valid = 0 if (defined( $CONFIG{'install-source'} ) &&
(! -e $CONFIG{'install-source'} ) )
}
}
#
# If count == 0 we had no recognised installation method.
#
if ( $count == 0 )
else
{
print <<EOF;
You did not specify an installation method.
One of the following must be given. (Run "xt-install-image --manual" for details)
--copy
--debootstrap
--rpmstrap
--tar
Aborting.
EOF
exit 1;
$valid = 1;
}
elsif ( $count > 1 )
if ( !$valid )
{
print <<EOF;
You specify multiple installation methods.
Please specify the installation method to use.
Only one of the following must be given:
For example:
--copy
--debootstrap
--rpmstrap
--tar
--install-method=copy --install-source=/some/path
--install-method=debootstrap
--install-method=rpmstrap
--install-method=tar --install-source=/some/file.tar
Aborting.
EOF
exit 1;
exit;
}
}

6
debian/changelog vendored
View File

@@ -1,4 +1,4 @@
-------- unreleased
xen-tools (3.1-1) unstable; urgency=low
* New upstream release v3.1.
- Installation of packages in hooks works. (Closes: #402889, #404518)
@@ -9,17 +9,17 @@
- Fixed typo in error handling. (Closes: #404509)
- When copying user accounts copy groups too. (Closes: #404521)
-- whoever updates it.
-- Steve Kemp <skx@debian.org> Fri, 23 Feb 2007 13:36:28 +0000
xen-tools (3.0-1) unstable; urgency=low
-- Radu Spineanu <radu@debian.org> Wed, 13 Dec 2006 11:17:28 +0000
[ Steve Kemp ]
* New upstream release of 3.0
- Tests that config files exists. (Closes: #402328)
- New option to create image but not install. (Closes: #383057, #402315)
- Made "etch" the default target to install. (Closes: #399705)
-- Radu Spineanu <radu@debian.org> Wed, 13 Dec 2006 11:17:28 +0000
xen-tools (3.0~beta1-2) unstable; urgency=low

View File

@@ -42,7 +42,7 @@
#
# Installation method.
#
# There are four different methods you can use to install a new copy
# There are four distinct methods which you may to install a new copy
# of Linux to use in your Xen guest domain:
#
# - Installation via the debootstrap command.
@@ -54,16 +54,24 @@
# that the image you're left with matches the 'dist' setting later in
# this file.
#
# Note that you can only uncomment one method - they are mutually exclusive.
# However the command line installation method will allow you to override
# the choice you make here.
#
##
#
#
# copy = /path/to/pristine/image
# debootstrap = 1
# rpmstrap = 1
# tar = /path/to/img.tar
# install-method = [ debootstrap | rpmstrap | copy | tar ]
#
#
install-method = debootstrap
#
# If you're using "copy", or "tar" you will need to specify the
# source location to copy from, or the source .tar file to unpack.
#
# You may specify that with a line such as:
#
# install-source = /path/to/copy
# install-source = /some/path/img.tar
#
#
#
@@ -71,14 +79,15 @@
# Command definitions.
##
#
# The "debootstrap" and "rpmstrap" commands are hardwired, but if you
# wish to alter the commands invoked when using the "--copy" + "--tar"
# options you can adjust these two settings:
# The "debootstrap" and "rpmstrap" commands are hardwired into the
# script, but if you wish to modify the commands which are executed
# when installing new systems by a "copy" or "tar" method you can
# do so here:
#
# --copy:
# instlal-method=copy:
# copy-cmd = /bin/cp -a $src/* $dest
#
# --tar:
# install-method=tar:
# tar-cmd = /bin/tar --numeric-owner -xvf $src
#
#

View File

@@ -18,7 +18,7 @@
# --
# http://www.steve.org.uk
#
# $Id: xen-tools,v 1.40 2006-12-25 12:25:40 steve Exp $
# $Id: xen-tools,v 1.41 2007-02-23 15:37:06 steve Exp $
#
@@ -53,7 +53,7 @@ _xen_create_image()
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
opts='--accounts --broadcast --boot --cache --config --debootstrap --dhcp --dir --dist --evms --force --fs --gateway --help --hostname --ide --image --initrd --ip --kernel --lvm --mac --manual --memory --mirror --no-hooks --no-install --noswap --p2p --passwd --role --rpmstrap --size --swap --version --verbose'
opts='--admins --accounts --broadcast --boot --cache --config --dhcp --dir --dist --evms --force --fs --gateway --help --hostname --ide --image --install-method --install-source --initrd --ip --kernel --lvm --mac --manual --memory --mirror --no-hooks --no-install --noswap --p2p --passwd --role --size --swap --version --verbose'
#
@@ -109,6 +109,10 @@ _xen_create_image()
COMPREPLY=( $( compgen -W 'sparse full' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install-method)
COMPREPLY=( $( compgen -W 'copy debootstrap rpmstrap tar' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--ip)
ip=`echo ${ip} | sed -e 's/[.][^.]*$/./'`
COMPREPLY=( $(compgen -W "${ip}" -- ${cur}) )
@@ -366,7 +370,7 @@ _xt-install-image()
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
opts='--copy --cache --config --debootstrap --dist --help --location --manual --mirror --rpmstrap --tar --verbose --version'
opts='--cache --config --dist --help --install-source --install-method --location --manual --mirror --verbose --version'
#
@@ -394,6 +398,10 @@ _xt-install-image()
COMPREPLY=( $( compgen -W '${dists} sid sarge etch' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install-method)
COMPREPLY=( $( compgen -W 'copy debootstrap rpmstrap tar' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--location)
_filedir -d
return 0