Print this page
9128 cw(1onbld) should be able to run multiple shadows
9129 file-locking tests shouldn't build multiple source files in one compiler invocation
9130 DTrace tst.gcc.d isn't useful
9132 cw(1onbld) shouldn't shadow pure preprocessing
Reviewed by: Andy Fiddaman <omnios@citrus-it.net>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/nightly.sh
+++ new/usr/src/tools/scripts/nightly.sh
1 1 #!/bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 # Copyright 2008, 2010, Richard Lowe
26 26 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
27 27 # Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
28 28 # Copyright (c) 2017 by Delphix. All rights reserved.
29 29 # Copyright 2018 Joyent, Inc.
30 30 # Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
31 31 #
32 32 # Based on the nightly script from the integration folks,
33 33 # Mostly modified and owned by mike_s.
34 34 # Changes also by kjc, dmk.
35 35 #
36 36 # BRINGOVER_WS may be specified in the env file.
37 37 # The default is the old behavior of CLONE_WS
38 38 #
39 39 # -i on the command line, means fast options, so when it's on the
40 40 # command line (only), lint and check builds are skipped no matter what
41 41 # the setting of their individual flags are in NIGHTLY_OPTIONS.
42 42 #
43 43 # LINTDIRS can be set in the env file, format is a list of:
44 44 #
45 45 # /dirname-to-run-lint-on flag
46 46 #
47 47 # Where flag is: y - enable lint noise diff output
48 48 # n - disable lint noise diff output
49 49 #
50 50 # For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
51 51 #
52 52 # OPTHOME may be set in the environment to override /opt
53 53 #
54 54
55 55 #
56 56 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
57 57 # under certain circumstances, which can really screw things up; unset it.
58 58 #
59 59 unset CDPATH
60 60
61 61 # Get the absolute path of the nightly script that the user invoked. This
62 62 # may be a relative path, and we need to do this before changing directory.
63 63 nightly_path=`whence $0`
64 64
65 65 #
66 66 # Keep track of where we found nightly so we can invoke the matching
67 67 # which_scm script. If that doesn't work, don't go guessing, just rely
68 68 # on the $PATH settings, which will generally give us either /opt/onbld
69 69 # or the user's workspace.
70 70 #
71 71 WHICH_SCM=$(dirname $nightly_path)/which_scm
72 72 if [[ ! -x $WHICH_SCM ]]; then
73 73 WHICH_SCM=which_scm
74 74 fi
75 75
76 76 function fatal_error
77 77 {
78 78 print -u2 "nightly: $*"
79 79 exit 1
80 80 }
81 81
82 82 #
83 83 # Function to do a DEBUG and non-DEBUG build. Needed because we might
84 84 # need to do another for the source build, and since we only deliver DEBUG or
85 85 # non-DEBUG packages.
86 86 #
87 87 # usage: normal_build
88 88 #
89 89 function normal_build {
90 90
91 91 typeset orig_p_FLAG="$p_FLAG"
92 92 typeset crypto_signer="$CODESIGN_USER"
93 93
94 94 suffix=""
95 95
96 96 # non-DEBUG build begins
97 97
98 98 if [ "$F_FLAG" = "n" ]; then
99 99 set_non_debug_build_flags
100 100 CODESIGN_USER="$crypto_signer" \
101 101 build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
102 102 else
103 103 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
104 104 fi
105 105
106 106 # non-DEBUG build ends
107 107
108 108 # DEBUG build begins
109 109
110 110 if [ "$D_FLAG" = "y" ]; then
111 111 set_debug_build_flags
112 112 CODESIGN_USER="$crypto_signer" \
113 113 build "DEBUG" "$suffix" "" "$MULTI_PROTO"
114 114 else
115 115 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
116 116 fi
117 117
118 118 # DEBUG build ends
119 119
120 120 p_FLAG="$orig_p_FLAG"
121 121 }
122 122
123 123 #
124 124 # usage: run_hook HOOKNAME ARGS...
125 125 #
126 126 # If variable "$HOOKNAME" is defined, insert a section header into
127 127 # our logs and then run the command with ARGS
128 128 #
129 129 function run_hook {
130 130 HOOKNAME=$1
131 131 eval HOOKCMD=\$$HOOKNAME
132 132 shift
133 133
134 134 if [ -n "$HOOKCMD" ]; then
135 135 (
136 136 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
137 137 ( $HOOKCMD "$@" 2>&1 )
138 138 if [ "$?" -ne 0 ]; then
139 139 # Let exit status propagate up
140 140 touch $TMPDIR/abort
141 141 fi
142 142 ) | tee -a $mail_msg_file >> $LOGFILE
143 143
144 144 if [ -f $TMPDIR/abort ]; then
145 145 build_ok=n
146 146 echo "\nAborting at request of $HOOKNAME" |
147 147 tee -a $mail_msg_file >> $LOGFILE
148 148 exit 1
149 149 fi
150 150 fi
151 151 }
152 152
153 153 # Return library search directive as function of given root.
154 154 function myldlibs {
155 155 echo "-L$1/lib -L$1/usr/lib"
156 156 }
157 157
158 158 # Return header search directive as function of given root.
159 159 function myheaders {
160 160 echo "-I$1/usr/include"
161 161 }
162 162
163 163 #
164 164 # Function to do the build, including package generation.
165 165 # usage: build LABEL SUFFIX ND MULTIPROTO
166 166 # - LABEL is used to tag build output.
167 167 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
168 168 # open-only vs full tree).
169 169 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
170 170 # - If MULTIPROTO is "yes", it means to name the proto area according to
171 171 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
172 172 #
173 173 function build {
174 174 LABEL=$1
175 175 SUFFIX=$2
176 176 ND=$3
177 177 MULTIPROTO=$4
178 178 INSTALLOG=install${SUFFIX}-${MACH}
179 179 NOISE=noise${SUFFIX}-${MACH}
180 180 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
181 181
182 182 ORIGROOT=$ROOT
183 183 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
184 184
185 185 export ENVLDLIBS1=`myldlibs $ROOT`
186 186 export ENVCPPFLAGS1=`myheaders $ROOT`
187 187
188 188 this_build_ok=y
189 189 #
190 190 # Build OS-Networking source
191 191 #
192 192 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
193 193 >> $LOGFILE
194 194
195 195 rm -f $SRC/${INSTALLOG}.out
196 196 cd $SRC
197 197 /bin/time $MAKE -e install 2>&1 | \
198 198 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
199 199
200 200 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
201 201 egrep ":" $SRC/${INSTALLOG}.out |
202 202 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
203 203 egrep -v "Ignoring unknown host" | \
204 204 egrep -v "cc .* -o error " | \
205 205 egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \
206 206 >> $mail_msg_file
207 207 sed -n "/^Undefined[ ]*first referenced$/,/^ld: fatal:/p" \
208 208 < $SRC/${INSTALLOG}.out >> $mail_msg_file
209 209 if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then
210 210 build_ok=n
211 211 this_build_ok=n
212 212 fi
213 213 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
214 214 >> $mail_msg_file
215 215 if [ "$?" = "0" ]; then
216 216 build_ok=n
217 217 this_build_ok=n
218 218 fi
219 219
220 220 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
221 221 egrep -i warning: $SRC/${INSTALLOG}.out \
222 222 | egrep -v '^tic:' \
223 223 | egrep -v "symbol (\`|')timezone' has differing types:" \
224 224 | egrep -v "parameter <PSTAMP> set to" \
225 225 | egrep -v "Ignoring unknown host" \
226 226 | egrep -v "redefining segment flags attribute for" \
227 227 | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file
228 228 if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then
229 229 build_ok=n
230 230 this_build_ok=n
231 231 fi
232 232
233 233 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
234 234 >> $LOGFILE
235 235
236 236 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
237 237 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
238 238
239 239 if [ "$i_FLAG" = "n" ]; then
240 240 rm -f $SRC/${NOISE}.ref
241 241 if [ -f $SRC/${NOISE}.out ]; then
242 242 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
243 243 fi
244 244 grep : $SRC/${INSTALLOG}.out \
245 245 | egrep -v '^/' \
246 246 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
247 247 | egrep -v '^tic:' \
248 248 | egrep -v '^mcs' \
249 249 | egrep -v '^LD_LIBRARY_PATH=' \
250 250 | egrep -v 'ar: creating' \
251 251 | egrep -v 'ar: writing' \
252 252 | egrep -v 'conflicts:' \
253 253 | egrep -v ':saved created' \
254 254 | egrep -v '^stty.*c:' \
255 255 | egrep -v '^mfgname.c:' \
256 256 | egrep -v '^uname-i.c:' \
257 257 | egrep -v '^volumes.c:' \
258 258 | egrep -v '^lint library construction:' \
259 259 | egrep -v 'tsort: INFORM:' \
260 260 | egrep -v 'stripalign:' \
261 261 | egrep -v 'chars, width' \
262 262 | egrep -v "symbol (\`|')timezone' has differing types:" \
263 263 | egrep -v 'PSTAMP' \
264 264 | egrep -v '^Manifying' \
265 265 | egrep -v 'Ignoring unknown host' \
266 266 | egrep -v 'Processing method:' \
267 267 | egrep -v '^Writing' \
268 268 | egrep -v 'spellin1:' \
269 269 | egrep -v '^adding:' \
270 270 | egrep -v "^echo 'msgid" \
271 271 | egrep -v '^echo ' \
272 272 | egrep -v '\.c:$' \
273 273 | egrep -v '^Adding file:' \
274 274 | egrep -v 'CLASSPATH=' \
275 275 | egrep -v '\/var\/mail\/:saved' \
276 276 | egrep -v -- '-DUTS_VERSION=' \
277 277 | egrep -v '^Running Mkbootstrap' \
278 278 | egrep -v '^Applet length read:' \
279 279 | egrep -v 'bytes written:' \
280 280 | egrep -v '^File:SolarisAuthApplet.bin' \
281 281 | egrep -v -i 'jibversion' \
282 282 | egrep -v '^Output size:' \
283 283 | egrep -v '^Solo size statistics:' \
284 284 | egrep -v '^Using ROM API Version' \
285 285 | egrep -v '^Zero Signature length:' \
286 286 | egrep -v '^Note \(probably harmless\):' \
287 287 | egrep -v '::' \
288 288 | egrep -v -- '-xcache' \
289 289 | egrep -v '^\+' \
290 290 | egrep -v '^cc1: note: -fwritable-strings' \
291 291 | egrep -v 'svccfg-native -s svc:/' \
292 292 | sort | uniq >$SRC/${NOISE}.out
293 293 if [ ! -f $SRC/${NOISE}.ref ]; then
294 294 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref
295 295 fi
296 296 echo "\n==== Build noise differences ($LABEL) ====\n" \
297 297 >>$mail_msg_file
298 298 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file
299 299 fi
300 300
301 301 #
302 302 # Re-sign selected binaries using signing server
303 303 # (gatekeeper builds only)
304 304 #
305 305 if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then
306 306 echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE
307 307 signing_file="${TMPDIR}/signing"
308 308 rm -f ${signing_file}
309 309 export CODESIGN_USER
310 310 signproto $SRC/tools/codesign/creds 2>&1 | \
311 311 tee -a ${signing_file} >> $LOGFILE
312 312 echo "\n==== Finished signing proto area at `date` ====\n" \
313 313 >> $LOGFILE
314 314 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
315 315 >> $mail_msg_file
316 316 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
317 317 if (( $? == 0 )) ; then
318 318 build_ok=n
319 319 this_build_ok=n
320 320 fi
321 321 fi
322 322
323 323 #
324 324 # Building Packages
325 325 #
326 326 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
327 327 if [ -d $SRC/pkg ]; then
328 328 echo "\n==== Creating $LABEL packages at `date` ====\n" \
329 329 >> $LOGFILE
330 330 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
331 331 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
332 332 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
333 333
334 334 rm -f $SRC/pkg/${INSTALLOG}.out
335 335 cd $SRC/pkg
336 336 /bin/time $MAKE -e install 2>&1 | \
337 337 tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE
338 338
339 339 echo "\n==== package build errors ($LABEL) ====\n" \
340 340 >> $mail_msg_file
341 341
342 342 egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \
343 343 grep ':' | \
344 344 grep -v PSTAMP | \
345 345 egrep -v "Ignoring unknown host" | \
346 346 tee $TMPDIR/package >> $mail_msg_file
347 347 if [[ -s $TMPDIR/package ]]; then
348 348 build_extras_ok=n
349 349 this_build_ok=n
350 350 fi
351 351 else
352 352 #
353 353 # Handle it gracefully if -p was set but there so
354 354 # no pkg directory.
355 355 #
356 356 echo "\n==== No $LABEL packages to build ====\n" \
357 357 >> $LOGFILE
358 358 fi
359 359 else
360 360 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
361 361 fi
362 362
363 363 ROOT=$ORIGROOT
364 364 }
365 365
366 366 # Usage: dolint /dir y|n
367 367 # Arg. 2 is a flag to turn on/off the lint diff output
368 368 function dolint {
369 369 if [ ! -d "$1" ]; then
370 370 echo "dolint error: $1 is not a directory"
371 371 exit 1
372 372 fi
373 373
374 374 if [ "$2" != "y" -a "$2" != "n" ]; then
375 375 echo "dolint internal error: $2 should be 'y' or 'n'"
376 376 exit 1
377 377 fi
378 378
379 379 lintdir=$1
380 380 dodiff=$2
381 381 base=`basename $lintdir`
382 382 LINTOUT=$lintdir/lint-${MACH}.out
383 383 LINTNOISE=$lintdir/lint-noise-${MACH}
384 384 export ENVLDLIBS1=`myldlibs $ROOT`
385 385 export ENVCPPFLAGS1=`myheaders $ROOT`
386 386
387 387 set_debug_build_flags
388 388
389 389 #
390 390 # '$MAKE lint' in $lintdir
391 391 #
392 392 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
393 393
394 394 # remove old lint.out
395 395 rm -f $lintdir/lint.out $lintdir/lint-noise.out
396 396 if [ -f $lintdir/lint-noise.ref ]; then
397 397 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref
398 398 fi
399 399
400 400 rm -f $LINTOUT
401 401 cd $lintdir
402 402 #
403 403 # Remove all .ln files to ensure a full reference file
404 404 #
405 405 rm -f Nothing_to_remove \
406 406 `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
407 407 -prune -o -type f -name '*.ln' -print `
408 408
409 409 /bin/time $MAKE -ek lint 2>&1 | \
410 410 tee -a $LINTOUT >> $LOGFILE
411 411
412 412 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file
413 413
414 414 grep "$MAKE:" $LINTOUT |
415 415 egrep -v "Ignoring unknown host" | \
416 416 tee $TMPDIR/lint_errs >> $mail_msg_file
417 417 if [[ -s $TMPDIR/lint_errs ]]; then
418 418 build_extras_ok=n
419 419 fi
420 420
421 421 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
422 422
423 423 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
424 424 >>$mail_msg_file
425 425 tail -3 $LINTOUT >>$mail_msg_file
426 426
427 427 rm -f ${LINTNOISE}.ref
428 428 if [ -f ${LINTNOISE}.out ]; then
429 429 mv ${LINTNOISE}.out ${LINTNOISE}.ref
430 430 fi
431 431 grep : $LINTOUT | \
432 432 egrep -v '^(real|user|sys)' |
433 433 egrep -v '(library construction)' | \
434 434 egrep -v ': global crosschecks' | \
435 435 egrep -v 'Ignoring unknown host' | \
436 436 egrep -v '\.c:$' | \
437 437 sort | uniq > ${LINTNOISE}.out
438 438 if [ ! -f ${LINTNOISE}.ref ]; then
439 439 cp ${LINTNOISE}.out ${LINTNOISE}.ref
440 440 fi
441 441
442 442 if [ "$dodiff" != "n" ]; then
443 443 echo "\n==== lint warnings $base ====\n" \
444 444 >>$mail_msg_file
445 445 # should be none, though there are a few that were filtered out
446 446 # above
447 447 egrep -i '(warning|lint):' ${LINTNOISE}.out \
448 448 | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file
449 449 if [[ -s $TMPDIR/lint_warns ]]; then
450 450 build_extras_ok=n
451 451 fi
452 452 echo "\n==== lint noise differences $base ====\n" \
453 453 >> $mail_msg_file
454 454 diff ${LINTNOISE}.ref ${LINTNOISE}.out \
455 455 >> $mail_msg_file
456 456 fi
457 457 }
458 458
459 459 #
460 460 # Build and install the onbld tools.
461 461 #
462 462 # usage: build_tools DESTROOT
463 463 #
464 464 # returns non-zero status if the build was successful.
465 465 #
466 466 function build_tools {
467 467 DESTROOT=$1
468 468
469 469 INSTALLOG=install-${MACH}
470 470
471 471 echo "\n==== Building tools at `date` ====\n" \
472 472 >> $LOGFILE
473 473
474 474 rm -f ${TOOLS}/${INSTALLOG}.out
475 475 cd ${TOOLS}
476 476 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
477 477 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
478 478
479 479 echo "\n==== Tools build errors ====\n" >> $mail_msg_file
480 480
481 481 egrep ":" ${TOOLS}/${INSTALLOG}.out |
482 482 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
483 483 egrep -v "Ignoring unknown host" | \
484 484 egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file
485 485
486 486 if [[ -s $TMPDIR/tools_errors ]]; then
487 487 return 1
488 488 fi
489 489 return 0
490 490 }
491 491
492 492 function staffer {
493 493 if [ $ISUSER -ne 0 ]; then
494 494 "$@"
495 495 else
496 496 arg="\"$1\""
497 497 shift
498 498 for i
499 499 do
500 500 arg="$arg \"$i\""
501 501 done
502 502 eval su $STAFFER -c \'$arg\'
503 503 fi
504 504 }
505 505
506 506 #
507 507 # Verify that the closed bins are present
508 508 #
509 509 function check_closed_bins {
510 510 if [[ -n "$ON_CLOSED_BINS" && ! -d "$ON_CLOSED_BINS" ]]; then
511 511 echo "ON_CLOSED_BINS must point to the closed binaries tree."
512 512 build_ok=n
513 513 exit 1
514 514 fi
515 515 }
516 516
517 517 #
518 518 # wrapper over wsdiff.
519 519 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
520 520 #
521 521 function do_wsdiff {
522 522 label=$1
523 523 oldproto=$2
524 524 newproto=$3
525 525
526 526 wsdiff="wsdiff"
527 527 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
528 528
529 529 echo "\n==== Getting object changes since last build at `date`" \
530 530 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
531 531 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
532 532 tee -a $LOGFILE >> $mail_msg_file
533 533 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
534 534 tee -a $LOGFILE >> $mail_msg_file
535 535 }
536 536
537 537 #
538 538 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
539 539 # together.
540 540 #
541 541
542 542 function set_non_debug_build_flags {
543 543 export RELEASE_BUILD ; RELEASE_BUILD=
544 544 unset EXTRA_OPTIONS
545 545 unset EXTRA_CFLAGS
546 546 }
547 547
548 548 function set_debug_build_flags {
549 549 unset RELEASE_BUILD
550 550 unset EXTRA_OPTIONS
551 551 unset EXTRA_CFLAGS
552 552 }
553 553
554 554
555 555 MACH=`uname -p`
556 556
557 557 if [ "$OPTHOME" = "" ]; then
558 558 OPTHOME=/opt
559 559 export OPTHOME
560 560 fi
561 561
562 562 USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
563 563
564 564 Where:
565 565 -i Fast incremental options (no clobber, lint, check)
566 566 -n Do not do a bringover
567 567 +t Use the build tools in $ONBLD_TOOLS/bin
568 568 -V VERS set the build version string to VERS
569 569
570 570 <env_file> file in Bourne shell syntax that sets and exports
571 571 variables that configure the operation of this script and many of
572 572 the scripts this one calls. If <env_file> does not exist,
573 573 it will be looked for in $OPTHOME/onbld/env.
574 574
575 575 non-DEBUG is the default build type. Build options can be set in the
576 576 NIGHTLY_OPTIONS variable in the <env_file> as follows:
577 577
578 578 -A check for ABI differences in .so files
579 579 -C check for cstyle/hdrchk errors
580 580 -D do a build with DEBUG on
581 581 -F do _not_ do a non-DEBUG build
582 582 -G gate keeper default group of options (-au)
583 583 -I integration engineer default group of options (-ampu)
584 584 -M do not run pmodes (safe file permission checker)
585 585 -N do not run protocmp
586 586 -R default group of options for building a release (-mp)
587 587 -U update proto area in the parent
588 588 -V VERS set the build version string to VERS
589 589 -f find unreferenced files
590 590 -i do an incremental build (no "make clobber")
591 591 -l do "make lint" in $LINTDIRS (default: $SRC y)
592 592 -m send mail to $MAILTO at end of build
593 593 -n do not do a bringover
594 594 -p create packages
595 595 -r check ELF runtime attributes in the proto area
596 596 -t build and use the tools in $SRC/tools (default setting)
597 597 +t Use the build tools in $ONBLD_TOOLS/bin
598 598 -u update proto_list_$MACH and friends in the parent workspace;
599 599 when used with -f, also build an unrefmaster.out in the parent
600 600 -w report on differences between previous and current proto areas
601 601 '
602 602 #
603 603 # A log file will be generated under the name $LOGFILE
604 604 # for partially completed build and log.`date '+%F'`
605 605 # in the same directory for fully completed builds.
606 606 #
607 607
608 608 # default values for low-level FLAGS; G I R are group FLAGS
609 609 A_FLAG=n
610 610 C_FLAG=n
611 611 D_FLAG=n
612 612 F_FLAG=n
613 613 f_FLAG=n
614 614 i_FLAG=n; i_CMD_LINE_FLAG=n
615 615 l_FLAG=n
616 616 M_FLAG=n
617 617 m_FLAG=n
618 618 N_FLAG=n
619 619 n_FLAG=n
620 620 p_FLAG=n
621 621 r_FLAG=n
622 622 t_FLAG=y
623 623 U_FLAG=n
624 624 u_FLAG=n
625 625 V_FLAG=n
626 626 w_FLAG=n
627 627 W_FLAG=n
628 628 #
629 629 build_ok=y
630 630 build_extras_ok=y
631 631
632 632 #
633 633 # examine arguments
634 634 #
635 635
636 636 OPTIND=1
637 637 while getopts +intV:W FLAG
638 638 do
639 639 case $FLAG in
640 640 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
641 641 ;;
642 642 n ) n_FLAG=y
643 643 ;;
644 644 +t ) t_FLAG=n
645 645 ;;
646 646 V ) V_FLAG=y
647 647 V_ARG="$OPTARG"
648 648 ;;
649 649 W ) W_FLAG=y
650 650 ;;
651 651 \? ) echo "$USAGE"
652 652 exit 1
653 653 ;;
654 654 esac
655 655 done
656 656
657 657 # correct argument count after options
658 658 shift `expr $OPTIND - 1`
659 659
660 660 # test that the path to the environment-setting file was given
661 661 if [ $# -ne 1 ]; then
662 662 echo "$USAGE"
663 663 exit 1
664 664 fi
665 665
666 666 # check if user is running nightly as root
667 667 # ISUSER is set non-zero if an ordinary user runs nightly, or is zero
668 668 # when root invokes nightly.
669 669 /usr/bin/id | grep '^uid=0(' >/dev/null 2>&1
670 670 ISUSER=$?; export ISUSER
671 671
672 672 #
673 673 # force locale to C
674 674 LANG=C; export LANG
675 675 LC_ALL=C; export LC_ALL
676 676 LC_COLLATE=C; export LC_COLLATE
677 677 LC_CTYPE=C; export LC_CTYPE
678 678 LC_MESSAGES=C; export LC_MESSAGES
679 679 LC_MONETARY=C; export LC_MONETARY
680 680 LC_NUMERIC=C; export LC_NUMERIC
681 681 LC_TIME=C; export LC_TIME
682 682
683 683 # clear environment variables we know to be bad for the build
684 684 unset LD_OPTIONS
685 685 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
686 686 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
687 687 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
688 688 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
689 689 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
690 690 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
691 691 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
692 692 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
693 693 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
694 694 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
695 695 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
696 696 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
697 697 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
698 698 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
699 699 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
700 700 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
701 701 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
702 702 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
703 703 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
704 704 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
705 705
706 706 unset CONFIG
707 707 unset GROUP
708 708 unset OWNER
709 709 unset REMOTE
710 710 unset ENV
711 711 unset ARCH
712 712 unset CLASSPATH
713 713 unset NAME
714 714
715 715 #
716 716 # To get ONBLD_TOOLS from the environment, it must come from the env file.
717 717 # If it comes interactively, it is generally TOOLS_PROTO, which will be
718 718 # clobbered before the compiler version checks, which will therefore fail.
719 719 #
720 720 unset ONBLD_TOOLS
721 721
722 722 #
723 723 # Setup environmental variables
724 724 #
725 725 if [ -f /etc/nightly.conf ]; then
726 726 . /etc/nightly.conf
727 727 fi
728 728
729 729 if [ -f $1 ]; then
730 730 if [[ $1 = */* ]]; then
731 731 . $1
732 732 else
733 733 . ./$1
734 734 fi
735 735 else
736 736 if [ -f $OPTHOME/onbld/env/$1 ]; then
737 737 . $OPTHOME/onbld/env/$1
738 738 else
739 739 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1"
740 740 exit 1
741 741 fi
742 742 fi
743 743
744 744 # contents of stdenv.sh inserted after next line:
745 745 # STDENV_START
746 746 # STDENV_END
747 747
748 748 # Check if we have sufficient data to continue...
749 749 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
750 750 if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
751 751 # Check if the gate data are valid if we don't do a "bringover" below
752 752 [[ -d "${CODEMGR_WS}" ]] || \
753 753 fatal_error "Error: ${CODEMGR_WS} is not a directory."
754 754 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
755 755 fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
756 756 fi
757 757
758 758 #
759 759 # place ourselves in a new task, respecting BUILD_PROJECT if set.
760 760 #
761 761 if [ -z "$BUILD_PROJECT" ]; then
762 762 /usr/bin/newtask -c $$
763 763 else
764 764 /usr/bin/newtask -c $$ -p $BUILD_PROJECT
765 765 fi
766 766
767 767 ps -o taskid= -p $$ | read build_taskid
768 768 ps -o project= -p $$ | read build_project
769 769
770 770 #
771 771 # See if NIGHTLY_OPTIONS is set
772 772 #
773 773 if [ "$NIGHTLY_OPTIONS" = "" ]; then
774 774 NIGHTLY_OPTIONS="-aBm"
775 775 fi
776 776
777 777 #
778 778 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
779 779 #
780 780 if [ "$BRINGOVER_WS" = "" ]; then
781 781 BRINGOVER_WS=$CLONE_WS
782 782 fi
783 783
784 784 #
785 785 # If BRINGOVER_FILES was not specified, default to usr
786 786 #
787 787 if [ "$BRINGOVER_FILES" = "" ]; then
788 788 BRINGOVER_FILES="usr"
789 789 fi
790 790
791 791 check_closed_bins
792 792
793 793 #
794 794 # Note: changes to the option letters here should also be applied to the
795 795 # bldenv script. `d' is listed for backward compatibility.
796 796 #
797 797 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
798 798 OPTIND=1
799 799 while getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS
800 800 do
801 801 case $FLAG in
802 802 A ) A_FLAG=y
803 803 ;;
804 804 B ) D_FLAG=y
805 805 ;; # old version of D
806 806 C ) C_FLAG=y
807 807 ;;
808 808 D ) D_FLAG=y
809 809 ;;
810 810 F ) F_FLAG=y
811 811 ;;
812 812 f ) f_FLAG=y
813 813 ;;
814 814 G ) u_FLAG=y
815 815 ;;
816 816 I ) m_FLAG=y
817 817 p_FLAG=y
818 818 u_FLAG=y
819 819 ;;
820 820 i ) i_FLAG=y
821 821 ;;
822 822 l ) l_FLAG=y
823 823 ;;
824 824 M ) M_FLAG=y
825 825 ;;
826 826 m ) m_FLAG=y
827 827 ;;
828 828 N ) N_FLAG=y
829 829 ;;
830 830 n ) n_FLAG=y
831 831 ;;
832 832 p ) p_FLAG=y
833 833 ;;
834 834 R ) m_FLAG=y
835 835 p_FLAG=y
836 836 ;;
837 837 r ) r_FLAG=y
838 838 ;;
839 839 +t ) t_FLAG=n
840 840 ;;
841 841 U ) if [ -z "${PARENT_ROOT}" ]; then
842 842 echo "PARENT_ROOT must be set if the U flag is" \
843 843 "present in NIGHTLY_OPTIONS."
844 844 exit 1
845 845 fi
846 846 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
847 847 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
848 848 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
849 849 fi
850 850 U_FLAG=y
851 851 ;;
852 852 u ) u_FLAG=y
853 853 ;;
854 854 w ) w_FLAG=y
855 855 ;;
856 856 W ) W_FLAG=y
857 857 ;;
858 858 \? ) echo "$USAGE"
859 859 exit 1
860 860 ;;
861 861 esac
862 862 done
863 863
864 864 if [ $ISUSER -ne 0 ]; then
865 865 # Set default value for STAFFER, if needed.
866 866 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
867 867 STAFFER=`/usr/xpg4/bin/id -un`
868 868 export STAFFER
869 869 fi
870 870 fi
871 871
872 872 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
873 873 MAILTO=$STAFFER
874 874 export MAILTO
875 875 fi
876 876
877 877 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
878 878 PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb"
879 879 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
880 880 export PATH
881 881
882 882 # roots of source trees, both relative to $SRC and absolute.
883 883 relsrcdirs="."
884 884 abssrcdirs="$SRC"
885 885
886 886 PROTOCMPTERSE="protocmp.terse -gu"
887 887 POUND_SIGN="#"
888 888 # have we set RELEASE_DATE in our env file?
889 889 if [ -z "$RELEASE_DATE" ]; then
890 890 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
891 891 fi
892 892 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
893 893 BASEWSDIR=$(basename $CODEMGR_WS)
894 894 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
895 895
896 896 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
897 897 # by avoiding repeated shell invocations to evaluate Makefile.master
898 898 # definitions.
899 899 export POUND_SIGN RELEASE_DATE DEV_CM
900 900
901 901 maketype="distributed"
902 902 if [[ -z "$MAKE" ]]; then
903 903 MAKE=dmake
904 904 elif [[ ! -x "$MAKE" ]]; then
905 905 echo "\$MAKE is set to garbage in the environment"
906 906 exit 1
907 907 fi
908 908 export PATH
909 909 export MAKE
910 910
911 911 if [ "${SUNWSPRO}" != "" ]; then
912 912 PATH="${SUNWSPRO}/bin:$PATH"
913 913 export PATH
914 914 fi
915 915
916 916 hostname=$(uname -n)
917 917 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
918 918 then
919 919 maxjobs=
920 920 if [[ -f $HOME/.make.machines ]]
921 921 then
922 922 # Note: there is a hard tab and space character in the []s
923 923 # below.
924 924 egrep -i "^[ ]*$hostname[ \.]" \
925 925 $HOME/.make.machines | read host jobs
926 926 maxjobs=${jobs##*=}
927 927 fi
928 928
929 929 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
930 930 then
931 931 # default
932 932 maxjobs=4
933 933 fi
934 934
935 935 export DMAKE_MAX_JOBS=$maxjobs
936 936 fi
937 937
938 938 DMAKE_MODE=parallel;
939 939 export DMAKE_MODE
940 940
941 941 if [ -z "${ROOT}" ]; then
942 942 echo "ROOT must be set."
943 943 exit 1
944 944 fi
945 945
946 946 #
947 947 # if -V flag was given, reset VERSION to V_ARG
948 948 #
949 949 if [ "$V_FLAG" = "y" ]; then
950 950 VERSION=$V_ARG
951 951 fi
952 952
953 953 TMPDIR="/tmp/nightly.tmpdir.$$"
954 954 export TMPDIR
955 955 rm -rf ${TMPDIR}
956 956 mkdir -p $TMPDIR || exit 1
957 957 chmod 777 $TMPDIR
958 958
959 959 #
960 960 # Work around folks who have historically used GCC_ROOT and convert it to
961 961 # GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could
962 962 # mess up the case where multiple different gcc versions are being used to
963 963 # shadow).
964 964 #
965 965 if [[ -n "${GCC_ROOT}" ]]; then
966 966 export GNUC_ROOT=${GCC_ROOT}
967 967 fi
968 968
969 969 #
970 970 # Tools should only be built non-DEBUG. Keep track of the tools proto
971 971 # area path relative to $TOOLS, because the latter changes in an
972 972 # export build.
973 973 #
974 974 # TOOLS_PROTO is included below for builds other than usr/src/tools
975 975 # that look for this location. For usr/src/tools, this will be
976 976 # overridden on the $MAKE command line in build_tools().
977 977 #
978 978 TOOLS=${SRC}/tools
979 979 TOOLS_PROTO_REL=proto/root_${MACH}-nd
980 980 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
981 981
982 982 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
983 983
984 984 # create directories that are automatically removed if the nightly script
985 985 # fails to start correctly
986 986 function newdir {
987 987 dir=$1
988 988 toadd=
989 989 while [ ! -d $dir ]; do
990 990 toadd="$dir $toadd"
991 991 dir=`dirname $dir`
992 992 done
993 993 torm=
994 994 newlist=
995 995 for dir in $toadd; do
996 996 if staffer mkdir $dir; then
997 997 newlist="$ISUSER $dir $newlist"
998 998 torm="$dir $torm"
999 999 else
1000 1000 [ -z "$torm" ] || staffer rmdir $torm
1001 1001 return 1
1002 1002 fi
1003 1003 done
1004 1004 newdirlist="$newlist $newdirlist"
1005 1005 return 0
1006 1006 }
1007 1007 newdirlist=
1008 1008
1009 1009 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
1010 1010
1011 1011 # since this script assumes the build is from full source, it nullifies
1012 1012 # variables likely to have been set by a "ws" script; nullification
1013 1013 # confines the search space for headers and libraries to the proto area
1014 1014 # built from this immediate source.
1015 1015 ENVLDLIBS1=
1016 1016 ENVLDLIBS2=
1017 1017 ENVLDLIBS3=
1018 1018 ENVCPPFLAGS1=
1019 1019 ENVCPPFLAGS2=
1020 1020 ENVCPPFLAGS3=
1021 1021 ENVCPPFLAGS4=
1022 1022 PARENT_ROOT=
1023 1023
1024 1024 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1025 1025 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
1026 1026
1027 1027 PKGARCHIVE_ORIG=$PKGARCHIVE
1028 1028
1029 1029 #
1030 1030 # Juggle the logs and optionally send mail on completion.
1031 1031 #
1032 1032
1033 1033 function logshuffle {
1034 1034 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
1035 1035 if [ -f $LLOG -o -d $LLOG ]; then
1036 1036 LLOG=$LLOG.$$
1037 1037 fi
1038 1038
1039 1039 rm -f "$ATLOG/latest" 2>/dev/null
1040 1040 mkdir -p $LLOG
1041 1041 export LLOG
1042 1042
1043 1043 if [ "$build_ok" = "y" ]; then
1044 1044 mv $ATLOG/proto_list_${MACH} $LLOG
1045 1045
1046 1046 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
1047 1047 mv $ATLOG/proto_list_tools_${MACH} $LLOG
1048 1048 fi
1049 1049
1050 1050 if [ -f $TMPDIR/wsdiff.results ]; then
1051 1051 mv $TMPDIR/wsdiff.results $LLOG
1052 1052 fi
1053 1053
1054 1054 if [ -f $TMPDIR/wsdiff-nd.results ]; then
1055 1055 mv $TMPDIR/wsdiff-nd.results $LLOG
1056 1056 fi
1057 1057 fi
1058 1058
1059 1059 #
1060 1060 # Now that we're about to send mail, it's time to check the noise
1061 1061 # file. In the event that an error occurs beyond this point, it will
1062 1062 # be recorded in the nightly.log file, but nowhere else. This would
1063 1063 # include only errors that cause the copying of the noise log to fail
1064 1064 # or the mail itself not to be sent.
1065 1065 #
1066 1066
1067 1067 exec >>$LOGFILE 2>&1
1068 1068 if [ -s $build_noise_file ]; then
1069 1069 echo "\n==== Nightly build noise ====\n" |
1070 1070 tee -a $LOGFILE >>$mail_msg_file
1071 1071 cat $build_noise_file >>$LOGFILE
1072 1072 cat $build_noise_file >>$mail_msg_file
1073 1073 echo | tee -a $LOGFILE >>$mail_msg_file
1074 1074 fi
1075 1075 rm -f $build_noise_file
1076 1076
1077 1077 case "$build_ok" in
1078 1078 y)
1079 1079 state=Completed
1080 1080 ;;
1081 1081 i)
1082 1082 state=Interrupted
1083 1083 ;;
1084 1084 *)
1085 1085 state=Failed
1086 1086 ;;
1087 1087 esac
1088 1088
1089 1089 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
1090 1090 state=Failed
1091 1091 fi
1092 1092
1093 1093 NIGHTLY_STATUS=$state
1094 1094 export NIGHTLY_STATUS
1095 1095
1096 1096 run_hook POST_NIGHTLY $state
1097 1097 run_hook SYS_POST_NIGHTLY $state
1098 1098
1099 1099 #
1100 1100 # mailx(1) sets From: based on the -r flag
1101 1101 # if it is given.
1102 1102 #
1103 1103 mailx_r=
1104 1104 if [[ -n "${MAILFROM}" ]]; then
1105 1105 mailx_r="-r ${MAILFROM}"
1106 1106 fi
1107 1107
1108 1108 cat $build_time_file $build_environ_file $mail_msg_file \
1109 1109 > ${LLOG}/mail_msg
1110 1110 if [ "$m_FLAG" = "y" ]; then
1111 1111 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1112 1112 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1113 1113 ${MAILTO}
1114 1114 fi
1115 1115
1116 1116 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1117 1117 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH}
1118 1118 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log
1119 1119 fi
1120 1120
1121 1121 mv $LOGFILE $LLOG
1122 1122
1123 1123 ln -s "$LLOG" "$ATLOG/latest"
1124 1124 }
1125 1125
1126 1126 #
1127 1127 # Remove the locks and temporary files on any exit
1128 1128 #
1129 1129 function cleanup {
1130 1130 logshuffle
1131 1131
1132 1132 [ -z "$lockfile" ] || staffer rm -f $lockfile
1133 1133 [ -z "$atloglockfile" ] || rm -f $atloglockfile
1134 1134 [ -z "$ulockfile" ] || staffer rm -f $ulockfile
1135 1135 [ -z "$Ulockfile" ] || rm -f $Ulockfile
1136 1136
1137 1137 set -- $newdirlist
1138 1138 while [ $# -gt 0 ]; do
1139 1139 ISUSER=$1 staffer rmdir $2
1140 1140 shift; shift
1141 1141 done
1142 1142 rm -rf $TMPDIR
1143 1143 }
1144 1144
1145 1145 function cleanup_signal {
1146 1146 build_ok=i
1147 1147 # this will trigger cleanup(), above.
1148 1148 exit 1
1149 1149 }
1150 1150
1151 1151 trap cleanup 0
1152 1152 trap cleanup_signal 1 2 3 15
1153 1153
1154 1154 #
1155 1155 # Generic lock file processing -- make sure that the lock file doesn't
1156 1156 # exist. If it does, it should name the build host and PID. If it
1157 1157 # doesn't, then make sure we can create it. Clean up locks that are
1158 1158 # known to be stale (assumes host name is unique among build systems
1159 1159 # for the workspace).
1160 1160 #
1161 1161 function create_lock {
1162 1162 lockf=$1
1163 1163 lockvar=$2
1164 1164
1165 1165 ldir=`dirname $lockf`
1166 1166 [ -d $ldir ] || newdir $ldir || exit 1
1167 1167 eval $lockvar=$lockf
1168 1168
1169 1169 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1170 1170 basews=`basename $CODEMGR_WS`
1171 1171 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1172 1172 if [ "$host" != "$hostname" ]; then
1173 1173 echo "$MACH build of $basews apparently" \
1174 1174 "already started by $user on $host as $pid."
1175 1175 exit 1
1176 1176 elif kill -s 0 $pid 2>/dev/null; then
1177 1177 echo "$MACH build of $basews already started" \
1178 1178 "by $user as $pid."
1179 1179 exit 1
1180 1180 else
1181 1181 # stale lock; clear it out and try again
1182 1182 rm -f $lockf
1183 1183 fi
1184 1184 done
1185 1185 }
1186 1186
1187 1187 #
1188 1188 # Return the list of interesting proto areas, depending on the current
1189 1189 # options.
1190 1190 #
1191 1191 function allprotos {
1192 1192 typeset roots="$ROOT"
1193 1193
1194 1194 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1195 1195 roots="$roots $ROOT-nd"
1196 1196 fi
1197 1197
1198 1198 echo $roots
1199 1199 }
1200 1200
1201 1201 # Ensure no other instance of this script is running on this host.
1202 1202 # LOCKNAME can be set in <env_file>, and is by default, but is not
1203 1203 # required due to the use of $ATLOG below.
1204 1204 if [ -n "$LOCKNAME" ]; then
1205 1205 create_lock /tmp/$LOCKNAME "lockfile"
1206 1206 fi
1207 1207 #
1208 1208 # Create from one, two, or three other locks:
1209 1209 # $ATLOG/nightly.lock
1210 1210 # - protects against multiple builds in same workspace
1211 1211 # $PARENT_WS/usr/src/nightly.$MACH.lock
1212 1212 # - protects against multiple 'u' copy-backs
1213 1213 # $NIGHTLY_PARENT_ROOT/nightly.lock
1214 1214 # - protects against multiple 'U' copy-backs
1215 1215 #
1216 1216 # Overriding ISUSER to 1 causes the lock to be created as root if the
1217 1217 # script is run as root. The default is to create it as $STAFFER.
1218 1218 ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile"
1219 1219 if [ "$u_FLAG" = "y" ]; then
1220 1220 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile"
1221 1221 fi
1222 1222 if [ "$U_FLAG" = "y" ]; then
1223 1223 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1224 1224 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile"
1225 1225 fi
1226 1226
1227 1227 # Locks have been taken, so we're doing a build and we're committed to
1228 1228 # the directories we may have created so far.
1229 1229 newdirlist=
1230 1230
1231 1231 #
1232 1232 # Create mail_msg_file
1233 1233 #
1234 1234 mail_msg_file="${TMPDIR}/mail_msg"
1235 1235 touch $mail_msg_file
1236 1236 build_time_file="${TMPDIR}/build_time"
1237 1237 build_environ_file="${TMPDIR}/build_environ"
1238 1238 touch $build_environ_file
1239 1239 #
1240 1240 # Move old LOGFILE aside
1241 1241 # ATLOG directory already made by 'create_lock' above
1242 1242 #
1243 1243 if [ -f $LOGFILE ]; then
1244 1244 mv -f $LOGFILE ${LOGFILE}-
1245 1245 fi
1246 1246 #
1247 1247 # Build OsNet source
1248 1248 #
1249 1249 START_DATE=`date`
1250 1250 SECONDS=0
1251 1251 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1252 1252 | tee -a $LOGFILE > $build_time_file
1253 1253
1254 1254 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1255 1255 tee -a $mail_msg_file >> $LOGFILE
1256 1256
1257 1257 # make sure we log only to the nightly build file
1258 1258 build_noise_file="${TMPDIR}/build_noise"
1259 1259 exec </dev/null >$build_noise_file 2>&1
1260 1260
1261 1261 run_hook SYS_PRE_NIGHTLY
1262 1262 run_hook PRE_NIGHTLY
1263 1263
1264 1264 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1265 1265 env >> $LOGFILE
1266 1266
1267 1267 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1268 1268
1269 1269 if [ "$N_FLAG" = "y" ]; then
1270 1270 if [ "$p_FLAG" = "y" ]; then
1271 1271 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1272 1272 WARNING: the p option (create packages) is set, but so is the N option (do
1273 1273 not run protocmp); this is dangerous; you should unset the N option
1274 1274 EOF
1275 1275 else
1276 1276 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1277 1277 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1278 1278 EOF
1279 1279 fi
1280 1280 echo "" | tee -a $mail_msg_file >> $LOGFILE
1281 1281 fi
1282 1282
1283 1283 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1284 1284 #
1285 1285 # In the past we just complained but went ahead with the lint
1286 1286 # pass, even though the proto area was built non-DEBUG. It's
1287 1287 # unlikely that non-DEBUG headers will make a difference, but
1288 1288 # rather than assuming it's a safe combination, force the user
1289 1289 # to specify a DEBUG build.
1290 1290 #
1291 1291 echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1292 1292 | tee -a $mail_msg_file >> $LOGFILE
1293 1293 l_FLAG=n
1294 1294 fi
1295 1295
1296 1296 if [ "$f_FLAG" = "y" ]; then
1297 1297 if [ "$i_FLAG" = "y" ]; then
1298 1298 echo "WARNING: the -f flag cannot be used during incremental" \
1299 1299 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1300 1300 f_FLAG=n
1301 1301 fi
1302 1302 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then
1303 1303 echo "WARNING: the -f flag requires -l, and -p;" \
1304 1304 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1305 1305 f_FLAG=n
1306 1306 fi
1307 1307 fi
1308 1308
1309 1309 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1310 1310 echo "WARNING: -w specified, but $ROOT does not exist;" \
1311 1311 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE
1312 1312 w_FLAG=n
1313 1313 fi
1314 1314
1315 1315 case $MULTI_PROTO in
1316 1316 yes|no) ;;
1317 1317 *)
1318 1318 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1319 1319 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1320 1320 echo "Setting MULTI_PROTO to \"no\".\n" | \
1321 1321 tee -a $mail_msg_file >> $LOGFILE
1322 1322 export MULTI_PROTO=no
1323 1323 ;;
1324 1324 esac
1325 1325
1326 1326 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1327 1327 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1328 1328
1329 1329 # Save the current proto area if we're comparing against the last build
1330 1330 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1331 1331 if [ -d "$ROOT.prev" ]; then
1332 1332 rm -rf $ROOT.prev
1333 1333 fi
1334 1334 mv $ROOT $ROOT.prev
1335 1335 fi
1336 1336
1337 1337 # Same for non-DEBUG proto area
1338 1338 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1339 1339 if [ -d "$ROOT-nd.prev" ]; then
1340 1340 rm -rf $ROOT-nd.prev
1341 1341 fi
1342 1342 mv $ROOT-nd $ROOT-nd.prev
1343 1343 fi
1344 1344
1345 1345 #
1346 1346 # Echo the SCM type of the parent workspace, this can't just be which_scm
1347 1347 # as that does not know how to identify various network repositories.
1348 1348 #
1349 1349 function parent_wstype {
1350 1350 typeset scm_type junk
1351 1351
1352 1352 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1353 1353 | read scm_type junk
1354 1354 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1355 1355 # Probe BRINGOVER_WS to determine its type
1356 1356 if [[ $BRINGOVER_WS == ssh://* ]]; then
1357 1357 scm_type="mercurial"
1358 1358 elif [[ $BRINGOVER_WS == http://* ]] && \
1359 1359 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1360 1360 egrep -s "application/mercurial" 2> /dev/null; then
1361 1361 scm_type="mercurial"
1362 1362 else
1363 1363 scm_type="none"
1364 1364 fi
1365 1365 fi
1366 1366
1367 1367 # fold both unsupported and unrecognized results into "none"
1368 1368 case "$scm_type" in
1369 1369 mercurial)
1370 1370 ;;
1371 1371 *) scm_type=none
1372 1372 ;;
1373 1373 esac
1374 1374
1375 1375 echo $scm_type
1376 1376 }
1377 1377
1378 1378 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1379 1379 function child_wstype {
1380 1380 typeset scm_type junk
1381 1381
1382 1382 # Probe CODEMGR_WS to determine its type
1383 1383 if [[ -d $CODEMGR_WS ]]; then
1384 1384 $WHICH_SCM | read scm_type junk || exit 1
1385 1385 fi
1386 1386
1387 1387 case "$scm_type" in
1388 1388 none|git|mercurial)
1389 1389 ;;
1390 1390 *) scm_type=none
1391 1391 ;;
1392 1392 esac
1393 1393
1394 1394 echo $scm_type
1395 1395 }
1396 1396
1397 1397 SCM_TYPE=$(child_wstype)
1398 1398
1399 1399 #
1400 1400 # Decide whether to clobber
1401 1401 #
1402 1402 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1403 1403 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1404 1404
1405 1405 cd $SRC
1406 1406 # remove old clobber file
1407 1407 rm -f $SRC/clobber.out
1408 1408 rm -f $SRC/clobber-${MACH}.out
1409 1409
1410 1410 # Remove all .make.state* files, just in case we are restarting
1411 1411 # the build after having interrupted a previous 'make clobber'.
1412 1412 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1413 1413 -o -name 'interfaces.*' \) -prune \
1414 1414 -o -name '.make.*' -print | xargs rm -f
1415 1415
1416 1416 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1417 1417 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1418 1418 grep "$MAKE:" $SRC/clobber-${MACH}.out |
1419 1419 egrep -v "Ignoring unknown host" | \
1420 1420 tee $TMPDIR/clobber_errs >> $mail_msg_file
1421 1421
1422 1422 if [[ -s $TMPDIR/clobber_errs ]]; then
1423 1423 build_extras_ok=n
1424 1424 fi
1425 1425
1426 1426 if [[ "$t_FLAG" = "y" ]]; then
1427 1427 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1428 1428 cd ${TOOLS}
1429 1429 rm -f ${TOOLS}/clobber-${MACH}.out
1430 1430 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1431 1431 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1432 1432 echo "\n==== Make tools clobber ERRORS ====\n" \
1433 1433 >> $mail_msg_file
1434 1434 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1435 1435 >> $mail_msg_file
1436 1436 if (( $? == 0 )); then
1437 1437 build_extras_ok=n
1438 1438 fi
1439 1439 rm -rf ${TOOLS_PROTO}
1440 1440 mkdir -p ${TOOLS_PROTO}
1441 1441 fi
1442 1442
1443 1443 typeset roots=$(allprotos)
1444 1444 echo "\n\nClearing $roots" >> "$LOGFILE"
1445 1445 rm -rf $roots
1446 1446
1447 1447 # Get back to a clean workspace as much as possible to catch
1448 1448 # problems that only occur on fresh workspaces.
1449 1449 # Remove all .make.state* files, libraries, and .o's that may
1450 1450 # have been omitted from clobber. A couple of libraries are
1451 1451 # under source code control, so leave them alone.
1452 1452 # We should probably blow away temporary directories too.
1453 1453 cd $SRC
1454 1454 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1455 1455 -o -name .git -o -name 'interfaces.*' \) -prune -o \
1456 1456 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1457 1457 -name '*.o' \) -print | \
1458 1458 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
1459 1459 else
1460 1460 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1461 1461 fi
1462 1462
1463 1463 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
1464 1464 typeset -x PATH=$PATH
1465 1465
1466 1466 # If the repository doesn't exist yet, then we want to populate it.
1467 1467 if [[ ! -d $CODEMGR_WS/.hg ]]; then
1468 1468 staffer hg init $CODEMGR_WS
1469 1469 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
1470 1470 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
1471 1471 touch $TMPDIR/new_repository
1472 1472 fi
1473 1473
1474 1474 typeset -x HGMERGE="/bin/false"
1475 1475
1476 1476 #
1477 1477 # If the user has changes, regardless of whether those changes are
1478 1478 # committed, and regardless of whether those changes conflict, then
1479 1479 # we'll attempt to merge them either implicitly (uncommitted) or
1480 1480 # explicitly (committed).
1481 1481 #
1482 1482 # These are the messages we'll use to help clarify mercurial output
1483 1483 # in those cases.
1484 1484 #
1485 1485 typeset mergefailmsg="\
1486 1486 ***\n\
1487 1487 *** nightly was unable to automatically merge your changes. You should\n\
1488 1488 *** redo the full merge manually, following the steps outlined by mercurial\n\
1489 1489 *** above, then restart nightly.\n\
1490 1490 ***\n"
1491 1491 typeset mergepassmsg="\
1492 1492 ***\n\
1493 1493 *** nightly successfully merged your changes. This means that your working\n\
1494 1494 *** directory has been updated, but those changes are not yet committed.\n\
1495 1495 *** After nightly completes, you should validate the results of the merge,\n\
1496 1496 *** then use hg commit manually.\n\
1497 1497 ***\n"
1498 1498
1499 1499 #
1500 1500 # For each repository in turn:
1501 1501 #
1502 1502 # 1. Do the pull. If this fails, dump the output and bail out.
1503 1503 #
1504 1504 # 2. If the pull resulted in an extra head, do an explicit merge.
1505 1505 # If this fails, dump the output and bail out.
1506 1506 #
1507 1507 # Because we can't rely on Mercurial to exit with a failure code
1508 1508 # when a merge fails (Mercurial issue #186), we must grep the
1509 1509 # output of pull/merge to check for attempted and/or failed merges.
1510 1510 #
1511 1511 # 3. If a merge failed, set the message and fail the bringover.
1512 1512 #
1513 1513 # 4. Otherwise, if a merge succeeded, set the message
1514 1514 #
1515 1515 # 5. Dump the output, and any message from step 3 or 4.
1516 1516 #
1517 1517
1518 1518 typeset HG_SOURCE=$BRINGOVER_WS
1519 1519 if [ ! -f $TMPDIR/new_repository ]; then
1520 1520 HG_SOURCE=$TMPDIR/open_bundle.hg
1521 1521 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
1522 1522 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
1523 1523
1524 1524 #
1525 1525 # If there are no incoming changesets, then incoming will
1526 1526 # fail, and there will be no bundle file. Reset the source,
1527 1527 # to allow the remaining logic to complete with no false
1528 1528 # negatives. (Unlike incoming, pull will return success
1529 1529 # for the no-change case.)
1530 1530 #
1531 1531 if (( $? != 0 )); then
1532 1532 HG_SOURCE=$BRINGOVER_WS
1533 1533 fi
1534 1534 fi
1535 1535
1536 1536 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
1537 1537 > $TMPDIR/pull_open.out 2>&1
1538 1538 if (( $? != 0 )); then
1539 1539 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
1540 1540 cat $TMPDIR/pull_open.out
1541 1541 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1542 1542 printf "$mergefailmsg"
1543 1543 fi
1544 1544 touch $TMPDIR/bringover_failed
1545 1545 return
1546 1546 fi
1547 1547
1548 1548 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1549 1549 staffer hg --cwd $CODEMGR_WS merge \
1550 1550 >> $TMPDIR/pull_open.out 2>&1
1551 1551 if (( $? != 0 )); then
1552 1552 printf "%s: merge failed as follows:\n\n" \
1553 1553 "$CODEMGR_WS"
1554 1554 cat $TMPDIR/pull_open.out
1555 1555 if grep "^merging.*failed" $TMPDIR/pull_open.out \
1556 1556 > /dev/null 2>&1; then
1557 1557 printf "$mergefailmsg"
1558 1558 fi
1559 1559 touch $TMPDIR/bringover_failed
1560 1560 return
1561 1561 fi
1562 1562 fi
1563 1563
1564 1564 printf "updated %s with the following results:\n" "$CODEMGR_WS"
1565 1565 cat $TMPDIR/pull_open.out
1566 1566 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
1567 1567 printf "$mergepassmsg"
1568 1568 fi
1569 1569 printf "\n"
1570 1570
1571 1571 #
1572 1572 # Per-changeset output is neither useful nor manageable for a
1573 1573 # newly-created repository.
1574 1574 #
1575 1575 if [ -f $TMPDIR/new_repository ]; then
1576 1576 return
1577 1577 fi
1578 1578
1579 1579 printf "\nadded the following changesets to open repository:\n"
1580 1580 cat $TMPDIR/incoming_open.out
1581 1581 }
1582 1582
1583 1583 type bringover_none > /dev/null 2>&1 || function bringover_none {
1584 1584 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1585 1585 touch $TMPDIR/bringover_failed
1586 1586 }
1587 1587
1588 1588 #
1589 1589 # Decide whether to bringover to the codemgr workspace
1590 1590 #
1591 1591 if [ "$n_FLAG" = "n" ]; then
1592 1592 PARENT_SCM_TYPE=$(parent_wstype)
1593 1593
1594 1594 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
1595 1595 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
1596 1596 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
1597 1597 exit 1
1598 1598 fi
1599 1599
1600 1600 run_hook PRE_BRINGOVER
1601 1601
1602 1602 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
1603 1603 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
1604 1604
1605 1605 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
1606 1606 tee -a $mail_msg_file >> $LOGFILE
1607 1607
1608 1608 if [ -f $TMPDIR/bringover_failed ]; then
1609 1609 rm -f $TMPDIR/bringover_failed
1610 1610 build_ok=n
1611 1611 echo "trouble with bringover, quitting at `date`." |
1612 1612 tee -a $mail_msg_file >> $LOGFILE
1613 1613 exit 1
1614 1614 fi
1615 1615
1616 1616 #
1617 1617 # It's possible that we used the bringover above to create
1618 1618 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
1619 1619 # but should now be the same as $BRINGOVER_WS.
1620 1620 #
1621 1621 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
1622 1622
1623 1623 run_hook POST_BRINGOVER
1624 1624
1625 1625 check_closed_bins
1626 1626
1627 1627 else
1628 1628 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
1629 1629 fi
1630 1630
1631 1631 # Safeguards
1632 1632 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1633 1633 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
1634 1634 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1635 1635
1636 1636 if [[ "$t_FLAG" = "y" ]]; then
1637 1637 echo "\n==== Bootstrapping cw ====\n" >> $LOGFILE
1638 1638 ( cd ${TOOLS}
1639 1639 set_non_debug_build_flags
1640 1640 rm -f $TMPDIR/make-state
1641 1641 $MAKE -K $TMPDIR/make-state -e TARGET=install cw 2>&1 >> $LOGFILE
1642 1642 [[ "$?" -ne 0 ]] && fatal_error "Error: could not bootstrap cw"
1643 1643 )
1644 1644
1645 1645 # Switch ONBLD_TOOLS early if -t is specified so that
1646 1646 # we could use bootstrapped cw for compiler checks.
1647 1647 ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld
1648 1648 export ONBLD_TOOLS
1649 1649 fi
1650 1650
1651 1651 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
1652 1652
1653 1653 # System
1654 1654 whence uname | tee -a $build_environ_file >> $LOGFILE
1655 1655 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
1656 1656 echo | tee -a $build_environ_file >> $LOGFILE
1657 1657
1658 1658 # make
1659 1659 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
1660 1660 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
1661 1661 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
1662 1662 tee -a $build_environ_file >> $LOGFILE
1663 1663
1664 1664 #
1665 1665 # Report the compiler versions.
↓ open down ↓ |
1665 lines elided |
↑ open up ↑ |
1666 1666 #
1667 1667
1668 1668 if [[ ! -f $SRC/Makefile ]]; then
1669 1669 build_ok=n
1670 1670 echo "\nUnable to find \"Makefile\" in $SRC." | \
1671 1671 tee -a $build_environ_file >> $LOGFILE
1672 1672 exit 1
1673 1673 fi
1674 1674
1675 1675 ( cd $SRC
1676 - for target in cc-version cc64-version java-version openssl-version; do
1676 + for target in cc-version java-version openssl-version; do
1677 1677 echo
1678 1678 #
1679 1679 # Put statefile somewhere we know we can write to rather than trip
1680 1680 # over a read-only $srcroot.
1681 1681 #
1682 1682 rm -f $TMPDIR/make-state
1683 1683 export SRC
1684 1684 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
1685 1685 continue
1686 1686 fi
1687 1687 touch $TMPDIR/nocompiler
1688 1688 done
1689 1689 echo
1690 1690 ) | tee -a $build_environ_file >> $LOGFILE
1691 1691
1692 1692 if [ -f $TMPDIR/nocompiler ]; then
1693 1693 rm -f $TMPDIR/nocompiler
1694 1694 build_ok=n
1695 1695 echo "Aborting due to missing compiler." |
1696 1696 tee -a $build_environ_file >> $LOGFILE
1697 1697 exit 1
1698 1698 fi
1699 1699
1700 1700 # as
1701 1701 whence as | tee -a $build_environ_file >> $LOGFILE
1702 1702 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
1703 1703 echo | tee -a $build_environ_file >> $LOGFILE
1704 1704
1705 1705 # Check that we're running a capable link-editor
1706 1706 whence ld | tee -a $build_environ_file >> $LOGFILE
1707 1707 LDVER=`ld -V 2>&1`
1708 1708 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
1709 1709 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1710 1710 if [ `expr $LDVER \< 422` -eq 1 ]; then
1711 1711 echo "The link-editor needs to be at version 422 or higher to build" | \
1712 1712 tee -a $build_environ_file >> $LOGFILE
1713 1713 echo "the latest stuff. Hope your build works." | \
1714 1714 tee -a $build_environ_file >> $LOGFILE
1715 1715 fi
1716 1716
1717 1717 #
1718 1718 # Build and use the workspace's tools if requested
1719 1719 #
1720 1720 if [[ "$t_FLAG" = "y" ]]; then
1721 1721 set_non_debug_build_flags
1722 1722
1723 1723 build_tools ${TOOLS_PROTO}
1724 1724 if (( $? != 0 )); then
1725 1725 build_ok=n
1726 1726 else
1727 1727 STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs
1728 1728 export STABS
1729 1729 CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs
1730 1730 export CTFSTABS
1731 1731 GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets
1732 1732 export GENOFFSETS
1733 1733
1734 1734 CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert
1735 1735 export CTFCONVERT
1736 1736 CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge
1737 1737 export CTFMERGE
1738 1738
1739 1739 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
1740 1740 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
1741 1741 export PATH
1742 1742
1743 1743 echo "\n==== New environment settings. ====\n" >> $LOGFILE
1744 1744 echo "STABS=${STABS}" >> $LOGFILE
1745 1745 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
1746 1746 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
1747 1747 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
1748 1748 echo "PATH=${PATH}" >> $LOGFILE
1749 1749 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
1750 1750 fi
1751 1751 fi
1752 1752
1753 1753 # timestamp the start of the normal build; the findunref tool uses it.
1754 1754 touch $SRC/.build.tstamp
1755 1755
1756 1756 normal_build
1757 1757
1758 1758 ORIG_SRC=$SRC
1759 1759 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
1760 1760
1761 1761
1762 1762 #
1763 1763 # There are several checks that need to look at the proto area, but
1764 1764 # they only need to look at one, and they don't care whether it's
1765 1765 # DEBUG or non-DEBUG.
1766 1766 #
1767 1767 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
1768 1768 checkroot=$ROOT-nd
1769 1769 else
1770 1770 checkroot=$ROOT
1771 1771 fi
1772 1772
1773 1773 if [ "$build_ok" = "y" ]; then
1774 1774 echo "\n==== Creating protolist system file at `date` ====" \
1775 1775 >> $LOGFILE
1776 1776 protolist $checkroot > $ATLOG/proto_list_${MACH}
1777 1777 echo "==== protolist system file created at `date` ====\n" \
1778 1778 >> $LOGFILE
1779 1779
1780 1780 if [ "$N_FLAG" != "y" ]; then
1781 1781
1782 1782 E1=
1783 1783 f1=
1784 1784 for f in $f1; do
1785 1785 if [ -f "$f" ]; then
1786 1786 E1="$E1 -e $f"
1787 1787 fi
1788 1788 done
1789 1789
1790 1790 E2=
1791 1791 f2=
1792 1792 if [ -d "$SRC/pkg" ]; then
1793 1793 f2="$f2 exceptions/packaging"
1794 1794 fi
1795 1795
1796 1796 for f in $f2; do
1797 1797 if [ -f "$f" ]; then
1798 1798 E2="$E2 -e $f"
1799 1799 fi
1800 1800 done
1801 1801 fi
1802 1802
1803 1803 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
1804 1804 echo "\n==== Validating manifests against proto area ====\n" \
1805 1805 >> $mail_msg_file
1806 1806 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \
1807 1807 tee $TMPDIR/protocmp_noise >> $mail_msg_file
1808 1808 if [[ -s $TMPDIR/protocmp_noise ]]; then
1809 1809 build_extras_ok=n
1810 1810 fi
1811 1811 fi
1812 1812
1813 1813 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1814 1814 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1815 1815 if [ -n "$E2" ]; then
1816 1816 ELIST=$E2
1817 1817 else
1818 1818 ELIST=$E1
1819 1819 fi
1820 1820 $PROTOCMPTERSE \
1821 1821 "Files in yesterday's proto area, but not today's:" \
1822 1822 "Files in today's proto area, but not yesterday's:" \
1823 1823 "Files that changed between yesterday and today:" \
1824 1824 ${ELIST} \
1825 1825 -d $REF_PROTO_LIST \
1826 1826 $ATLOG/proto_list_${MACH} \
1827 1827 >> $mail_msg_file
1828 1828 fi
1829 1829 fi
1830 1830
1831 1831 if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \
1832 1832 "$build_extras_ok" == "y" ]]; then
1833 1833 staffer cp $ATLOG/proto_list_${MACH} \
1834 1834 $PARENT_WS/usr/src/proto_list_${MACH}
1835 1835 fi
1836 1836
1837 1837 # Update parent proto area if necessary. This is done now
1838 1838 # so that the proto area has either DEBUG or non-DEBUG kernels.
1839 1839 # Note that this clears out the lock file, so we can dispense with
1840 1840 # the variable now.
1841 1841 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1842 1842 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1843 1843 tee -a $LOGFILE >> $mail_msg_file
1844 1844 rm -rf $NIGHTLY_PARENT_ROOT/*
1845 1845 unset Ulockfile
1846 1846 mkdir -p $NIGHTLY_PARENT_ROOT
1847 1847 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1848 1848 ( cd $ROOT; tar cf - . |
1849 1849 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 |
1850 1850 tee -a $mail_msg_file >> $LOGFILE
1851 1851 fi
1852 1852 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
1853 1853 rm -rf $NIGHTLY_PARENT_ROOT-nd/*
1854 1854 mkdir -p $NIGHTLY_PARENT_ROOT-nd
1855 1855 cd $ROOT-nd
1856 1856 ( tar cf - . |
1857 1857 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
1858 1858 tee -a $mail_msg_file >> $LOGFILE
1859 1859 fi
1860 1860 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1861 1861 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1862 1862 tee -a $LOGFILE >> $mail_msg_file
1863 1863 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1864 1864 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
1865 1865 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1866 1866 ( cd $TOOLS_PROTO; tar cf - . |
1867 1867 ( cd $NIGHTLY_PARENT_TOOLS_ROOT;
1868 1868 umask 0; tar xpf - ) ) 2>&1 |
1869 1869 tee -a $mail_msg_file >> $LOGFILE
1870 1870 fi
1871 1871 fi
1872 1872 fi
1873 1873
1874 1874 #
1875 1875 # ELF verification: ABI (-A) and runtime (-r) checks
1876 1876 #
1877 1877 if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then
1878 1878 # Directory ELF-data.$MACH holds the files produced by these tests.
1879 1879 elf_ddir=$SRC/ELF-data.$MACH
1880 1880
1881 1881 # If there is a previous ELF-data backup directory, remove it. Then,
1882 1882 # rotate current ELF-data directory into its place and create a new
1883 1883 # empty directory
1884 1884 rm -rf $elf_ddir.ref
1885 1885 if [[ -d $elf_ddir ]]; then
1886 1886 mv $elf_ddir $elf_ddir.ref
1887 1887 fi
1888 1888 mkdir -p $elf_ddir
1889 1889
1890 1890 # Call find_elf to produce a list of the ELF objects in the proto area.
1891 1891 # This list is passed to check_rtime and interface_check, preventing
1892 1892 # them from separately calling find_elf to do the same work twice.
1893 1893 find_elf -fr $checkroot > $elf_ddir/object_list
1894 1894
1895 1895 if [[ $A_FLAG = y ]]; then
1896 1896 echo "\n==== Check versioning and ABI information ====\n" | \
1897 1897 tee -a $LOGFILE >> $mail_msg_file
1898 1898
1899 1899 # Produce interface description for the proto. Report errors.
1900 1900 interface_check -o -w $elf_ddir -f object_list \
1901 1901 -i interface -E interface.err
1902 1902 if [[ -s $elf_ddir/interface.err ]]; then
1903 1903 tee -a $LOGFILE < $elf_ddir/interface.err \
1904 1904 >> $mail_msg_file
1905 1905 build_extras_ok=n
1906 1906 fi
1907 1907
1908 1908 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1909 1909 # description file to that from the baseline gate. Issue a
1910 1910 # warning if the baseline is not present, and keep going.
1911 1911 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1912 1912 base_ifile="$ELF_DATA_BASELINE_DIR/interface"
1913 1913
1914 1914 echo "\n==== Compare versioning and ABI information" \
1915 1915 "to baseline ====\n" | \
1916 1916 tee -a $LOGFILE >> $mail_msg_file
1917 1917 echo "Baseline: $base_ifile\n" >> $LOGFILE
1918 1918
1919 1919 if [[ -f $base_ifile ]]; then
1920 1920 interface_cmp -d -o $base_ifile \
1921 1921 $elf_ddir/interface > $elf_ddir/interface.cmp
1922 1922 if [[ -s $elf_ddir/interface.cmp ]]; then
1923 1923 echo | tee -a $LOGFILE >> $mail_msg_file
1924 1924 tee -a $LOGFILE < \
1925 1925 $elf_ddir/interface.cmp \
1926 1926 >> $mail_msg_file
1927 1927 build_extras_ok=n
1928 1928 fi
1929 1929 else
1930 1930 echo "baseline not available. comparison" \
1931 1931 "skipped" | \
1932 1932 tee -a $LOGFILE >> $mail_msg_file
1933 1933 fi
1934 1934
1935 1935 fi
1936 1936 fi
1937 1937
1938 1938 if [[ $r_FLAG = y ]]; then
1939 1939 echo "\n==== Check ELF runtime attributes ====\n" | \
1940 1940 tee -a $LOGFILE >> $mail_msg_file
1941 1941
1942 1942 # If we're doing a DEBUG build the proto area will be left
1943 1943 # with debuggable objects, thus don't assert -s.
1944 1944 if [[ $D_FLAG = y ]]; then
1945 1945 rtime_sflag=""
1946 1946 else
1947 1947 rtime_sflag="-s"
1948 1948 fi
1949 1949 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
1950 1950 -D object_list -f object_list -E runtime.err \
1951 1951 -I runtime.attr.raw
1952 1952 if (( $? != 0 )); then
1953 1953 build_extras_ok=n
1954 1954 fi
1955 1955
1956 1956 # check_rtime -I output needs to be sorted in order to
1957 1957 # compare it to that from previous builds.
1958 1958 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
1959 1959 rm $elf_ddir/runtime.attr.raw
1960 1960
1961 1961 # Report errors
1962 1962 if [[ -s $elf_ddir/runtime.err ]]; then
1963 1963 tee -a $LOGFILE < $elf_ddir/runtime.err \
1964 1964 >> $mail_msg_file
1965 1965 build_extras_ok=n
1966 1966 fi
1967 1967
1968 1968 # If there is an ELF-data directory from a previous build,
1969 1969 # then diff the attr files. These files contain information
1970 1970 # about dependencies, versioning, and runpaths. There is some
1971 1971 # overlap with the ABI checking done above, but this also
1972 1972 # flushes out non-ABI interface differences along with the
1973 1973 # other information.
1974 1974 echo "\n==== Diff ELF runtime attributes" \
1975 1975 "(since last build) ====\n" | \
1976 1976 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
1977 1977
1978 1978 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
1979 1979 diff $elf_ddir.ref/runtime.attr \
1980 1980 $elf_ddir/runtime.attr \
1981 1981 >> $mail_msg_file
1982 1982 fi
1983 1983 fi
1984 1984
1985 1985 # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
1986 1986 if [[ "$u_FLAG" = "y" ]]; then
1987 1987 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH
1988 1988
1989 1989 # If parent lacks the ELF-data.$MACH directory, create it
1990 1990 if [[ ! -d $p_elf_ddir ]]; then
1991 1991 staffer mkdir -p $p_elf_ddir
1992 1992 fi
1993 1993
1994 1994 # These files are used asynchronously by other builds for ABI
1995 1995 # verification, as above for the -A option. As such, we require
1996 1996 # the file replacement to be atomic. Copy the data to a temp
1997 1997 # file in the same filesystem and then rename into place.
1998 1998 (
1999 1999 cd $elf_ddir
2000 2000 for elf_dfile in *; do
2001 2001 staffer cp $elf_dfile \
2002 2002 ${p_elf_ddir}/${elf_dfile}.new
2003 2003 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
2004 2004 ${p_elf_ddir}/${elf_dfile}
2005 2005 done
2006 2006 )
2007 2007 fi
2008 2008 fi
2009 2009
2010 2010 # DEBUG lint of kernel begins
2011 2011
2012 2012 if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
2013 2013 if [ "$LINTDIRS" = "" ]; then
2014 2014 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y"
2015 2015 LINTDIRS="$SRC y"
2016 2016 fi
2017 2017 set $LINTDIRS
2018 2018 while [ $# -gt 0 ]; do
2019 2019 dolint $1 $2; shift; shift
2020 2020 done
2021 2021 else
2022 2022 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2023 2023 fi
2024 2024
2025 2025 # "make check" begins
2026 2026
2027 2027 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2028 2028 # remove old check.out
2029 2029 rm -f $SRC/check.out
2030 2030
2031 2031 rm -f $SRC/check-${MACH}.out
2032 2032 cd $SRC
2033 2033 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
2034 2034 >> $LOGFILE
2035 2035 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2036 2036
2037 2037 grep ":" $SRC/check-${MACH}.out |
2038 2038 egrep -v "Ignoring unknown host" | \
2039 2039 sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file
2040 2040
2041 2041 if [[ -s $TMPDIR/check_errors ]]; then
2042 2042 build_extras_ok=n
2043 2043 fi
2044 2044 else
2045 2045 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2046 2046 fi
2047 2047
2048 2048 echo "\n==== Find core files ====\n" | \
2049 2049 tee -a $LOGFILE >> $mail_msg_file
2050 2050
2051 2051 find $abssrcdirs -name core -a -type f -exec file {} \; | \
2052 2052 tee -a $LOGFILE >> $mail_msg_file
2053 2053
2054 2054 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2055 2055 echo "\n==== Diff unreferenced files (since last build) ====\n" \
2056 2056 | tee -a $LOGFILE >>$mail_msg_file
2057 2057 rm -f $SRC/unref-${MACH}.ref
2058 2058 if [ -f $SRC/unref-${MACH}.out ]; then
2059 2059 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2060 2060 fi
2061 2061
2062 2062 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2063 2063 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2064 2064 sort > $SRC/unref-${MACH}.out
2065 2065
2066 2066 if [ ! -f $SRC/unref-${MACH}.ref ]; then
2067 2067 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2068 2068 fi
2069 2069
2070 2070 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2071 2071 fi
2072 2072
2073 2073 # Verify that the usual lists of files, such as exception lists,
2074 2074 # contain only valid references to files. If the build has failed,
2075 2075 # then don't check the proto area.
2076 2076 CHECK_PATHS=${CHECK_PATHS:-y}
2077 2077 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2078 2078 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2079 2079 >>$mail_msg_file
2080 2080 arg=-b
2081 2081 [ "$build_ok" = y ] && arg=
2082 2082 checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1
2083 2083 if [[ -s $SRC/check-paths.out ]]; then
2084 2084 tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file
2085 2085 build_extras_ok=n
2086 2086 fi
2087 2087 fi
2088 2088
2089 2089 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2090 2090 echo "\n==== Impact on file permissions ====\n" \
2091 2091 >> $mail_msg_file
2092 2092
2093 2093 abspkg=
2094 2094 for d in $abssrcdirs; do
2095 2095 if [ -d "$d/pkg" ]; then
2096 2096 abspkg="$abspkg $d"
2097 2097 fi
2098 2098 done
2099 2099
2100 2100 if [ -n "$abspkg" ]; then
2101 2101 for d in "$abspkg"; do
2102 2102 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
2103 2103 done
2104 2104 fi
2105 2105 fi
2106 2106
2107 2107 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
2108 2108 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2109 2109 do_wsdiff DEBUG $ROOT.prev $ROOT
2110 2110 fi
2111 2111
2112 2112 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2113 2113 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2114 2114 fi
2115 2115 fi
2116 2116
2117 2117 END_DATE=`date`
2118 2118 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2119 2119 tee -a $LOGFILE >> $build_time_file
2120 2120
2121 2121 typeset -i10 hours
2122 2122 typeset -Z2 minutes
2123 2123 typeset -Z2 seconds
2124 2124
2125 2125 elapsed_time=$SECONDS
2126 2126 ((hours = elapsed_time / 3600 ))
2127 2127 ((minutes = elapsed_time / 60 % 60))
2128 2128 ((seconds = elapsed_time % 60))
2129 2129
2130 2130 echo "\n==== Total build time ====" | \
2131 2131 tee -a $LOGFILE >> $build_time_file
2132 2132 echo "\nreal ${hours}:${minutes}:${seconds}" | \
2133 2133 tee -a $LOGFILE >> $build_time_file
2134 2134
2135 2135 if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2136 2136 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
2137 2137
2138 2138 #
2139 2139 # Produce a master list of unreferenced files -- ideally, we'd
2140 2140 # generate the master just once after all of the nightlies
2141 2141 # have finished, but there's no simple way to know when that
2142 2142 # will be. Instead, we assume that we're the last nightly to
2143 2143 # finish and merge all of the unref-${MACH}.out files in
2144 2144 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
2145 2145 # finish, then this file will be the authoritative master
2146 2146 # list. Otherwise, another ${MACH}'s nightly will eventually
2147 2147 # overwrite ours with its own master, but in the meantime our
2148 2148 # temporary "master" will be no worse than any older master
2149 2149 # which was already on the parent.
2150 2150 #
2151 2151
2152 2152 set -- $PARENT_WS/usr/src/unref-*.out
2153 2153 cp "$1" ${TMPDIR}/unref.merge
2154 2154 shift
2155 2155
2156 2156 for unreffile; do
2157 2157 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2158 2158 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2159 2159 done
2160 2160
2161 2161 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2162 2162 fi
2163 2163
2164 2164 #
2165 2165 # All done save for the sweeping up.
2166 2166 # (whichever exit we hit here will trigger the "cleanup" trap which
2167 2167 # optionally sends mail on completion).
2168 2168 #
2169 2169 if [[ "$build_ok" == "y" ]]; then
2170 2170 if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then
2171 2171 exit 0
2172 2172 fi
2173 2173 fi
2174 2174
2175 2175 exit 1
↓ open down ↓ |
489 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX