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

Last change on this file since 661 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
RevLine 
[589]1#!/usr/bin/perl -w
2# automatisches buildskript fuer smartclient
3# liest die konfiguration aus der mit -b übergebenen Datei
[660]4# $Id: buildall.pl,v 1.18 2003/08/18 13:34:39 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
[660]36my $DEST_DIR="/tmp/smartclient_build/";
37
38
[594]39my $build = "build.sh";
[626]40our ($opt_b, $opt_x);
[589]41my @ArrayofBuilds;
[626]42getopts('b:x');
[589]43
[610]44
[628]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";
[593]49};
50
[589]51(open(BUILDLIST,$opt_b)) || die "Die Buildlist $opt_b konnte nicht gefunden werden";
52
53
54while (<BUILDLIST>) #Buildlist parsen
55 {
[626]56 my $dir;
57 my $arch;
58 my $opt;
[589]59 next if (/^\#.*$/);
[626]60 # if (/([\w\/]+)\s*:([\/\w\-\+\.]+)\s+:((\s*\-\-\w*)*)$/)
[593]61 if (/(\S+)\s*:(\S+)\s*:(\S+)\s*$/)
[589]62 {
63 ($dir, $arch, $opt) = ($1, $2, $3);
64 chomp ($arch);
[626]65 my @build=($dir, $arch, $opt);
[589]66 push @ArrayofBuilds, [@build];
67 }
68 }
69
[593]70
71
[599]72print "What will be done:\n\n";
73($wert1,$wert2,$wert3)= ("Path","Distribuition","Buildoptions");
74$~="TABELLE";
75write;
76print "\n";
[626]77for my $i (0 .. $#ArrayofBuilds)
[589]78 {
[599]79 ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][2]);
80 $~="TABELLE";
81 write;
[593]82 }
[623]83
[612]84print 'Are all the srpms extracted and all options OK? (y/n)';
[593]85
[626]86my $answer=<STDIN>;
[593]87chomp ($answer);
88if ($answer ne "y") {die("canceled")};
89
[660]90$ENV{'DEST_DIR'}=$DEST_DIR;
91
[626]92my $mypath;
93for my $i (0 .. $#ArrayofBuilds)
[593]94 {
95 print("$ArrayofBuilds[$i][0]\t\t$ArrayofBuilds[$i][1]\t\t$ArrayofBuilds[$i][2]\n");
[589]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];
[596]107
[593]108
[589]109 $_=$ArrayofBuilds[$i][0];
110 print "$_ \n";
111 tr/\//\_/;
[660]112 `mkdir -p $DEST_DIR`;
113 my $logfilename = "$DEST_DIR/$_$ArrayofBuilds[$i][1].log";
[611]114
[623]115 my $build_cmd="cd $mypath && $build";
116
117 # open a xterm to display build output
118 if ($opt_x)
[611]119 {
[626]120 system "xterm -T \"build log for PACKET: $mypath ARCH:$ArrayofBuilds[$i][1] \" -e less +F $logfilename &";
121 print "++++++++++++++++++++++++++++++++++++++++++\n";
[611]122 }
[623]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);
[626]128 $build_cmd = "cd $dir && $build $base-[0-9]*rpm";
[611]129 }
130
[623]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";
[626]135 print "$build_cmd\n";
[611]136
[660]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 }
[626]144 open( PIPE, "$build_cmd 2>&1 |" );
145 while( <PIPE> ) {
146 if( ! $opt_x ) {
147 print;
148 }
[628]149 print LOG_FD if $do_log;
[626]150 }
151 close PIPE; my $retval=$?;
[628]152 close LOG_FD if $do_log;
[626]153
[623]154 if ( $retval == 0 )
[596]155 {
[619]156 $ArrayofBuilds[$i][3]= "SUCCESS $ArrayofBuilds[$i][0]: OK";
[596]157 print"****** ******\n";
[612]158 print"****** building of $ArrayofBuilds[$i][0]: OK \n" ;
[596]159 print"****** ******\n";
160 }
[623]161 else
[596]162 {
[612]163 $ArrayofBuilds[$i][3]="ERROR $ArrayofBuilds[$i][0]: *FAILED*\n";
[596]164 print"****** ******\n";
[612]165 print"\n\n\nERROR: building of $ArrayofBuilds[$i][0]: *FAILED*\n";
[596]166 print"****** ******\n";
167 }
[589]168}
169
[596]170print "Building results:\n";
171
[599]172
173
174($wert1,$wert2,$wert3)= ("Path","Distribuition","Result");
175$~="TABELLE";
176write;
177print "\n";
178
[626]179for my $i (0 .. $#ArrayofBuilds)
[596]180 {
[599]181 ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3]);
182 $~="TABELLE";
183 write;
[619]184 # print("$ArrayofBuilds[$i][0]:Result: $ArrayofBuilds[$i][3]");
[596]185 }
186
[589]187print "buildall.pl terminated\n";
Note: See TracBrowser for help on using the repository browser.