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