source: trunk/technical/common/build/buildall.pl@ 656

Last change on this file since 656 was 628, checked in by joergs, on Oct 18, 2002 at 10:37:46 AM

Test ob logfile angelegt werden kann. Verwindert tausende von Fehlermeldungen, wenn dies nicht der Fall ist.

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