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