diff --git a/webtools/tinderbox/examples/buildit.config b/webtools/tinderbox/examples/buildit.config new file mode 100755 index 00000000000..e866e3d307f --- /dev/null +++ b/webtools/tinderbox/examples/buildit.config @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +sub InitVars { + +#initialize variables +#$binary_name = '/netscape-export'; +$BinaryName = '/mozilla-export'; +$BuildDepend = 1; #depend or clobber +$BuildTree = ''; +$BuildTag = ''; +$BuildName = ''; +#$BuildContinue = 0; +$TopLevel = 'mozilla/'; +$BuildObjName = ''; +$BuildSleep = 10; +$BuildUnixclasses = 0; +$EarlyExit = 1; +$BuildStartDir = 'ns/'; +$BuildConfigDir = 'mozilla/config'; + +} #EndSub-InitVars + +sub SetupEnv { + + umask(0); + $ENV{'MOZILLA_CLIENT'} = 1; + $ENV{'NETSCAPE_HIERARCHY'} = 1; + $ENV{'BUILD_OFFICIAL'} = 1; + $ENV{'NSPR20'} = 1; + $ENV{'AWT_11'} = 1; + $ENV{'MOZ_SECURITY'} = 1; + $ENV{"CVSROOT"} = '/m/src'; + $ENV{"MAKE"} = 'gmake -e'; + $ENV{'MOZ_MEDIUM'} = 1; + $ENV{'NO_MDUPDATE'} = 1; + $ENV{'EDITOR'} = 1; + +} #EndSub-SetupEnv + +sub SetupPath { + + my($Path); + $Path = $ENV{PATH}; + print "Path before: $Path\n"; + $ENV{'PATH'} = '/tools/ns/bin:/tools/contrib/bin:/usr/local/bin:/usr/sbin:/usr/bsd:/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/etc:/usr/hosts:/usr/ucb:'; + + # This won't work on x86 or sunos4 systems.... + if ( $OS eq 'SunOS' ) { + $ENV{'PATH'} = '/usr/ccs/bin:/tools/ns/soft/gcc-2.6.3/run/default/sparc_sun_solaris2.4/bin:' . $ENV{'PATH'}; + $ENV{'NO_MDUPDATE'} = 1; + } + + if ( $OS eq 'AIX' ) { + $ENV{'PATH'} = $ENV{'PATH'} . '/usr/lpp/xlC/bin:/usr/local-aix/bin:'; + } + + $Path = $ENV{PATH}; + print "Path After: $Path\n"; + +} #EndSub-SetupPath + + +1; diff --git a/webtools/tinderbox/examples/mozilla-unix.pl b/webtools/tinderbox/examples/mozilla-unix.pl index 460f54de8a7..5b0545f4e50 100755 --- a/webtools/tinderbox/examples/mozilla-unix.pl +++ b/webtools/tinderbox/examples/mozilla-unix.pl @@ -1,159 +1,221 @@ #!/tools/ns/bin/perl5 +require 5.000; +require "buildit.config"; + use Sys::Hostname; +use Cwd; -#initialize variables -$build_depend=1; #depend or clobber -$build_tree = ''; -$build_tag = ''; -$build_name = ''; -$build_continue = 0; -$build_dir = ''; -$build_objname = ''; -$build_lite = 0; -$build_sleep = 10; -$early_exit = 1; +&InitVars; +&ParseArgs; +&GetSystemInfo; +&SetupEnv; +&SetupPath; +&BuildIt; -&parse_args; +sub GetSystemInfo { -$os = `uname -s`; -chop($os); +$OS = `uname -s`; +$OSVer = `uname -r`; -$osver = `uname -r`; -chop($osver); +chop($OS, $OSVer); -$dirname = $os . '_' . $osver . '_' . ($build_depend?'depend':'clobber'); -$build_name = $os . ' ' . $osver . ' ' . ($build_depend?'Depend':'Clobber'); - -&setup_env; - -$logfile = "${dirname}.log"; - -if( !$build_depend ){ - $clobber_str = 'clobber_all'; +if ( $OS eq 'AIX' ) { + $OSVer = `uname -v`; + chop($OSVer); + $OSVer = $OSVer . "." . `uname -r`; + chop($OSVer); } -$ENV{"CVSROOT"} = ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'; -mkdir("$dirname", 0777); -chdir("$dirname") || die "couldn't cd to $dirname"; +if ( $OS eq 'IRIX64' ) { + $OS = 'IRIX'; +} -$start_dir = `pwd`; -$last_time = 0; -chop($start_dir); +if ( $OS eq 'SCO_SV' ) { + $OS = 'SCOOS'; + $OSVer = '5.0'; +} -print "starting dir is :$start_dir\n"; +$DirName = $OS . '_' . $OSVer . '_' . ($BuildDepend?'depend':'clobber'); +$BuildName = $OS . ' ' . $OSVer . ' ' . ($BuildDepend?'Depend':'Clobber'); -while( $early_exit ){ - chdir("$start_dir"); - if( time - $last_time < (60 * $build_sleep) ) { - $sleep_time = (60 * $build_sleep) - (time - $last_time); - print "\n\nSleeping $sleep_time seconds ...\n"; - sleep( $sleep_time ); - } - $last_time = time; +$RealOS = $OS; +$RealOSVer = $OSVer; - $start_time = time-60*10; - $start_time_str = &cvs_time( $start_time ); +if ( $OS eq 'HP-UX' ) { + $RealOSVer = substr($OSVer,0,4); +} - &start_build; +if ( $OS eq 'Linux' ) { + $RealOSVer = substr($OSVer,0,3); +} - $cur_dir = `pwd`; - chop($cur_dir); - if( $cur_dir ne $start_dir ){ - print "startdir: $start_dir, curdir $cur_dir\n"; - die "curdir != startdir"; +if ( $ENV{"BUILD_OPT"} eq 1 ) { + $BuildObjName = $RealOS . $RealOSVer . '_OPT.OBJ'; +} +else { + $BuildObjName = $RealOS . $RealOSVer . '_DBG.OBJ'; +} + +$logfile = "${DirName}.log"; + +if ( !$BuildDepend ) { + $ClobberStr = "realclean"; +} + +} #EndSub-GetSystemInfo + +sub BuildIt { +mkdir("$DirName", 0777); +chdir("$DirName") || die "Couldn't enter $DirName"; + +$StartDir = getcwd(); +$LastTime = 0; + +print "Starting dir is : $StartDir\n"; + +$EarlyExit = 1; + +while ( $EarlyExit ) { + chdir("$StartDir"); + if ( time - $LastTime < (60 * $BuildSleep) ) { + $SleepTime = (60 * $BuildSleep) - (time - $LastTime); + print "\n\nSleeping $SleepTime seconds ...\n"; + sleep($SleepTime); } - unlink( "${dirname}.log" ); + $LastTime = time; - print "opening ${dirname}.log\n"; - open( LOG, ">${dirname}.log" ) || print "can't open $?\n"; - $hostname = hostname(); - print LOG "current dir is -- $hostname:$cur_dir\n"; - &print_env; - $build_dir = $cur_dir; + $StartTime = time - 60 * 10; + $StartTimeStr = &CVSTime($StartTime); - $build_status = 0; -if (!$build_test) { - open( PULL, "cvs co MozillaSourceUnix 2>&1 |"); + &StartBuild; - while( ){ - print $_; - print LOG $_; + $CurrentDir = getcwd(); + if ( $CurrentDir ne $StartDir ) { + print "startdir: $StartDir, curdir $CurrentDir\n"; + die "curdir != startdir"; + } + + $BuildDir = $CurrentDir; + + unlink( "${DirName}.log" ); + + print "opening ${DirName}.log\n"; + open( LOG, ">${DirName}.log" ) || print "can't open $?\n"; + print LOG "current dir is -- $hostname:$CurrentDir\n"; + &PrintEnv; + + $BuildStatus = 0; + if (!($BuildTest)) { +# pull tree + print LOG "cvs co ns/client.mk"; + + if ( $BuildTag ne '' ) { + open( PULLMAKE, "cvs co -r $BuildTag ns/client.mk 2>&1 |"); + } + else { + open( PULLMAKE, "cvs co ns/client.mk 2>&1 |"); + } + + while ( ) { + print $_; + print LOG $_; + } + close( PULLMAKE ); + + print LOG "gmake -f ns/client.mk setup"; + + if ( $BuildTag ne '' ) { + open( PULL, "cvs co -r $BuildTag client.mk 2>&1 |"); + } + else { + open( PULL, "gmake -f ns/client.mk setup 2>&1 |"); + } + + while ( ) { + print $_; + print LOG $_; } close( PULL ); -} - chdir("mozilla/config") || die "couldn't chdir to 'mozilla/config'"; + } + chdir($BuildConfigDir) || die "couldn't chdir to $BuildConfigDir"; print LOG "gmake show_objname 2>&1 |\n"; open ( GETOBJ, "gmake show_objname 2>&1 |\n"); while ( ) { - print $_; - print LOG $_; - $build_objname = $_; - chop($build_objname); + print "$_"; + print LOG "$_"; + $BuildObjName = $_; + chop($BuildObjName); } close ( ); - print "objname is " . $build_objname . " \n"; + print "objname is " . $BuildObjName . " \n"; # if we are building depend, rebuild dependencies - if ($build_depend) { - print LOG "gmake depend 2>&1 |\n"; - open ( MAKEDEPEND, "gmake depend 2>&1 |\n"); - while ( ) { - print $_; - print LOG $_; - } - close ( ); + if ($BuildDepend) { + print LOG "gmake depend 2>&1 |\n"; + open ( MAKEDEPEND, "gmake depend 2>&1 |\n"); + while ( ) { + print $_; + print LOG $_; + } + close ( ); } - chdir("..") || die "couldn't chdir to 'ns'"; - print LOG "gmake export libs install 2>&1 |\n"; + chdir("../.."); + + chdir($BuildStartDir) || die "couldn't chdir to $BuildStartDir"; + print LOG "gmake -e export libs install 2>&1 |\n"; # preflight build by deleting any existing binary - if (&binaryexists) { - print LOG "deleting netscape-export\n"; - &deletebinary; - } + if (&BinaryExists) { + print LOG "deleting existing binary\n"; + &DeleteBinary; + } # now build damn you - open( BUILD, "gmake $clobber_str export libs install 2>&1 |"); + open( BUILD, "gmake -e $ClobberStr export libs install 2>&1 |"); - while( ){ - print $_; - print LOG $_; + while ( ) { + print $_; + print LOG $_; + } + close( BUILD ); + +# if we have a binary after building, build worked + + if (&BinaryExists) { + print LOG "export binary exists, build SUCCESSFUL!\n"; + $BuildStatus = 0; + if ($BuildUnixClasses) { + &PackageClasses; } - close( BUILD ); - -# if we have a netscape-export after building, build worked - if (&binaryexists) { - print LOG "netscape-export exists, build SUCCESSFUL!\n"; - $build_status = 0; } else { - print LOG "netscape-export missing, build FAILED\n"; - $build_status = 666; + print LOG "export binary missing, build FAILED\n"; + $BuildStatus = 666; } - print LOG "\nBuild Status = $build_status\n"; + print LOG "\nBuild Status = $BuildStatus\n"; - $build_status_str = ( $build_status ? 'busted' : 'success' ); + $BuildStatusStr = ( $BuildStatus ? 'busted' : 'success' ); - print LOG "tinderbox: tree: $build_tree\n"; - print LOG "tinderbox: builddate: $start_time\n"; - print LOG "tinderbox: status: $build_status_str\n"; - print LOG "tinderbox: build: $build_name\n"; + print LOG "tinderbox: tree: $BuildTree\n"; + print LOG "tinderbox: builddate: $StartTime\n"; + print LOG "tinderbox: status: $BuildStatusStr\n"; + print LOG "tinderbox: build: $BuildName\n"; print LOG "tinderbox: errorparser: unix\n"; print LOG "tinderbox: buildfamily: unix\n"; close( LOG ); - chdir("$start_dir"); + chdir("$StartDir"); - unlink( "${dirname}.log.last" ); + unlink( "${DirName}.log.last" ); # this fun line added on 2/5/98. do not remove. Translated to english, # that's "take any line longer than 1000 characters, and split it into less @@ -162,144 +224,163 @@ if (!$build_test) { # This is to prevent cases where a . occurs in the log file. Sendmail # interprets that as the end of the mail, and truncates the log before # it gets to Tinderbox. (terry weismann, chris yeh) - system("fold -1000 < ${dirname}.log | sed -e 's/^\.\$//' > ${dirname}.log.last"); - system( "/bin/mail tinderbox-daemon\@warp < ${dirname}.log.last" ); +# +# This was replaced by a perl 'port' of the above, writen by +# preed@netscape.com; good things: no need for system() call, and now it's +# all in perl, so we don't have to do OS checking like before. +open(LOG, "${DirName}.log") || die "Couldn't open logfile: $!\n"; +open(OUTLOG, ">${DirName}.log.last") || die "Couldn't open logfile: $!\n"; + +while () { +$q = 0; + +for (;;) { +$val = $q * 1000; +$Output = substr($_, $val, 1000); + +last if $Output eq undef; + +$Output =~ s/^\.$//g; +$Output =~ s/\n//g; +print OUTLOG "$Output\n"; +$q++; +} #EndFor + +} #EndWhile + +close(LOG); +close(OUTLOG); + + system( "/bin/mail tinderbox-daemon\@warp < ${DirName}.log.last" ); # if this is a test run, set early_exit to 0. This mean one loop of execution - if ($build_test) { - $early_exit = 0; + if ($BuildTest) { + $EarlyExit = 0; } } -sub cvs_time { - local( $ret_time ); +} #EndSub-BuildIt - ($sec,$minute,$hour,$mday,$mon,$year) = localtime( $_[0] ); +sub CVSTime { + local($StartTimeArg) = @_; +# local($RetTime, $StartTimeArg, $sec, $minute, $hour, $mday, $mon, $year); + + ($sec,$minute,$hour,$mday,$mon,$year) = localtime($StartTimeArg); $mon++; # month is 0 based. - sprintf("%02d/%02d/%02d %02d:%02d:00", - $mon,$mday,$year,$hour,$minute ); + sprintf("%02d/%02d/%02d %02d:%02d:00", $mon,$mday,$year,$hour,$minute ); } -sub start_build { - #open( LOG, ">>logfile" ); +sub StartBuild { open( LOG, "|/bin/mail tinderbox-daemon\@warp" ); print LOG "\n"; - print LOG "tinderbox: tree: $build_tree\n"; - print LOG "tinderbox: builddate: $start_time\n"; + print LOG "tinderbox: tree: $BuildTree\n"; + print LOG "tinderbox: builddate: $StartTime\n"; print LOG "tinderbox: status: building\n"; - print LOG "tinderbox: build: $build_name\n"; + print LOG "tinderbox: build: $BuildName\n"; print LOG "tinderbox: errorparser: unix\n"; print LOG "tinderbox: buildfamily: unix\n"; print LOG "\n"; close( LOG ); } -sub parse_args { - local($i); +# check for the existence of the binary +sub BinaryExists { + my($Binname); + $BinName = $BuildDir . '/' . $TopLevel . 'cmd/xfe/' . $BuildObjName . $BinaryName; + print LOG $BinName . "\n"; + if ((-e $BinName) && (-x $BinName) && (-s $BinName)) { + 1; + } + else { + 0; + } +} - if( @ARGV == 0 ){ - &usage; +sub DeleteBinary { + my($BinName); + $BinName = $BuildDir . '/' . $TopLevel . 'cmd/xfe/' . $BuildObjName . $BinaryName; + print LOG "unlinking $BinName\n"; + unlink ($BinName) || print LOG "unlinking $BinName failed\n"; +} + +sub PackageClasses { + my($BinName, $TarName); + $tarname = $BuildDir . '/unix_classes.tar.gz'; + unlink ($TarName) || print LOG "unlinking $TarName failed\n"; + open( BUILD, "gmake -e class_tar 2>&1 |"); + $BinName = $BuildDir . $TopLevel . '/dist/unix_classes.tar.gz'; + link ($BinName,$TarName) || print LOG "linking $BinName to $TarName failed\n"; +} + +sub ParseArgs { + my($i); + + if( @ARGV == 0 ) { + &PrintUsage; } $i = 0; - while( $i < @ARGV ){ - if ($ARGV[$i] eq '--lite') { - $build_lite = 1; + while( $i < @ARGV ) { + if ($ARGV[$i] eq '--depend') { + $BuildDepend = 1; } - elsif( $ARGV[$i] eq '--depend' ){ - $build_depend = 1; - } - elsif ( $ARGV[$i] eq '--clobber' ){ - $build_depend = 0; - } - elsif ( $ARGV[$i] eq '--continue' ){ - $build_continue = 1; - } - elsif ( $ARGV[$i] eq '--test' ){ - $build_test = 1; - } - elsif ( $ARGV[$i] eq '-tag' ){ - $i++; - $build_tag = $ARGV[$i]; - if( $build_tag eq '' || $build_tag eq '-t'){ - &usage; - } - } - elsif ( $ARGV[$i] eq '-t' ){ - $i++; - $build_tree = $ARGV[$i]; - if( $build_tree eq '' ){ - &usage; - } - } - $i++; + elsif ($ARGV[$i] eq '--clobber') { + $BuildDepend = 0; + } + elsif ( $ARGV[$i] eq '--test' ) { + $BuildTest = 1; + } + elsif ($ARGV[$i] eq '--saveclasses') { + $BuildUnixClasses = 1; + } + elsif ($ARGV[$i] eq '--testbuild') { + $i++; + if ($ARGV[$i] =~ /^[\w\d\.]+\:\d+\.\d+$/) { + $RunAcceptanceTests = 1; + $AcceptanceDisplay = "$ARGV[$i]"; + } else { + &PrintUsage; + } + } + elsif ( $ARGV[$i] eq '-tag' ) { + $i++; + $BuildTag = $ARGV[$i]; + if ( $BuildTag eq '' || $BuildTag eq '-t') { + &PrintUsage; + } + } + elsif ( $ARGV[$i] eq '-t' ) { + $i++; + $BuildTree = $ARGV[$i]; + if ( $BuildTree eq '' ) { + &PrintUsage; + } + } else { + &PrintUsage; + } + + $i++; + } #EndWhile + + if ( $BuildTree =~ /^\s+$/i ) { + &PrintUsage; } - if( $build_tree eq '' ){ - &usage; + + if ($BuildDepend eq undef) { + &PrintUsage; } + +} #EndSub-ParseArgs + +sub PrintUsage { + die "usage: buildit.pl [--depend | --clobber] [--test --saveclasses [--testbuild DISPLAY_NAME] ] -tag TREETAG -t TREENAME\n"; } -sub usage { - die "usage: buildit.pl [--depend | --clobber] --continue --test -tag TREETAG -t TREENAME\n"; -} - -sub setup_env { - local($p); - $p = $ENV{PATH}; - print "Path before: $p\n"; - umask(0); - $ENV{'MOZILLA_CLIENT'} = 1; - $ENV{'NETSCAPE_HIERARCHY'} = 1; - $ENV{'BUILD_OFFICIAL'} = 1; - $ENV{'NSPR20'} = 1; - $ENV{'AWT_11'} = 1; - $ENV{'NO_SECURITY'} = 1; - if ($build_lite) { -# $ENV{'MOZ_LITE'} = 1; - $ENV{'MOZ_MEDIUM'} = 1; - } - $ENV{'PATH'} = '/usr/local/bin:/tools/ns/bin:/usr/local/bin:/tools/contrib/bin:/usr/local/bin:/usr/sbin:/usr/bsd:/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/etc:/usr/hosts:/usr/ucb:'; - - if( $os eq 'SunOS' ){ - $ENV{'PATH'} = '/usr/ccs/bin:/tools/ns/soft/gcc-2.6.3/run/default/sparc_sun_solaris2.4/bin:' - . $ENV{'PATH'}; - $ENV{'NO_MDUPDATE'} = 1; - } - - if( $os eq 'AIX' ){ - $ENV{'PATH'} = $ENV{'PATH'} . '/usr/lpp/xlC/bin:/usr/local-aix/bin:' - ; - #$ENV{'NO_MDUPDATE'} = 1; - } - - $p = $ENV{PATH}; - print "Path After: $p\n"; -} - -sub print_env { -foreach $key (keys %ENV) { +sub PrintEnv { + foreach $key (keys %ENV) { print LOG "$key = $ENV{$key}\n"; print "$key = $ENV{$key}\n"; -} -} + } +} #EndSub-PrintEnv -# check for the existance of netscape-export -sub binaryexists { - $binname = $build_dir . '/mozilla/cmd/xfe/' . $build_objname . '/mozilla-export'; - print LOG $binname . "\n"; - if ((-e $binname) && (-x $binname) && (-s $binname)) { - 1; - } - else { - 0; - } -} - -sub deletebinary { - -$binname = $build_dir . '/mozilla/cmd/xfe/' . $build_objname . '/mozilla-export'; -print LOG "unlinking $binname\n"; -unlink ($binname) || print LOG "unlinking $binname failed\n"; - -}