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

Last change on this file since 654 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
Line 
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.17 2002/10/18 08:37:46 joergs Exp $
5# Philipp Storz, SuSE Linux AG
6# pstorz@suse.de
7
8use strict;
9use Getopt::Std;
10use File::stat;
11use File::Basename;
12
13my $wert1;
14my $wert2;
15my $wert3;
16
17format TABELLE =
18@<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
19$wert1, $wert2, $wert3
20.
21
22
23# Programmoptionen:
24# -b (buildlist)
25# -x (buildlog im seperaten xtern
26
27my $workdir=`pwd`;
28chomp $workdir;
29
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
36my $build = "build.sh";
37our ($opt_b, $opt_x);
38my @ArrayofBuilds;
39getopts('b:x');
40
41
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";
46};
47
48(open(BUILDLIST,$opt_b)) || die "Die Buildlist $opt_b konnte nicht gefunden werden";
49
50
51while (<BUILDLIST>) #Buildlist parsen
52 {
53 my $dir;
54 my $arch;
55 my $opt;
56 next if (/^\#.*$/);
57 # if (/([\w\/]+)\s*:([\/\w\-\+\.]+)\s+:((\s*\-\-\w*)*)$/)
58 if (/(\S+)\s*:(\S+)\s*:(\S+)\s*$/)
59 {
60 ($dir, $arch, $opt) = ($1, $2, $3);
61 chomp ($arch);
62 my @build=($dir, $arch, $opt);
63 push @ArrayofBuilds, [@build];
64 }
65 }
66
67
68
69print "What will be done:\n\n";
70($wert1,$wert2,$wert3)= ("Path","Distribuition","Buildoptions");
71$~="TABELLE";
72write;
73print "\n";
74for my $i (0 .. $#ArrayofBuilds)
75 {
76 ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][2]);
77 $~="TABELLE";
78 write;
79 }
80
81print 'Are all the srpms extracted and all options OK? (y/n)';
82
83my $answer=<STDIN>;
84chomp ($answer);
85if ($answer ne "y") {die("canceled")};
86
87my $mypath;
88for my $i (0 .. $#ArrayofBuilds)
89 {
90 print("$ArrayofBuilds[$i][0]\t\t$ArrayofBuilds[$i][1]\t\t$ArrayofBuilds[$i][2]\n");
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];
102
103
104 $_=$ArrayofBuilds[$i][0];
105 print "$_ \n";
106 tr/\//\_/;
107 my $logfilename = "/tmp/smartclient_build/$_.$ArrayofBuilds[$i][1].log";
108
109 my $build_cmd="cd $mypath && $build";
110
111 # open a xterm to display build output
112 if ($opt_x)
113 {
114 system "xterm -T \"build log for PACKET: $mypath ARCH:$ArrayofBuilds[$i][1] \" -e less +F $logfilename &";
115 print "++++++++++++++++++++++++++++++++++++++++++\n";
116 }
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);
122 $build_cmd = "cd $dir && $build $base-[0-9]*rpm";
123 }
124
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";
129 print "$build_cmd\n";
130 print "you can watch building with following command: \n";
131 print "less +F $logfilename\n\n";
132
133 my $do_log = open( LOG_FD, ">$logfilename" ) || print "could not open logfile $logfilename";
134 open( PIPE, "$build_cmd 2>&1 |" );
135 while( <PIPE> ) {
136 if( ! $opt_x ) {
137 print;
138 }
139 print LOG_FD if $do_log;
140 }
141 close PIPE; my $retval=$?;
142 close LOG_FD if $do_log;
143
144 if ( $retval == 0 )
145 {
146 $ArrayofBuilds[$i][3]= "SUCCESS $ArrayofBuilds[$i][0]: OK";
147 print"****** ******\n";
148 print"****** building of $ArrayofBuilds[$i][0]: OK \n" ;
149 print"****** ******\n";
150 }
151 else
152 {
153 $ArrayofBuilds[$i][3]="ERROR $ArrayofBuilds[$i][0]: *FAILED*\n";
154 print"****** ******\n";
155 print"\n\n\nERROR: building of $ArrayofBuilds[$i][0]: *FAILED*\n";
156 print"****** ******\n";
157 }
158}
159
160print "Building results:\n";
161
162
163
164($wert1,$wert2,$wert3)= ("Path","Distribuition","Result");
165$~="TABELLE";
166write;
167print "\n";
168
169for my $i (0 .. $#ArrayofBuilds)
170 {
171 ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3]);
172 $~="TABELLE";
173 write;
174 # print("$ArrayofBuilds[$i][0]:Result: $ArrayofBuilds[$i][3]");
175 }
176
177print "buildall.pl terminated\n";
Note: See TracBrowser for help on using the repository browser.