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