Complete overhaul of the configuration system, allowing the user to
select one of multiple configurations at runtime.
This commit is contained in:
parent
f801952a0b
commit
9929cb456d
@ -31,19 +31,46 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
my @BRANCHES = qw(CURRENT);
|
my %CONFIGS = (
|
||||||
my @TARGETS = qw(world generic lint);
|
# Global settings
|
||||||
my @OPTIONS = qw(--update --verbose);
|
'global' => {
|
||||||
my %ARCHES = (
|
'TBDIR' => '/home/des/tinderbox',
|
||||||
'alpha' => [ 'alpha' ],
|
'OPTIONS' => [ '--update', '--verbose' ],
|
||||||
'i386' => [ 'i386', 'pc98' ],
|
'EMAIL' => 'developers,%%ARCH%%',
|
||||||
'ia64' => [ 'ia64' ],
|
},
|
||||||
'sparc64' => [ 'sparc64' ],
|
# 5-CURRENT tinderbox
|
||||||
|
'cueball' => {
|
||||||
|
'COMMENT' => "-CURRENT tinderbox",
|
||||||
|
'BRANCHES' => [ 'CURRENT' ],
|
||||||
|
'TARGETS' => [ 'world', 'generic' ],
|
||||||
|
'ARCHES' => {
|
||||||
|
'alpha' => [ 'alpha' ],
|
||||||
|
'i386' => [ 'i386', 'pc98' ],
|
||||||
|
'ia64' => [ 'ia64' ],
|
||||||
|
'sparc64' => [ 'sparc64' ],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
# 4-STABLE tinderbox
|
||||||
|
'triangle' => {
|
||||||
|
'COMMENT' => "-STABLE tinderbox",
|
||||||
|
'BRANCHES' => [ 'RELENG_4' ],
|
||||||
|
'TARGETS' => [ 'world', 'generic' ],
|
||||||
|
'ARCHES' => {
|
||||||
|
'alpha' => [ 'alpha' ],
|
||||||
|
'i386' => [ 'i386', 'pc98' ],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
# Test setup
|
||||||
|
'9ball' => {
|
||||||
|
'BRANCHES' => [ 'CURRENT' ],
|
||||||
|
'TARGETS' => [ 'world', 'generic' ],
|
||||||
|
'ARCHES' => {
|
||||||
|
'i386' => [ 'i386' ],
|
||||||
|
},
|
||||||
|
'EMAIL' => 'des@ofug.org',
|
||||||
|
},
|
||||||
);
|
);
|
||||||
my $HOST = 'cueball.rtp.freebsd.org';
|
my %CONFIG = ();
|
||||||
my $USER = 'des';
|
|
||||||
my $TBDIR = "/home/$USER/tinderbox";
|
|
||||||
my $EMAIL = 'src-developers@freebsd.org';
|
|
||||||
|
|
||||||
sub report($$$) {
|
sub report($$$) {
|
||||||
my $recipient = shift;
|
my $recipient = shift;
|
||||||
@ -56,6 +83,8 @@ sub report($$$) {
|
|||||||
print(STDERR "Subject: $subject\n\n");
|
print(STDERR "Subject: $subject\n\n");
|
||||||
print(STDERR "[failed to send report by email]\n\n");
|
print(STDERR "[failed to send report by email]\n\n");
|
||||||
print(STDERR $message);
|
print(STDERR $message);
|
||||||
|
} else {
|
||||||
|
print(STDERR "mailed report to $recipient\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,14 +94,14 @@ sub tinderbox($$$$) {
|
|||||||
my $arch = shift;
|
my $arch = shift;
|
||||||
my $machine = shift;
|
my $machine = shift;
|
||||||
|
|
||||||
my $logfile = "$TBDIR/tinderbox-$branch-$arch-$machine.log";
|
my $logfile = "$CONFIG{'TBDIR'}/tinderbox-$branch-$arch-$machine.log";
|
||||||
|
|
||||||
my @args = ($tinderbox, @OPTIONS);
|
my @args = ($tinderbox, @{$CONFIG{'OPTIONS'}});
|
||||||
push(@args, "--branch=$branch");
|
push(@args, "--branch=$branch");
|
||||||
push(@args, "--arch=$arch");
|
push(@args, "--arch=$arch");
|
||||||
push(@args, "--machine=$machine");
|
push(@args, "--machine=$machine");
|
||||||
push(@args, "--logfile=$logfile");
|
push(@args, "--logfile=$logfile");
|
||||||
push(@args, @TARGETS);
|
push(@args, @{$CONFIG{'TARGETS'}});
|
||||||
|
|
||||||
print(STDERR join(' ', @args), "\n");
|
print(STDERR join(' ', @args), "\n");
|
||||||
rename($logfile, "$logfile.old");
|
rename($logfile, "$logfile.old");
|
||||||
@ -87,34 +116,30 @@ sub tinderbox($$$$) {
|
|||||||
while (<LOGFILE>) {
|
while (<LOGFILE>) {
|
||||||
if (m/^TB \*\*\*/) {
|
if (m/^TB \*\*\*/) {
|
||||||
if (@accumulate && $error) {
|
if (@accumulate && $error) {
|
||||||
if (@accumulate > 20) {
|
|
||||||
$messages .= "[...]\n";
|
|
||||||
while (@accumulate > 20) {
|
|
||||||
shift(@accumulate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$messages .= join('', @accumulate);
|
$messages .= join('', @accumulate);
|
||||||
}
|
}
|
||||||
$messages .= $_;
|
$messages .= $_;
|
||||||
@accumulate = ();
|
@accumulate = ();
|
||||||
$error = 0;
|
$error = 0;
|
||||||
} elsif (m/\bStop\b/) {
|
next;
|
||||||
push(@accumulate, $_);
|
|
||||||
$error = 1;
|
|
||||||
} else {
|
|
||||||
push(@accumulate, $_);
|
|
||||||
}
|
}
|
||||||
|
if (m/\bStop\b/) {
|
||||||
|
$error = 1;
|
||||||
|
}
|
||||||
|
if (@accumulate > 20) {
|
||||||
|
shift(@accumulate);
|
||||||
|
$accumulate[0] = "[...]";
|
||||||
|
}
|
||||||
|
push(@accumulate, $_);
|
||||||
}
|
}
|
||||||
if (@accumulate && $error) {
|
if (@accumulate && $error) {
|
||||||
if (@accumulate > 20) {
|
|
||||||
$messages .= "[...]\n";
|
|
||||||
while (@accumulate > 20) {
|
|
||||||
shift(@accumulate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$messages .= join('', @accumulate);
|
$messages .= join('', @accumulate);
|
||||||
}
|
}
|
||||||
report($EMAIL,
|
my $recipient = $CONFIG{'EMAIL'};
|
||||||
|
$recipient =~ s/\%\%branch\%\%/$branch/gi;
|
||||||
|
$recipient =~ s/\%\%arch\%\%/$arch/gi;
|
||||||
|
$recipient =~ s/\%\%machine\%\%/$machine/gi;
|
||||||
|
report($recipient,
|
||||||
"$branch tinderbox failure on $arch/$machine",
|
"$branch tinderbox failure on $arch/$machine",
|
||||||
$messages);
|
$messages);
|
||||||
} else {
|
} else {
|
||||||
@ -123,15 +148,30 @@ sub tinderbox($$$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MAIN:{
|
sub usage() {
|
||||||
$ENV{"PATH"} = "";
|
|
||||||
|
|
||||||
my $host = lc(`/bin/hostname`);
|
print(STDERR "usage: tbmaster config\n");
|
||||||
chomp($host);
|
print(STDERR "recognized configs:");
|
||||||
if ($host ne $HOST || $ENV{'USER'} ne $USER) {
|
foreach my $config (sort(keys(%CONFIGS))) {
|
||||||
die("don't run this script without configuring it first!\n");
|
print(STDERR " $config")
|
||||||
|
unless ($config eq 'global');
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN:{
|
||||||
|
usage()
|
||||||
|
unless (@ARGV == 1);
|
||||||
|
my $config = lc($ARGV[0]);
|
||||||
|
usage()
|
||||||
|
unless (exists($CONFIG{$config}) && $config ne 'global');
|
||||||
|
%CONFIG = %{$CONFIGS{$config}};
|
||||||
|
foreach my $key (keys(%{$CONFIGS{'global'}})) {
|
||||||
|
$CONFIG{$key} = $CONFIGS{'global'}->{$key}
|
||||||
|
unless (exists($CONFIG{$key}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ENV{"PATH"} = "";
|
||||||
my $tinderbox = $0;
|
my $tinderbox = $0;
|
||||||
if ($tinderbox =~ m|(.*/)tbmaster(.*)$|) {
|
if ($tinderbox =~ m|(.*/)tbmaster(.*)$|) {
|
||||||
$tinderbox = "${1}tinderbox${2}";
|
$tinderbox = "${1}tinderbox${2}";
|
||||||
@ -140,9 +180,9 @@ MAIN:{
|
|||||||
die("where is the tinderbox script?\n");
|
die("where is the tinderbox script?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $branch (sort(@BRANCHES)) {
|
foreach my $branch (sort(@{$CONFIG{'BRANCHES'}})) {
|
||||||
foreach my $arch (sort(keys(%ARCHES))) {
|
foreach my $arch (sort(keys(%{$CONFIG{'ARCHES'}}))) {
|
||||||
foreach my $machine (sort(@{$ARCHES{$arch}})) {
|
foreach my $machine (sort(@{$CONFIG{'ARCHES'}->{$arch}})) {
|
||||||
tinderbox($tinderbox, $branch, $arch, $machine);
|
tinderbox($tinderbox, $branch, $arch, $machine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user