[589] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | # automatisches buildskript fuer smartclient
|
---|
| 3 | # liest die konfiguration aus der mit -b übergebenen Datei
|
---|
[623] | 4 | # $Id: buildall.pl,v 1.15 2002/10/16 18:08:34 joergs Exp $
|
---|
[601] | 5 | # Philipp Storz, SuSE Linux AG
|
---|
| 6 | # pstorz@suse.de
|
---|
[623] | 7 |
|
---|
[589] | 8 | use Getopt::Std;
|
---|
[623] | 9 | use File::stat;
|
---|
| 10 | use File::Basename;
|
---|
[589] | 11 |
|
---|
[599] | 12 |
|
---|
| 13 | format TABELLE =
|
---|
| 14 | @<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---|
| 15 | $wert1, $wert2, $wert3
|
---|
| 16 | .
|
---|
| 17 |
|
---|
| 18 |
|
---|
[589] | 19 | # Programmoptionen: -b (buildlist)
|
---|
| 20 |
|
---|
| 21 | my $smartclient_root="../../"; # Pfad, zu dem die Pfade in buildlist stehen
|
---|
[594] | 22 | my $build = "build.sh";
|
---|
[589] | 23 | our ($opt_b);
|
---|
| 24 | my @ArrayofBuilds;
|
---|
| 25 | getopts('b:');
|
---|
| 26 |
|
---|
[610] | 27 |
|
---|
[593] | 28 | if (!$opt_b)
|
---|
[610] | 29 | {
|
---|
| 30 | $opt_b = "buildlist";
|
---|
| 31 | print "using default buildlist: buildlist\n\n";
|
---|
| 32 | print "other buildlist can be specified with -b buildlist\n\n";
|
---|
[593] | 33 | };
|
---|
| 34 |
|
---|
[589] | 35 | (open(BUILDLIST,$opt_b)) || die "Die Buildlist $opt_b konnte nicht gefunden werden";
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | while (<BUILDLIST>) #Buildlist parsen
|
---|
| 39 | {
|
---|
| 40 | next if (/^\#.*$/);
|
---|
[593] | 41 | # if (/([\w\/]+)\s*:([\/\w\-\+\.]+)\s+:((\s*\-\-\w*)*)$/)
|
---|
| 42 | if (/(\S+)\s*:(\S+)\s*:(\S+)\s*$/)
|
---|
[589] | 43 | {
|
---|
| 44 | ($dir, $arch, $opt) = ($1, $2, $3);
|
---|
| 45 | chomp ($arch);
|
---|
| 46 | @build=($dir, $arch, $opt);
|
---|
| 47 | push @ArrayofBuilds, [@build];
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 |
|
---|
[593] | 51 |
|
---|
| 52 |
|
---|
[599] | 53 | print "What will be done:\n\n";
|
---|
| 54 | ($wert1,$wert2,$wert3)= ("Path","Distribuition","Buildoptions");
|
---|
| 55 | $~="TABELLE";
|
---|
| 56 | write;
|
---|
| 57 | print "\n";
|
---|
[589] | 58 | for $i (0 .. $#ArrayofBuilds)
|
---|
| 59 | {
|
---|
[599] | 60 | ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][2]);
|
---|
| 61 | $~="TABELLE";
|
---|
| 62 | write;
|
---|
[593] | 63 | }
|
---|
[623] | 64 |
|
---|
[612] | 65 | print 'Are all the srpms extracted and all options OK? (y/n)';
|
---|
[593] | 66 |
|
---|
| 67 | $answer =<STDIN>;
|
---|
| 68 | chomp ($answer);
|
---|
| 69 | if ($answer ne "y") {die("canceled")};
|
---|
| 70 |
|
---|
| 71 | for $i (0 .. $#ArrayofBuilds)
|
---|
| 72 | {
|
---|
| 73 | print("$ArrayofBuilds[$i][0]\t\t$ArrayofBuilds[$i][1]\t\t$ArrayofBuilds[$i][2]\n");
|
---|
[589] | 74 | $mypath = $smartclient_root.$ArrayofBuilds[$i][0];
|
---|
| 75 |
|
---|
| 76 | if ($ArrayofBuilds[$i][2])
|
---|
| 77 | {
|
---|
| 78 | $ENV{'BUILD_MODE'}=$ArrayofBuilds[$i][2];
|
---|
| 79 | }
|
---|
| 80 | else
|
---|
| 81 | {
|
---|
| 82 | $ENV{'BUILD_MODE'}="--clean";
|
---|
| 83 | }
|
---|
| 84 | $ENV{'BUILD_DIST'}=$ArrayofBuilds[$i][1];
|
---|
[596] | 85 |
|
---|
[593] | 86 |
|
---|
[589] | 87 | $_=$ArrayofBuilds[$i][0];
|
---|
| 88 | print "$_ \n";
|
---|
| 89 | tr/\//\_/;
|
---|
[593] | 90 | $logfilename = $_.".$ArrayofBuilds[$i][1].log";
|
---|
[611] | 91 |
|
---|
| 92 |
|
---|
[623] | 93 | my $build_log="| tee $logfilename";
|
---|
| 94 | my $build_cmd="cd $mypath && $build";
|
---|
| 95 |
|
---|
| 96 | # open a xterm to display build output
|
---|
| 97 | if ($opt_x)
|
---|
[611] | 98 | {
|
---|
[596] | 99 | system "xterm -T \"build log for PACKET: $mypath ARCH:$ArrayofBuilds[$i][1] \" -e less +F $workdir/$mypath/$logfilename &";
|
---|
[589] | 100 | print "++++++++++++++++++++++++++++++++++++++++++\n";
|
---|
[623] | 101 | $build_log=">$logfilename 2>&1";
|
---|
[611] | 102 | }
|
---|
[623] | 103 |
|
---|
| 104 | # if mypath is not a directory, so it is a src.rpm (hopefully)
|
---|
| 105 | if( ! -d $mypath ) {
|
---|
| 106 | my $base = basename($mypath);
|
---|
| 107 | my $dir = dirname($mypath);
|
---|
| 108 | $build_cmd = "cd $dir && $build $base-*rpm";
|
---|
[611] | 109 | }
|
---|
| 110 |
|
---|
[623] | 111 | print "++++++++++++++++++++++++++++++++++++++++++\n";
|
---|
| 112 | print "BUILD_DIST ist $ENV{'BUILD_DIST'}\n";
|
---|
| 113 | print "BUILD_MODE ist $ENV{'BUILD_MODE'}\n";
|
---|
| 114 | print "executing build command:\n";
|
---|
| 115 | print "$build_cmd $build_log\n";
|
---|
| 116 | print "you can watch building with following command: \n";
|
---|
| 117 | $workdir=`pwd`;
|
---|
| 118 | chomp $workdir;
|
---|
| 119 | print "less +F $workdir/$mypath/$logfilename\n\n";
|
---|
[611] | 120 |
|
---|
[623] | 121 | $retval = system "$build_cmd $build_log";
|
---|
| 122 |
|
---|
| 123 | if ( $retval == 0 )
|
---|
[596] | 124 | {
|
---|
[619] | 125 | $ArrayofBuilds[$i][3]= "SUCCESS $ArrayofBuilds[$i][0]: OK";
|
---|
[596] | 126 | print"****** ******\n";
|
---|
[612] | 127 | print"****** building of $ArrayofBuilds[$i][0]: OK \n" ;
|
---|
[596] | 128 | print"****** ******\n";
|
---|
| 129 | }
|
---|
[623] | 130 | else
|
---|
[596] | 131 | {
|
---|
[612] | 132 | $ArrayofBuilds[$i][3]="ERROR $ArrayofBuilds[$i][0]: *FAILED*\n";
|
---|
[596] | 133 | print"****** ******\n";
|
---|
[612] | 134 | print"\n\n\nERROR: building of $ArrayofBuilds[$i][0]: *FAILED*\n";
|
---|
[596] | 135 | print"****** ******\n";
|
---|
| 136 | }
|
---|
[589] | 137 | }
|
---|
| 138 |
|
---|
[596] | 139 | print "Building results:\n";
|
---|
| 140 |
|
---|
[599] | 141 |
|
---|
| 142 |
|
---|
| 143 | ($wert1,$wert2,$wert3)= ("Path","Distribuition","Result");
|
---|
| 144 | $~="TABELLE";
|
---|
| 145 | write;
|
---|
| 146 | print "\n";
|
---|
| 147 |
|
---|
[596] | 148 | for $i (0 .. $#ArrayofBuilds)
|
---|
| 149 | {
|
---|
[599] | 150 | ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3]);
|
---|
| 151 | $~="TABELLE";
|
---|
| 152 | write;
|
---|
[619] | 153 | # print("$ArrayofBuilds[$i][0]:Result: $ArrayofBuilds[$i][3]");
|
---|
[596] | 154 | }
|
---|
| 155 |
|
---|
[589] | 156 | print "buildall.pl terminated\n";
|
---|