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