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