Print this page
3971 remove EXPORT_RELEASE_BUILD
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 #
29 29 # Based on the nightly script from the integration folks,
30 30 # Mostly modified and owned by mike_s.
31 31 # Changes also by kjc, dmk.
32 32 #
33 33 # BRINGOVER_WS may be specified in the env file.
34 34 # The default is the old behavior of CLONE_WS
35 35 #
36 36 # -i on the command line, means fast options, so when it's on the
37 37 # command line (only), lint and check builds are skipped no matter what
38 38 # the setting of their individual flags are in NIGHTLY_OPTIONS.
39 39 #
40 40 # LINTDIRS can be set in the env file, format is a list of:
41 41 #
42 42 # /dirname-to-run-lint-on flag
43 43 #
44 44 # Where flag is: y - enable lint noise diff output
45 45 # n - disable lint noise diff output
46 46 #
47 47 # For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
48 48 #
49 49 # OPTHOME and TEAMWARE may be set in the environment to override /opt
50 50 # and /opt/teamware defaults.
51 51 #
52 52
53 53 #
54 54 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
55 55 # under certain circumstances, which can really screw things up; unset it.
56 56 #
57 57 unset CDPATH
58 58
59 59 # Get the absolute path of the nightly script that the user invoked. This
60 60 # may be a relative path, and we need to do this before changing directory.
61 61 nightly_path=`whence $0`
62 62
63 63 #
64 64 # Keep track of where we found nightly so we can invoke the matching
65 65 # which_scm script. If that doesn't work, don't go guessing, just rely
66 66 # on the $PATH settings, which will generally give us either /opt/onbld
67 67 # or the user's workspace.
68 68 #
69 69 WHICH_SCM=$(dirname $nightly_path)/which_scm
70 70 if [[ ! -x $WHICH_SCM ]]; then
71 71 WHICH_SCM=which_scm
72 72 fi
73 73
74 74 function fatal_error
75 75 {
76 76 print -u2 "nightly: $*"
77 77 exit 1
78 78 }
79 79
80 80 #
81 81 # Function to do a DEBUG and non-DEBUG build. Needed because we might
82 82 # need to do another for the source build, and since we only deliver DEBUG or
83 83 # non-DEBUG packages.
84 84 #
85 85 # usage: normal_build
86 86 #
87 87 function normal_build {
88 88
89 89 typeset orig_p_FLAG="$p_FLAG"
90 90 typeset crypto_signer="$CODESIGN_USER"
91 91
92 92 suffix=""
93 93
94 94 # non-DEBUG build begins
95 95
96 96 if [ "$F_FLAG" = "n" ]; then
97 97 set_non_debug_build_flags
98 98 CODESIGN_USER="$crypto_signer" \
99 99 build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
100 100 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \
101 101 "$p_FLAG" = "y" ]; then
102 102 copy_ihv_pkgs non-DEBUG -nd
103 103 fi
104 104 else
105 105 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
106 106 fi
107 107
108 108 # non-DEBUG build ends
109 109
110 110 # DEBUG build begins
111 111
112 112 if [ "$D_FLAG" = "y" ]; then
113 113 set_debug_build_flags
114 114 CODESIGN_USER="$crypto_signer" \
115 115 build "DEBUG" "$suffix" "" "$MULTI_PROTO"
116 116 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \
117 117 "$p_FLAG" = "y" ]; then
118 118 copy_ihv_pkgs DEBUG ""
119 119 fi
120 120 else
121 121 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
122 122 fi
123 123
124 124 # DEBUG build ends
125 125
126 126 p_FLAG="$orig_p_FLAG"
127 127 }
128 128
129 129 #
130 130 # usage: run_hook HOOKNAME ARGS...
131 131 #
132 132 # If variable "$HOOKNAME" is defined, insert a section header into
133 133 # our logs and then run the command with ARGS
134 134 #
135 135 function run_hook {
136 136 HOOKNAME=$1
137 137 eval HOOKCMD=\$$HOOKNAME
138 138 shift
139 139
140 140 if [ -n "$HOOKCMD" ]; then
141 141 (
142 142 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
143 143 ( $HOOKCMD "$@" 2>&1 )
144 144 if [ "$?" -ne 0 ]; then
145 145 # Let exit status propagate up
146 146 touch $TMPDIR/abort
147 147 fi
148 148 ) | tee -a $mail_msg_file >> $LOGFILE
149 149
150 150 if [ -f $TMPDIR/abort ]; then
151 151 build_ok=n
152 152 echo "\nAborting at request of $HOOKNAME" |
153 153 tee -a $mail_msg_file >> $LOGFILE
154 154 exit 1
155 155 fi
156 156 fi
157 157 }
158 158
159 159 #
160 160 # usage: filelist DESTDIR PATTERN
161 161 #
162 162 function filelist {
163 163 DEST=$1
164 164 PATTERN=$2
165 165 cd ${DEST}
166 166 }
167 167
168 168 # function to save off binaries after a full build for later
169 169 # restoration
170 170 function save_binaries {
171 171 # save off list of binaries
172 172 echo "\n==== Saving binaries from build at `date` ====\n" | \
173 173 tee -a $mail_msg_file >> $LOGFILE
174 174 rm -f ${BINARCHIVE}
175 175 cd ${CODEMGR_WS}
176 176 filelist ${CODEMGR_WS} '^preserve:' >> $LOGFILE
177 177 filelist ${CODEMGR_WS} '^preserve:' | \
178 178 cpio -ocB 2>/dev/null | compress \
179 179 > ${BINARCHIVE}
180 180 }
181 181
182 182 # delete files
183 183 # usage: hybridize_files DESTDIR MAKE_TARGET
184 184 function hybridize_files {
185 185 DEST=$1
186 186 MAKETARG=$2
187 187
188 188 echo "\n==== Hybridizing files at `date` ====\n" | \
189 189 tee -a $mail_msg_file >> $LOGFILE
190 190 for i in `filelist ${DEST} '^delete:'`
191 191 do
192 192 echo "removing ${i}." | tee -a $mail_msg_file >> $LOGFILE
193 193 rm -rf "${i}"
194 194 done
195 195 for i in `filelist ${DEST} '^hybridize:' `
196 196 do
197 197 echo "hybridizing ${i}." | tee -a $mail_msg_file >> $LOGFILE
198 198 rm -f ${i}+
199 199 sed -e "/^# HYBRID DELETE START/,/^# HYBRID DELETE END/d" \
200 200 < ${i} > ${i}+
201 201 mv ${i}+ ${i}
202 202 done
203 203 }
204 204
205 205 # restore binaries into the proper source tree.
206 206 # usage: restore_binaries DESTDIR MAKE_TARGET
207 207 function restore_binaries {
208 208 DEST=$1
209 209 MAKETARG=$2
210 210
211 211 echo "\n==== Restoring binaries to ${MAKETARG} at `date` ====\n" | \
212 212 tee -a $mail_msg_file >> $LOGFILE
213 213 cd ${DEST}
214 214 zcat ${BINARCHIVE} | \
215 215 cpio -idmucvB 2>/dev/null | tee -a $mail_msg_file >> ${LOGFILE}
216 216 }
217 217
218 218 # rename files we save binaries of
219 219 # usage: rename_files DESTDIR MAKE_TARGET
220 220 function rename_files {
221 221 DEST=$1
222 222 MAKETARG=$2
223 223 echo "\n==== Renaming source files in ${MAKETARG} at `date` ====\n" | \
224 224 tee -a $mail_msg_file >> $LOGFILE
225 225 for i in `filelist ${DEST} '^rename:'`
226 226 do
227 227 echo ${i} | tee -a $mail_msg_file >> ${LOGFILE}
228 228 rm -f ${i}.export
229 229 mv ${i} ${i}.export
230 230 done
231 231 }
232 232
233 233 #
234 234 # Copy some or all of the source tree.
235 235 #
236 236 # Returns 0 for success, non-zero for failure.
237 237 #
238 238 # usage: copy_source CODEMGR_WS DESTDIR LABEL SRCROOT
239 239 #
240 240 function copy_source {
241 241 WS=$1
242 242 DEST=$2
243 243 label=$3
244 244 srcroot=$4
245 245
246 246 printf "\n==== Creating %s source from %s (%s) ====\n\n" \
247 247 "$DEST" "$WS" "$label" | tee -a $mail_msg_file >> $LOGFILE
248 248
249 249 printf "cleaning out %s\n" "$DEST." >> $LOGFILE
250 250 rm -rf "$DEST" >> $LOGFILE 2>&1
251 251
252 252 printf "creating %s\n" "$DEST." >> $LOGFILE
253 253 mkdir -p "$DEST" 2>> $LOGFILE
254 254
255 255 if (( $? != 0 )) ; then
256 256 printf "failed to create %s\n" "$DEST" |
257 257 tee -a $mail_msg_file >> $LOGFILE
258 258 build_ok=n
259 259 return 1
260 260 fi
261 261 cd "$WS"
262 262
263 263 printf "populating %s\n" "$DEST." >> $LOGFILE
264 264
265 265 case "$SCM_TYPE" in
266 266 teamware)
267 267 find $srcroot -name 's\.*' -a -type f -print | \
268 268 sed -e 's,SCCS\/s.,,' | \
269 269 grep -v '/\.del-*' | \
270 270 cpio -pd $DEST >>$LOGFILE 2>&1
271 271 if (( $? != 0 )) ; then
272 272 printf "cpio failed for %s\n" "$DEST" |
273 273 tee -a $mail_msg_file >> $LOGFILE
274 274 build_ok=n
275 275 return 1
276 276 fi
277 277 ;;
278 278 mercurial)
279 279 copy_source_mercurial $DEST $srcroot
280 280 if (( $? != 0 )) ; then
281 281 build_ok=n
282 282 return 1
283 283 fi
284 284 ;;
285 285 *)
286 286 build_ok=n
287 287 echo "Tree copy is not supported for workspace type" \
288 288 "$SCM_TYPE" | tee -a $mail_msg_file >> $LOGFILE
289 289 return 1
290 290 ;;
291 291 esac
292 292
293 293 return 0
294 294 }
295 295
296 296 #
297 297 # Mercurial-specific copy code for copy_source(). Handles the
298 298 # combined open and closed trees.
299 299 #
300 300 # Returns 0 for success, non-zero for failure.
301 301 #
302 302 # usage: copy_source_mercurial destdir srcroot
303 303 #
304 304 function copy_source_mercurial {
305 305 typeset dest=$1
306 306 typeset srcroot=$2
307 307 typeset open_top closed_top
308 308
309 309 case $srcroot in
310 310 usr)
311 311 open_top=usr
312 312 if [[ "$CLOSED_IS_PRESENT" = yes ]]; then
313 313 closed_top=usr/closed
314 314 fi
315 315 ;;
316 316 usr/closed*)
317 317 if [[ "$CLOSED_IS_PRESENT" = no ]]; then
318 318 printf "can't copy %s: closed tree not present.\n" \
319 319 "$srcroot" | tee -a $mail_msg_file >> $LOGFILE
320 320 return 1
321 321 fi
322 322 closed_top="$srcroot"
323 323 ;;
324 324 *)
325 325 open_top="$srcroot"
326 326 ;;
327 327 esac
328 328
329 329 if [[ -n "$open_top" ]]; then
330 330 hg locate -I "$open_top" | cpio -pd "$dest" >>$LOGFILE 2>&1
331 331 if (( $? != 0 )) ; then
332 332 printf "cpio failed for %s\n" "$dest" |
333 333 tee -a $mail_msg_file >> $LOGFILE
334 334 return 1
335 335 fi
336 336 fi
337 337
338 338 if [[ -n "$closed_top" ]]; then
339 339 mkdir -p "$dest/usr/closed" || return 1
340 340 if [[ "$closed_top" = usr/closed ]]; then
341 341 (cd usr/closed; hg locate |
342 342 cpio -pd "$dest/usr/closed") >>$LOGFILE 2>&1
343 343 if (( $? != 0 )) ; then
344 344 printf "cpio failed for %s/usr/closed\n" \
345 345 "$dest" | tee -a $mail_msg_file >> $LOGFILE
346 346 return 1
347 347 fi
348 348 else
349 349 # copy subtree of usr/closed
350 350 closed_top=${closed_top#usr/closed/}
351 351 (cd usr/closed; hg locate -I "$closed_top" |
352 352 cpio -pd "$dest/usr/closed") >>$LOGFILE 2>&1
353 353 if (( $? != 0 )) ; then
354 354 printf "cpio failed for %s/usr/closed/%s\n" \
355 355 "$dest" "$closed_top" |
356 356 tee -a $mail_msg_file >> $LOGFILE
357 357 return 1
358 358 fi
359 359 fi
360 360 fi
361 361
362 362 return 0
363 363 }
364 364
365 365 #
366 366 # function to create (but not build) the export/crypt source tree.
367 367 # usage: set_up_source_build CODEMGR_WS DESTDIR MAKE_TARGET
368 368 # Sets SRC to the modified source tree, for use by the caller when it
369 369 # builds the tree.
370 370 #
371 371 function set_up_source_build {
372 372 WS=$1
373 373 DEST=$2
374 374 MAKETARG=$3
375 375
376 376 copy_source $WS $DEST $MAKETARG usr
377 377 if (( $? != 0 )); then
378 378 echo "\nCould not copy source tree for source build." |
379 379 tee -a $mail_msg_file >> $LOGFILE
380 380 build_ok=n
381 381 return
382 382 fi
383 383
384 384 SRC=${DEST}/usr/src
385 385
386 386 cd $SRC
387 387 rm -f ${MAKETARG}.out
388 388 echo "making ${MAKETARG} in ${SRC}." >> $LOGFILE
389 389 /bin/time $MAKE -e ${MAKETARG} 2>&1 | \
390 390 tee -a $SRC/${MAKETARG}.out >> $LOGFILE
391 391 echo "\n==== ${MAKETARG} build errors ====\n" >> $mail_msg_file
392 392 egrep ":" $SRC/${MAKETARG}.out | \
393 393 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
394 394 egrep -v "Ignoring unknown host" | \
395 395 egrep -v "warning" >> $mail_msg_file
396 396
397 397 echo "clearing state files." >> $LOGFILE
398 398 find . -name '.make*' -exec rm -f {} \;
399 399 }
400 400
401 401 # Return library search directive as function of given root.
402 402 function myldlibs {
403 403 echo "-L$1/lib -L$1/usr/lib"
404 404 }
405 405
406 406 # Return header search directive as function of given root.
407 407 function myheaders {
408 408 echo "-I$1/usr/include"
409 409 }
410 410
411 411 #
412 412 # Function to do the build, including package generation.
413 413 # usage: build LABEL SUFFIX ND MULTIPROTO
414 414 # - LABEL is used to tag build output.
415 415 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
416 416 # open-only vs full tree).
417 417 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
418 418 # - If MULTIPROTO is "yes", it means to name the proto area according to
419 419 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
420 420 #
421 421 function build {
422 422 LABEL=$1
423 423 SUFFIX=$2
424 424 ND=$3
425 425 MULTIPROTO=$4
426 426 INSTALLOG=install${SUFFIX}-${MACH}
427 427 NOISE=noise${SUFFIX}-${MACH}
428 428 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
429 429
430 430 ORIGROOT=$ROOT
431 431 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
432 432
433 433 if [[ "$O_FLAG" = y ]]; then
434 434 echo "\nSetting CLOSEDROOT= ${ROOT}-closed\n" >> $LOGFILE
435 435 export CLOSEDROOT=${ROOT}-closed
436 436 fi
437 437
438 438 export ENVLDLIBS1=`myldlibs $ROOT`
439 439 export ENVCPPFLAGS1=`myheaders $ROOT`
440 440
441 441 this_build_ok=y
442 442 #
443 443 # Build OS-Networking source
444 444 #
445 445 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
446 446 >> $LOGFILE
447 447
448 448 rm -f $SRC/${INSTALLOG}.out
449 449 cd $SRC
450 450 /bin/time $MAKE -e install 2>&1 | \
451 451 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
452 452
453 453 if [[ "$SCM_TYPE" = teamware ]]; then
454 454 echo "\n==== SCCS Noise ($LABEL) ====\n" >> $mail_msg_file
455 455 egrep 'sccs(check:| *get)' $SRC/${INSTALLOG}.out >> \
456 456 $mail_msg_file
457 457 fi
458 458
459 459 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
460 460 egrep ":" $SRC/${INSTALLOG}.out |
461 461 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
462 462 egrep -v "Ignoring unknown host" | \
463 463 egrep -v "cc .* -o error " | \
464 464 egrep -v "warning" >> $mail_msg_file
465 465 if [ "$?" = "0" ]; then
466 466 build_ok=n
467 467 this_build_ok=n
468 468 fi
469 469 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
470 470 >> $mail_msg_file
471 471 if [ "$?" = "0" ]; then
472 472 build_ok=n
473 473 this_build_ok=n
474 474 fi
475 475
476 476 if [ "$W_FLAG" = "n" ]; then
477 477 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
478 478 egrep -i warning: $SRC/${INSTALLOG}.out \
479 479 | egrep -v '^tic:' \
480 480 | egrep -v "symbol (\`|')timezone' has differing types:" \
481 481 | egrep -v "parameter <PSTAMP> set to" \
482 482 | egrep -v "Ignoring unknown host" \
483 483 | egrep -v "redefining segment flags attribute for" \
484 484 >> $mail_msg_file
485 485 fi
486 486
487 487 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
488 488 >> $LOGFILE
489 489
490 490 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
491 491 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
492 492
493 493 if [ "$i_FLAG" = "n" -a "$W_FLAG" = "n" ]; then
494 494 rm -f $SRC/${NOISE}.ref
495 495 if [ -f $SRC/${NOISE}.out ]; then
496 496 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
497 497 fi
498 498 grep : $SRC/${INSTALLOG}.out \
499 499 | egrep -v '^/' \
500 500 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
501 501 | egrep -v '^tic:' \
502 502 | egrep -v '^mcs' \
503 503 | egrep -v '^LD_LIBRARY_PATH=' \
504 504 | egrep -v 'ar: creating' \
505 505 | egrep -v 'ar: writing' \
506 506 | egrep -v 'conflicts:' \
507 507 | egrep -v ':saved created' \
508 508 | egrep -v '^stty.*c:' \
509 509 | egrep -v '^mfgname.c:' \
510 510 | egrep -v '^uname-i.c:' \
511 511 | egrep -v '^volumes.c:' \
512 512 | egrep -v '^lint library construction:' \
513 513 | egrep -v 'tsort: INFORM:' \
514 514 | egrep -v 'stripalign:' \
515 515 | egrep -v 'chars, width' \
516 516 | egrep -v "symbol (\`|')timezone' has differing types:" \
517 517 | egrep -v 'PSTAMP' \
518 518 | egrep -v '|%WHOANDWHERE%|' \
519 519 | egrep -v '^Manifying' \
520 520 | egrep -v 'Ignoring unknown host' \
521 521 | egrep -v 'Processing method:' \
522 522 | egrep -v '^Writing' \
523 523 | egrep -v 'spellin1:' \
524 524 | egrep -v '^adding:' \
525 525 | egrep -v "^echo 'msgid" \
526 526 | egrep -v '^echo ' \
527 527 | egrep -v '\.c:$' \
528 528 | egrep -v '^Adding file:' \
529 529 | egrep -v 'CLASSPATH=' \
530 530 | egrep -v '\/var\/mail\/:saved' \
531 531 | egrep -v -- '-DUTS_VERSION=' \
532 532 | egrep -v '^Running Mkbootstrap' \
533 533 | egrep -v '^Applet length read:' \
534 534 | egrep -v 'bytes written:' \
535 535 | egrep -v '^File:SolarisAuthApplet.bin' \
536 536 | egrep -v -i 'jibversion' \
537 537 | egrep -v '^Output size:' \
538 538 | egrep -v '^Solo size statistics:' \
539 539 | egrep -v '^Using ROM API Version' \
540 540 | egrep -v '^Zero Signature length:' \
541 541 | egrep -v '^Note \(probably harmless\):' \
542 542 | egrep -v '::' \
543 543 | egrep -v -- '-xcache' \
544 544 | egrep -v '^\+' \
545 545 | egrep -v '^cc1: note: -fwritable-strings' \
546 546 | egrep -v 'svccfg-native -s svc:/' \
547 547 | sort | uniq >$SRC/${NOISE}.out
548 548 if [ ! -f $SRC/${NOISE}.ref ]; then
549 549 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref
550 550 fi
551 551 echo "\n==== Build noise differences ($LABEL) ====\n" \
552 552 >>$mail_msg_file
553 553 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file
554 554 fi
555 555
556 556 #
557 557 # Re-sign selected binaries using signing server
558 558 # (gatekeeper builds only)
559 559 #
560 560 if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then
561 561 echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE
562 562 signing_file="${TMPDIR}/signing"
563 563 rm -f ${signing_file}
564 564 export CODESIGN_USER
565 565 signproto $SRC/tools/codesign/creds 2>&1 | \
566 566 tee -a ${signing_file} >> $LOGFILE
567 567 echo "\n==== Finished signing proto area at `date` ====\n" \
568 568 >> $LOGFILE
569 569 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
570 570 >> $mail_msg_file
571 571 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
572 572 if (( $? == 0 )) ; then
573 573 build_ok=n
574 574 this_build_ok=n
575 575 fi
576 576 fi
577 577
578 578 #
579 579 # Building Packages
580 580 #
581 581 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
582 582 if [ -d $SRC/pkg -o -d $SRC/pkgdefs ]; then
583 583 echo "\n==== Creating $LABEL packages at `date` ====\n" \
584 584 >> $LOGFILE
585 585 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
586 586 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
587 587 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
588 588
589 589 for d in pkg pkgdefs; do
590 590 if [ ! -f "$SRC/$d/Makefile" ]; then
591 591 continue
592 592 fi
593 593 rm -f $SRC/$d/${INSTALLOG}.out
594 594 cd $SRC/$d
595 595 /bin/time $MAKE -e install 2>&1 | \
596 596 tee -a $SRC/$d/${INSTALLOG}.out >> $LOGFILE
597 597 done
598 598
599 599 echo "\n==== package build errors ($LABEL) ====\n" \
600 600 >> $mail_msg_file
601 601
602 602 for d in pkg pkgdefs; do
603 603 if [ ! -f "$SRC/$d/Makefile" ]; then
604 604 continue
605 605 fi
606 606
607 607 egrep "${MAKE}|ERROR|WARNING" $SRC/$d/${INSTALLOG}.out | \
608 608 grep ':' | \
609 609 grep -v PSTAMP | \
610 610 egrep -v "Ignoring unknown host" \
611 611 >> $mail_msg_file
612 612 done
613 613 else
614 614 #
615 615 # Handle it gracefully if -p was set but there are
616 616 # neither pkg nor pkgdefs directories.
617 617 #
618 618 echo "\n==== No $LABEL packages to build ====\n" \
619 619 >> $LOGFILE
620 620 fi
621 621 else
622 622 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
623 623 fi
624 624
625 625 ROOT=$ORIGROOT
626 626 }
627 627
628 628 # Usage: dolint /dir y|n
629 629 # Arg. 2 is a flag to turn on/off the lint diff output
630 630 function dolint {
631 631 if [ ! -d "$1" ]; then
632 632 echo "dolint error: $1 is not a directory"
633 633 exit 1
634 634 fi
635 635
636 636 if [ "$2" != "y" -a "$2" != "n" ]; then
637 637 echo "dolint internal error: $2 should be 'y' or 'n'"
638 638 exit 1
639 639 fi
640 640
641 641 lintdir=$1
642 642 dodiff=$2
643 643 base=`basename $lintdir`
644 644 LINTOUT=$lintdir/lint-${MACH}.out
645 645 LINTNOISE=$lintdir/lint-noise-${MACH}
646 646 export ENVLDLIBS1=`myldlibs $ROOT`
647 647 export ENVCPPFLAGS1=`myheaders $ROOT`
648 648
649 649 set_debug_build_flags
650 650
651 651 #
652 652 # '$MAKE lint' in $lintdir
653 653 #
654 654 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
655 655
656 656 # remove old lint.out
657 657 rm -f $lintdir/lint.out $lintdir/lint-noise.out
658 658 if [ -f $lintdir/lint-noise.ref ]; then
659 659 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref
660 660 fi
661 661
662 662 rm -f $LINTOUT
663 663 cd $lintdir
664 664 #
665 665 # Remove all .ln files to ensure a full reference file
666 666 #
667 667 rm -f Nothing_to_remove \
668 668 `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
669 669 -prune -o -type f -name '*.ln' -print `
670 670
671 671 /bin/time $MAKE -ek lint 2>&1 | \
672 672 tee -a $LINTOUT >> $LOGFILE
673 673 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file
674 674 grep "$MAKE:" $LINTOUT |
675 675 egrep -v "Ignoring unknown host" \
676 676 >> $mail_msg_file
677 677
678 678 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
679 679
680 680 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
681 681 >>$mail_msg_file
682 682 tail -3 $LINTOUT >>$mail_msg_file
683 683
684 684 rm -f ${LINTNOISE}.ref
685 685 if [ -f ${LINTNOISE}.out ]; then
686 686 mv ${LINTNOISE}.out ${LINTNOISE}.ref
687 687 fi
688 688 grep : $LINTOUT | \
689 689 egrep -v '^(real|user|sys)' |
690 690 egrep -v '(library construction)' | \
691 691 egrep -v ': global crosschecks' | \
692 692 egrep -v 'Ignoring unknown host' | \
693 693 egrep -v '\.c:$' | \
694 694 sort | uniq > ${LINTNOISE}.out
695 695 if [ ! -f ${LINTNOISE}.ref ]; then
696 696 cp ${LINTNOISE}.out ${LINTNOISE}.ref
697 697 fi
698 698 if [ "$dodiff" != "n" ]; then
699 699 echo "\n==== lint warnings $base ====\n" \
700 700 >>$mail_msg_file
701 701 # should be none, though there are a few that were filtered out
702 702 # above
703 703 egrep -i '(warning|lint):' ${LINTNOISE}.out \
704 704 | sort | uniq >> $mail_msg_file
705 705 echo "\n==== lint noise differences $base ====\n" \
706 706 >> $mail_msg_file
707 707 diff ${LINTNOISE}.ref ${LINTNOISE}.out \
708 708 >> $mail_msg_file
709 709 fi
710 710 }
711 711
712 712 # Install proto area from IHV build
713 713
714 714 function copy_ihv_proto {
715 715
716 716 echo "\n==== Installing IHV proto area ====\n" \
717 717 >> $LOGFILE
718 718 if [ -d "$IA32_IHV_ROOT" ]; then
719 719 if [ ! -d "$ROOT" ]; then
720 720 echo "mkdir -p $ROOT" >> $LOGFILE
721 721 mkdir -p $ROOT
722 722 fi
723 723 echo "copying $IA32_IHV_ROOT to $ROOT\n" >> $LOGFILE
724 724 cd $IA32_IHV_ROOT
725 725 tar cf - . | (cd $ROOT; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
726 726 else
727 727 echo "$IA32_IHV_ROOT: not found" >> $LOGFILE
728 728 fi
729 729
730 730 if [ "$MULTI_PROTO" = yes ]; then
731 731 if [ ! -d "$ROOT-nd" ]; then
732 732 echo "mkdir -p $ROOT-nd" >> $LOGFILE
733 733 mkdir -p $ROOT-nd
734 734 fi
735 735 # If there's a non-DEBUG version of the IHV proto area,
736 736 # copy it, but copy something if there's not.
737 737 if [ -d "$IA32_IHV_ROOT-nd" ]; then
738 738 echo "copying $IA32_IHV_ROOT-nd to $ROOT-nd\n" >> $LOGFILE
739 739 cd $IA32_IHV_ROOT-nd
740 740 elif [ -d "$IA32_IHV_ROOT" ]; then
741 741 echo "copying $IA32_IHV_ROOT to $ROOT-nd\n" >> $LOGFILE
742 742 cd $IA32_IHV_ROOT
743 743 else
744 744 echo "$IA32_IHV_ROOT{-nd,}: not found" >> $LOGFILE
745 745 return
746 746 fi
747 747 tar cf - . | (cd $ROOT-nd; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
748 748 fi
749 749 }
750 750
751 751 # Install IHV packages in PKGARCHIVE
752 752 # usage: copy_ihv_pkgs LABEL SUFFIX
753 753 function copy_ihv_pkgs {
754 754 LABEL=$1
755 755 SUFFIX=$2
756 756 # always use non-DEBUG IHV packages
757 757 IA32_IHV_PKGS=${IA32_IHV_PKGS_ORIG}-nd
758 758 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
759 759
760 760 echo "\n==== Installing IHV packages from $IA32_IHV_PKGS ($LABEL) ====\n" \
761 761 >> $LOGFILE
762 762 if [ -d "$IA32_IHV_PKGS" ]; then
763 763 cd $IA32_IHV_PKGS
764 764 tar cf - * | \
765 765 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
766 766 else
767 767 echo "$IA32_IHV_PKGS: not found" >> $LOGFILE
768 768 fi
769 769
770 770 echo "\n==== Installing IHV packages from $IA32_IHV_BINARY_PKGS ($LABEL) ====\n" \
771 771 >> $LOGFILE
772 772 if [ -d "$IA32_IHV_BINARY_PKGS" ]; then
773 773 cd $IA32_IHV_BINARY_PKGS
774 774 tar cf - * | \
775 775 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
776 776 else
777 777 echo "$IA32_IHV_BINARY_PKGS: not found" >> $LOGFILE
778 778 fi
779 779 }
780 780
781 781 #
782 782 # Build and install the onbld tools.
783 783 #
784 784 # usage: build_tools DESTROOT
785 785 #
786 786 # returns non-zero status if the build was successful.
787 787 #
788 788 function build_tools {
789 789 DESTROOT=$1
790 790
791 791 INSTALLOG=install-${MACH}
792 792
793 793 echo "\n==== Building tools at `date` ====\n" \
794 794 >> $LOGFILE
795 795
796 796 rm -f ${TOOLS}/${INSTALLOG}.out
797 797 cd ${TOOLS}
798 798 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
799 799 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
800 800
801 801 echo "\n==== Tools build errors ====\n" >> $mail_msg_file
802 802
803 803 egrep ":" ${TOOLS}/${INSTALLOG}.out |
804 804 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
805 805 egrep -v "Ignoring unknown host" | \
806 806 egrep -v warning >> $mail_msg_file
807 807 return $?
808 808 }
809 809
810 810 #
811 811 # Set up to use locally installed tools.
812 812 #
813 813 # usage: use_tools TOOLSROOT
814 814 #
815 815 function use_tools {
816 816 TOOLSROOT=$1
817 817
818 818 #
819 819 # If we're not building ON workspace, then the TOOLSROOT
820 820 # settings here are clearly ignored by the workspace
821 821 # makefiles, prepending nonexistent directories to PATH is
822 822 # harmless, and we clearly do not wish to override
823 823 # ONBLD_TOOLS.
824 824 #
825 825 # If we're building an ON workspace, then the prepended PATH
826 826 # elements should supercede the preexisting ONBLD_TOOLS paths,
827 827 # and we want to override ONBLD_TOOLS to catch the tools that
828 828 # don't have specific path env vars here.
829 829 #
830 830 # So the only conditional behavior is overriding ONBLD_TOOLS,
831 831 # and we check for "an ON workspace" by looking for
832 832 # ${TOOLSROOT}/opt/onbld.
833 833 #
834 834
835 835 STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs
836 836 export STABS
837 837 CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs
838 838 export CTFSTABS
839 839 GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets
840 840 export GENOFFSETS
841 841
842 842 CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert
843 843 export CTFCONVERT
844 844 CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge
845 845 export CTFMERGE
846 846
847 847 CTFCVTPTBL=${TOOLSROOT}/opt/onbld/bin/ctfcvtptbl
848 848 export CTFCVTPTBL
849 849 CTFFINDMOD=${TOOLSROOT}/opt/onbld/bin/ctffindmod
850 850 export CTFFINDMOD
851 851
852 852 if [ "$VERIFY_ELFSIGN" = "y" ]; then
853 853 ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp
854 854 else
855 855 ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign
856 856 fi
857 857 export ELFSIGN
858 858
859 859 PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}"
860 860 PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}"
861 861 export PATH
862 862
863 863 if [ -d "${TOOLSROOT}/opt/onbld" ]; then
864 864 ONBLD_TOOLS=${TOOLSROOT}/opt/onbld
865 865 export ONBLD_TOOLS
866 866 fi
867 867
868 868 echo "\n==== New environment settings. ====\n" >> $LOGFILE
869 869 echo "STABS=${STABS}" >> $LOGFILE
870 870 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
871 871 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
872 872 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
873 873 echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE
874 874 echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE
875 875 echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE
876 876 echo "PATH=${PATH}" >> $LOGFILE
877 877 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
878 878 }
879 879
880 880 function staffer {
881 881 if [ $ISUSER -ne 0 ]; then
882 882 "$@"
883 883 else
884 884 arg="\"$1\""
885 885 shift
886 886 for i
887 887 do
888 888 arg="$arg \"$i\""
889 889 done
890 890 eval su $STAFFER -c \'$arg\'
891 891 fi
892 892 }
893 893
894 894 #
895 895 # Verify that the closed tree is present if it needs to be.
896 896 # Sets CLOSED_IS_PRESENT for future use.
897 897 #
898 898 function check_closed_tree {
899 899 if [ -z "$CLOSED_IS_PRESENT" ]; then
900 900 if [ -d $CODEMGR_WS/usr/closed ]; then
901 901 CLOSED_IS_PRESENT="yes"
902 902 else
903 903 CLOSED_IS_PRESENT="no"
904 904 fi
905 905 export CLOSED_IS_PRESENT
906 906 fi
907 907 if [[ "$CLOSED_IS_PRESENT" = no && ! -d "$ON_CLOSED_BINS" ]]; then
908 908 #
909 909 # If it's an old (pre-split) tree or an empty
910 910 # workspace, don't complain.
911 911 #
912 912 if grep -s CLOSED_BUILD $SRC/Makefile.master > /dev/null; then
913 913 echo "If the closed sources are not present," \
914 914 "ON_CLOSED_BINS"
915 915 echo "must point to the closed binaries tree."
916 916 build_ok=n
917 917 exit 1
918 918 fi
919 919 fi
920 920 }
921 921
922 922 function obsolete_build {
923 923 echo "WARNING: Obsolete $1 build requested; request will be ignored"
924 924 }
925 925
926 926 #
927 927 # wrapper over wsdiff.
928 928 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
929 929 #
930 930 function do_wsdiff {
931 931 label=$1
932 932 oldproto=$2
933 933 newproto=$3
934 934
935 935 wsdiff="wsdiff"
936 936 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
937 937
938 938 echo "\n==== Getting object changes since last build at `date`" \
939 939 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
940 940 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
941 941 tee -a $LOGFILE >> $mail_msg_file
942 942 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
943 943 tee -a $LOGFILE >> $mail_msg_file
944 944 }
945 945
946 946 #
947 947 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
948 948 # together.
949 949 #
950 950
951 951 function set_non_debug_build_flags {
952 952 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
953 953 export RELEASE_BUILD ; RELEASE_BUILD=
954 954 unset EXTRA_OPTIONS
955 955 unset EXTRA_CFLAGS
956 956 }
957 957
958 958 function set_debug_build_flags {
959 959 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
960 960 unset RELEASE_BUILD
961 961 unset EXTRA_OPTIONS
962 962 unset EXTRA_CFLAGS
963 963 }
964 964
965 965
966 966 MACH=`uname -p`
967 967
968 968 if [ "$OPTHOME" = "" ]; then
969 969 OPTHOME=/opt
970 970 export OPTHOME
971 971 fi
972 972 if [ "$TEAMWARE" = "" ]; then
973 973 TEAMWARE=$OPTHOME/teamware
974 974 export TEAMWARE
975 975 fi
976 976
977 977 USAGE='Usage: nightly [-in] [+t] [-V VERS ] [ -S E|D|H|O ] <env_file>
978 978
979 979 Where:
980 980 -i Fast incremental options (no clobber, lint, check)
981 981 -n Do not do a bringover
982 982 +t Use the build tools in $ONBLD_TOOLS/bin
983 983 -V VERS set the build version string to VERS
984 984 -S Build a variant of the source product
985 985 E - build exportable source
986 986 D - build domestic source (exportable + crypt)
987 987 H - build hybrid source (binaries + deleted source)
988 988 O - build (only) open source
989 989
990 990 <env_file> file in Bourne shell syntax that sets and exports
991 991 variables that configure the operation of this script and many of
992 992 the scripts this one calls. If <env_file> does not exist,
993 993 it will be looked for in $OPTHOME/onbld/env.
994 994
995 995 non-DEBUG is the default build type. Build options can be set in the
996 996 NIGHTLY_OPTIONS variable in the <env_file> as follows:
997 997
998 998 -A check for ABI differences in .so files
999 999 -C check for cstyle/hdrchk errors
1000 1000 -D do a build with DEBUG on
1001 1001 -F do _not_ do a non-DEBUG build
1002 1002 -G gate keeper default group of options (-au)
1003 1003 -I integration engineer default group of options (-ampu)
1004 1004 -M do not run pmodes (safe file permission checker)
1005 1005 -N do not run protocmp
1006 1006 -O generate OpenSolaris deliverables
1007 1007 -R default group of options for building a release (-mp)
1008 1008 -U update proto area in the parent
1009 1009 -V VERS set the build version string to VERS
1010 1010 -X copy x86 IHV proto area
1011 1011 -f find unreferenced files
1012 1012 -i do an incremental build (no "make clobber")
1013 1013 -l do "make lint" in $LINTDIRS (default: $SRC y)
1014 1014 -m send mail to $MAILTO at end of build
1015 1015 -n do not do a bringover
1016 1016 -o build using root privileges to set OWNER/GROUP (old style)
1017 1017 -p create packages
1018 1018 -r check ELF runtime attributes in the proto area
1019 1019 -t build and use the tools in $SRC/tools (default setting)
1020 1020 +t Use the build tools in $ONBLD_TOOLS/bin
1021 1021 -u update proto_list_$MACH and friends in the parent workspace;
1022 1022 when used with -f, also build an unrefmaster.out in the parent
1023 1023 -w report on differences between previous and current proto areas
1024 1024 -z compress cpio archives with gzip
1025 1025 -W Do not report warnings (freeware gate ONLY)
1026 1026 -S Build a variant of the source product
1027 1027 E - build exportable source
1028 1028 D - build domestic source (exportable + crypt)
1029 1029 H - build hybrid source (binaries + deleted source)
1030 1030 O - build (only) open source
1031 1031 '
1032 1032 #
1033 1033 # A log file will be generated under the name $LOGFILE
1034 1034 # for partially completed build and log.`date '+%F'`
1035 1035 # in the same directory for fully completed builds.
1036 1036 #
1037 1037
1038 1038 # default values for low-level FLAGS; G I R are group FLAGS
1039 1039 A_FLAG=n
1040 1040 C_FLAG=n
1041 1041 D_FLAG=n
1042 1042 F_FLAG=n
1043 1043 f_FLAG=n
1044 1044 i_FLAG=n; i_CMD_LINE_FLAG=n
1045 1045 l_FLAG=n
1046 1046 M_FLAG=n
1047 1047 m_FLAG=n
1048 1048 N_FLAG=n
1049 1049 n_FLAG=n
1050 1050 O_FLAG=n
1051 1051 o_FLAG=n
1052 1052 P_FLAG=n
1053 1053 p_FLAG=n
1054 1054 r_FLAG=n
1055 1055 T_FLAG=n
1056 1056 t_FLAG=y
1057 1057 U_FLAG=n
1058 1058 u_FLAG=n
1059 1059 V_FLAG=n
1060 1060 W_FLAG=n
1061 1061 w_FLAG=n
1062 1062 X_FLAG=n
1063 1063 SD_FLAG=n
1064 1064 SE_FLAG=n
1065 1065 SH_FLAG=n
1066 1066 SO_FLAG=n
1067 1067 #
1068 1068 XMOD_OPT=
1069 1069 #
1070 1070 build_ok=y
1071 1071
1072 1072 function is_source_build {
1073 1073 [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o \
1074 1074 "$SH_FLAG" = "y" -o "$SO_FLAG" = "y" ]
1075 1075 return $?
1076 1076 }
1077 1077
1078 1078 #
1079 1079 # examine arguments
1080 1080 #
1081 1081
1082 1082 #
1083 1083 # single function for setting -S flag and doing error checking.
1084 1084 # usage: set_S_flag <type>
1085 1085 # where <type> is the source build type ("E", "D", ...).
1086 1086 #
1087 1087 function set_S_flag {
1088 1088 if is_source_build; then
1089 1089 echo "Can only build one source variant at a time."
1090 1090 exit 1
1091 1091 fi
1092 1092 if [ "$1" = "E" ]; then
1093 1093 SE_FLAG=y
1094 1094 elif [ "$1" = "D" ]; then
1095 1095 SD_FLAG=y
1096 1096 elif [ "$1" = "H" ]; then
1097 1097 SH_FLAG=y
1098 1098 elif [ "$1" = "O" ]; then
1099 1099 SO_FLAG=y
1100 1100 else
1101 1101 echo "$USAGE"
1102 1102 exit 1
1103 1103 fi
1104 1104 }
1105 1105
1106 1106 OPTIND=1
1107 1107 while getopts +inS:tV: FLAG
1108 1108 do
1109 1109 case $FLAG in
1110 1110 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
1111 1111 ;;
1112 1112 n ) n_FLAG=y
1113 1113 ;;
1114 1114 S )
1115 1115 set_S_flag $OPTARG
1116 1116 ;;
1117 1117 +t ) t_FLAG=n
1118 1118 ;;
1119 1119 V ) V_FLAG=y
1120 1120 V_ARG="$OPTARG"
1121 1121 ;;
1122 1122 \? ) echo "$USAGE"
1123 1123 exit 1
1124 1124 ;;
1125 1125 esac
1126 1126 done
1127 1127
1128 1128 # correct argument count after options
1129 1129 shift `expr $OPTIND - 1`
1130 1130
1131 1131 # test that the path to the environment-setting file was given
1132 1132 if [ $# -ne 1 ]; then
1133 1133 echo "$USAGE"
1134 1134 exit 1
1135 1135 fi
1136 1136
1137 1137 # check if user is running nightly as root
1138 1138 # ISUSER is set non-zero if an ordinary user runs nightly, or is zero
1139 1139 # when root invokes nightly.
1140 1140 /usr/bin/id | grep '^uid=0(' >/dev/null 2>&1
1141 1141 ISUSER=$?; export ISUSER
1142 1142
1143 1143 #
1144 1144 # force locale to C
1145 1145 LC_COLLATE=C; export LC_COLLATE
1146 1146 LC_CTYPE=C; export LC_CTYPE
1147 1147 LC_MESSAGES=C; export LC_MESSAGES
1148 1148 LC_MONETARY=C; export LC_MONETARY
1149 1149 LC_NUMERIC=C; export LC_NUMERIC
1150 1150 LC_TIME=C; export LC_TIME
1151 1151
1152 1152 # clear environment variables we know to be bad for the build
1153 1153 unset LD_OPTIONS
1154 1154 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
1155 1155 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
1156 1156 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
1157 1157 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
1158 1158 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
1159 1159 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
1160 1160 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
1161 1161 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
1162 1162 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
1163 1163 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
1164 1164 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
1165 1165 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
1166 1166 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
1167 1167 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
1168 1168 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
1169 1169 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
1170 1170 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
1171 1171 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
1172 1172 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
1173 1173 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
1174 1174
1175 1175 unset CONFIG
1176 1176 unset GROUP
1177 1177 unset OWNER
1178 1178 unset REMOTE
1179 1179 unset ENV
1180 1180 unset ARCH
1181 1181 unset CLASSPATH
1182 1182 unset NAME
1183 1183
1184 1184 #
1185 1185 # To get ONBLD_TOOLS from the environment, it must come from the env file.
1186 1186 # If it comes interactively, it is generally TOOLS_PROTO, which will be
1187 1187 # clobbered before the compiler version checks, which will therefore fail.
1188 1188 #
1189 1189 unset ONBLD_TOOLS
1190 1190
1191 1191 #
1192 1192 # Setup environmental variables
1193 1193 #
1194 1194 if [ -f /etc/nightly.conf ]; then
1195 1195 . /etc/nightly.conf
1196 1196 fi
1197 1197
1198 1198 if [ -f $1 ]; then
1199 1199 if [[ $1 = */* ]]; then
1200 1200 . $1
1201 1201 else
1202 1202 . ./$1
1203 1203 fi
1204 1204 else
1205 1205 if [ -f $OPTHOME/onbld/env/$1 ]; then
1206 1206 . $OPTHOME/onbld/env/$1
1207 1207 else
1208 1208 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1"
1209 1209 exit 1
1210 1210 fi
1211 1211 fi
1212 1212
1213 1213 # contents of stdenv.sh inserted after next line:
1214 1214 # STDENV_START
1215 1215 # STDENV_END
1216 1216
1217 1217 # Check if we have sufficient data to continue...
1218 1218 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1219 1219 if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
1220 1220 # Check if the gate data are valid if we don't do a "bringover" below
1221 1221 [[ -d "${CODEMGR_WS}" ]] || \
1222 1222 fatal_error "Error: ${CODEMGR_WS} is not a directory."
1223 1223 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
1224 1224 fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1225 1225 fi
1226 1226
1227 1227 #
1228 1228 # place ourselves in a new task, respecting BUILD_PROJECT if set.
1229 1229 #
1230 1230 if [ -z "$BUILD_PROJECT" ]; then
1231 1231 /usr/bin/newtask -c $$
1232 1232 else
1233 1233 /usr/bin/newtask -c $$ -p $BUILD_PROJECT
1234 1234 fi
1235 1235
1236 1236 ps -o taskid= -p $$ | read build_taskid
1237 1237 ps -o project= -p $$ | read build_project
1238 1238
1239 1239 #
1240 1240 # See if NIGHTLY_OPTIONS is set
1241 1241 #
1242 1242 if [ "$NIGHTLY_OPTIONS" = "" ]; then
1243 1243 NIGHTLY_OPTIONS="-aBm"
1244 1244 fi
1245 1245
1246 1246 #
1247 1247 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
1248 1248 #
1249 1249 if [ "$BRINGOVER_WS" = "" ]; then
1250 1250 BRINGOVER_WS=$CLONE_WS
1251 1251 fi
1252 1252
1253 1253 #
1254 1254 # If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS
1255 1255 #
1256 1256 if [ "$CLOSED_BRINGOVER_WS" = "" ]; then
1257 1257 CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS
1258 1258 fi
1259 1259
1260 1260 #
1261 1261 # If BRINGOVER_FILES was not specified, default to usr
1262 1262 #
1263 1263 if [ "$BRINGOVER_FILES" = "" ]; then
1264 1264 BRINGOVER_FILES="usr"
1265 1265 fi
1266 1266
1267 1267 #
1268 1268 # If the closed sources are not present, the closed binaries must be
1269 1269 # present for the build to succeed. If there's no pointer to the
1270 1270 # closed binaries, flag that now, rather than forcing the user to wait
1271 1271 # a couple hours (or more) to find out.
1272 1272 #
1273 1273 orig_closed_is_present="$CLOSED_IS_PRESENT"
1274 1274 check_closed_tree
1275 1275
1276 1276 #
1277 1277 # Note: changes to the option letters here should also be applied to the
1278 1278 # bldenv script. `d' is listed for backward compatibility.
1279 1279 #
1280 1280 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
1281 1281 OPTIND=1
1282 1282 while getopts +ABCDdFfGIilMmNnOoPpRrS:TtUuWwXxz FLAG $NIGHTLY_OPTIONS
1283 1283 do
1284 1284 case $FLAG in
1285 1285 A ) A_FLAG=y
1286 1286 #
1287 1287 # If ELF_DATA_BASELINE_DIR is not defined, and we are on SWAN
1288 1288 # (based on CLOSED_IS_PRESENT), then refuse to run. The value
1289 1289 # of ELF version checking is greatly enhanced by including
1290 1290 # the baseline gate comparison.
1291 1291 if [ "$CLOSED_IS_PRESENT" = 'yes' -a \
1292 1292 "$ELF_DATA_BASELINE_DIR" = '' ]; then
1293 1293 echo "ELF_DATA_BASELINE_DIR must be set if the A" \
1294 1294 "flag is present in\nNIGHTLY_OPTIONS and closed" \
1295 1295 "sources are present. Update environment file."
1296 1296 exit 1;
1297 1297 fi
1298 1298 ;;
1299 1299 B ) D_FLAG=y
1300 1300 ;; # old version of D
1301 1301 C ) C_FLAG=y
1302 1302 ;;
1303 1303 D ) D_FLAG=y
1304 1304 ;;
1305 1305 F ) F_FLAG=y
1306 1306 ;;
1307 1307 f ) f_FLAG=y
1308 1308 ;;
1309 1309 G ) u_FLAG=y
1310 1310 ;;
1311 1311 I ) m_FLAG=y
1312 1312 p_FLAG=y
1313 1313 u_FLAG=y
1314 1314 ;;
1315 1315 i ) i_FLAG=y
1316 1316 ;;
1317 1317 l ) l_FLAG=y
1318 1318 ;;
1319 1319 M ) M_FLAG=y
1320 1320 ;;
1321 1321 m ) m_FLAG=y
1322 1322 ;;
1323 1323 N ) N_FLAG=y
1324 1324 ;;
1325 1325 n ) n_FLAG=y
1326 1326 ;;
1327 1327 O ) O_FLAG=y
1328 1328 ;;
1329 1329 o ) o_FLAG=y
1330 1330 ;;
1331 1331 P ) P_FLAG=y
1332 1332 ;; # obsolete
1333 1333 p ) p_FLAG=y
1334 1334 ;;
1335 1335 R ) m_FLAG=y
1336 1336 p_FLAG=y
1337 1337 ;;
1338 1338 r ) r_FLAG=y
1339 1339 ;;
1340 1340 S )
1341 1341 set_S_flag $OPTARG
1342 1342 ;;
1343 1343 T ) T_FLAG=y
1344 1344 ;; # obsolete
1345 1345 +t ) t_FLAG=n
1346 1346 ;;
1347 1347 U ) if [ -z "${PARENT_ROOT}" ]; then
1348 1348 echo "PARENT_ROOT must be set if the U flag is" \
1349 1349 "present in NIGHTLY_OPTIONS."
1350 1350 exit 1
1351 1351 fi
1352 1352 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
1353 1353 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
1354 1354 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
1355 1355 fi
1356 1356 U_FLAG=y
1357 1357 ;;
1358 1358 u ) u_FLAG=y
1359 1359 ;;
1360 1360 W ) W_FLAG=y
1361 1361 ;;
1362 1362
1363 1363 w ) w_FLAG=y
1364 1364 ;;
1365 1365 X ) # now that we no longer need realmode builds, just
1366 1366 # copy IHV packages. only meaningful on x86.
1367 1367 if [ "$MACH" = "i386" ]; then
1368 1368 X_FLAG=y
1369 1369 fi
1370 1370 ;;
1371 1371 x ) XMOD_OPT="-x"
1372 1372 ;;
1373 1373 \? ) echo "$USAGE"
1374 1374 exit 1
1375 1375 ;;
1376 1376 esac
1377 1377 done
1378 1378
1379 1379 if [ $ISUSER -ne 0 ]; then
1380 1380 if [ "$o_FLAG" = "y" ]; then
1381 1381 echo "Old-style build requires root permission."
1382 1382 exit 1
1383 1383 fi
1384 1384
1385 1385 # Set default value for STAFFER, if needed.
1386 1386 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
1387 1387 STAFFER=`/usr/xpg4/bin/id -un`
1388 1388 export STAFFER
1389 1389 fi
1390 1390 fi
1391 1391
1392 1392 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
1393 1393 MAILTO=$STAFFER
1394 1394 export MAILTO
1395 1395 fi
1396 1396
1397 1397 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
1398 1398 PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb"
1399 1399 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
1400 1400 export PATH
1401 1401
1402 1402 # roots of source trees, both relative to $SRC and absolute.
1403 1403 relsrcdirs="."
1404 1404 if [[ -d $CODEMGR_WS/usr/closed && "$CLOSED_IS_PRESENT" != no ]]; then
1405 1405 relsrcdirs="$relsrcdirs ../closed"
1406 1406 fi
1407 1407 abssrcdirs=""
1408 1408 for d in $relsrcdirs; do
1409 1409 abssrcdirs="$abssrcdirs $SRC/$d"
1410 1410 done
1411 1411
1412 1412 unset CH
1413 1413 if [ "$o_FLAG" = "y" ]; then
1414 1414 # root invoked old-style build -- make sure it works as it always has
1415 1415 # by exporting 'CH'. The current Makefile.master doesn't use this, but
1416 1416 # the old ones still do.
1417 1417 PROTOCMPTERSE="protocmp.terse"
1418 1418 CH=
1419 1419 export CH
1420 1420 else
1421 1421 PROTOCMPTERSE="protocmp.terse -gu"
1422 1422 fi
1423 1423 POUND_SIGN="#"
1424 1424 # have we set RELEASE_DATE in our env file?
1425 1425 if [ -z "$RELEASE_DATE" ]; then
1426 1426 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
1427 1427 fi
1428 1428 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
1429 1429 BASEWSDIR=$(basename $CODEMGR_WS)
1430 1430 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
1431 1431
1432 1432 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
1433 1433 # by avoiding repeated shell invocations to evaluate Makefile.master definitions.
1434 1434 # we export o_FLAG and X_FLAG for use by makebfu, and by usr/src/pkg/Makefile
1435 1435 export o_FLAG X_FLAG POUND_SIGN RELEASE_DATE DEV_CM
1436 1436
1437 1437 maketype="distributed"
1438 1438 MAKE=dmake
1439 1439 # get the dmake version string alone
1440 1440 DMAKE_VERSION=$( $MAKE -v )
1441 1441 DMAKE_VERSION=${DMAKE_VERSION#*: }
1442 1442 # focus in on just the dotted version number alone
1443 1443 DMAKE_MAJOR=$( echo $DMAKE_VERSION | \
1444 1444 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' )
1445 1445 # extract the second (or final) integer
1446 1446 DMAKE_MINOR=${DMAKE_MAJOR#*.}
1447 1447 DMAKE_MINOR=${DMAKE_MINOR%%.*}
1448 1448 # extract the first integer
1449 1449 DMAKE_MAJOR=${DMAKE_MAJOR%%.*}
1450 1450 CHECK_DMAKE=${CHECK_DMAKE:-y}
1451 1451 # x86 was built on the 12th, sparc on the 13th.
1452 1452 if [ "$CHECK_DMAKE" = "y" -a \
1453 1453 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \
1454 1454 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \
1455 1455 "$DMAKE_MAJOR" -lt 7 -o \
1456 1456 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then
1457 1457 if [ -z "$DMAKE_VERSION" ]; then
1458 1458 echo "$MAKE is missing."
1459 1459 exit 1
1460 1460 fi
1461 1461 echo `whence $MAKE`" version is:"
1462 1462 echo " ${DMAKE_VERSION}"
1463 1463 cat <<EOF
1464 1464
1465 1465 This version may not be safe for use. Either set TEAMWARE to a better
1466 1466 path or (if you really want to use this version of dmake anyway), add
1467 1467 the following to your environment to disable this check:
1468 1468
1469 1469 CHECK_DMAKE=n
1470 1470 EOF
1471 1471 exit 1
1472 1472 fi
1473 1473 export PATH
1474 1474 export MAKE
1475 1475
1476 1476 if [[ "$O_FLAG" = y ]]; then
1477 1477 export TONICBUILD=""
1478 1478 else
1479 1479 export TONICBUILD="#"
1480 1480 fi
1481 1481
1482 1482 if [ "${SUNWSPRO}" != "" ]; then
1483 1483 PATH="${SUNWSPRO}/bin:$PATH"
1484 1484 export PATH
1485 1485 fi
1486 1486
1487 1487 hostname=$(uname -n)
1488 1488 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
1489 1489 then
1490 1490 maxjobs=
1491 1491 if [[ -f $HOME/.make.machines ]]
1492 1492 then
1493 1493 # Note: there is a hard tab and space character in the []s
1494 1494 # below.
1495 1495 egrep -i "^[ ]*$hostname[ \.]" \
1496 1496 $HOME/.make.machines | read host jobs
1497 1497 maxjobs=${jobs##*=}
1498 1498 fi
1499 1499
1500 1500 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
1501 1501 then
1502 1502 # default
1503 1503 maxjobs=4
1504 1504 fi
1505 1505
1506 1506 export DMAKE_MAX_JOBS=$maxjobs
1507 1507 fi
1508 1508
1509 1509 DMAKE_MODE=parallel;
1510 1510 export DMAKE_MODE
1511 1511
1512 1512 if [ -z "${ROOT}" ]; then
1513 1513 echo "ROOT must be set."
1514 1514 exit 1
1515 1515 fi
1516 1516
1517 1517 #
1518 1518 # if -V flag was given, reset VERSION to V_ARG
1519 1519 #
1520 1520 if [ "$V_FLAG" = "y" ]; then
1521 1521 VERSION=$V_ARG
1522 1522 fi
1523 1523
1524 1524 #
1525 1525 # Check for IHV root for copying ihv proto area
1526 1526 #
1527 1527 if [ "$X_FLAG" = "y" ]; then
1528 1528 if [ "$IA32_IHV_ROOT" = "" ]; then
1529 1529 echo "IA32_IHV_ROOT: must be set for copying ihv proto"
1530 1530 args_ok=n
1531 1531 fi
1532 1532 if [ ! -d "$IA32_IHV_ROOT" ]; then
1533 1533 echo "$IA32_IHV_ROOT: not found"
1534 1534 args_ok=n
1535 1535 fi
1536 1536 if [ "$IA32_IHV_WS" = "" ]; then
1537 1537 echo "IA32_IHV_WS: must be set for copying ihv proto"
1538 1538 args_ok=n
1539 1539 fi
1540 1540 if [ ! -d "$IA32_IHV_WS" ]; then
1541 1541 echo "$IA32_IHV_WS: not found"
1542 1542 args_ok=n
1543 1543 fi
1544 1544 fi
1545 1545
1546 1546 # Append source version
1547 1547 if [ "$SE_FLAG" = "y" ]; then
1548 1548 VERSION="${VERSION}:EXPORT"
1549 1549 fi
1550 1550
1551 1551 if [ "$SD_FLAG" = "y" ]; then
1552 1552 VERSION="${VERSION}:DOMESTIC"
1553 1553 fi
1554 1554
1555 1555 if [ "$SH_FLAG" = "y" ]; then
1556 1556 VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT"
1557 1557 fi
1558 1558
1559 1559 if [ "$SO_FLAG" = "y" ]; then
1560 1560 VERSION="${VERSION}:OPEN_ONLY"
1561 1561 fi
1562 1562
1563 1563 TMPDIR="/tmp/nightly.tmpdir.$$"
1564 1564 export TMPDIR
1565 1565 rm -rf ${TMPDIR}
1566 1566 mkdir -p $TMPDIR || exit 1
1567 1567 chmod 777 $TMPDIR
1568 1568
1569 1569 #
1570 1570 # Keep elfsign's use of pkcs11_softtoken from looking in the user home
1571 1571 # directory, which doesn't always work. Needed until all build machines
1572 1572 # have the fix for 6271754
1573 1573 #
1574 1574 SOFTTOKEN_DIR=$TMPDIR
1575 1575 export SOFTTOKEN_DIR
1576 1576
1577 1577 #
1578 1578 # Tools should only be built non-DEBUG. Keep track of the tools proto
1579 1579 # area path relative to $TOOLS, because the latter changes in an
1580 1580 # export build.
1581 1581 #
1582 1582 # TOOLS_PROTO is included below for builds other than usr/src/tools
1583 1583 # that look for this location. For usr/src/tools, this will be
1584 1584 # overridden on the $MAKE command line in build_tools().
1585 1585 #
1586 1586 TOOLS=${SRC}/tools
1587 1587 TOOLS_PROTO_REL=proto/root_${MACH}-nd
1588 1588 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
1589 1589
1590 1590 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
1591 1591
1592 1592 # create directories that are automatically removed if the nightly script
1593 1593 # fails to start correctly
1594 1594 function newdir {
1595 1595 dir=$1
1596 1596 toadd=
1597 1597 while [ ! -d $dir ]; do
1598 1598 toadd="$dir $toadd"
1599 1599 dir=`dirname $dir`
1600 1600 done
1601 1601 torm=
1602 1602 newlist=
1603 1603 for dir in $toadd; do
1604 1604 if staffer mkdir $dir; then
1605 1605 newlist="$ISUSER $dir $newlist"
1606 1606 torm="$dir $torm"
1607 1607 else
1608 1608 [ -z "$torm" ] || staffer rmdir $torm
1609 1609 return 1
1610 1610 fi
1611 1611 done
1612 1612 newdirlist="$newlist $newdirlist"
1613 1613 return 0
1614 1614 }
1615 1615 newdirlist=
1616 1616
1617 1617 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
1618 1618
1619 1619 # since this script assumes the build is from full source, it nullifies
1620 1620 # variables likely to have been set by a "ws" script; nullification
1621 1621 # confines the search space for headers and libraries to the proto area
1622 1622 # built from this immediate source.
1623 1623 ENVLDLIBS1=
1624 1624 ENVLDLIBS2=
1625 1625 ENVLDLIBS3=
1626 1626 ENVCPPFLAGS1=
1627 1627 ENVCPPFLAGS2=
1628 1628 ENVCPPFLAGS3=
1629 1629 ENVCPPFLAGS4=
1630 1630 PARENT_ROOT=
1631 1631
1632 1632 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1633 1633 PARENT_ROOT
1634 1634
1635 1635 PKGARCHIVE_ORIG=$PKGARCHIVE
1636 1636 IA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS
1637 1637
1638 1638 #
1639 1639 # Juggle the logs and optionally send mail on completion.
1640 1640 #
1641 1641
1642 1642 function logshuffle {
1643 1643 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
1644 1644 if [ -f $LLOG -o -d $LLOG ]; then
1645 1645 LLOG=$LLOG.$$
1646 1646 fi
1647 1647 mkdir $LLOG
1648 1648 export LLOG
1649 1649
1650 1650 if [ "$build_ok" = "y" ]; then
1651 1651 mv $ATLOG/proto_list_${MACH} $LLOG
1652 1652
1653 1653 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
1654 1654 mv $ATLOG/proto_list_tools_${MACH} $LLOG
1655 1655 fi
1656 1656
1657 1657 if [ -f $TMPDIR/wsdiff.results ]; then
1658 1658 mv $TMPDIR/wsdiff.results $LLOG
1659 1659 fi
1660 1660
1661 1661 if [ -f $TMPDIR/wsdiff-nd.results ]; then
1662 1662 mv $TMPDIR/wsdiff-nd.results $LLOG
1663 1663 fi
1664 1664 fi
1665 1665
1666 1666 #
1667 1667 # Now that we're about to send mail, it's time to check the noise
1668 1668 # file. In the event that an error occurs beyond this point, it will
1669 1669 # be recorded in the nightly.log file, but nowhere else. This would
1670 1670 # include only errors that cause the copying of the noise log to fail
1671 1671 # or the mail itself not to be sent.
1672 1672 #
1673 1673
1674 1674 exec >>$LOGFILE 2>&1
1675 1675 if [ -s $build_noise_file ]; then
1676 1676 echo "\n==== Nightly build noise ====\n" |
1677 1677 tee -a $LOGFILE >>$mail_msg_file
1678 1678 cat $build_noise_file >>$LOGFILE
1679 1679 cat $build_noise_file >>$mail_msg_file
1680 1680 echo | tee -a $LOGFILE >>$mail_msg_file
1681 1681 fi
1682 1682 rm -f $build_noise_file
1683 1683
1684 1684 case "$build_ok" in
1685 1685 y)
1686 1686 state=Completed
1687 1687 ;;
1688 1688 i)
1689 1689 state=Interrupted
1690 1690 ;;
1691 1691 *)
1692 1692 state=Failed
1693 1693 ;;
1694 1694 esac
1695 1695 NIGHTLY_STATUS=$state
1696 1696 export NIGHTLY_STATUS
1697 1697
1698 1698 run_hook POST_NIGHTLY $state
1699 1699 run_hook SYS_POST_NIGHTLY $state
1700 1700
1701 1701 #
1702 1702 # mailx(1) sets From: based on the -r flag
1703 1703 # if it is given.
1704 1704 #
1705 1705 mailx_r=
1706 1706 if [[ -n "${MAILFROM}" ]]; then
1707 1707 mailx_r="-r ${MAILFROM}"
1708 1708 fi
1709 1709
1710 1710 cat $build_time_file $build_environ_file $mail_msg_file \
1711 1711 > ${LLOG}/mail_msg
1712 1712 if [ "$m_FLAG" = "y" ]; then
1713 1713 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1714 1714 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1715 1715 ${MAILTO}
1716 1716 fi
1717 1717
1718 1718 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1719 1719 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH}
1720 1720 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log
1721 1721 fi
1722 1722
1723 1723 mv $LOGFILE $LLOG
1724 1724 }
1725 1725
1726 1726 #
1727 1727 # Remove the locks and temporary files on any exit
1728 1728 #
1729 1729 function cleanup {
1730 1730 logshuffle
1731 1731
1732 1732 [ -z "$lockfile" ] || staffer rm -f $lockfile
1733 1733 [ -z "$atloglockfile" ] || rm -f $atloglockfile
1734 1734 [ -z "$ulockfile" ] || staffer rm -f $ulockfile
1735 1735 [ -z "$Ulockfile" ] || rm -f $Ulockfile
1736 1736
1737 1737 set -- $newdirlist
1738 1738 while [ $# -gt 0 ]; do
1739 1739 ISUSER=$1 staffer rmdir $2
1740 1740 shift; shift
1741 1741 done
1742 1742 rm -rf $TMPDIR
1743 1743 }
1744 1744
1745 1745 function cleanup_signal {
1746 1746 build_ok=i
1747 1747 # this will trigger cleanup(), above.
1748 1748 exit 1
1749 1749 }
1750 1750
1751 1751 trap cleanup 0
1752 1752 trap cleanup_signal 1 2 3 15
1753 1753
1754 1754 #
1755 1755 # Generic lock file processing -- make sure that the lock file doesn't
1756 1756 # exist. If it does, it should name the build host and PID. If it
1757 1757 # doesn't, then make sure we can create it. Clean up locks that are
1758 1758 # known to be stale (assumes host name is unique among build systems
1759 1759 # for the workspace).
1760 1760 #
1761 1761 function create_lock {
1762 1762 lockf=$1
1763 1763 lockvar=$2
1764 1764
1765 1765 ldir=`dirname $lockf`
1766 1766 [ -d $ldir ] || newdir $ldir || exit 1
1767 1767 eval $lockvar=$lockf
1768 1768
1769 1769 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1770 1770 basews=`basename $CODEMGR_WS`
1771 1771 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1772 1772 if [ "$host" != "$hostname" ]; then
1773 1773 echo "$MACH build of $basews apparently" \
1774 1774 "already started by $user on $host as $pid."
1775 1775 exit 1
1776 1776 elif kill -s 0 $pid 2>/dev/null; then
1777 1777 echo "$MACH build of $basews already started" \
1778 1778 "by $user as $pid."
1779 1779 exit 1
1780 1780 else
1781 1781 # stale lock; clear it out and try again
1782 1782 rm -f $lockf
1783 1783 fi
1784 1784 done
1785 1785 }
1786 1786
1787 1787 #
1788 1788 # Return the list of interesting proto areas, depending on the current
1789 1789 # options.
1790 1790 #
1791 1791 function allprotos {
1792 1792 typeset roots="$ROOT"
1793 1793
1794 1794 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1795 1795 roots="$roots $ROOT-nd"
1796 1796 fi
1797 1797
1798 1798 if [[ $O_FLAG = y ]]; then
1799 1799 roots="$roots $ROOT-closed"
1800 1800 [ $MULTI_PROTO = yes ] && roots="$roots $ROOT-nd-closed"
1801 1801 fi
1802 1802
1803 1803 echo $roots
1804 1804 }
1805 1805
1806 1806 # Ensure no other instance of this script is running on this host.
1807 1807 # LOCKNAME can be set in <env_file>, and is by default, but is not
1808 1808 # required due to the use of $ATLOG below.
1809 1809 if [ -n "$LOCKNAME" ]; then
1810 1810 create_lock /tmp/$LOCKNAME "lockfile"
1811 1811 fi
1812 1812 #
1813 1813 # Create from one, two, or three other locks:
1814 1814 # $ATLOG/nightly.lock
1815 1815 # - protects against multiple builds in same workspace
1816 1816 # $PARENT_WS/usr/src/nightly.$MACH.lock
1817 1817 # - protects against multiple 'u' copy-backs
1818 1818 # $NIGHTLY_PARENT_ROOT/nightly.lock
1819 1819 # - protects against multiple 'U' copy-backs
1820 1820 #
1821 1821 # Overriding ISUSER to 1 causes the lock to be created as root if the
1822 1822 # script is run as root. The default is to create it as $STAFFER.
1823 1823 ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile"
1824 1824 if [ "$u_FLAG" = "y" ]; then
1825 1825 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile"
1826 1826 fi
1827 1827 if [ "$U_FLAG" = "y" ]; then
1828 1828 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1829 1829 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile"
1830 1830 fi
1831 1831
1832 1832 # Locks have been taken, so we're doing a build and we're committed to
1833 1833 # the directories we may have created so far.
1834 1834 newdirlist=
1835 1835
1836 1836 #
1837 1837 # Create mail_msg_file
1838 1838 #
1839 1839 mail_msg_file="${TMPDIR}/mail_msg"
1840 1840 touch $mail_msg_file
1841 1841 build_time_file="${TMPDIR}/build_time"
1842 1842 build_environ_file="${TMPDIR}/build_environ"
1843 1843 touch $build_environ_file
1844 1844 #
1845 1845 # Move old LOGFILE aside
1846 1846 # ATLOG directory already made by 'create_lock' above
1847 1847 #
1848 1848 if [ -f $LOGFILE ]; then
1849 1849 mv -f $LOGFILE ${LOGFILE}-
1850 1850 fi
1851 1851 #
1852 1852 # Build OsNet source
1853 1853 #
1854 1854 START_DATE=`date`
1855 1855 SECONDS=0
1856 1856 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1857 1857 | tee -a $LOGFILE > $build_time_file
1858 1858
1859 1859 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1860 1860 tee -a $mail_msg_file >> $LOGFILE
1861 1861
1862 1862 # make sure we log only to the nightly build file
1863 1863 build_noise_file="${TMPDIR}/build_noise"
1864 1864 exec </dev/null >$build_noise_file 2>&1
1865 1865
1866 1866 run_hook SYS_PRE_NIGHTLY
1867 1867 run_hook PRE_NIGHTLY
1868 1868
1869 1869 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1870 1870 env >> $LOGFILE
1871 1871
1872 1872 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1873 1873
1874 1874 if [ "$P_FLAG" = "y" ]; then
1875 1875 obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE
1876 1876 fi
1877 1877
1878 1878 if [ "$T_FLAG" = "y" ]; then
1879 1879 obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE
1880 1880 fi
1881 1881
1882 1882 if is_source_build; then
1883 1883 if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then
1884 1884 echo "WARNING: the -S flags do not support incremental" \
1885 1885 "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE
1886 1886 i_FLAG=n
1887 1887 i_CMD_LINE_FLAG=n
1888 1888 fi
1889 1889 if [ "$N_FLAG" = "n" ]; then
1890 1890 echo "WARNING: the -S flags do not support protocmp;" \
1891 1891 "protocmp disabled\n" | \
1892 1892 tee -a $mail_msg_file >> $LOGFILE
1893 1893 N_FLAG=y
1894 1894 fi
1895 1895 if [ "$l_FLAG" = "y" ]; then
1896 1896 echo "WARNING: the -S flags do not support lint;" \
1897 1897 "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE
1898 1898 l_FLAG=n
1899 1899 fi
1900 1900 if [ "$C_FLAG" = "y" ]; then
1901 1901 echo "WARNING: the -S flags do not support cstyle;" \
1902 1902 "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE
1903 1903 C_FLAG=n
1904 1904 fi
1905 1905 else
1906 1906 if [ "$N_FLAG" = "y" ]; then
1907 1907 if [ "$p_FLAG" = "y" ]; then
1908 1908 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1909 1909 WARNING: the p option (create packages) is set, but so is the N option (do
1910 1910 not run protocmp); this is dangerous; you should unset the N option
1911 1911 EOF
1912 1912 else
1913 1913 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1914 1914 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1915 1915 EOF
1916 1916 fi
1917 1917 echo "" | tee -a $mail_msg_file >> $LOGFILE
1918 1918 fi
1919 1919 fi
1920 1920
1921 1921 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1922 1922 #
1923 1923 # In the past we just complained but went ahead with the lint
1924 1924 # pass, even though the proto area was built non-DEBUG. It's
1925 1925 # unlikely that non-DEBUG headers will make a difference, but
1926 1926 # rather than assuming it's a safe combination, force the user
1927 1927 # to specify a DEBUG build.
1928 1928 #
1929 1929 echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1930 1930 | tee -a $mail_msg_file >> $LOGFILE
1931 1931 l_FLAG=n
1932 1932 fi
1933 1933
1934 1934 if [ "$f_FLAG" = "y" ]; then
1935 1935 if [ "$i_FLAG" = "y" ]; then
1936 1936 echo "WARNING: the -f flag cannot be used during incremental" \
1937 1937 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1938 1938 f_FLAG=n
1939 1939 fi
1940 1940 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then
1941 1941 echo "WARNING: the -f flag requires -l, and -p;" \
1942 1942 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1943 1943 f_FLAG=n
1944 1944 fi
1945 1945 fi
1946 1946
1947 1947 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1948 1948 echo "WARNING: -w specified, but $ROOT does not exist;" \
1949 1949 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE
1950 1950 w_FLAG=n
1951 1951 fi
1952 1952
1953 1953 if [ "$t_FLAG" = "n" ]; then
1954 1954 #
1955 1955 # We're not doing a tools build, so make sure elfsign(1) is
1956 1956 # new enough to safely sign non-crypto binaries. We test
1957 1957 # debugging output from elfsign to detect the old version.
1958 1958 #
1959 1959 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \
1960 1960 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \
1961 1961 | egrep algorithmOID`
1962 1962 if [ -z "$newelfsigntest" ]; then
1963 1963 echo "WARNING: /usr/bin/elfsign out of date;" \
1964 1964 "will only sign crypto modules\n" | \
1965 1965 tee -a $mail_msg_file >> $LOGFILE
1966 1966 export ELFSIGN_OBJECT=true
1967 1967 elif [ "$VERIFY_ELFSIGN" = "y" ]; then
1968 1968 echo "WARNING: VERIFY_ELFSIGN=y requires" \
1969 1969 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \
1970 1970 tee -a $mail_msg_file >> $LOGFILE
1971 1971 fi
1972 1972 fi
1973 1973
1974 1974 [ "$O_FLAG" = y ] && MULTI_PROTO=yes
1975 1975
1976 1976 case $MULTI_PROTO in
1977 1977 yes|no) ;;
1978 1978 *)
1979 1979 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1980 1980 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1981 1981 echo "Setting MULTI_PROTO to \"no\".\n" | \
1982 1982 tee -a $mail_msg_file >> $LOGFILE
1983 1983 export MULTI_PROTO=no
1984 1984 ;;
1985 1985 esac
1986 1986
1987 1987 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1988 1988 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1989 1989
1990 1990 # Save the current proto area if we're comparing against the last build
1991 1991 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1992 1992 if [ -d "$ROOT.prev" ]; then
1993 1993 rm -rf $ROOT.prev
1994 1994 fi
1995 1995 mv $ROOT $ROOT.prev
1996 1996 fi
1997 1997
1998 1998 # Same for non-DEBUG proto area
1999 1999 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
2000 2000 if [ -d "$ROOT-nd.prev" ]; then
2001 2001 rm -rf $ROOT-nd.prev
2002 2002 fi
2003 2003 mv $ROOT-nd $ROOT-nd.prev
2004 2004 fi
2005 2005
2006 2006 #
2007 2007 # Echo the SCM type of the parent workspace, this can't just be which_scm
2008 2008 # as that does not know how to identify various network repositories.
2009 2009 #
2010 2010 function parent_wstype {
2011 2011 typeset scm_type junk
2012 2012
2013 2013 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
2014 2014 | read scm_type junk
2015 2015 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
2016 2016 # Probe BRINGOVER_WS to determine its type
2017 2017 if [[ $BRINGOVER_WS == svn*://* ]]; then
2018 2018 scm_type="subversion"
2019 2019 elif [[ $BRINGOVER_WS == file://* ]] &&
2020 2020 egrep -s "This is a Subversion repository" \
2021 2021 ${BRINGOVER_WS#file://}/README.txt 2> /dev/null; then
2022 2022 scm_type="subversion"
2023 2023 elif [[ $BRINGOVER_WS == ssh://* ]]; then
2024 2024 scm_type="mercurial"
2025 2025 elif [[ $BRINGOVER_WS == http://* ]] && \
2026 2026 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
2027 2027 egrep -s "application/mercurial" 2> /dev/null; then
2028 2028 scm_type="mercurial"
2029 2029 elif svn info $BRINGOVER_WS > /dev/null 2>&1; then
2030 2030 scm_type="subversion"
2031 2031 else
2032 2032 scm_type="none"
2033 2033 fi
2034 2034 fi
2035 2035
2036 2036 # fold both unsupported and unrecognized results into "none"
2037 2037 case "$scm_type" in
2038 2038 none|subversion|teamware|mercurial)
2039 2039 ;;
2040 2040 *) scm_type=none
2041 2041 ;;
2042 2042 esac
2043 2043
2044 2044 echo $scm_type
2045 2045 }
2046 2046
2047 2047 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
2048 2048 function child_wstype {
2049 2049 typeset scm_type junk
2050 2050
2051 2051 # Probe CODEMGR_WS to determine its type
2052 2052 if [[ -d $CODEMGR_WS ]]; then
2053 2053 $WHICH_SCM | read scm_type junk || exit 1
2054 2054 fi
2055 2055
2056 2056 case "$scm_type" in
2057 2057 none|subversion|git|teamware|mercurial)
2058 2058 ;;
2059 2059 *) scm_type=none
2060 2060 ;;
2061 2061 esac
2062 2062
2063 2063 echo $scm_type
2064 2064 }
2065 2065
2066 2066 SCM_TYPE=$(child_wstype)
2067 2067
2068 2068 #
2069 2069 # Decide whether to clobber
2070 2070 #
2071 2071 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
2072 2072 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
2073 2073
2074 2074 cd $SRC
2075 2075 # remove old clobber file
2076 2076 rm -f $SRC/clobber.out
2077 2077 rm -f $SRC/clobber-${MACH}.out
2078 2078
2079 2079 # Remove all .make.state* files, just in case we are restarting
2080 2080 # the build after having interrupted a previous 'make clobber'.
2081 2081 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
2082 2082 -o -name 'interfaces.*' \) -prune \
2083 2083 -o -name '.make.*' -print | xargs rm -f
2084 2084
2085 2085 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
2086 2086 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
2087 2087 grep "$MAKE:" $SRC/clobber-${MACH}.out |
2088 2088 egrep -v "Ignoring unknown host" \
2089 2089 >> $mail_msg_file
2090 2090
2091 2091 if [[ "$t_FLAG" = "y" || "$O_FLAG" = "y" ]]; then
2092 2092 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
2093 2093 cd ${TOOLS}
2094 2094 rm -f ${TOOLS}/clobber-${MACH}.out
2095 2095 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
2096 2096 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
2097 2097 echo "\n==== Make tools clobber ERRORS ====\n" \
2098 2098 >> $mail_msg_file
2099 2099 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
2100 2100 >> $mail_msg_file
2101 2101 rm -rf ${TOOLS_PROTO}
2102 2102 mkdir -p ${TOOLS_PROTO}
2103 2103 fi
2104 2104
2105 2105 typeset roots=$(allprotos)
2106 2106 echo "\n\nClearing $roots" >> "$LOGFILE"
2107 2107 rm -rf $roots
2108 2108
2109 2109 # Get back to a clean workspace as much as possible to catch
2110 2110 # problems that only occur on fresh workspaces.
2111 2111 # Remove all .make.state* files, libraries, and .o's that may
2112 2112 # have been omitted from clobber. A couple of libraries are
2113 2113 # under source code control, so leave them alone.
2114 2114 # We should probably blow away temporary directories too.
2115 2115 cd $SRC
2116 2116 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
2117 2117 -o -name .git -o -name 'interfaces.*' \) -prune -o \
2118 2118 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
2119 2119 -name '*.o' \) -print | \
2120 2120 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
2121 2121 else
2122 2122 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
2123 2123 fi
2124 2124
2125 2125 type bringover_teamware > /dev/null 2>&1 || function bringover_teamware {
2126 2126 # sleep on the parent workspace's lock
2127 2127 while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks
2128 2128 do
2129 2129 sleep 120
2130 2130 done
2131 2131
2132 2132 if [[ -z $BRINGOVER ]]; then
2133 2133 BRINGOVER=$TEAMWARE/bin/bringover
2134 2134 fi
2135 2135
2136 2136 staffer $BRINGOVER -c "nightly update" -p $BRINGOVER_WS \
2137 2137 -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 ||
2138 2138 touch $TMPDIR/bringover_failed
2139 2139
2140 2140 staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1
2141 2141 if [ -s $TMPDIR/bringovercheck.out ]; then
2142 2142 echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n"
2143 2143 cat $TMPDIR/bringovercheck.out
2144 2144 fi
2145 2145 }
2146 2146
2147 2147 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
2148 2148 typeset -x PATH=$PATH
2149 2149
2150 2150 # If the repository doesn't exist yet, then we want to populate it.
2151 2151 if [[ ! -d $CODEMGR_WS/.hg ]]; then
2152 2152 staffer hg init $CODEMGR_WS
2153 2153 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
2154 2154 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
2155 2155 touch $TMPDIR/new_repository
2156 2156 fi
2157 2157
2158 2158 #
2159 2159 # If the user set CLOSED_BRINGOVER_WS and didn't set CLOSED_IS_PRESENT
2160 2160 # to "no," then we'll want to initialise the closed repository
2161 2161 #
2162 2162 # We use $orig_closed_is_present instead of $CLOSED_IS_PRESENT,
2163 2163 # because for newly-created source trees, the latter will be "no"
2164 2164 # until after the bringover completes.
2165 2165 #
2166 2166 if [[ "$orig_closed_is_present" != "no" && \
2167 2167 -n "$CLOSED_BRINGOVER_WS" && \
2168 2168 ! -d $CODEMGR_WS/usr/closed/.hg ]]; then
2169 2169 staffer mkdir -p $CODEMGR_WS/usr/closed
2170 2170 staffer hg init $CODEMGR_WS/usr/closed
2171 2171 staffer echo "[paths]" > $CODEMGR_WS/usr/closed/.hg/hgrc
2172 2172 staffer echo "default=$CLOSED_BRINGOVER_WS" >> $CODEMGR_WS/usr/closed/.hg/hgrc
2173 2173 touch $TMPDIR/new_closed
2174 2174 export CLOSED_IS_PRESENT=yes
2175 2175 fi
2176 2176
2177 2177 typeset -x HGMERGE="/bin/false"
2178 2178
2179 2179 #
2180 2180 # If the user has changes, regardless of whether those changes are
2181 2181 # committed, and regardless of whether those changes conflict, then
2182 2182 # we'll attempt to merge them either implicitly (uncommitted) or
2183 2183 # explicitly (committed).
2184 2184 #
2185 2185 # These are the messages we'll use to help clarify mercurial output
2186 2186 # in those cases.
2187 2187 #
2188 2188 typeset mergefailmsg="\
2189 2189 ***\n\
2190 2190 *** nightly was unable to automatically merge your changes. You should\n\
2191 2191 *** redo the full merge manually, following the steps outlined by mercurial\n\
2192 2192 *** above, then restart nightly.\n\
2193 2193 ***\n"
2194 2194 typeset mergepassmsg="\
2195 2195 ***\n\
2196 2196 *** nightly successfully merged your changes. This means that your working\n\
2197 2197 *** directory has been updated, but those changes are not yet committed.\n\
2198 2198 *** After nightly completes, you should validate the results of the merge,\n\
2199 2199 *** then use hg commit manually.\n\
2200 2200 ***\n"
2201 2201
2202 2202 #
2203 2203 # For each repository in turn:
2204 2204 #
2205 2205 # 1. Do the pull. If this fails, dump the output and bail out.
2206 2206 #
2207 2207 # 2. If the pull resulted in an extra head, do an explicit merge.
2208 2208 # If this fails, dump the output and bail out.
2209 2209 #
2210 2210 # Because we can't rely on Mercurial to exit with a failure code
2211 2211 # when a merge fails (Mercurial issue #186), we must grep the
2212 2212 # output of pull/merge to check for attempted and/or failed merges.
2213 2213 #
2214 2214 # 3. If a merge failed, set the message and fail the bringover.
2215 2215 #
2216 2216 # 4. Otherwise, if a merge succeeded, set the message
2217 2217 #
2218 2218 # 5. Dump the output, and any message from step 3 or 4.
2219 2219 #
2220 2220
2221 2221 typeset HG_SOURCE=$BRINGOVER_WS
2222 2222 if [ ! -f $TMPDIR/new_repository ]; then
2223 2223 HG_SOURCE=$TMPDIR/open_bundle.hg
2224 2224 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
2225 2225 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
2226 2226
2227 2227 #
2228 2228 # If there are no incoming changesets, then incoming will
2229 2229 # fail, and there will be no bundle file. Reset the source,
2230 2230 # to allow the remaining logic to complete with no false
2231 2231 # negatives. (Unlike incoming, pull will return success
2232 2232 # for the no-change case.)
2233 2233 #
2234 2234 if (( $? != 0 )); then
2235 2235 HG_SOURCE=$BRINGOVER_WS
2236 2236 fi
2237 2237 fi
2238 2238
2239 2239 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
2240 2240 > $TMPDIR/pull_open.out 2>&1
2241 2241 if (( $? != 0 )); then
2242 2242 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
2243 2243 cat $TMPDIR/pull_open.out
2244 2244 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then
2245 2245 printf "$mergefailmsg"
2246 2246 fi
2247 2247 touch $TMPDIR/bringover_failed
2248 2248 return
2249 2249 fi
2250 2250
2251 2251 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then
2252 2252 staffer hg --cwd $CODEMGR_WS merge \
2253 2253 >> $TMPDIR/pull_open.out 2>&1
2254 2254 if (( $? != 0 )); then
2255 2255 printf "%s: merge failed as follows:\n\n" \
2256 2256 "$CODEMGR_WS"
2257 2257 cat $TMPDIR/pull_open.out
2258 2258 if grep "^merging.*failed" $TMPDIR/pull_open.out \
2259 2259 > /dev/null 2>&1; then
2260 2260 printf "$mergefailmsg"
2261 2261 fi
2262 2262 touch $TMPDIR/bringover_failed
2263 2263 return
2264 2264 fi
2265 2265 fi
2266 2266
2267 2267 printf "updated %s with the following results:\n" "$CODEMGR_WS"
2268 2268 cat $TMPDIR/pull_open.out
2269 2269 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
2270 2270 printf "$mergepassmsg"
2271 2271 fi
2272 2272 printf "\n"
2273 2273
2274 2274 #
2275 2275 # We only want to update usr/closed if it exists, and we haven't been
2276 2276 # told not to via $CLOSED_IS_PRESENT, and we actually know where to
2277 2277 # pull from ($CLOSED_BRINGOVER_WS).
2278 2278 #
2279 2279 if [[ $CLOSED_IS_PRESENT = yes && \
2280 2280 -d $CODEMGR_WS/usr/closed/.hg && \
2281 2281 -n $CLOSED_BRINGOVER_WS ]]; then
2282 2282
2283 2283 HG_SOURCE=$CLOSED_BRINGOVER_WS
2284 2284 if [ ! -f $TMPDIR/new_closed ]; then
2285 2285 HG_SOURCE=$TMPDIR/closed_bundle.hg
2286 2286 staffer hg --cwd $CODEMGR_WS/usr/closed incoming \
2287 2287 --bundle $HG_SOURCE -v $CLOSED_BRINGOVER_WS \
2288 2288 > $TMPDIR/incoming_closed.out
2289 2289
2290 2290 #
2291 2291 # If there are no incoming changesets, then incoming will
2292 2292 # fail, and there will be no bundle file. Reset the source,
2293 2293 # to allow the remaining logic to complete with no false
2294 2294 # negatives. (Unlike incoming, pull will return success
2295 2295 # for the no-change case.)
2296 2296 #
2297 2297 if (( $? != 0 )); then
2298 2298 HG_SOURCE=$CLOSED_BRINGOVER_WS
2299 2299 fi
2300 2300 fi
2301 2301
2302 2302 staffer hg --cwd $CODEMGR_WS/usr/closed pull -u \
2303 2303 $HG_SOURCE > $TMPDIR/pull_closed.out 2>&1
2304 2304 if (( $? != 0 )); then
2305 2305 printf "closed pull failed as follows:\n\n"
2306 2306 cat $TMPDIR/pull_closed.out
2307 2307 if grep "^merging.*failed" $TMPDIR/pull_closed.out \
2308 2308 > /dev/null 2>&1; then
2309 2309 printf "$mergefailmsg"
2310 2310 fi
2311 2311 touch $TMPDIR/bringover_failed
2312 2312 return
2313 2313 fi
2314 2314
2315 2315 if grep "not updating" $TMPDIR/pull_closed.out > /dev/null 2>&1; then
2316 2316 staffer hg --cwd $CODEMGR_WS/usr/closed merge \
2317 2317 >> $TMPDIR/pull_closed.out 2>&1
2318 2318 if (( $? != 0 )); then
2319 2319 printf "closed merge failed as follows:\n\n"
2320 2320 cat $TMPDIR/pull_closed.out
2321 2321 if grep "^merging.*failed" $TMPDIR/pull_closed.out > /dev/null 2>&1; then
2322 2322 printf "$mergefailmsg"
2323 2323 fi
2324 2324 touch $TMPDIR/bringover_failed
2325 2325 return
2326 2326 fi
2327 2327 fi
2328 2328
2329 2329 printf "updated %s with the following results:\n" \
2330 2330 "$CODEMGR_WS/usr/closed"
2331 2331 cat $TMPDIR/pull_closed.out
2332 2332 if grep "^merging" $TMPDIR/pull_closed.out > /dev/null 2>&1; then
2333 2333 printf "$mergepassmsg"
2334 2334 fi
2335 2335 fi
2336 2336
2337 2337 #
2338 2338 # Per-changeset output is neither useful nor manageable for a
2339 2339 # newly-created repository.
2340 2340 #
2341 2341 if [ -f $TMPDIR/new_repository ]; then
2342 2342 return
2343 2343 fi
2344 2344
2345 2345 printf "\nadded the following changesets to open repository:\n"
2346 2346 cat $TMPDIR/incoming_open.out
2347 2347
2348 2348 #
2349 2349 # The closed repository could have been newly created, even though
2350 2350 # the open one previously existed...
2351 2351 #
2352 2352 if [ -f $TMPDIR/new_closed ]; then
2353 2353 return
2354 2354 fi
2355 2355
2356 2356 if [ -f $TMPDIR/incoming_closed.out ]; then
2357 2357 printf "\nadded the following changesets to closed repository:\n"
2358 2358 cat $TMPDIR/incoming_closed.out
2359 2359 fi
2360 2360 }
2361 2361
2362 2362 type bringover_subversion > /dev/null 2>&1 || function bringover_subversion {
2363 2363 typeset -x PATH=$PATH
2364 2364
2365 2365 if [[ ! -d $CODEMGR_WS/.svn ]]; then
2366 2366 staffer svn checkout $BRINGOVER_WS $CODEMGR_WS ||
2367 2367 touch $TMPDIR/bringover_failed
2368 2368 else
2369 2369 typeset root
2370 2370 root=$(staffer svn info $CODEMGR_WS |
2371 2371 nawk '/^Repository Root:/ {print $NF}')
2372 2372 if [[ $root != $BRINGOVER_WS ]]; then
2373 2373 # We fail here because there's no way to update
2374 2374 # from a named repo.
2375 2375 cat <<-EOF
2376 2376 \$BRINGOVER_WS doesn't match repository root:
2377 2377 \$BRINGOVER_WS: $BRINGOVER_WS
2378 2378 Repository root: $root
2379 2379 EOF
2380 2380 touch $TMPDIR/bringover_failed
2381 2381 else
2382 2382 # If a conflict happens, svn still exits 0.
2383 2383 staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out ||
2384 2384 touch $TMPDIR/bringover_failed
2385 2385 if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then
2386 2386 touch $TMPDIR/bringover_failed
2387 2387 fi
2388 2388 fi
2389 2389 fi
2390 2390 }
2391 2391
2392 2392 type bringover_none > /dev/null 2>&1 || function bringover_none {
2393 2393 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
2394 2394 touch $TMPDIR/bringover_failed
2395 2395 }
2396 2396
2397 2397 #
2398 2398 # Decide whether to bringover to the codemgr workspace
2399 2399 #
2400 2400 if [ "$n_FLAG" = "n" ]; then
2401 2401 PARENT_SCM_TYPE=$(parent_wstype)
2402 2402
2403 2403 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
2404 2404 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
2405 2405 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
2406 2406 exit 1
2407 2407 fi
2408 2408
2409 2409 run_hook PRE_BRINGOVER
2410 2410
2411 2411 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
2412 2412 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
2413 2413
2414 2414 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
2415 2415 tee -a $mail_msg_file >> $LOGFILE
2416 2416
2417 2417 if [ -f $TMPDIR/bringover_failed ]; then
2418 2418 rm -f $TMPDIR/bringover_failed
2419 2419 build_ok=n
2420 2420 echo "trouble with bringover, quitting at `date`." |
2421 2421 tee -a $mail_msg_file >> $LOGFILE
2422 2422 exit 1
2423 2423 fi
2424 2424
2425 2425 #
2426 2426 # It's possible that we used the bringover above to create
2427 2427 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
2428 2428 # but should now be the same as $BRINGOVER_WS.
2429 2429 #
2430 2430 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
2431 2431
2432 2432 run_hook POST_BRINGOVER
2433 2433
2434 2434 #
2435 2435 # Possible transition from pre-split workspace to split
2436 2436 # workspace. See if the bringover changed anything.
2437 2437 #
2438 2438 CLOSED_IS_PRESENT="$orig_closed_is_present"
2439 2439 check_closed_tree
2440 2440
2441 2441 else
2442 2442 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
2443 2443 fi
2444 2444
2445 2445 if [[ "$O_FLAG" = y && "$CLOSED_IS_PRESENT" != "yes" ]]; then
2446 2446 build_ok=n
2447 2447 echo "OpenSolaris binary deliverables need usr/closed." \
2448 2448 | tee -a "$mail_msg_file" >> $LOGFILE
2449 2449 exit 1
2450 2450 fi
2451 2451
2452 2452 # Safeguards
2453 2453 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
2454 2454 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
2455 2455 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
2456 2456
2457 2457 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
2458 2458
2459 2459 # System
2460 2460 whence uname | tee -a $build_environ_file >> $LOGFILE
2461 2461 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
2462 2462 echo | tee -a $build_environ_file >> $LOGFILE
2463 2463
2464 2464 # make
2465 2465 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
2466 2466 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
2467 2467 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
2468 2468 tee -a $build_environ_file >> $LOGFILE
2469 2469
2470 2470 #
2471 2471 # Report the compiler versions.
2472 2472 #
2473 2473
2474 2474 if [[ ! -f $SRC/Makefile ]]; then
2475 2475 build_ok=n
2476 2476 echo "\nUnable to find \"Makefile\" in $SRC." | \
2477 2477 tee -a $build_environ_file >> $LOGFILE
2478 2478 exit 1
2479 2479 fi
2480 2480
2481 2481 ( cd $SRC
2482 2482 for target in cc-version cc64-version java-version; do
2483 2483 echo
2484 2484 #
2485 2485 # Put statefile somewhere we know we can write to rather than trip
2486 2486 # over a read-only $srcroot.
2487 2487 #
2488 2488 rm -f $TMPDIR/make-state
2489 2489 export SRC
2490 2490 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
2491 2491 continue
2492 2492 fi
2493 2493 touch $TMPDIR/nocompiler
2494 2494 done
2495 2495 echo
2496 2496 ) | tee -a $build_environ_file >> $LOGFILE
2497 2497
2498 2498 if [ -f $TMPDIR/nocompiler ]; then
2499 2499 rm -f $TMPDIR/nocompiler
2500 2500 build_ok=n
2501 2501 echo "Aborting due to missing compiler." |
2502 2502 tee -a $build_environ_file >> $LOGFILE
2503 2503 exit 1
2504 2504 fi
2505 2505
2506 2506 # as
2507 2507 whence as | tee -a $build_environ_file >> $LOGFILE
2508 2508 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
2509 2509 echo | tee -a $build_environ_file >> $LOGFILE
2510 2510
2511 2511 # Check that we're running a capable link-editor
2512 2512 whence ld | tee -a $build_environ_file >> $LOGFILE
2513 2513 LDVER=`ld -V 2>&1`
2514 2514 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
2515 2515 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
2516 2516 if [ `expr $LDVER \< 422` -eq 1 ]; then
2517 2517 echo "The link-editor needs to be at version 422 or higher to build" | \
2518 2518 tee -a $build_environ_file >> $LOGFILE
2519 2519 echo "the latest stuff. Hope your build works." | \
2520 2520 tee -a $build_environ_file >> $LOGFILE
2521 2521 fi
2522 2522
2523 2523 #
2524 2524 # Build and use the workspace's tools if requested
2525 2525 #
2526 2526 if [[ "$t_FLAG" = "y" || "$O_FLAG" = y ]]; then
2527 2527 set_non_debug_build_flags
2528 2528
2529 2529 build_tools ${TOOLS_PROTO}
2530 2530 if [[ $? != 0 && "$t_FLAG" = y ]]; then
2531 2531 use_tools $TOOLS_PROTO
2532 2532 fi
2533 2533 fi
2534 2534
2535 2535 #
2536 2536 # copy ihv proto area in addition to the build itself
2537 2537 #
2538 2538 if [ "$X_FLAG" = "y" ]; then
2539 2539 copy_ihv_proto
2540 2540 fi
2541 2541
2542 2542 if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then
2543 2543 echo "\n==== NOT Building base OS-Net source ====\n" | \
2544 2544 tee -a $LOGFILE >> $mail_msg_file
2545 2545 else
2546 2546 # timestamp the start of the normal build; the findunref tool uses it.
2547 2547 touch $SRC/.build.tstamp
2548 2548
2549 2549 normal_build
2550 2550 fi
2551 2551
2552 2552 #
2553 2553 # Generate the THIRDPARTYLICENSE files if needed. This is done after
2554 2554 # the build, so that dynamically-created license files are there.
2555 2555 # It's done before findunref to help identify license files that need
2556 2556 # to be added to tools/opensolaris/license-list.
2557 2557 #
2558 2558 if [ "$O_FLAG" = y -a "$build_ok" = y ]; then
2559 2559 echo "\n==== Generating THIRDPARTYLICENSE files ====\n" |
2560 2560 tee -a "$mail_msg_file" >> "$LOGFILE"
2561 2561
2562 2562 if [ -d $ROOT/licenses/usr ]; then
2563 2563 ( cd $ROOT/licenses ; \
2564 2564 mktpl $SRC/pkg/license-list ) >> "$LOGFILE" 2>&1
2565 2565 if (( $? != 0 )) ; then
2566 2566 echo "Couldn't create THIRDPARTYLICENSE files" |
2567 2567 tee -a "$mail_msg_file" >> "$LOGFILE"
2568 2568 fi
2569 2569 else
2570 2570 echo "No licenses found under $ROOT/licenses" |
2571 2571 tee -a "$mail_msg_file" >> "$LOGFILE"
2572 2572 fi
2573 2573 fi
2574 2574
2575 2575 ORIG_SRC=$SRC
2576 2576 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
2577 2577
2578 2578 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
2579 2579 save_binaries
2580 2580 fi
2581 2581
2582 2582
2583 2583 # EXPORT_SRC comes after CRYPT_SRC since a domestic build will need
2584 2584 # $SRC pointing to the export_source usr/src.
2585 2585
2586 2586 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
2587 2587 if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
2588 2588 set_up_source_build ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC
2589 2589 fi
2590 2590
2591 2591 if [ $build_ok = y ]; then
2592 2592 set_up_source_build ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC
2593 2593 fi
2594 2594 fi
2595 2595
2596 2596 if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
2597 2597 # drop the crypt files in place.
2598 2598 cd ${EXPORT_SRC}
2599 2599 echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \
2600 2600 >> ${LOGFILE}
2601 2601 zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \
2602 2602 cpio -idmucvB 2>/dev/null >> ${LOGFILE}
2603 2603 if [ "$?" = "0" ]; then
2604 2604 echo "\n==== DOMESTIC extraction succeeded ====\n" \
2605 2605 >> $mail_msg_file
2606 2606 else
2607 2607 echo "\n==== DOMESTIC extraction failed ====\n" \
2608 2608 >> $mail_msg_file
2609 2609 fi
2610 2610
2611 2611 fi
2612 2612
2613 2613 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2614 2614 #
2615 2615 # Copy the open sources into their own tree.
2616 2616 # If copy_source fails, it will have already generated an
2617 2617 # error message and set build_ok=n, so we don't need to worry
2618 2618 # about that here.
2619 2619 #
2620 2620 copy_source $CODEMGR_WS $OPEN_SRCDIR OPEN_SOURCE usr/src
2621 2621 fi
2622 2622
2623 2623 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2624 2624 SRC=$OPEN_SRCDIR/usr/src
2625 2625 export CLOSED_IS_PRESENT=no
2626 2626 fi
2627 2627
2628 2628 if is_source_build && [ $build_ok = y ] ; then
2629 2629 # remove proto area(s) here, since we don't clobber
2630 2630 rm -rf `allprotos`
2631 2631 if [ "$t_FLAG" = "y" ]; then
2632 2632 set_non_debug_build_flags
2633 2633 ORIG_TOOLS=$TOOLS
2634 2634 #
2635 2635 # SRC was set earlier to point to the source build
↓ open down ↓ |
2635 lines elided |
↑ open up ↑ |
2636 2636 # source tree (e.g., $EXPORT_SRC).
2637 2637 #
2638 2638 TOOLS=${SRC}/tools
2639 2639 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
2640 2640 build_tools ${TOOLS_PROTO}
2641 2641 if [[ $? != 0 ]]; then
2642 2642 use_tools ${TOOLS_PROTO}
2643 2643 fi
2644 2644 fi
2645 2645
2646 - export EXPORT_RELEASE_BUILD ; EXPORT_RELEASE_BUILD=#
2647 2646 normal_build
2648 2647 fi
2649 2648
2650 2649 #
2651 2650 # There are several checks that need to look at the proto area, but
2652 2651 # they only need to look at one, and they don't care whether it's
2653 2652 # DEBUG or non-DEBUG.
2654 2653 #
2655 2654 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
2656 2655 checkroot=$ROOT-nd
2657 2656 else
2658 2657 checkroot=$ROOT
2659 2658 fi
2660 2659
2661 2660 if [ "$build_ok" = "y" ]; then
2662 2661 echo "\n==== Creating protolist system file at `date` ====" \
2663 2662 >> $LOGFILE
2664 2663 protolist $checkroot > $ATLOG/proto_list_${MACH}
2665 2664 echo "==== protolist system file created at `date` ====\n" \
2666 2665 >> $LOGFILE
2667 2666
2668 2667 if [ "$N_FLAG" != "y" ]; then
2669 2668
2670 2669 E1=
2671 2670 f1=
2672 2671 if [ -d "$SRC/pkgdefs" ]; then
2673 2672 f1="$SRC/pkgdefs/etc/exception_list_$MACH"
2674 2673 if [ "$X_FLAG" = "y" ]; then
2675 2674 f1="$f1 $IA32_IHV_WS/usr/src/pkgdefs/etc/exception_list_$MACH"
2676 2675 fi
2677 2676 fi
2678 2677
2679 2678 for f in $f1; do
2680 2679 if [ -f "$f" ]; then
2681 2680 E1="$E1 -e $f"
2682 2681 fi
2683 2682 done
2684 2683
2685 2684 E2=
2686 2685 f2=
2687 2686 if [ -d "$SRC/pkg" ]; then
2688 2687 f2="$f2 exceptions/packaging"
2689 2688 fi
2690 2689
2691 2690 for f in $f2; do
2692 2691 if [ -f "$f" ]; then
2693 2692 E2="$E2 -e $f"
2694 2693 fi
2695 2694 done
2696 2695
2697 2696 if [ -f "$REF_PROTO_LIST" ]; then
2698 2697 #
2699 2698 # For builds that copy the IHV proto area (-X), add the
2700 2699 # IHV proto list to the reference list if the reference
2701 2700 # was built without -X.
2702 2701 #
2703 2702 # For builds that don't copy the IHV proto area, add the
2704 2703 # IHV proto list to the build's proto list if the
2705 2704 # reference was built with -X.
2706 2705 #
2707 2706 # Use the presence of the first file entry of the cached
2708 2707 # IHV proto list in the reference list to determine
2709 2708 # whether it was built with -X or not.
2710 2709 #
2711 2710 IHV_REF_PROTO_LIST=$SRC/pkg/proto_list_ihv_$MACH
2712 2711 grepfor=$(nawk '$1 == "f" { print $2; exit }' \
2713 2712 $IHV_REF_PROTO_LIST 2> /dev/null)
2714 2713 if [ $? = 0 -a -n "$grepfor" ]; then
2715 2714 if [ "$X_FLAG" = "y" ]; then
2716 2715 grep -w "$grepfor" \
2717 2716 $REF_PROTO_LIST > /dev/null
2718 2717 if [ ! "$?" = "0" ]; then
2719 2718 REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST"
2720 2719 fi
2721 2720 else
2722 2721 grep -w "$grepfor" \
2723 2722 $REF_PROTO_LIST > /dev/null
2724 2723 if [ "$?" = "0" ]; then
2725 2724 IHV_PROTO_LIST="$IHV_REF_PROTO_LIST"
2726 2725 fi
2727 2726 fi
2728 2727 fi
2729 2728 fi
2730 2729 fi
2731 2730
2732 2731 if [ "$N_FLAG" != "y" -a -f $SRC/pkgdefs/Makefile ]; then
2733 2732 echo "\n==== Impact on SVr4 packages ====\n" >> $mail_msg_file
2734 2733 #
2735 2734 # Compare the build's proto list with current package
2736 2735 # definitions to audit the quality of package
2737 2736 # definitions and makefile install targets. Use the
2738 2737 # current exception list.
2739 2738 #
2740 2739 PKGDEFS_LIST=""
2741 2740 for d in $abssrcdirs; do
2742 2741 if [ -d $d/pkgdefs ]; then
2743 2742 PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs"
2744 2743 fi
2745 2744 done
2746 2745 if [ "$X_FLAG" = "y" -a \
2747 2746 -d $IA32_IHV_WS/usr/src/pkgdefs ]; then
2748 2747 PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs"
2749 2748 fi
2750 2749 $PROTOCMPTERSE \
2751 2750 "Files missing from the proto area:" \
2752 2751 "Files missing from packages:" \
2753 2752 "Inconsistencies between pkgdefs and proto area:" \
2754 2753 ${E1} \
2755 2754 ${PKGDEFS_LIST} \
2756 2755 $ATLOG/proto_list_${MACH} \
2757 2756 >> $mail_msg_file
2758 2757 fi
2759 2758
2760 2759 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
2761 2760 echo "\n==== Validating manifests against proto area ====\n" \
2762 2761 >> $mail_msg_file
2763 2762 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) \
2764 2763 >> $mail_msg_file
2765 2764
2766 2765 fi
2767 2766
2768 2767 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
2769 2768 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
2770 2769 if [ -n "$E2" ]; then
2771 2770 ELIST=$E2
2772 2771 else
2773 2772 ELIST=$E1
2774 2773 fi
2775 2774 $PROTOCMPTERSE \
2776 2775 "Files in yesterday's proto area, but not today's:" \
2777 2776 "Files in today's proto area, but not yesterday's:" \
2778 2777 "Files that changed between yesterday and today:" \
2779 2778 ${ELIST} \
2780 2779 -d $REF_PROTO_LIST \
2781 2780 $REF_IHV_PROTO \
2782 2781 $ATLOG/proto_list_${MACH} \
2783 2782 $IHV_PROTO_LIST \
2784 2783 >> $mail_msg_file
2785 2784 fi
2786 2785 fi
2787 2786
2788 2787 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
2789 2788 staffer cp $ATLOG/proto_list_${MACH} \
2790 2789 $PARENT_WS/usr/src/proto_list_${MACH}
2791 2790 fi
2792 2791
2793 2792 # Update parent proto area if necessary. This is done now
2794 2793 # so that the proto area has either DEBUG or non-DEBUG kernels.
2795 2794 # Note that this clears out the lock file, so we can dispense with
2796 2795 # the variable now.
2797 2796 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
2798 2797 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
2799 2798 tee -a $LOGFILE >> $mail_msg_file
2800 2799 rm -rf $NIGHTLY_PARENT_ROOT/*
2801 2800 unset Ulockfile
2802 2801 mkdir -p $NIGHTLY_PARENT_ROOT
2803 2802 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2804 2803 ( cd $ROOT; tar cf - . |
2805 2804 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 |
2806 2805 tee -a $mail_msg_file >> $LOGFILE
2807 2806 fi
2808 2807 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2809 2808 rm -rf $NIGHTLY_PARENT_ROOT-nd/*
2810 2809 mkdir -p $NIGHTLY_PARENT_ROOT-nd
2811 2810 cd $ROOT-nd
2812 2811 ( tar cf - . |
2813 2812 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
2814 2813 tee -a $mail_msg_file >> $LOGFILE
2815 2814 fi
2816 2815 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
2817 2816 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
2818 2817 tee -a $LOGFILE >> $mail_msg_file
2819 2818 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
2820 2819 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
2821 2820 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2822 2821 ( cd $TOOLS_PROTO; tar cf - . |
2823 2822 ( cd $NIGHTLY_PARENT_TOOLS_ROOT;
2824 2823 umask 0; tar xpf - ) ) 2>&1 |
2825 2824 tee -a $mail_msg_file >> $LOGFILE
2826 2825 fi
2827 2826 fi
2828 2827 fi
2829 2828
2830 2829 #
2831 2830 # ELF verification: ABI (-A) and runtime (-r) checks
2832 2831 #
2833 2832 if [[ ($build_ok = y) && ( ($A_FLAG = y) || ($r_FLAG = y) ) ]]; then
2834 2833 # Directory ELF-data.$MACH holds the files produced by these tests.
2835 2834 elf_ddir=$SRC/ELF-data.$MACH
2836 2835
2837 2836 # If there is a previous ELF-data backup directory, remove it. Then,
2838 2837 # rotate current ELF-data directory into its place and create a new
2839 2838 # empty directory
2840 2839 rm -rf $elf_ddir.ref
2841 2840 if [[ -d $elf_ddir ]]; then
2842 2841 mv $elf_ddir $elf_ddir.ref
2843 2842 fi
2844 2843 mkdir -p $elf_ddir
2845 2844
2846 2845 # Call find_elf to produce a list of the ELF objects in the proto area.
2847 2846 # This list is passed to check_rtime and interface_check, preventing
2848 2847 # them from separately calling find_elf to do the same work twice.
2849 2848 find_elf -fr $checkroot > $elf_ddir/object_list
2850 2849
2851 2850 if [[ $A_FLAG = y ]]; then
2852 2851 echo "\n==== Check versioning and ABI information ====\n" | \
2853 2852 tee -a $LOGFILE >> $mail_msg_file
2854 2853
2855 2854 # Produce interface description for the proto. Report errors.
2856 2855 interface_check -o -w $elf_ddir -f object_list \
2857 2856 -i interface -E interface.err
2858 2857 if [[ -s $elf_ddir/interface.err ]]; then
2859 2858 tee -a $LOGFILE < $elf_ddir/interface.err \
2860 2859 >> $mail_msg_file
2861 2860 fi
2862 2861
2863 2862 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
2864 2863 # description file to that from the baseline gate. Issue a
2865 2864 # warning if the baseline is not present, and keep going.
2866 2865 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
2867 2866 base_ifile="$ELF_DATA_BASELINE_DIR/interface"
2868 2867
2869 2868 echo "\n==== Compare versioning and ABI information" \
2870 2869 "to baseline ====\n" | \
2871 2870 tee -a $LOGFILE >> $mail_msg_file
2872 2871 echo "Baseline: $base_ifile\n" >> $LOGFILE
2873 2872
2874 2873 if [[ -f $base_ifile ]]; then
2875 2874 interface_cmp -d -o $base_ifile \
2876 2875 $elf_ddir/interface > $elf_ddir/interface.cmp
2877 2876 if [[ -s $elf_ddir/interface.cmp ]]; then
2878 2877 echo | tee -a $LOGFILE >> $mail_msg_file
2879 2878 tee -a $LOGFILE < \
2880 2879 $elf_ddir/interface.cmp \
2881 2880 >> $mail_msg_file
2882 2881 fi
2883 2882 else
2884 2883 echo "baseline not available. comparison" \
2885 2884 "skipped" | \
2886 2885 tee -a $LOGFILE >> $mail_msg_file
2887 2886 fi
2888 2887
2889 2888 fi
2890 2889 fi
2891 2890
2892 2891 if [[ $r_FLAG = y ]]; then
2893 2892 echo "\n==== Check ELF runtime attributes ====\n" | \
2894 2893 tee -a $LOGFILE >> $mail_msg_file
2895 2894
2896 2895 # If we're doing a DEBUG build the proto area will be left
2897 2896 # with debuggable objects, thus don't assert -s.
2898 2897 if [[ $D_FLAG = y ]]; then
2899 2898 rtime_sflag=""
2900 2899 else
2901 2900 rtime_sflag="-s"
2902 2901 fi
2903 2902 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
2904 2903 -D object_list -f object_list -E runtime.err \
2905 2904 -I runtime.attr.raw
2906 2905
2907 2906 # check_rtime -I output needs to be sorted in order to
2908 2907 # compare it to that from previous builds.
2909 2908 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
2910 2909 rm $elf_ddir/runtime.attr.raw
2911 2910
2912 2911 # Report errors
2913 2912 if [[ -s $elf_ddir/runtime.err ]]; then
2914 2913 tee -a $LOGFILE < $elf_ddir/runtime.err \
2915 2914 >> $mail_msg_file
2916 2915 fi
2917 2916
2918 2917 # If there is an ELF-data directory from a previous build,
2919 2918 # then diff the attr files. These files contain information
2920 2919 # about dependencies, versioning, and runpaths. There is some
2921 2920 # overlap with the ABI checking done above, but this also
2922 2921 # flushes out non-ABI interface differences along with the
2923 2922 # other information.
2924 2923 echo "\n==== Diff ELF runtime attributes" \
2925 2924 "(since last build) ====\n" | \
2926 2925 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
2927 2926
2928 2927 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
2929 2928 diff $elf_ddir.ref/runtime.attr \
2930 2929 $elf_ddir/runtime.attr \
2931 2930 >> $mail_msg_file
2932 2931 fi
2933 2932 fi
2934 2933
2935 2934 # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
2936 2935 if [[ "$u_FLAG" = "y" ]]; then
2937 2936 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH
2938 2937
2939 2938 # If parent lacks the ELF-data.$MACH directory, create it
2940 2939 if [[ ! -d $p_elf_ddir ]]; then
2941 2940 staffer mkdir -p $p_elf_ddir
2942 2941 fi
2943 2942
2944 2943 # These files are used asynchronously by other builds for ABI
2945 2944 # verification, as above for the -A option. As such, we require
2946 2945 # the file replacement to be atomic. Copy the data to a temp
2947 2946 # file in the same filesystem and then rename into place.
2948 2947 (
2949 2948 cd $elf_ddir
2950 2949 for elf_dfile in *; do
2951 2950 staffer cp $elf_dfile \
2952 2951 ${p_elf_ddir}/${elf_dfile}.new
2953 2952 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
2954 2953 ${p_elf_ddir}/${elf_dfile}
2955 2954 done
2956 2955 )
2957 2956 fi
2958 2957 fi
2959 2958
2960 2959 # DEBUG lint of kernel begins
2961 2960
2962 2961 if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
2963 2962 if [ "$LINTDIRS" = "" ]; then
2964 2963 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y"
2965 2964 LINTDIRS="$SRC y"
2966 2965 fi
2967 2966 set $LINTDIRS
2968 2967 while [ $# -gt 0 ]; do
2969 2968 dolint $1 $2; shift; shift
2970 2969 done
2971 2970 else
2972 2971 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2973 2972 fi
2974 2973
2975 2974 # "make check" begins
2976 2975
2977 2976 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2978 2977 # remove old check.out
2979 2978 rm -f $SRC/check.out
2980 2979
2981 2980 rm -f $SRC/check-${MACH}.out
2982 2981 cd $SRC
2983 2982 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
2984 2983 >> $LOGFILE
2985 2984 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2986 2985
2987 2986 grep ":" $SRC/check-${MACH}.out |
2988 2987 egrep -v "Ignoring unknown host" | \
2989 2988 sort | uniq >> $mail_msg_file
2990 2989 else
2991 2990 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2992 2991 fi
2993 2992
2994 2993 echo "\n==== Find core files ====\n" | \
2995 2994 tee -a $LOGFILE >> $mail_msg_file
2996 2995
2997 2996 find $abssrcdirs -name core -a -type f -exec file {} \; | \
2998 2997 tee -a $LOGFILE >> $mail_msg_file
2999 2998
3000 2999 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
3001 3000 echo "\n==== Diff unreferenced files (since last build) ====\n" \
3002 3001 | tee -a $LOGFILE >>$mail_msg_file
3003 3002 rm -f $SRC/unref-${MACH}.ref
3004 3003 if [ -f $SRC/unref-${MACH}.out ]; then
3005 3004 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
3006 3005 fi
3007 3006
3008 3007 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
3009 3008 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
3010 3009 sort > $SRC/unref-${MACH}.out
3011 3010
3012 3011 if [ ! -f $SRC/unref-${MACH}.ref ]; then
3013 3012 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
3014 3013 fi
3015 3014
3016 3015 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
3017 3016 fi
3018 3017
3019 3018 #
3020 3019 # Generate the OpenSolaris deliverables if requested. Some of these
3021 3020 # steps need to come after findunref and are commented below.
3022 3021 #
3023 3022
3024 3023 # If we are doing an OpenSolaris _source_ build (-S O) then we do
3025 3024 # not have usr/closed available to us to generate closedbins from,
3026 3025 # so skip this part.
3027 3026 if [ "$SO_FLAG" = n -a "$O_FLAG" = y -a "$build_ok" = y ]; then
3028 3027 echo "\n==== Generating OpenSolaris tarballs ====\n" | \
3029 3028 tee -a $mail_msg_file >> $LOGFILE
3030 3029
3031 3030 cd $CODEMGR_WS
3032 3031
3033 3032 #
3034 3033 # This step grovels through the package manifests, so it
3035 3034 # must come after findunref.
3036 3035 #
3037 3036 # We assume no DEBUG vs non-DEBUG package content variation
3038 3037 # here; if that changes, then the "make all" in $SRC/pkg will
3039 3038 # need to be moved into the conditionals and repeated for each
3040 3039 # different build.
3041 3040 #
3042 3041 echo "Generating closed binaries tarball(s)..." >> $LOGFILE
3043 3042 closed_basename=on-closed-bins
3044 3043 if [ "$D_FLAG" = y ]; then
3045 3044 bindrop "$closed_basename" >>"$LOGFILE" 2>&1
3046 3045 if (( $? != 0 )) ; then
3047 3046 echo "Couldn't create DEBUG closed binaries." |
3048 3047 tee -a $mail_msg_file >> $LOGFILE
3049 3048 build_ok=n
3050 3049 fi
3051 3050 fi
3052 3051 if [ "$F_FLAG" = n ]; then
3053 3052 bindrop -n "$closed_basename-nd" >>"$LOGFILE" 2>&1
3054 3053 if (( $? != 0 )) ; then
3055 3054 echo "Couldn't create non-DEBUG closed binaries." |
3056 3055 tee -a $mail_msg_file >> $LOGFILE
3057 3056 build_ok=n
3058 3057 fi
3059 3058 fi
3060 3059
3061 3060 echo "Generating README.opensolaris..." >> $LOGFILE
3062 3061 cat $SRC/tools/opensolaris/README.opensolaris.tmpl | \
3063 3062 mkreadme_osol $CODEMGR_WS/README.opensolaris >> $LOGFILE 2>&1
3064 3063 if (( $? != 0 )) ; then
3065 3064 echo "Couldn't create README.opensolaris." |
3066 3065 tee -a $mail_msg_file >> $LOGFILE
3067 3066 build_ok=n
3068 3067 fi
3069 3068 fi
3070 3069
3071 3070 # Verify that the usual lists of files, such as exception lists,
3072 3071 # contain only valid references to files. If the build has failed,
3073 3072 # then don't check the proto area.
3074 3073 CHECK_PATHS=${CHECK_PATHS:-y}
3075 3074 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
3076 3075 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
3077 3076 >>$mail_msg_file
3078 3077 arg=-b
3079 3078 [ "$build_ok" = y ] && arg=
3080 3079 checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file
3081 3080 fi
3082 3081
3083 3082 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
3084 3083 echo "\n==== Impact on file permissions ====\n" \
3085 3084 >> $mail_msg_file
3086 3085
3087 3086 abspkgdefs=
3088 3087 abspkg=
3089 3088 for d in $abssrcdirs; do
3090 3089 if [ -d "$d/pkgdefs" ]; then
3091 3090 abspkgdefs="$abspkgdefs $d"
3092 3091 fi
3093 3092 if [ -d "$d/pkg" ]; then
3094 3093 abspkg="$abspkg $d"
3095 3094 fi
3096 3095 done
3097 3096
3098 3097 if [ -n "$abspkgdefs" ]; then
3099 3098 pmodes -qvdP \
3100 3099 `find $abspkgdefs -name pkginfo.tmpl -print -o \
3101 3100 -name .del\* -prune | sed -e 's:/pkginfo.tmpl$::' | \
3102 3101 sort -u` >> $mail_msg_file
3103 3102 fi
3104 3103
3105 3104 if [ -n "$abspkg" ]; then
3106 3105 for d in "$abspkg"; do
3107 3106 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
3108 3107 done
3109 3108 fi
3110 3109 fi
3111 3110
3112 3111 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
3113 3112 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
3114 3113 do_wsdiff DEBUG $ROOT.prev $ROOT
3115 3114 fi
3116 3115
3117 3116 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
3118 3117 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
3119 3118 fi
3120 3119 fi
3121 3120
3122 3121 END_DATE=`date`
3123 3122 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
3124 3123 tee -a $LOGFILE >> $build_time_file
3125 3124
3126 3125 typeset -i10 hours
3127 3126 typeset -Z2 minutes
3128 3127 typeset -Z2 seconds
3129 3128
3130 3129 elapsed_time=$SECONDS
3131 3130 ((hours = elapsed_time / 3600 ))
3132 3131 ((minutes = elapsed_time / 60 % 60))
3133 3132 ((seconds = elapsed_time % 60))
3134 3133
3135 3134 echo "\n==== Total build time ====" | \
3136 3135 tee -a $LOGFILE >> $build_time_file
3137 3136 echo "\nreal ${hours}:${minutes}:${seconds}" | \
3138 3137 tee -a $LOGFILE >> $build_time_file
3139 3138
3140 3139 if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
3141 3140 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
3142 3141
3143 3142 #
3144 3143 # Produce a master list of unreferenced files -- ideally, we'd
3145 3144 # generate the master just once after all of the nightlies
3146 3145 # have finished, but there's no simple way to know when that
3147 3146 # will be. Instead, we assume that we're the last nightly to
3148 3147 # finish and merge all of the unref-${MACH}.out files in
3149 3148 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
3150 3149 # finish, then this file will be the authoritative master
3151 3150 # list. Otherwise, another ${MACH}'s nightly will eventually
3152 3151 # overwrite ours with its own master, but in the meantime our
3153 3152 # temporary "master" will be no worse than any older master
3154 3153 # which was already on the parent.
3155 3154 #
3156 3155
3157 3156 set -- $PARENT_WS/usr/src/unref-*.out
3158 3157 cp "$1" ${TMPDIR}/unref.merge
3159 3158 shift
3160 3159
3161 3160 for unreffile; do
3162 3161 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
3163 3162 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
3164 3163 done
3165 3164
3166 3165 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
3167 3166 fi
3168 3167
3169 3168 #
3170 3169 # All done save for the sweeping up.
3171 3170 # (whichever exit we hit here will trigger the "cleanup" trap which
3172 3171 # optionally sends mail on completion).
3173 3172 #
3174 3173 if [ "$build_ok" = "y" ]; then
3175 3174 exit 0
3176 3175 fi
3177 3176 exit 1
↓ open down ↓ |
521 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX