author | dermotm |
Wed, 01 Sep 2004 13:42:01 +0000 | |
changeset 3811 | 722e9d4e61c0 |
parent 3628 | cf6118e136d2 |
child 4027 | 91a01db89bb9 |
permissions | -rwxr-xr-x |
482 | 1 |
#!/usr/bin/perl |
2 |
||
3 |
use strict; |
|
4 |
use warnings; |
|
5 |
use Getopt::Long qw(:config gnu_getopt no_auto_abbrev); |
|
6 |
use rpm_spec; |
|
7 |
||
1058 | 8 |
# --------- defaults ------------------------------------------------------- |
482 | 9 |
my $default_spec_dir = `dirname $0`; |
10 |
$default_spec_dir =~ s/\s//g; |
|
11 |
||
3811 | 12 |
# use "rpmbuild" (RPM v4) if present or "rpm -ba" (RPM v3) if not |
13 |
my $RPM_BUILD = 'rpmbuild'; |
|
14 |
my $cmd_found = `which rpmbuild | wc -l`; |
|
15 |
if ($cmd_found == 0) { |
|
16 |
$RPM_BUILD = 'rpm'; |
|
17 |
} |
|
18 |
||
482 | 19 |
my $default_log_dir = '/tmp'; |
20 |
my $default_tarball_dir = "/sgnome/pkgs/gnome-2.2/misc/tarballs"; |
|
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
21 |
my $default_source_dirs = $default_spec_dir . "/ext-sources" . |
1255 | 22 |
":" . $default_spec_dir . "/manpages/man1" . |
23 |
":" . $default_spec_dir . "/manpages/man3" . |
|
24 |
":" . $default_spec_dir . "/manpages/man4" . |
|
2798 | 25 |
":" . $default_spec_dir . "/manpages/man5" . |
2801 | 26 |
":" . "/sgnome/tarballs/moz-evo"; |
482 | 27 |
my $default_patch_dir = $default_spec_dir . "/patches"; |
28 |
my $default_sys_rpm_dir = "/usr/src/packages"; |
|
29 |
my $default_nightly_date_format = '%y%m%d'; |
|
30 |
||
1058 | 31 |
# --------- global vars ---------------------------------------------------- |
32 |
# config settings |
|
482 | 33 |
my $the_spec_dir = $default_spec_dir; |
34 |
my $the_log_dir = $default_log_dir; |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
35 |
my $the_summary_log; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
36 |
my $the_summary_title; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
37 |
my $the_logdir_url; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
38 |
my $the_rpm_url; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
39 |
my $the_srpm_url; |
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
40 |
my $the_source_dirs = $default_source_dirs; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
41 |
my @the_source_dirlist; |
482 | 42 |
my $the_tarball_dir = $default_tarball_dir; |
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
43 |
my $the_good_build_dir; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
44 |
my $the_good_rpms_copy_dir; |
482 | 45 |
my $the_patch_dir = $default_patch_dir; |
46 |
my $the_sys_rpm_dir = $default_sys_rpm_dir; |
|
1058 | 47 |
my $rpm_target; |
482 | 48 |
|
49 |
my $check_deps = 1; |
|
1058 | 50 |
my $live_summary = 0; |
482 | 51 |
|
52 |
my $build_command; |
|
53 |
||
54 |
my $exit_val = 0; |
|
55 |
my $verbose = 1; |
|
56 |
my $debug_level = 0; |
|
57 |
my $full_path = 0; |
|
58 |
my $halt_on_errors = 0; |
|
1418 | 59 |
my $mail_errors_file; |
60 |
my $mail_errors_to; |
|
61 |
my $mail_errors_cc; |
|
62 |
my $prodname = "unnamed"; |
|
482 | 63 |
my $is_nightly = 0; |
64 |
my $the_nightly_date_format = $default_nightly_date_format; |
|
65 |
||
1058 | 66 |
# counter used as an id for the spec files |
482 | 67 |
my $spec_id = 0; |
1058 | 68 |
|
69 |
# array of spec objects |
|
482 | 70 |
my @specs_to_build = (); |
1058 | 71 |
my @build_status; |
72 |
my @status_details; |
|
73 |
my @remove_list = (); |
|
482 | 74 |
|
75 |
my %provider; |
|
76 |
my %warned_about; |
|
77 |
||
1058 | 78 |
# --------- utility functions ---------------------------------------------- |
482 | 79 |
our $opt_specdir = $default_spec_dir; |
80 |
||
1058 | 81 |
# return the name of the log file given the id of the spec file |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
82 |
sub get_log_name ($) { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
83 |
my $spec_id = shift; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
84 |
my $spec = $specs_to_build[$spec_id]; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
85 |
my $spec_file = $spec->get_param ('file_name'); |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
86 |
my $base_name = $spec_file; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
87 |
$base_name =~ s/^.*\/([^\/]+)/$1/; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
88 |
my $log_name = "$base_name"; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
89 |
$log_name =~ s/(\.spec|)$/.log/; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
90 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
91 |
return $log_name; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
92 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
93 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
94 |
my $current_log; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
95 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
96 |
sub open_log ($) { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
97 |
my $log_filename = shift; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
98 |
|
1058 | 99 |
if (not defined ($log_filename)) { |
100 |
return; |
|
101 |
} |
|
102 |
||
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
103 |
if (defined ($current_log)) { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
104 |
if ($current_log ne $log_filename) { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
105 |
close LOG_FILE; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
106 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
107 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
108 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
109 |
$current_log = undef; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
110 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
111 |
if (! open LOG_FILE, ">>$log_filename") { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
112 |
msg_warning (0, "Failed to open log file $log_filename"); |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
113 |
return; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
114 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
115 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
116 |
$current_log = $log_filename; |
1058 | 117 |
|
118 |
msg_log ("--- log starts --- " . `date`); |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
119 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
120 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
121 |
sub close_log () { |
1058 | 122 |
msg_log ("--- log ends --- " . `date`); |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
123 |
close LOG_FILE; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
124 |
$current_log = undef; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
125 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
126 |
|
482 | 127 |
sub print_message ($$) { |
128 |
my $min_verbose = shift; |
|
129 |
my $message = shift; |
|
130 |
||
131 |
chomp $message; |
|
132 |
||
133 |
if ($verbose > $min_verbose) { |
|
134 |
print "$message\n"; |
|
135 |
} |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
136 |
if (defined ($current_log)) { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
137 |
print LOG_FILE "$message\n"; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
138 |
} |
482 | 139 |
} |
140 |
||
141 |
sub msg_error ($) { |
|
142 |
my $message = shift; |
|
143 |
||
144 |
print_message (0, "ERROR: $message"); |
|
145 |
if ($halt_on_errors > 0) { |
|
146 |
print "ERROR: Exiting...\n"; |
|
147 |
exit (255); |
|
148 |
} |
|
149 |
} |
|
150 |
||
151 |
sub msg_warning ($$) { |
|
152 |
my $min_verbose = shift; |
|
153 |
my $message = shift; |
|
154 |
||
155 |
print_message ($min_verbose, "WARNING: $message"); |
|
156 |
} |
|
157 |
||
158 |
sub msg_info ($$) { |
|
159 |
my $min_verbose = shift; |
|
160 |
my $message = shift; |
|
161 |
||
162 |
print_message ($min_verbose, "INFO: $message"); |
|
163 |
} |
|
164 |
||
165 |
sub msg_debug ($$) { |
|
166 |
my $min_debug = shift; |
|
167 |
my $message = shift; |
|
168 |
||
169 |
if ($debug_level > $min_debug) { |
|
170 |
print "DEBUG: $message\n"; |
|
171 |
} |
|
172 |
} |
|
173 |
||
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
174 |
sub msg_log ($) { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
175 |
my $message = shift; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
176 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
177 |
if (defined ($current_log)) { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
178 |
print LOG_FILE "$message\n"; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
179 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
180 |
} |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
181 |
|
1058 | 182 |
sub find_file ($) { |
183 |
my $glob = shift; |
|
482 | 184 |
|
1058 | 185 |
my @files = `find $glob 2>&1`; |
186 |
if ($? == 0) { |
|
187 |
my $file = $files[$#files]; |
|
188 |
chomp $file; |
|
189 |
return ($file); |
|
482 | 190 |
} |
1058 | 191 |
|
192 |
return (undef); |
|
482 | 193 |
} |
194 |
||
1418 | 195 |
sub mail_log ($) { |
1059
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
196 |
my $spec_id = shift; |
1418 | 197 |
my $address; |
198 |
my $cc; |
|
199 |
my $log_name = get_log_name ($spec_id); |
|
200 |
my $spec_name = $specs_to_build[$spec_id]->{name}; |
|
201 |
my $base_name = $log_name; |
|
202 |
$log_name =~ s/\.log$//; |
|
203 |
||
204 |
if (defined ($mail_errors_file)) { |
|
205 |
$address = get_address_from_file ($mail_errors_file, $base_name); |
|
2747 | 206 |
} |
207 |
||
208 |
if (not defined ($address)) { |
|
209 |
$address = $mail_errors_to; |
|
210 |
} |
|
211 |
||
212 |
if (not defined ($address)) { |
|
213 |
$address = $mail_errors_cc; |
|
214 |
} else { |
|
215 |
$cc = $mail_errors_cc; |
|
216 |
} |
|
217 |
||
218 |
if (not defined ($address)) { |
|
219 |
return; |
|
1418 | 220 |
} |
1059
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
221 |
|
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
222 |
my $log_file = get_log_name ($spec_id); |
2369 | 223 |
msg_info (1, "mailing the build log to $address"); |
1418 | 224 |
|
225 |
my $subject; |
|
226 |
||
2747 | 227 |
my $log_pointer; |
228 |
if (defined ($the_logdir_url)) { |
|
2815 | 229 |
$log_pointer = "$the_logdir_url/${log_name}.log"; |
2747 | 230 |
} else { |
231 |
$log_pointer = "$the_log_dir/$log_file"; |
|
232 |
} |
|
233 |
||
1418 | 234 |
if (defined ($prodname)) { |
235 |
$subject = "BUILD FAILED ($prodname): $spec_name"; |
|
236 |
} else { |
|
237 |
$subject = "BUILD FAILED: $spec_name"; |
|
238 |
} |
|
239 |
||
240 |
if (defined ($cc)) { |
|
2747 | 241 |
`( echo "Full log: $log_pointer" ; echo; echo "--- tail of the log follows ---"; echo; tail -100 $the_log_dir/$log_file ) | mailx -s "$subject" -c "$cc" $address`; |
1418 | 242 |
} else { |
2747 | 243 |
`( echo "Full log: $log_pointer" ; echo; echo "--- tail of the log follows ---"; echo; tail -100 $the_log_dir/$log_file ) | mailx -s "$subject" $address`; |
1418 | 244 |
} |
1059
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
245 |
} |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
246 |
|
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
247 |
sub get_address_from_file ($$) { |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
248 |
my $fname = shift; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
249 |
my $pkg = shift; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
250 |
|
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
251 |
$pkg =~ s/\.spec$//; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
252 |
|
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
253 |
if (! open ADDR_FILE, "<$fname") { |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
254 |
msg_warning (0, "Could not open file $fname"); |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
255 |
return undef; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
256 |
} |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
257 |
my @lines = <ADDR_FILE>; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
258 |
my @addresses = grep /^$pkg:/, @lines; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
259 |
my $address = $addresses[0]; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
260 |
if (not defined ($address)) { |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
261 |
return undef; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
262 |
} |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
263 |
$address =~ s/^$pkg://; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
264 |
$address =~ s/\s//g; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
265 |
close ADDR_FILE; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
266 |
return $address; |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
267 |
} |
8415b42f1053
added support for mailing the maintainer if the build breaks
laca
parents:
1058
diff
changeset
|
268 |
|
1058 | 269 |
# --------- functions to process the command line args --------------------- |
482 | 270 |
sub add_spec ($) { |
271 |
my $spec_name = shift; |
|
272 |
||
273 |
my $spec; |
|
274 |
||
275 |
if (-f $spec_name) { |
|
1058 | 276 |
$spec = rpm_spec->new ($spec_name, $rpm_target); |
482 | 277 |
} else { |
278 |
if (not $spec_name =~ /\.spec$/) { |
|
279 |
$spec_name = "${opt_specdir}/${spec_name}.spec"; |
|
280 |
} |
|
1058 | 281 |
$spec = rpm_spec->new ("$spec_name", $rpm_target); |
482 | 282 |
} |
283 |
||
284 |
if (not defined ($spec)) { |
|
285 |
msg_error ("$spec_name not found\n"); |
|
286 |
} else { |
|
2798 | 287 |
if ($is_nightly) { |
288 |
$spec->add_define ("nightly", "1"); |
|
289 |
} |
|
482 | 290 |
my $this_spec_id = $spec_id ++; |
291 |
$specs_to_build[$this_spec_id] = $spec; |
|
292 |
my @packages = $spec->get_param_array ('packages'); |
|
293 |
||
1058 | 294 |
$build_status[$this_spec_id] = 'NOT_BUILT'; |
482 | 295 |
$status_details[$this_spec_id] = ''; |
296 |
||
297 |
foreach my $pkg (@packages) { |
|
298 |
my @provides = $spec->get_pkg_param_array ($pkg, 'provides'); |
|
299 |
foreach my $prov (@provides) { |
|
300 |
if (not defined $prov) { |
|
301 |
next; |
|
302 |
} |
|
303 |
$prov =~ s/ .*//; |
|
304 |
$provider{$prov} = $this_spec_id; |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
||
310 |
sub set_quiet { |
|
311 |
$verbose = 0; |
|
312 |
} |
|
313 |
||
314 |
sub process_args { |
|
315 |
my $arg = shift; |
|
316 |
||
317 |
if (not defined ($build_command)) { |
|
318 |
if (($arg ne "build") and ($arg ne "build-order") and |
|
319 |
($arg ne "uninstall-pkgs") and |
|
320 |
($arg ne "install-order")) { |
|
321 |
msg_error ("unknown command: $arg"); |
|
322 |
usage (1); |
|
323 |
} |
|
324 |
$build_command = $arg; |
|
325 |
} else { |
|
326 |
add_spec ($arg); |
|
327 |
} |
|
328 |
} |
|
329 |
||
330 |
sub process_options { |
|
331 |
||
332 |
Getopt::Long::Configure ("bundling"); |
|
333 |
||
334 |
our $opt_logdir = $default_log_dir; |
|
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
335 |
our $opt_sourcedirs = $default_source_dirs; |
482 | 336 |
our $opt_tarballdir = $default_tarball_dir; |
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
337 |
our $opt_good_build_dir; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
338 |
our $opt_good_rpms_copy_dir; |
482 | 339 |
our $opt_patchdir = $default_patch_dir; |
340 |
our $opt_rpmdir = $default_sys_rpm_dir; |
|
341 |
our $opt_deps = 1; |
|
1058 | 342 |
our $opt_live_summary = 0; |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
343 |
our $opt_summary_log; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
344 |
our $opt_summary_title; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
345 |
our $opt_logdir_url; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
346 |
our $opt_rpm_url; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
347 |
our $opt_srpm_url; |
482 | 348 |
our $opt_date = $default_nightly_date_format; |
349 |
||
350 |
GetOptions ('v|verbose+' => \$verbose, |
|
351 |
'debug=n' => \$debug_level, |
|
352 |
'q|quiet' => \&set_quiet, |
|
353 |
'specdir|spec|S=s', |
|
354 |
'halt-on-errors!', \$halt_on_errors, |
|
1418 | 355 |
'mail-errors-to=s' => \$mail_errors_to, |
356 |
'mail-errors-cc=s' => \$mail_errors_cc, |
|
357 |
'mail-errors-file=s' => \$mail_errors_file, |
|
358 |
'prodname=s' => \$prodname, |
|
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
359 |
'sourcedirs|sourcedir|src|srcdirs|srcdir|sources|source|s=s', |
482 | 360 |
'logdir|log|l=s', |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
361 |
'summary-log=s', |
1058 | 362 |
'live-summary|live!', |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
363 |
'summary-title=s', |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
364 |
'logdir-url=s', |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
365 |
'rpm-url=s', |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
366 |
'srpm-url=s', |
1058 | 367 |
'target=s' => \$rpm_target, |
482 | 368 |
'deps!', |
369 |
'tarballdir|tar|tarball|tardir|t=s', |
|
787 | 370 |
'good-build-dir=s', |
371 |
'good-rpms-copy-dir=s', |
|
2798 | 372 |
'nightly!' => \$is_nightly, |
482 | 373 |
'date|date-format|nightly-date-format=s', |
374 |
'patchdir|patch|p=s', |
|
375 |
'rpmdir|rpm|r=s', |
|
376 |
'full-path' => \$full_path, |
|
377 |
'help' => \&usage, |
|
378 |
'<>' => \&process_args); |
|
379 |
||
380 |
$the_spec_dir = $opt_specdir; |
|
381 |
$the_log_dir = $opt_logdir; |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
382 |
$the_summary_log = $opt_summary_log; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
383 |
$the_summary_title = $opt_summary_title; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
384 |
$the_logdir_url = $opt_logdir_url; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
385 |
$the_rpm_url = $opt_rpm_url; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
386 |
$the_srpm_url = $opt_srpm_url; |
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
387 |
$the_source_dirs = $opt_sourcedirs; |
482 | 388 |
$the_tarball_dir = $opt_tarballdir; |
389 |
$the_patch_dir = $opt_patchdir; |
|
390 |
$the_sys_rpm_dir = $opt_rpmdir; |
|
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
391 |
$the_good_build_dir = $opt_good_build_dir; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
392 |
$the_good_rpms_copy_dir = $opt_good_rpms_copy_dir; |
482 | 393 |
$check_deps = $opt_deps; |
1058 | 394 |
$live_summary = $opt_live_summary; |
482 | 395 |
$the_nightly_date_format = $opt_date; |
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
396 |
|
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
397 |
@the_source_dirlist = split /:/, $the_source_dirs; |
482 | 398 |
} |
399 |
||
400 |
sub usage (;$) { |
|
401 |
my $retval = shift; |
|
402 |
if (not defined ($retval)) { |
|
403 |
$retval = 0; |
|
404 |
} |
|
405 |
||
406 |
print << "EOF"; |
|
407 |
build-gnome2 [options] [command] specs... |
|
408 |
||
409 |
Options: |
|
410 |
||
411 |
-v|--verbose: |
|
412 |
Increase verbosity: the more -v's the more diag messages |
|
413 |
||
414 |
-q|--quiet: |
|
415 |
Silent operation. |
|
416 |
||
417 |
--specdir=dir, --spec=dir: |
|
418 |
Use dir as the default directory for spec files. |
|
419 |
Default: $default_spec_dir |
|
420 |
||
421 |
--tarballdir=dir, --tardir=dir, --tar=dir: |
|
422 |
Search for source tarballs in dir. |
|
423 |
Default: $default_tarball_dir |
|
424 |
||
425 |
--sourcedir=dir, --srcdir=dir, --src=dir: |
|
426 |
Location of the additional sources referenced in the spec |
|
427 |
files. Default: $default_spec_dir |
|
428 |
||
429 |
--patchdir=dir, --patch=dir: |
|
430 |
Look for the patches referenced in the spec files in dir. |
|
431 |
Default: $default_patch_dir |
|
432 |
||
433 |
--rpmdir=dir --rpm=dir: |
|
434 |
Use dir as the rpm base directory (where the SPECS, |
|
435 |
SOURCES, RPMS, SRPMS, BUILD directories are found). |
|
436 |
Default: $default_sys_rpm_dir |
|
437 |
||
438 |
--logdir=dir, --log=dir: |
|
439 |
Write build logs to dir. Default: $default_log_dir |
|
440 |
||
441 |
--nodeps, --deps: |
|
442 |
Ignore/verify dependencies before building a component. |
|
443 |
Default: --deps |
|
444 |
||
1058 | 445 |
--target=arch |
446 |
If used, the same option will be passed to rpm when |
|
447 |
building the package(s) |
|
448 |
||
482 | 449 |
--halt-on-errors: |
450 |
Halt on the first build error, do not attempt to continue. |
|
451 |
||
452 |
--full-path: |
|
453 |
Print the full path to the rpm when running install-order. |
|
454 |
||
455 |
--nightly, --nonightly: |
|
456 |
Suffix/Don't suffix the rpm Release with the current date. |
|
457 |
Default: --nonightly; |
|
458 |
||
459 |
--date-format=format, --date=format: |
|
460 |
Use "date +format" to generate the date suffix for |
|
461 |
the nightly builds. Default: $default_nightly_date_format |
|
462 |
||
463 |
||
464 |
Commands: |
|
465 |
||
466 |
build Build the specs specified on the command line |
|
467 |
||
468 |
build-order Print the build order of the specs specified on the |
|
469 |
command line. |
|
470 |
||
471 |
install-order Print the rpms in the order they should be installed |
|
472 |
||
473 |
uninstall-pkgs Remove all rpms defined in the spec files specified |
|
474 |
on the command line. (runs rpm --erase --nodeps) |
|
475 |
||
476 |
||
477 |
specs... |
|
478 |
||
479 |
List of spec files to build. Either full path names or names of spec |
|
480 |
files in the default spec directory (with or without the .spec suffix). |
|
481 |
EOF |
|
482 |
exit $retval; |
|
483 |
} |
|
484 |
||
1058 | 485 |
# --------- print reports -------------------------------------------------- |
486 |
# plain text report on stdout and |
|
487 |
# html report if summary log file name |
|
488 |
# was specified on the command line |
|
489 |
sub print_status { |
|
490 |
print_status_text (); |
|
491 |
print_status_html (); |
|
482 | 492 |
} |
493 |
||
1058 | 494 |
sub print_live_status { |
495 |
if ($live_summary) { |
|
496 |
print_status_html (); |
|
482 | 497 |
} |
1058 | 498 |
} |
482 | 499 |
|
1058 | 500 |
sub print_status_text { |
482 | 501 |
my $spec_name; |
502 |
print "\nSummary:\n\n"; |
|
531 | 503 |
printf "%20s | %10s | %s\n", "package", "status", "details"; |
504 |
print "---------------------+------------+------------------------------------------\n"; |
|
482 | 505 |
for (my $i = 0; $i <= $#specs_to_build; $i++) { |
506 |
$spec_name=$specs_to_build[$i]->{name}; |
|
531 | 507 |
printf "%20s | %10s | %s\n", $spec_name, $build_status[$i], |
482 | 508 |
$status_details[$i]; |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
509 |
} |
1058 | 510 |
} |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
511 |
|
1058 | 512 |
sub print_status_html { |
513 |
my $spec_name; |
|
514 |
||
515 |
if (not defined ($the_summary_log)) { |
|
516 |
return; |
|
517 |
} |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
518 |
|
1058 | 519 |
if (! open SUM_LOG, ">$the_summary_log") { |
520 |
msg_warning (0, "Failed to open file $the_summary_log for writing"); |
|
521 |
return; |
|
522 |
} |
|
523 |
||
524 |
print SUM_LOG "<HTML>\n<HEAD>\n<TITLE>Build report</TITLE>\n"; |
|
525 |
print SUM_LOG "</HEAD>\n<BODY BGCOLOR=#FFFFFF>\n"; |
|
526 |
if (defined ($the_summary_title)) { |
|
527 |
print SUM_LOG "<P><H3>$the_summary_title</H3><P>\n"; |
|
528 |
} |
|
529 |
print SUM_LOG "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=5 WIDTH=90%>\n"; |
|
530 |
print SUM_LOG " <TR>\n"; |
|
531 |
print SUM_LOG " <TD BGCOLOR=#666699><B>package</B></TD>\n"; |
|
532 |
print SUM_LOG " <TD BGCOLOR=#666699><B>version</B></TD>\n"; |
|
533 |
print SUM_LOG " <TD BGCOLOR=#666699><B>release</B></TD>\n"; |
|
534 |
print SUM_LOG " <TD BGCOLOR=#666699><B>status</B></TD>"; |
|
535 |
print SUM_LOG " <TD BGCOLOR=#666699><B>details</B></TD>\n"; |
|
536 |
print SUM_LOG " </TR>\n"; |
|
537 |
for (my $i = 0; $i <= $#specs_to_build; $i++) { |
|
538 |
my $log_name = get_log_name ($i); |
|
539 |
$spec_name=$specs_to_build[$i]->{name}; |
|
540 |
my $version = $specs_to_build[$i]->{version}; |
|
541 |
my $release = $specs_to_build[$i]->{release}; |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
542 |
print SUM_LOG " <TR>\n"; |
1058 | 543 |
if (defined ($the_srpm_url)) { |
544 |
if (($build_status[$i] eq "PASSED") and defined ($the_srpm_url)) { |
|
545 |
print SUM_LOG " <TD><A HREF=\"$the_srpm_url/$spec_name-$version-$release.src.rpm\">$spec_name</A></TD>\n"; |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
546 |
} else { |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
547 |
print SUM_LOG " <TD>$spec_name</TD>\n"; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
548 |
} |
1058 | 549 |
} else { |
550 |
print SUM_LOG " <TD>$spec_name</TD>\n"; |
|
551 |
} |
|
552 |
print SUM_LOG " <TD>", $version, "</TD>\n"; |
|
553 |
print SUM_LOG " <TD>", $release, "</TD>\n"; |
|
554 |
my $color_start = ""; |
|
555 |
my $color_end = ""; |
|
556 |
if ($build_status[$i] eq "PASSED") { |
|
557 |
$color_start = "<FONT COLOR=#11AA11>"; |
|
558 |
$color_end = "</FONT>"; |
|
559 |
} elsif ($build_status[$i] eq "BEING_BUILT") { |
|
560 |
$color_start = "<FONT COLOR=#FFA500>"; |
|
561 |
$color_end = "</FONT>"; |
|
562 |
} elsif ($build_status[$i] eq "DEP") { |
|
563 |
$color_start = "<FONT COLOR=#FFA500>"; |
|
564 |
$color_end = "</FONT>"; |
|
565 |
} elsif ($build_status[$i] eq "NOT_BUILT") { |
|
566 |
$color_start = ""; |
|
567 |
$color_end = ""; |
|
568 |
} else { |
|
569 |
$color_start = "<FONT COLOR=#CC1111>"; |
|
570 |
$color_end = "</FONT>"; |
|
571 |
} |
|
572 |
if (defined ($the_logdir_url) and ($build_status[$i] ne "NOT_BUILT")) { |
|
573 |
print SUM_LOG " <TD><A HREF=\"$the_logdir_url/$log_name\">", |
|
574 |
$color_start, $build_status[$i], $color_end, |
|
575 |
"</A></TD>\n"; |
|
576 |
} else { |
|
577 |
print SUM_LOG " <TD>", |
|
578 |
$color_start, $build_status[$i], $color_end, |
|
579 |
"</A></TD>\n"; |
|
580 |
} |
|
581 |
if ($build_status[$i] eq "PASSED") { |
|
582 |
if (defined ($the_rpm_url)) { |
|
583 |
print SUM_LOG " <TD>RPMS: \n"; |
|
584 |
my @rpms = $specs_to_build[$i]-> get_param_array ('rpms'); |
|
585 |
my $ctr = 1; |
|
586 |
for my $rpm (@rpms) { |
|
587 |
print SUM_LOG " <A HREF=\"$the_rpm_url/$rpm\">[$ctr]</a> \n"; |
|
588 |
$ctr++; |
|
589 |
} |
|
590 |
print SUM_LOG " </TD>\n"; |
|
609 | 591 |
} else { |
1058 | 592 |
print SUM_LOG " <TD> </TD>\n"; |
609 | 593 |
} |
1058 | 594 |
} else { |
595 |
print SUM_LOG " <TD><PRE>", $status_details[$i], "</PRE></TD>\n"; |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
596 |
} |
1058 | 597 |
print SUM_LOG " </TR>\n"; |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
598 |
} |
1058 | 599 |
print SUM_LOG "</TABLE><P>\n"; |
600 |
print SUM_LOG "<SMALL>", `date`, "</SMALL>\n"; |
|
601 |
print SUM_LOG "</BODY>\n</HTML>\n"; |
|
602 |
close SUM_LOG; |
|
482 | 603 |
} |
604 |
||
1058 | 605 |
# --------- rpm utility functions ------------------------------------------ |
482 | 606 |
sub is_provided ($) { |
607 |
my $capability = shift; |
|
608 |
||
610 | 609 |
$capability =~ s/\s.*//; |
482 | 610 |
`sh -c "rpm -q --whatprovides $capability" >/dev/null 2>&1`; |
611 |
my $result = (! $?); |
|
612 |
`sh -c "rpm -q $capability" >/dev/null 2>&1`; |
|
613 |
$result = ($result or (! $?)); |
|
614 |
||
615 |
return ($result); |
|
616 |
} |
|
617 |
||
618 |
sub what_provides ($) { |
|
619 |
my $capability = shift; |
|
620 |
||
621 |
$capability =~ s/ .*//; |
|
622 |
my $rpm=`sh -c "rpm -q --whatprovides $capability" 2>&1`; |
|
623 |
if ($?) { |
|
624 |
$rpm=`sh -c "rpm -q $capability" 2>&1`; |
|
625 |
} |
|
626 |
chomp $rpm; |
|
627 |
return ($rpm); |
|
628 |
} |
|
629 |
||
1741 | 630 |
sub spec_id_of ($) { |
631 |
my $name = shift; |
|
632 |
||
633 |
for (my $i = 0; $i <= $#specs_to_build; $i++) { |
|
634 |
if ($specs_to_build[$i]->{name} eq $name) { |
|
635 |
return $i; |
|
636 |
} |
|
637 |
} |
|
638 |
||
639 |
return undef; |
|
640 |
} |
|
641 |
||
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
642 |
sub install_good_rpms ($) { |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
643 |
my $spec_id = shift; |
2798 | 644 |
|
645 |
return if not defined($spec_id); |
|
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
646 |
my $spec = $specs_to_build[$spec_id]; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
647 |
|
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
648 |
my @rpms = $spec->get_param_array ('rpms'); |
789 | 649 |
map $_ =~ s/$spec->{version}-$spec->{release}.$spec->{buildarchitecture}.rpm/[0-9]*-[0-9]*.*.rpm/, @rpms; |
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
650 |
map $_ =~ s/^/$the_good_build_dir\//, @rpms; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
651 |
|
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
652 |
for (my $i = 0; $i <= $#rpms; $i++) { |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
653 |
my $current_rpm = $rpms[$i]; |
789 | 654 |
msg_info (1, "Looking for last known good rpm as $current_rpm"); |
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
655 |
$rpms[$i] = find_file ($current_rpm); |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
656 |
if (not defined ($rpms[$i])) { |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
657 |
msg_error ("No file matches $current_rpm"); |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
658 |
return 0; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
659 |
} else { |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
660 |
msg_info (1, "Found $rpms[$i]"); |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
661 |
} |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
662 |
} |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
663 |
|
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
664 |
my $command = "rpm --upgrade -v @rpms"; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
665 |
|
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
666 |
if ($verbose > 0) { |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
667 |
map msg_info (0, "Installing last known good rpm: $_\n"), @rpms; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
668 |
} |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
669 |
|
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
670 |
my $msg=`$command 2>&1`; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
671 |
|
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
672 |
if ($? > 0) { |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
673 |
msg_error "failed to install last known good rpm: $msg"; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
674 |
$status_details[$spec_id] = $status_details[$spec_id] . |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
675 |
"; Failed to install last known good rpm: " . $msg; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
676 |
return 0; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
677 |
} |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
678 |
|
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
679 |
if (defined ($the_good_rpms_copy_dir)) { |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
680 |
`mkdir -p $the_good_rpms_copy_dir`; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
681 |
`cp @rpms $the_good_rpms_copy_dir`; |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
682 |
} |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
683 |
|
790 | 684 |
return 1; |
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
685 |
} |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
785
diff
changeset
|
686 |
|
482 | 687 |
sub install_rpms ($) { |
688 |
my $spec_id = shift; |
|
689 |
my $spec = $specs_to_build[$spec_id]; |
|
690 |
||
691 |
my @rpms = $spec->get_param_array ('rpm_paths'); |
|
692 |
map $_ =~ s/^/$the_sys_rpm_dir\//, @rpms; |
|
693 |
my $command = "rpm --upgrade -v @rpms"; |
|
694 |
||
695 |
if ($verbose > 0) { |
|
696 |
map msg_info (0, "Installing $_\n"), @rpms; |
|
697 |
} |
|
698 |
||
699 |
my $msg=`$command 2>&1`; |
|
700 |
if ($? > 0) { |
|
701 |
msg_error "failed to install rpm: $msg"; |
|
702 |
$build_status[$spec_id] = 'FAILED'; |
|
703 |
$status_details[$spec_id] = $msg; |
|
704 |
return 0; |
|
705 |
} |
|
706 |
||
707 |
return 1; |
|
708 |
} |
|
709 |
||
710 |
sub print_rpms ($) { |
|
711 |
my $spec_id = shift; |
|
712 |
my $spec = $specs_to_build[$spec_id]; |
|
713 |
||
714 |
if ($full_path) { |
|
715 |
my @rpms = $spec->get_param_array ('rpm_paths'); |
|
716 |
map print("$the_sys_rpm_dir\/$_\n"), @rpms; |
|
717 |
} else { |
|
718 |
my @rpms = $spec->get_param_array ('rpms'); |
|
719 |
map print("$_\n"), @rpms; |
|
720 |
} |
|
721 |
} |
|
722 |
||
1058 | 723 |
sub print_spec ($) { |
482 | 724 |
my $spec_id = shift; |
1058 | 725 |
my $spec = $specs_to_build[$spec_id]; |
726 |
||
727 |
print "$spec->{file_name}\n"; |
|
728 |
} |
|
729 |
||
730 |
sub push_to_remove_list ($) { |
|
731 |
my $spec_id = shift; |
|
482 | 732 |
my $spec = $specs_to_build[$spec_id]; |
733 |
||
734 |
my @rpms = $spec->get_param_array ('packages'); |
|
1058 | 735 |
map unshift (@remove_list, $_), @rpms; |
736 |
} |
|
737 |
||
738 |
# --------- dependency checking code --------------------------------------- |
|
739 |
sub warn_always ($$$) { |
|
740 |
my $spec_name = shift; |
|
741 |
my $dep = shift; |
|
742 |
my $reason = shift; |
|
743 |
||
744 |
if ($reason eq "DEP_FAILED") { |
|
745 |
msg_warning (1, "$spec_name requires $dep"); |
|
746 |
msg_warning (1, "but that failed to build"); |
|
747 |
msg_warning (1, "Can't build $spec_name"); |
|
748 |
} elsif ($reason eq "NOT_FOUND") { |
|
749 |
msg_warning (0, "no spec file or installed package provides $dep"); |
|
750 |
msg_warning (0, "can't build $spec_name"); |
|
751 |
} |
|
752 |
} |
|
753 |
||
754 |
sub warn_once ($$$) { |
|
755 |
my $spec_name = shift; |
|
756 |
my $dep = shift; |
|
757 |
my $reason = shift; |
|
758 |
||
759 |
if ($reason eq "DEP_FAILED") { |
|
760 |
# should not happen |
|
761 |
msg_error ("assertion failed: warn_once / DEP_FAILED"); |
|
762 |
} elsif ($reason eq "NOT_FOUND") { |
|
763 |
if (not defined ($warned_about{$dep})) { |
|
764 |
msg_warning (1, "$dep is required but not found"); |
|
765 |
$warned_about{$dep}=1; |
|
766 |
} |
|
767 |
} |
|
768 |
} |
|
769 |
||
770 |
sub get_dependencies ($@) { |
|
771 |
my $spec_id = shift; |
|
772 |
my @packages = @_; |
|
773 |
my $spec = $specs_to_build[$spec_id]; |
|
774 |
||
775 |
my @dependencies = (); |
|
776 |
my @this_pkg_requires; |
|
777 |
foreach my $pkg (@packages) { |
|
778 |
@this_pkg_requires = $spec->get_pkg_param_array ($pkg, 'requires'); |
|
779 |
msg_debug (3, "adding \"@this_pkg_requires\" to the dependencies of $spec->{name}"); |
|
780 |
push (@dependencies, @this_pkg_requires); |
|
781 |
} |
|
782 |
||
783 |
return @dependencies; |
|
784 |
} |
|
785 |
||
786 |
sub check_dependency ($$&&@) { |
|
787 |
my $spec_id = shift; |
|
788 |
my $capability = shift; |
|
789 |
my $recursive_callback = shift; |
|
790 |
my $warning_callback = shift; |
|
791 |
my @rec_cb_opts = @_; |
|
792 |
my $spec_name = $specs_to_build[$spec_id]->{name}; |
|
793 |
||
794 |
my $result = 1; |
|
795 |
||
796 |
if (not defined ($capability)) { |
|
797 |
return 1; |
|
798 |
} |
|
799 |
||
800 |
if ((defined ($provider{$capability})) and |
|
801 |
($provider{$capability} == $spec_id)) { |
|
802 |
return 1; |
|
803 |
} |
|
804 |
||
805 |
if (defined $provider{$capability}) { |
|
806 |
if ($build_status[$provider{$capability}] eq "PASSED") { |
|
807 |
return 1; |
|
808 |
} elsif ($build_status[$provider{$capability}] ne "NOT_BUILT") { |
|
809 |
if (!is_provided ($capability)) { |
|
810 |
&$warning_callback ($spec_name, $capability, "DEP_FAILED"); |
|
811 |
return 0; |
|
812 |
} |
|
813 |
return 1; |
|
814 |
} |
|
815 |
||
816 |
msg_info (1, "need to build $capability first"); |
|
817 |
my $save_log_name = $current_log; |
|
818 |
my $result = &$recursive_callback ($provider{$capability}, @rec_cb_opts); |
|
819 |
open_log ($save_log_name); |
|
820 |
return $result; |
|
821 |
} elsif (!is_provided ($capability)) { |
|
822 |
&$warning_callback ($spec_name, $capability, "NOT_FOUND"); |
|
823 |
return 0; |
|
824 |
} else { |
|
825 |
return 1; |
|
826 |
} |
|
827 |
||
828 |
# should not happen |
|
829 |
msg_error("Assertion failed: check_dependency: return 0"); |
|
830 |
return 0; |
|
831 |
} |
|
832 |
||
833 |
# --------- copy build spec files, tarballs, patches ----------------------- |
|
834 |
sub copy_spec ($) { |
|
835 |
my $spec_id = shift; |
|
836 |
my $spec = $specs_to_build[$spec_id]; |
|
837 |
my $spec_file = $spec->get_param ('file_name'); |
|
838 |
my $base_name = $spec_file; |
|
839 |
$base_name =~ s/^.*\/([^\/]+)/$1/; |
|
840 |
my $target = "$the_sys_rpm_dir/SPECS/$base_name"; |
|
841 |
||
842 |
msg_info (1, "copying spec file $base_name to the SPECS dir"); |
|
843 |
||
844 |
if ($is_nightly) { |
|
845 |
my $the_nightly_date = `date "+$the_nightly_date_format"`; |
|
846 |
if ($? > 0) { |
|
847 |
msg_error ("incorrect date format: $the_nightly_date_format"); |
|
848 |
$build_status[$spec_id] = 'ERROR'; |
|
849 |
$status_details[$spec_id] = "incorrect nightly date format: $the_nightly_date"; |
|
850 |
return 0; |
|
851 |
} |
|
852 |
||
853 |
open SPEC_OUT, ">$target"; |
|
854 |
my $msg=`cp $spec_file /tmp/.gnome_build.tmp.$$ 2>&1`; |
|
855 |
if ($? > 0) { |
|
856 |
msg_error ("failed to copy $spec_file"); |
|
857 |
msg_error ("can't continue with $spec->{name}"); |
|
858 |
$build_status[$spec_id] = 'FAILED'; |
|
859 |
$status_details[$spec_id] = "cound not copy spec file: $msg"; |
|
860 |
return 0; |
|
861 |
} |
|
862 |
open SPEC_IN, "</tmp/.gnome_build.tmp.$$"; |
|
863 |
my $line; |
|
864 |
while (1) { |
|
865 |
$line = <SPEC_IN>; |
|
866 |
if (not defined ($line)) { |
|
867 |
last; |
|
868 |
} |
|
869 |
if ($line =~ /^Release\s*:/) { |
|
870 |
$line =~ s/\s*$/.$the_nightly_date/; |
|
871 |
} |
|
872 |
print SPEC_OUT $line; |
|
873 |
} |
|
874 |
close SPEC_OUT; |
|
875 |
close SPEC_IN; |
|
876 |
||
877 |
`rm -f /tmp/.gnome_build.tmp.$$`; |
|
2798 | 878 |
my $s = rpm_spec->new ($target, $rpm_target); |
879 |
$specs_to_build[$spec_id] = $s; |
|
880 |
$s->add_define ("nightly", "1"); |
|
1058 | 881 |
} else { |
882 |
`cmp -s $spec_file $target`; |
|
883 |
if ($? != 0) { # the files differ |
|
884 |
my $msg=`cp $spec_file $target 2>&1`; |
|
885 |
if ($? > 0) { |
|
886 |
msg_error "failed to copy $spec_file"; |
|
887 |
$build_status[$spec_id] = 'FAILED'; |
|
888 |
$status_details[$spec_id] = "failed to copy spec file: $msg"; |
|
889 |
return 0; |
|
890 |
} |
|
891 |
} else { |
|
892 |
msg_info (3, " $spec_file and"); |
|
893 |
msg_info (3, " $target"); |
|
894 |
msg_info (3, " are the same; not copying"); |
|
895 |
} |
|
896 |
} |
|
897 |
||
898 |
return 1; |
|
899 |
} |
|
900 |
||
1268 | 901 |
sub find_source ($$) { |
902 |
my $spec_id = shift; |
|
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
903 |
my $src = shift; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
904 |
my $is_tarball = 0; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
905 |
my $src_path; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
906 |
|
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
907 |
if ($src =~ /\.(tar\.gz|tgz|tar\.bz2|tar\.bzip2)$/) { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
908 |
$is_tarball = 1; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
909 |
|
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
910 |
$src_path = "$the_tarball_dir/$src"; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
911 |
if (! -f "$src_path") { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
912 |
msg_info (3, " $src not found in $the_tarball_dir"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
913 |
} else { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
914 |
msg_info (3, " found in $the_tarball_dir"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
915 |
return $src_path; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
916 |
} |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
917 |
} |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
918 |
foreach my $extsrcdir (@the_source_dirlist) { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
919 |
$src_path = "$extsrcdir/$src"; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
920 |
if (! -f "$src_path") { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
921 |
msg_info (3, " $src not found in $extsrcdir"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
922 |
} else { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
923 |
msg_info (3, " found in $extsrcdir"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
924 |
return "$src_path"; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
925 |
} |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
926 |
} |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
927 |
|
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
928 |
if (!$is_tarball) { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
929 |
$src_path = "$the_tarball_dir/$src"; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
930 |
if (! -f "$src_path") { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
931 |
msg_info (3, " trying the tarball directory"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
932 |
msg_info (3, " $src not found in $the_tarball_dir"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
933 |
} else { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
934 |
msg_info (3, " found in $the_tarball_dir"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
935 |
msg_warning (1, "$src is not expected to be in the tarball dir"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
936 |
return $src_path; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
937 |
} |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
938 |
} |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
939 |
|
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
940 |
$build_status[$spec_id] = 'FAILED'; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
941 |
$status_details[$spec_id] = "Source $src not found"; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
942 |
msg_error ("Source file $src not found"); |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
943 |
return undef; |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
944 |
} |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
945 |
|
1058 | 946 |
sub copy_sources ($) { |
947 |
my $spec_id = shift; |
|
948 |
my $spec = $specs_to_build[$spec_id]; |
|
949 |
||
950 |
my @sources = $spec->get_param_array ('sources'); |
|
951 |
my $src_path; |
|
952 |
my $target; |
|
953 |
||
954 |
msg_info (1, "copying sources to $the_sys_rpm_dir/SOURCES"); |
|
955 |
||
956 |
foreach my $src (@sources) { |
|
957 |
if (not defined ($src)) { |
|
958 |
next; |
|
959 |
} |
|
1268 | 960 |
$src_path = find_source ($spec_id, $src); |
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
961 |
if (not defined ($src_path)) { |
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
962 |
return 0; |
1058 | 963 |
} |
964 |
||
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
965 |
msg_info (2, " copying $src"); |
1058 | 966 |
|
967 |
$target = "$the_sys_rpm_dir/SOURCES/$src"; |
|
968 |
||
969 |
`cmp -s $src_path $target`; |
|
970 |
||
971 |
if ($? != 0) { # the files differ |
|
972 |
my $msg=`cp $src_path $target 2>&1`; |
|
973 |
if ($? > 0) { |
|
974 |
msg_error ("failed to copy $src_path"); |
|
975 |
$build_status[$spec_id] = 'ERROR'; |
|
976 |
$status_details[$spec_id] = $msg; |
|
977 |
return 0; |
|
978 |
} |
|
979 |
} |
|
980 |
||
981 |
} |
|
982 |
||
983 |
return 1; |
|
984 |
} |
|
985 |
||
986 |
sub copy_patches ($) { |
|
987 |
my $spec_id = shift; |
|
988 |
my $spec = $specs_to_build[$spec_id]; |
|
989 |
||
990 |
my @patches = $spec->get_param_array ('patches'); |
|
991 |
my $patch_path; |
|
992 |
my $target; |
|
993 |
foreach my $patch (@patches) { |
|
994 |
if (not defined ($patch)) { |
|
995 |
next; |
|
996 |
} |
|
997 |
||
998 |
msg_info (2, "copying patch $patch"); |
|
999 |
||
1000 |
$patch_path = "$the_patch_dir/$patch"; |
|
1001 |
||
1002 |
if (! -f "$patch_path") { |
|
1003 |
$build_status[$spec_id] = 'ERROR'; |
|
1004 |
$status_details[$spec_id] = "Patch $patch_path not found"; |
|
1005 |
msg_error ("Patch $patch_path not found"); |
|
1006 |
return 0; |
|
1007 |
} |
|
1008 |
||
1009 |
$target = "$the_sys_rpm_dir/SOURCES/$patch"; |
|
1010 |
||
1011 |
`cmp -s $patch_path $target`; |
|
1012 |
||
1013 |
if ($? != 0) { # the files differ |
|
1014 |
my $msg=`cp $patch_path $target 2>&1`; |
|
1015 |
if ($? > 0) { |
|
1016 |
msg_error "failed to copy $patch_path"; |
|
1017 |
$build_status[$spec_id] = 'ERROR'; |
|
1018 |
$status_details[$spec_id] = $msg; |
|
1019 |
return 0; |
|
1020 |
} |
|
1021 |
} else { |
|
1022 |
msg_info (3, " $patch and"); |
|
1023 |
msg_info (3, " $the_sys_rpm_dir/SOURCES/$patch"); |
|
1024 |
msg_info (3, " are the same; not copying"); |
|
1025 |
} |
|
1026 |
||
1027 |
} |
|
1028 |
||
1029 |
return 1; |
|
1030 |
} |
|
1031 |
||
1032 |
# --------- build command -------------------------------------------------- |
|
1033 |
sub do_build () { |
|
1034 |
print_live_status; |
|
1035 |
||
1036 |
for (my $i = 0; $i <= $#specs_to_build; $i++) { |
|
1037 |
if ($build_status[$i] eq "NOT_BUILT") { |
|
1038 |
if (! build_spec ($i)) { |
|
1039 |
if (defined ($the_good_build_dir)) { |
|
1040 |
msg_info (0, "Attempting to use a known good rpm"); |
|
1041 |
install_good_rpms ($i); |
|
1042 |
} |
|
1043 |
} |
|
1044 |
print_live_status; |
|
1045 |
} |
|
1046 |
if ($build_status[$i] ne "PASSED") { |
|
1418 | 1047 |
if ($build_status[$i] ne "DEP_FAILED") { |
1048 |
mail_log ($i); |
|
1049 |
} |
|
1058 | 1050 |
$exit_val++; |
1051 |
} |
|
1052 |
} |
|
1053 |
||
1054 |
if ($verbose > 0) { |
|
1055 |
print_status; |
|
1056 |
} |
|
482 | 1057 |
} |
1058 |
||
1059 |
sub build_spec ($) { |
|
1060 |
my $spec_id = shift; |
|
1061 |
my $spec = $specs_to_build[$spec_id]; |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
1062 |
my $logname = $the_log_dir . "/" . get_log_name ($spec_id); |
482 | 1063 |
|
1064 |
msg_debug (0, "Trying to build $spec->{name}"); |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
1065 |
open_log ($logname); |
482 | 1066 |
|
1058 | 1067 |
if ($build_status[$spec_id] ne "NOT_BUILT") { |
482 | 1068 |
if ($build_status[$spec_id] eq "DEP") { |
1069 |
$build_status[$spec_id]="ERROR"; |
|
1070 |
$status_details[$spec_id]="Circular dependency detected"; |
|
1071 |
msg_error ("Circular dependency detected " . |
|
1072 |
"while trying to build $spec->{name}"); |
|
1073 |
} |
|
1074 |
return 0; |
|
1075 |
} |
|
1076 |
||
1077 |
my @packages = $spec->get_param_array ('packages'); |
|
1078 |
msg_debug (3, "packages: $spec->{file_name} defines: @packages"); |
|
1079 |
||
1058 | 1080 |
foreach my $pkg (@packages) { |
1081 |
if (not defined ($pkg)) { |
|
1082 |
next; |
|
1083 |
} |
|
1084 |
msg_info (2, "Checking if $pkg is installed"); |
|
1085 |
if (is_provided ($pkg) and $check_deps) { |
|
1086 |
my $provider = what_provides ($pkg); |
|
1087 |
msg_warning (0, "$pkg is already provided by $provider"); |
|
1088 |
msg_warning (0, "not building $pkg"); |
|
1089 |
$build_status[$spec_id]='SKIPPED'; |
|
1090 |
$status_details[$spec_id]="$pkg already installed"; |
|
1091 |
||
1092 |
return 0; |
|
482 | 1093 |
} |
1094 |
} |
|
1095 |
||
1058 | 1096 |
if ($check_deps) { |
1097 |
my @dependencies = get_dependencies ($spec_id, @packages); |
|
1098 |
||
1099 |
my $this_result; |
|
1100 |
my $result = 1; |
|
1101 |
||
1102 |
$build_status[$spec_id] = "DEP"; |
|
1103 |
$status_details[$spec_id] = "building dependencies first"; |
|
1104 |
||
1105 |
msg_info (1, "Checking dependencies of $spec->{name}"); |
|
482 | 1106 |
|
1058 | 1107 |
foreach my $dep (@dependencies) { |
1108 |
$dep =~ s/ .*//; |
|
1109 |
||
1110 |
$this_result = check_dependency ($spec_id, $dep, |
|
1111 |
\&build_spec, \&warn_always, ()); |
|
1112 |
if (!$this_result) { |
|
1113 |
if (defined ($the_good_build_dir)) { |
|
1114 |
msg_info (0, "Attempting to use a known good rpm"); |
|
1741 | 1115 |
$this_result = install_good_rpms (spec_id_of ($dep)); |
1058 | 1116 |
} |
1117 |
if (! $this_result) { |
|
1118 |
msg_warning (1, "$spec->{name} requires $dep"); |
|
1119 |
} |
|
1120 |
} |
|
1121 |
$result = ($this_result and $result); |
|
1122 |
} |
|
482 | 1123 |
|
1058 | 1124 |
if (! $result) { |
482 | 1125 |
$build_status[$spec_id]="DEP_FAILED"; |
1126 |
$status_details[$spec_id]="Dependency check failed"; |
|
1058 | 1127 |
|
482 | 1128 |
msg_warning (0, "Dependency check for $spec->{name} failed"); |
1129 |
||
1130 |
return 0; |
|
1131 |
} |
|
1132 |
} |
|
1133 |
||
1058 | 1134 |
copy_spec ($spec_id) || return 0; |
1135 |
copy_sources ($spec_id) || return 0; |
|
1136 |
copy_patches ($spec_id) || return 0; |
|
1137 |
||
1138 |
if ($live_summary) { |
|
1139 |
$build_status[$spec_id] = 'BEING_BUILT'; |
|
3811 | 1140 |
$status_details[$spec_id] = "$RPM_BUILD -ba running"; |
1058 | 1141 |
print_live_status; |
482 | 1142 |
} |
3628 | 1143 |
run_rpmbuild_ba ($spec_id) || return 0; |
1058 | 1144 |
|
1145 |
install_rpms ($spec_id) || return 0; |
|
482 | 1146 |
|
1147 |
$build_status[$spec_id] = "PASSED"; |
|
1058 | 1148 |
$status_details[$spec_id] = ""; |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
1149 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
1150 |
close_log; |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
1151 |
|
482 | 1152 |
return 1; |
1058 | 1153 |
|
1154 |
} |
|
1155 |
||
3628 | 1156 |
sub run_rpmbuild_ba ($) { |
1058 | 1157 |
my $spec_id = shift; |
1158 |
my $spec = $specs_to_build[$spec_id]; |
|
1159 |
my $spec_file = $spec->get_param ('file_name'); |
|
1160 |
my $base_name = $spec_file; |
|
1161 |
$base_name =~ s/^.*\/([^\/]+)/$1/; |
|
1162 |
my $log_name = "$base_name"; |
|
1163 |
$log_name = get_log_name ($spec_id); |
|
1164 |
||
1165 |
msg_info (0, "Running rpm build of $spec->{name} ($base_name)"); |
|
1166 |
msg_info (1, "Log file: $the_log_dir/$log_name"); |
|
1167 |
||
1168 |
my $save_log_name = $current_log; |
|
3811 | 1169 |
msg_log ("INFO: Starting $RPM_BUILD -ba at " . `date`); |
1058 | 1170 |
close_log; |
1171 |
my $tempfile = "/tmp/rpm.out.$$"; |
|
2798 | 1172 |
my $defnightly = ""; |
1173 |
if ($is_nightly) { |
|
1174 |
$defnightly = " --define \"nightly 1\"" |
|
1175 |
} |
|
2424 | 1176 |
if (defined($rpm_target) and ($rpm_target eq $spec->{buildarchitecture})) { |
3811 | 1177 |
system ("$RPM_BUILD --target $rpm_target -ba $the_sys_rpm_dir/SPECS/$base_name $defnightly > $tempfile 2>&1"); |
1058 | 1178 |
} else { |
3811 | 1179 |
system ("$RPM_BUILD -ba $the_sys_rpm_dir/SPECS/$base_name $defnightly > $tempfile 2>&1"); |
1058 | 1180 |
} |
1181 |
my $rpm_result = $?; |
|
1182 |
system ("sed -e 's/^/RPM: /' $tempfile >> $the_log_dir/$log_name 2>&1; rm -f $tempfile"); |
|
1183 |
open_log ($save_log_name); |
|
3811 | 1184 |
msg_log ("INFO: $RPM_BUILD -ba finished at " . `date`); |
1058 | 1185 |
|
1186 |
if ($rpm_result) { |
|
1187 |
msg_error ("Build of $spec->{name} FAILED"); |
|
1188 |
$build_status[$spec_id] = "FAILED"; |
|
1189 |
$status_details[$spec_id] = 'RPM build failed'; |
|
1190 |
return 0; |
|
1191 |
} |
|
1192 |
||
1193 |
msg_info (0, "$spec->{name} PASSED"); |
|
1194 |
return 1; |
|
1195 |
} |
|
1196 |
||
1197 |
# --------- build-order and install-order commands ------------------------- |
|
1198 |
sub do_build_order () { |
|
1199 |
for (my $i = 0; $i <= $#specs_to_build; $i++) { |
|
1200 |
print_order ($i, \&print_spec); |
|
1201 |
} |
|
1202 |
} |
|
1203 |
||
1204 |
sub do_install_order () { |
|
1205 |
for (my $i = 0; $i <= $#specs_to_build; $i++) { |
|
1206 |
print_order ($i, \&print_rpms); |
|
1207 |
} |
|
482 | 1208 |
} |
1209 |
||
1058 | 1210 |
sub print_order ($&) { |
1211 |
my $spec_id = shift; |
|
1212 |
my $print_command = shift; |
|
1213 |
my $spec = $specs_to_build[$spec_id]; |
|
1214 |
||
1215 |
if ($build_status[$spec_id] ne "NOT_BUILT") { |
|
1216 |
if ($build_status[$spec_id] eq "DEP") { |
|
1217 |
$build_status[$spec_id]="ERROR"; |
|
1218 |
$status_details[$spec_id]="Circular dependency detected"; |
|
1219 |
msg_error ("Circular dependency detected " . |
|
1220 |
"while checking dependencies of $spec->{name}"); |
|
1221 |
} |
|
1222 |
return 0; |
|
1223 |
} |
|
1224 |
||
1225 |
if ($check_deps) { |
|
1226 |
my @packages = $spec->get_param_array ('packages'); |
|
1227 |
my @dependencies = get_dependencies ($spec_id, @packages); |
|
1228 |
||
1229 |
$build_status[$spec_id] = "DEP"; |
|
1230 |
||
1231 |
msg_info (1, "Checking dependencies of $spec->{name}"); |
|
1232 |
||
1233 |
foreach my $dep (@dependencies) { |
|
1234 |
$dep =~ s/ .*//; |
|
1235 |
||
1236 |
check_dependency ($spec_id, $dep, \&print_order, \&warn_once, ($print_command)); } |
|
1237 |
} |
|
1238 |
||
1239 |
copy_spec ($spec_id) || return 0; |
|
1240 |
||
1241 |
$build_status[$spec_id] = "PASSED"; |
|
1242 |
&$print_command ($spec_id); |
|
1243 |
} |
|
1244 |
||
1245 |
# --------- uninstall-pkgs command ----------------------------------------- |
|
1246 |
sub do_uninstall_pkgs () { |
|
1247 |
for (my $i = 0; $i <= $#specs_to_build; $i++) { |
|
1248 |
print_order ($i, \&push_to_remove_list); |
|
1249 |
} |
|
1250 |
||
1251 |
foreach my $pkg_to_remove (@remove_list) { |
|
1252 |
msg_info (0, "Removing $pkg_to_remove"); |
|
1253 |
my $cmd_out = `rpm -v --erase --nodeps $pkg_to_remove 2>&1`; |
|
1254 |
if ($? > 0) { |
|
1255 |
$exit_val++; |
|
1256 |
} |
|
1257 |
$cmd_out =~ s/^/INFO: rpm: /; |
|
1258 |
if ($verbose > 0) { |
|
1241
2610ab6fd775
implement searchin multiple ext source directories for the source files
laca
parents:
1059
diff
changeset
|
1259 |
print $cmd_out . "\n"; |
1058 | 1260 |
} |
1261 |
} |
|
1262 |
} |
|
1263 |
||
1264 |
# --------- main program --------------------------------------------------- |
|
482 | 1265 |
sub main { |
1266 |
process_options; |
|
1267 |
||
1268 |
if (not defined ($build_command)) { |
|
1269 |
usage (1); |
|
1270 |
} |
|
1271 |
||
1272 |
if (not defined ($specs_to_build[0])) { |
|
1273 |
msg_info (0, "Nothing to do."); |
|
1274 |
exit (0); |
|
1275 |
} |
|
1276 |
||
1058 | 1277 |
if ($build_command eq "build") { |
1278 |
do_build; |
|
1279 |
} elsif ($build_command eq "uninstall-pkgs") { |
|
1280 |
do_uninstall_pkgs; |
|
1281 |
} elsif ($build_command eq "build-order") { |
|
1282 |
do_build_order; |
|
1283 |
} elsif ($build_command eq "install-order") { |
|
1284 |
do_install_order; |
|
482 | 1285 |
} |
1286 |
||
1287 |
exit ($exit_val); |
|
1288 |
} |
|
1289 |
||
1290 |
main; |