diff options
author | des <des@FreeBSD.org> | 2004-02-03 19:19:29 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2004-02-03 19:19:29 +0000 |
commit | d4cb213bdf531e146e4d22192c21ad8747a95349 (patch) | |
tree | 761ec876f08e6f27c187bc40d23c1f32fcdf8638 /tools | |
parent | 42373eaca91834080587faf943dfe287c8fb5538 (diff) | |
download | FreeBSD-src-d4cb213bdf531e146e4d22192c21ad8747a95349.zip FreeBSD-src-d4cb213bdf531e146e4d22192c21ad8747a95349.tar.gz |
Allow multiple configs to be specified to a single tbmaster instance.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/tinderbox/tbmaster.1 | 2 | ||||
-rw-r--r-- | tools/tools/tinderbox/tbmaster.pl | 114 |
2 files changed, 75 insertions, 41 deletions
diff --git a/tools/tools/tinderbox/tbmaster.1 b/tools/tools/tinderbox/tbmaster.1 index 1ffc6b8..6c20fe0 100644 --- a/tools/tools/tinderbox/tbmaster.1 +++ b/tools/tools/tinderbox/tbmaster.1 @@ -47,6 +47,8 @@ The following options are recognized: .Bl -tag -width 12n .It Fl c Ar CONFIG , Fl -config Ns = Ns Ar CONFIG The name of the configuration to use. +If specified multiple times, all listed configurations will be run in +sequence. The default is the hostname minus the domain part. .It Fl d , Fl -dump Dumps the configuration and exits without running the tinderbox. diff --git a/tools/tools/tinderbox/tbmaster.pl b/tools/tools/tinderbox/tbmaster.pl index b9ea181..32a1cb6 100644 --- a/tools/tools/tinderbox/tbmaster.pl +++ b/tools/tools/tinderbox/tbmaster.pl @@ -39,11 +39,11 @@ my $VERSION = "2.3"; my $COPYRIGHT = "Copyright (c) 2003 Dag-Erling Smørgrav. " . "All rights reserved."; -my $config; # Name of current config +my @configs; # Names of requested configations my $dump; # Dump configuration and exit my $etcdir; # Configuration directory -my %CONFIG = ( +my %INITIAL_CONFIG = ( 'BRANCHES' => [ 'CURRENT' ], 'COMMENT' => '', 'CVSUP' => '', @@ -62,6 +62,7 @@ my %CONFIG = ( 'TARGETS' => [ 'update', 'world' ], 'TINDERBOX' => '%%HOME%%/tinderbox', ); +my %CONFIG; ### ### Perform variable expansion @@ -82,6 +83,14 @@ sub expand($) { } ### +### Reset the configuration to initial values +### +sub clearconf() { + + %CONFIG = %INITIAL_CONFIG; +} + +### ### Read in a configuration file ### sub readconf($) { @@ -335,6 +344,9 @@ $COPYRIGHT Usage: $0 [options] [parameters] +Options: + -d, --dump Dump the processed configuration + Parameters: -c, --config=FILE Configuration name -e, --etcdir=DIR Configuration directory @@ -346,46 +358,12 @@ Report bugs to <des\@freebsd.org>. } ### -### Main +### Main loop ### -MAIN:{ - # Set defaults - $ENV{'PATH'} = "/usr/bin:/usr/sbin:/bin:/sbin"; - $config = `uname -n`; - chomp($config); - $config =~ s/^(\w+)(\..*)?/$1/; - $CONFIG{'HOSTNAME'} = `/usr/bin/uname -n`; - if ($CONFIG{'HOSTNAME'} =~ m/^([0-9a-z-]+(?:\.[0-9a-z-]+)*)$/) { - $CONFIG{'HOSTNAME'} = $1; - } else { - $CONFIG{'HOSTNAME'} = 'unknown'; - } - if ($ENV{'HOME'} =~ m/^((?:\/[\w\.-]+)+)\/*$/) { - $CONFIG{'HOME'} = $1; - $etcdir = "$1/etc"; - $ENV{'PATH'} = "$1/bin:$ENV{'PATH'}" - if (-d "$1/bin"); - } +sub tbmaster($) { + my $config = shift; - # Get options - {Getopt::Long::Configure("auto_abbrev", "bundling");} - GetOptions( - "c|config=s" => \$config, - "d|dump" => \$dump, - "e|etcdir=s" => \$etcdir, - ) or usage(); - if (@ARGV) { - usage(); - } - - if (defined($etcdir)) { - if ($etcdir !~ m/^([\w\/\.-]+)$/) { - die("invalid etcdir\n"); - } - $etcdir = $1; - chdir($etcdir) - or die("$etcdir: $!\n"); - } + clearconf(); readconf('default.rc'); readconf("$config.rc") or die("$config.rc: $!\n"); @@ -404,7 +382,7 @@ MAIN:{ } print("\n"); } - exit(0); + return; } if (!length(expand('TINDERBOX')) || !-x expand('TINDERBOX')) { @@ -428,3 +406,57 @@ MAIN:{ } } } + +### +### Main +### +MAIN:{ + # Set defaults + $ENV{'PATH'} = "/usr/bin:/usr/sbin:/bin:/sbin"; + $INITIAL_CONFIG{'HOSTNAME'} = `/usr/bin/uname -n`; + if ($INITIAL_CONFIG{'HOSTNAME'} =~ m/^([0-9a-z-]+(?:\.[0-9a-z-]+)*)$/) { + $INITIAL_CONFIG{'HOSTNAME'} = $1; + } else { + $INITIAL_CONFIG{'HOSTNAME'} = 'unknown'; + } + if ($ENV{'HOME'} =~ m/^((?:\/[\w\.-]+)+)\/*$/) { + $INITIAL_CONFIG{'HOME'} = $1; + $etcdir = "$1/etc"; + $ENV{'PATH'} = "$1/bin:$ENV{'PATH'}" + if (-d "$1/bin"); + } + + # Get options + {Getopt::Long::Configure("auto_abbrev", "bundling");} + GetOptions( + "c|config=s" => \@configs, + "d|dump" => \$dump, + "e|etcdir=s" => \$etcdir, + ) or usage(); + if (@ARGV) { + usage(); + } + + # Check options + if (@configs) { + @configs = split(/,/, join(',', @configs)); + } else { + $configs[0] = `/usr/bin/uname -n`; + chomp($configs[0]); + $configs[0] =~ s/^(\w+)(\..*)?/$1/; + } + if (defined($etcdir)) { + if ($etcdir !~ m/^([\w\/\.-]+)$/) { + die("invalid etcdir\n"); + } + $etcdir = $1; + chdir($etcdir) + or die("$etcdir: $!\n"); + } + + # Run all specified or implied configurations + foreach my $config (@configs) { + tbmaster($config); + } + exit(0); +} |