| 1 | #!/usr/bin/perl -w
|
|---|
| 2 | # automatisches buildskript fuer smartclient
|
|---|
| 3 | # liest die konfiguration aus der mit -b übergebenen Datei
|
|---|
| 4 | # $Id: buildall.pl,v 1.15 2002/10/16 18:08:34 joergs Exp $
|
|---|
| 5 | # Philipp Storz, SuSE Linux AG
|
|---|
| 6 | # pstorz@suse.de
|
|---|
| 7 |
|
|---|
| 8 | use Getopt::Std;
|
|---|
| 9 | use File::stat;
|
|---|
| 10 | use File::Basename;
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | format TABELLE =
|
|---|
| 14 | @<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|---|
| 15 | $wert1, $wert2, $wert3
|
|---|
| 16 | .
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | # Programmoptionen: -b (buildlist)
|
|---|
| 20 |
|
|---|
| 21 | my $smartclient_root="../../"; # Pfad, zu dem die Pfade in buildlist stehen
|
|---|
| 22 | my $build = "build.sh";
|
|---|
| 23 | our ($opt_b);
|
|---|
| 24 | my @ArrayofBuilds;
|
|---|
| 25 | getopts('b:');
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | if (!$opt_b)
|
|---|
| 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";
|
|---|
| 33 | };
|
|---|
| 34 |
|
|---|
| 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 (/^\#.*$/);
|
|---|
| 41 | # if (/([\w\/]+)\s*:([\/\w\-\+\.]+)\s+:((\s*\-\-\w*)*)$/)
|
|---|
| 42 | if (/(\S+)\s*:(\S+)\s*:(\S+)\s*$/)
|
|---|
| 43 | {
|
|---|
| 44 | ($dir, $arch, $opt) = ($1, $2, $3);
|
|---|
| 45 | chomp ($arch);
|
|---|
| 46 | @build=($dir, $arch, $opt);
|
|---|
| 47 | push @ArrayofBuilds, [@build];
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | print "What will be done:\n\n";
|
|---|
| 54 | ($wert1,$wert2,$wert3)= ("Path","Distribuition","Buildoptions");
|
|---|
| 55 | $~="TABELLE";
|
|---|
| 56 | write;
|
|---|
| 57 | print "\n";
|
|---|
| 58 | for $i (0 .. $#ArrayofBuilds)
|
|---|
| 59 | {
|
|---|
| 60 | ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][2]);
|
|---|
| 61 | $~="TABELLE";
|
|---|
| 62 | write;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | print 'Are all the srpms extracted and all options OK? (y/n)';
|
|---|
| 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");
|
|---|
| 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];
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | $_=$ArrayofBuilds[$i][0];
|
|---|
| 88 | print "$_ \n";
|
|---|
| 89 | tr/\//\_/;
|
|---|
| 90 | $logfilename = $_.".$ArrayofBuilds[$i][1].log";
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 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)
|
|---|
| 98 | {
|
|---|
| 99 | system "xterm -T \"build log for PACKET: $mypath ARCH:$ArrayofBuilds[$i][1] \" -e less +F $workdir/$mypath/$logfilename &";
|
|---|
| 100 | print "++++++++++++++++++++++++++++++++++++++++++\n";
|
|---|
| 101 | $build_log=">$logfilename 2>&1";
|
|---|
| 102 | }
|
|---|
| 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";
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 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";
|
|---|
| 120 |
|
|---|
| 121 | $retval = system "$build_cmd $build_log";
|
|---|
| 122 |
|
|---|
| 123 | if ( $retval == 0 )
|
|---|
| 124 | {
|
|---|
| 125 | $ArrayofBuilds[$i][3]= "SUCCESS $ArrayofBuilds[$i][0]: OK";
|
|---|
| 126 | print"****** ******\n";
|
|---|
| 127 | print"****** building of $ArrayofBuilds[$i][0]: OK \n" ;
|
|---|
| 128 | print"****** ******\n";
|
|---|
| 129 | }
|
|---|
| 130 | else
|
|---|
| 131 | {
|
|---|
| 132 | $ArrayofBuilds[$i][3]="ERROR $ArrayofBuilds[$i][0]: *FAILED*\n";
|
|---|
| 133 | print"****** ******\n";
|
|---|
| 134 | print"\n\n\nERROR: building of $ArrayofBuilds[$i][0]: *FAILED*\n";
|
|---|
| 135 | print"****** ******\n";
|
|---|
| 136 | }
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | print "Building results:\n";
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | ($wert1,$wert2,$wert3)= ("Path","Distribuition","Result");
|
|---|
| 144 | $~="TABELLE";
|
|---|
| 145 | write;
|
|---|
| 146 | print "\n";
|
|---|
| 147 |
|
|---|
| 148 | for $i (0 .. $#ArrayofBuilds)
|
|---|
| 149 | {
|
|---|
| 150 | ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3]);
|
|---|
| 151 | $~="TABELLE";
|
|---|
| 152 | write;
|
|---|
| 153 | # print("$ArrayofBuilds[$i][0]:Result: $ArrayofBuilds[$i][3]");
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | print "buildall.pl terminated\n";
|
|---|