#!/usr/bin/perl -w =head1 NAME xt-customize-image - Customize a freshly installed copy of GNU/Linux =cut =head1 SYNOPSIS xt-customize-image [options] Help Options: --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. Mandatory Options: --location The location of the new installation --dist The name of the distribution which has been installed. All other options from B will be passed as environmental variables. =cut =head1 NOTES This script is invoked by B after it has created a fresh installation of Linux withing a temporary location. This script will be invoked with a full copy of the arguments from B in its environment, along with several command line arguments. The command line arguments which are mandatory are: --location - The temporary installation root of the new install --dist - The distribution which has been installed. =cut =head1 AUTHOR Steve -- http://www.steve.org.uk/ $Id: xt-customize-image,v 1.6 2006-06-09 15:12:24 steve Exp $ =cut =head1 LICENSE Copyright (c) 2005-2006 by Steve Kemp. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license. =cut use strict; use Env; use Getopt::Long; use Pod::Usage; # # Configuration values read from the command line. # # We do not need to read any configuration file. # my %CONFIG; # # Release number. # my $RELEASE = '2.0'; # # Parse the command line arguments. # parseCommandLineArguments(); # # Check our arguments # checkArguments(); # # Run each relevent hook script. # runDistributionHooks(); # # Exit cleanly - any errors which have already occurred will result # in "exit 1". # exit 0; =head2 parseArguments Parse the command line arguments this script was given. =cut sub parseCommandLineArguments { my $HELP = 0; my $MANUAL = 0; my $VERSION = 0; # # Parse options. # GetOptions( "location=s", \$CONFIG{'location'}, "dist=s", \$CONFIG{'dist'}, "verbose", \$CONFIG{'verbose'}, "help", \$HELP, "manual", \$MANUAL, "version", \$VERSION ); pod2usage(1) if $HELP; pod2usage(-verbose => 2 ) if $MANUAL; if ( $VERSION ) { my $REVISION = '$Revision: 1.6 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { $REVISION = $1; } print "xt-customize-image release $RELEASE - CVS: $REVISION\n"; exit; } } =head2 checkArguments Test that the command line arguments we were given make sense. =cut sub checkArguments { # # We require a location. # if ( ! defined( $CONFIG{'location'} ) ) { print "The '--location' argument is mandatory\n"; exit 1; } # # Test that the location we've been told contains # a fresh installation of Linux exists # if ( ! -d $CONFIG{'location'} ) { print "The installation directory we've been given doesn't exist\n"; print "We tried to use : $CONFIG{'location'}\n"; exit 1; } # # We require a distribution name. # if ( ! defined( $CONFIG{'dist'} ) ) { print "The '--dist' argument is mandatory\n"; exit 1; } # # Test that the distribution name we've been given # to configure has a collection of hook scripts. # # If there are no scripts then we clearly cannot # customise it! # my $dir = "/usr/lib/xen-tools/" . $CONFIG{'dist'} . ".d"; if ( ! -d $dir ) { print <