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

Last change on this file since 660 was 660, checked in by joergs, on Aug 18, 2003 at 3:34:39 PM

specifying DEST_DIR here instead of build.sh
bugfix with log files

File size: 4.5 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.18 2003/08/18 13:34:39 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 $DEST_DIR="/tmp/smartclient_build/";
37
38
39my $build = "build.sh";
40our ($opt_b, $opt_x);
41my @ArrayofBuilds;
42getopts('b:x');
43
44
45if (!$opt_b) {
46 $opt_b = "buildlist";
47 print "using default buildlist: buildlist\n\n";
48 print "other buildlist can be specified with -b buildlist\n\n";
49};
50
51(open(BUILDLIST,$opt_b)) || die "Die Buildlist $opt_b konnte nicht gefunden werden";
52
53
54while (<BUILDLIST>) #Buildlist parsen
55 {
56 my $dir;
57 my $arch;
58 my $opt;
59 next if (/^\#.*$/);
60 # if (/([\w\/]+)\s*:([\/\w\-\+\.]+)\s+:((\s*\-\-\w*)*)$/)
61 if (/(\S+)\s*:(\S+)\s*:(\S+)\s*$/)
62 {
63 ($dir, $arch, $opt) = ($1, $2, $3);
64 chomp ($arch);
65 my @build=($dir, $arch, $opt);
66 push @ArrayofBuilds, [@build];
67 }
68 }
69
70
71
72print "What will be done:\n\n";
73($wert1,$wert2,$wert3)= ("Path","Distribuition","Buildoptions");
74$~="TABELLE";
75write;
76print "\n";
77for my $i (0 .. $#ArrayofBuilds)
78 {
79 ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][2]);
80 $~="TABELLE";
81 write;
82 }
83
84print 'Are all the srpms extracted and all options OK? (y/n)';
85
86my $answer=<STDIN>;
87chomp ($answer);
88if ($answer ne "y") {die("canceled")};
89
90$ENV{'DEST_DIR'}=$DEST_DIR;
91
92my $mypath;
93for my $i (0 .. $#ArrayofBuilds)
94 {
95 print("$ArrayofBuilds[$i][0]\t\t$ArrayofBuilds[$i][1]\t\t$ArrayofBuilds[$i][2]\n");
96 $mypath = $smartclient_root.$ArrayofBuilds[$i][0];
97
98 if ($ArrayofBuilds[$i][2])
99 {
100 $ENV{'BUILD_MODE'}=$ArrayofBuilds[$i][2];
101 }
102 else
103 {
104 $ENV{'BUILD_MODE'}="--clean";
105 }
106 $ENV{'BUILD_DIST'}=$ArrayofBuilds[$i][1];
107
108
109 $_=$ArrayofBuilds[$i][0];
110 print "$_ \n";
111 tr/\//\_/;
112 `mkdir -p $DEST_DIR`;
113 my $logfilename = "$DEST_DIR/$_$ArrayofBuilds[$i][1].log";
114
115 my $build_cmd="cd $mypath && $build";
116
117 # open a xterm to display build output
118 if ($opt_x)
119 {
120 system "xterm -T \"build log for PACKET: $mypath ARCH:$ArrayofBuilds[$i][1] \" -e less +F $logfilename &";
121 print "++++++++++++++++++++++++++++++++++++++++++\n";
122 }
123
124 # if mypath is not a directory, so it is a src.rpm (hopefully)
125 if( ! -d $mypath ) {
126 my $base = basename($mypath);
127 my $dir = dirname($mypath);
128 $build_cmd = "cd $dir && $build $base-[0-9]*rpm";
129 }
130
131 print "++++++++++++++++++++++++++++++++++++++++++\n";
132 print "BUILD_DIST ist $ENV{'BUILD_DIST'}\n";
133 print "BUILD_MODE ist $ENV{'BUILD_MODE'}\n";
134 print "executing build command:\n";
135 print "$build_cmd\n";
136
137 my $do_log = open( LOG_FD, ">$logfilename" );
138 if( $do_log ) {
139 print "you can watch building with following command: \n";
140 print "less +F $logfilename\n\n";
141 } else {
142 print "could not open logfile $logfilename\n";
143 }
144 open( PIPE, "$build_cmd 2>&1 |" );
145 while( <PIPE> ) {
146 if( ! $opt_x ) {
147 print;
148 }
149 print LOG_FD if $do_log;
150 }
151 close PIPE; my $retval=$?;
152 close LOG_FD if $do_log;
153
154 if ( $retval == 0 )
155 {
156 $ArrayofBuilds[$i][3]= "SUCCESS $ArrayofBuilds[$i][0]: OK";
157 print"****** ******\n";
158 print"****** building of $ArrayofBuilds[$i][0]: OK \n" ;
159 print"****** ******\n";
160 }
161 else
162 {
163 $ArrayofBuilds[$i][3]="ERROR $ArrayofBuilds[$i][0]: *FAILED*\n";
164 print"****** ******\n";
165 print"\n\n\nERROR: building of $ArrayofBuilds[$i][0]: *FAILED*\n";
166 print"****** ******\n";
167 }
168}
169
170print "Building results:\n";
171
172
173
174($wert1,$wert2,$wert3)= ("Path","Distribuition","Result");
175$~="TABELLE";
176write;
177print "\n";
178
179for my $i (0 .. $#ArrayofBuilds)
180 {
181 ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3]);
182 $~="TABELLE";
183 write;
184 # print("$ArrayofBuilds[$i][0]:Result: $ArrayofBuilds[$i][3]");
185 }
186
187print "buildall.pl terminated\n";
Note: See TracBrowser for help on using the repository browser.