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

Last change on this file since 626 was 626, checked in by joergs, on Oct 17, 2002 at 3:12:57 PM

jetzt richtige Zusammenfassung.
Cleanup.
use strict

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