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