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