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 893 mkdir -p $PKGARCHIVE 894 895 for d in pkg pkgdefs; do 896 if [ ! -d $SRC/$d ]; 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 [ ! -d $SRC/$d ]; 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 -0 build the globalization package 1284 -A check for ABI differences in .so files 1285 -C check for cstyle/hdrchk errors 1286 -D do a build with DEBUG on 1287 -F do _not_ do a non-DEBUG build 1288 -G gate keeper default group of options (-0au) 1289 -I integration engineer default group of options (-ampu) 1290 -M do not run pmodes (safe file permission checker) 1291 -N do not run protocmp 1292 -O generate OpenSolaris deliverables 1293 -R default group of options for building a release (-mp) 1294 -U update proto area in the parent 1295 -V VERS set the build version string to VERS 1296 -X copy x86 IHV proto area 1297 -a create cpio archives 1298 -f find unreferenced files 1299 -i do an incremental build (no "make clobber") 1300 -l do "make lint" in $LINTDIRS (default: $SRC y) 1301 -m send mail to $MAILTO at end of build 1302 -n do not do a bringover 1303 -o build using root privileges to set OWNER/GROUP (old style) 1304 -p create packages 1305 -r check ELF runtime attributes in the proto area 1306 -t build and use the tools in $SRC/tools 1307 -u update proto_list_$MACH and friends in the parent workspace; 1308 when used with -f, also build an unrefmaster.out in the parent 1309 -w report on differences between previous and current proto areas 1310 -z compress cpio archives with gzip 1311 -W Do not report warnings (freeware gate ONLY) 1312 -S Build a variant of the source product 1313 E - build exportable source 1314 D - build domestic source (exportable + crypt) 1315 H - build hybrid source (binaries + deleted source) 1316 O - build (only) open source 1317' 1318# 1319# -x less public handling of xmod source for the source product 1320# 1321# A log file will be generated under the name $LOGFILE 1322# for partially completed build and log.`date '+%F'` 1323# in the same directory for fully completed builds. 1324# 1325 1326# default values for low-level FLAGS; G I R are group FLAGS 1327A_FLAG=n 1328a_FLAG=n 1329C_FLAG=n 1330D_FLAG=n 1331F_FLAG=n 1332f_FLAG=n 1333i_FLAG=n; i_CMD_LINE_FLAG=n 1334l_FLAG=n 1335M_FLAG=n 1336m_FLAG=n 1337N_FLAG=n 1338n_FLAG=n 1339O_FLAG=n 1340o_FLAG=n 1341P_FLAG=n 1342p_FLAG=n 1343r_FLAG=n 1344T_FLAG=n 1345t_FLAG=y 1346U_FLAG=n 1347u_FLAG=n 1348V_FLAG=n 1349W_FLAG=n 1350w_FLAG=n 1351X_FLAG=n 1352z_FLAG=n 1353SD_FLAG=n 1354SE_FLAG=n 1355SH_FLAG=n 1356SO_FLAG=n 1357# 1358XMOD_OPT= 1359# 1360build_ok=y 1361 1362function is_source_build { 1363 [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o \ 1364 "$SH_FLAG" = "y" -o "$SO_FLAG" = "y" ] 1365 return $? 1366} 1367 1368# 1369# examine arguments 1370# 1371 1372# 1373# single function for setting -S flag and doing error checking. 1374# usage: set_S_flag <type> 1375# where <type> is the source build type ("E", "D", ...). 1376# 1377function set_S_flag { 1378 if is_source_build; then 1379 echo "Can only build one source variant at a time." 1380 exit 1 1381 fi 1382 if [ "$1" = "E" ]; then 1383 SE_FLAG=y 1384 elif [ "$1" = "D" ]; then 1385 SD_FLAG=y 1386 elif [ "$1" = "H" ]; then 1387 SH_FLAG=y 1388 elif [ "$1" = "O" ]; then 1389 SO_FLAG=y 1390 else 1391 echo "$USAGE" 1392 exit 1 1393 fi 1394} 1395 1396OPTIND=1 1397while getopts inS:tV: FLAG 1398do 1399 case $FLAG in 1400 i ) i_FLAG=y; i_CMD_LINE_FLAG=y 1401 ;; 1402 n ) n_FLAG=y 1403 ;; 1404 S ) 1405 set_S_flag $OPTARG 1406 ;; 1407 +t ) t_FLAG=n 1408 ;; 1409 V ) V_FLAG=y 1410 V_ARG="$OPTARG" 1411 ;; 1412 \? ) echo "$USAGE" 1413 exit 1 1414 ;; 1415 esac 1416done 1417 1418# correct argument count after options 1419shift `expr $OPTIND - 1` 1420 1421# test that the path to the environment-setting file was given 1422if [ $# -ne 1 ]; then 1423 echo "$USAGE" 1424 exit 1 1425fi 1426 1427# check if user is running nightly as root 1428# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 1429# when root invokes nightly. 1430/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 1431ISUSER=$?; export ISUSER 1432 1433# 1434# force locale to C 1435LC_COLLATE=C; export LC_COLLATE 1436LC_CTYPE=C; export LC_CTYPE 1437LC_MESSAGES=C; export LC_MESSAGES 1438LC_MONETARY=C; export LC_MONETARY 1439LC_NUMERIC=C; export LC_NUMERIC 1440LC_TIME=C; export LC_TIME 1441 1442# clear environment variables we know to be bad for the build 1443unset LD_OPTIONS 1444unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 1445unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 1446unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 1447unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 1448unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 1449unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 1450unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 1451unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 1452unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 1453unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 1454unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 1455unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 1456unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 1457unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 1458unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 1459unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 1460unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 1461unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 1462unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 1463unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 1464 1465unset CONFIG 1466unset GROUP 1467unset OWNER 1468unset REMOTE 1469unset ENV 1470unset ARCH 1471unset CLASSPATH 1472unset NAME 1473 1474# 1475# To get ONBLD_TOOLS from the environment, it must come from the env file. 1476# If it comes interactively, it is generally TOOLS_PROTO, which will be 1477# clobbered before the compiler version checks, which will therefore fail. 1478# 1479unset ONBLD_TOOLS 1480 1481# 1482# Setup environmental variables 1483# 1484if [ -f /etc/nightly.conf ]; then 1485 . /etc/nightly.conf 1486fi 1487 1488if [ -f $1 ]; then 1489 if [[ $1 = */* ]]; then 1490 . $1 1491 else 1492 . ./$1 1493 fi 1494else 1495 if [ -f $OPTHOME/onbld/env/$1 ]; then 1496 . $OPTHOME/onbld/env/$1 1497 else 1498 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 1499 exit 1 1500 fi 1501fi 1502 1503# contents of stdenv.sh inserted after next line: 1504# STDENV_START 1505# STDENV_END 1506 1507# 1508# place ourselves in a new task, respecting BUILD_PROJECT if set. 1509# 1510if [ -z "$BUILD_PROJECT" ]; then 1511 /usr/bin/newtask -c $$ 1512else 1513 /usr/bin/newtask -c $$ -p $BUILD_PROJECT 1514fi 1515 1516ps -o taskid= -p $$ | read build_taskid 1517ps -o project= -p $$ | read build_project 1518 1519# 1520# See if NIGHTLY_OPTIONS is set 1521# 1522if [ "$NIGHTLY_OPTIONS" = "" ]; then 1523 NIGHTLY_OPTIONS="-aBm" 1524fi 1525 1526# 1527# If BRINGOVER_WS was not specified, let it default to CLONE_WS 1528# 1529if [ "$BRINGOVER_WS" = "" ]; then 1530 BRINGOVER_WS=$CLONE_WS 1531fi 1532 1533# 1534# If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS 1535# 1536if [ "$CLOSED_BRINGOVER_WS" = "" ]; then 1537 CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS 1538fi 1539 1540# 1541# If BRINGOVER_FILES was not specified, default to usr 1542# 1543if [ "$BRINGOVER_FILES" = "" ]; then 1544 BRINGOVER_FILES="usr" 1545fi 1546 1547# 1548# If the closed sources are not present, the closed binaries must be 1549# present for the build to succeed. If there's no pointer to the 1550# closed binaries, flag that now, rather than forcing the user to wait 1551# a couple hours (or more) to find out. 1552# 1553orig_closed_is_present="$CLOSED_IS_PRESENT" 1554check_closed_tree 1555 1556# 1557# Note: changes to the option letters here should also be applied to the 1558# bldenv script. `d' is listed for backward compatibility. 1559# 1560NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 1561OPTIND=1 1562while getopts AaBCDdFfGIilMmNnOoPpRrS:TtUuWwXxz FLAG $NIGHTLY_OPTIONS 1563do 1564 case $FLAG in 1565 A ) A_FLAG=y 1566 ;; 1567 a ) a_FLAG=y 1568 ;; 1569 B ) D_FLAG=y 1570 ;; # old version of D 1571 C ) C_FLAG=y 1572 ;; 1573 D ) D_FLAG=y 1574 ;; 1575 F ) F_FLAG=y 1576 ;; 1577 f ) f_FLAG=y 1578 ;; 1579 G ) a_FLAG=y 1580 u_FLAG=y 1581 ;; 1582 I ) a_FLAG=y 1583 m_FLAG=y 1584 p_FLAG=y 1585 u_FLAG=y 1586 ;; 1587 i ) i_FLAG=y 1588 ;; 1589 l ) l_FLAG=y 1590 ;; 1591 M ) M_FLAG=y 1592 ;; 1593 m ) m_FLAG=y 1594 ;; 1595 N ) N_FLAG=y 1596 ;; 1597 n ) n_FLAG=y 1598 ;; 1599 O ) O_FLAG=y 1600 ;; 1601 o ) o_FLAG=y 1602 ;; 1603 P ) P_FLAG=y 1604 ;; # obsolete 1605 p ) p_FLAG=y 1606 ;; 1607 R ) m_FLAG=y 1608 p_FLAG=y 1609 ;; 1610 r ) r_FLAG=y 1611 ;; 1612 S ) 1613 set_S_flag $OPTARG 1614 ;; 1615 T ) T_FLAG=y 1616 ;; # obsolete 1617 +t ) t_FLAG=n 1618 ;; 1619 U ) 1620 if [ -z "${PARENT_ROOT}" ]; then 1621 echo "PARENT_ROOT must be set if the U flag is" \ 1622 "present in NIGHTLY_OPTIONS." 1623 exit 1 1624 fi 1625 if [ -z "${PARENT_TOOLS_ROOT}" ]; then 1626 echo "PARENT_TOOLS_ROOT must be set if the U flag is" \ 1627 "present in NIGHTLY_OPTIONS." 1628 exit 1 1629 fi 1630 U_FLAG=y 1631 NIGHTLY_PARENT_ROOT=$PARENT_ROOT 1632 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 1633 ;; 1634 u ) u_FLAG=y 1635 ;; 1636 W ) W_FLAG=y 1637 ;; 1638 1639 w ) w_FLAG=y 1640 ;; 1641 X ) # now that we no longer need realmode builds, just 1642 # copy IHV packages. only meaningful on x86. 1643 if [ "$MACH" = "i386" ]; then 1644 X_FLAG=y 1645 fi 1646 ;; 1647 x ) XMOD_OPT="-x" 1648 ;; 1649 z ) z_FLAG=y 1650 ;; 1651 \? ) echo "$USAGE" 1652 exit 1 1653 ;; 1654 esac 1655done 1656 1657if [ $ISUSER -ne 0 ]; then 1658 if [ "$o_FLAG" = "y" ]; then 1659 echo "Old-style build requires root permission." 1660 exit 1 1661 fi 1662 1663 # Set default value for STAFFER, if needed. 1664 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 1665 STAFFER=`/usr/xpg4/bin/id -un` 1666 export STAFFER 1667 fi 1668fi 1669 1670if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 1671 MAILTO=$STAFFER 1672 export MAILTO 1673fi 1674 1675PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 1676PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb" 1677PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 1678export PATH 1679 1680# roots of source trees, both relative to $SRC and absolute. 1681relsrcdirs="." 1682if [[ -d $CODEMGR_WS/usr/closed && "$CLOSED_IS_PRESENT" != no ]]; then 1683 relsrcdirs="$relsrcdirs ../closed" 1684fi 1685abssrcdirs="" 1686for d in $relsrcdirs; do 1687 abssrcdirs="$abssrcdirs $SRC/$d" 1688done 1689 1690unset CH 1691if [ "$o_FLAG" = "y" ]; then 1692# root invoked old-style build -- make sure it works as it always has 1693# by exporting 'CH'. The current Makefile.master doesn't use this, but 1694# the old ones still do. 1695 PROTOCMPTERSE="protocmp.terse" 1696 CH= 1697 export CH 1698else 1699 PROTOCMPTERSE="protocmp.terse -gu" 1700fi 1701POUND_SIGN="#" 1702# have we set RELEASE_DATE in our env file? 1703if [ -z "$RELEASE_DATE" ]; then 1704 RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 1705fi 1706BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 1707BASEWSDIR=$(basename $CODEMGR_WS) 1708DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 1709 1710# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 1711# by avoiding repeated shell invocations to evaluate Makefile.master definitions. 1712export o_FLAG X_FLAG POUND_SIGN RELEASE_DATE DEV_CM 1713 1714maketype="distributed" 1715MAKE=dmake 1716# get the dmake version string alone 1717DMAKE_VERSION=$( $MAKE -v ) 1718DMAKE_VERSION=${DMAKE_VERSION#*: } 1719# focus in on just the dotted version number alone 1720DMAKE_MAJOR=$( echo $DMAKE_VERSION | \ 1721 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' ) 1722# extract the second (or final) integer 1723DMAKE_MINOR=${DMAKE_MAJOR#*.} 1724DMAKE_MINOR=${DMAKE_MINOR%%.*} 1725# extract the first integer 1726DMAKE_MAJOR=${DMAKE_MAJOR%%.*} 1727CHECK_DMAKE=${CHECK_DMAKE:-y} 1728# x86 was built on the 12th, sparc on the 13th. 1729if [ "$CHECK_DMAKE" = "y" -a \ 1730 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \ 1731 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \ 1732 "$DMAKE_MAJOR" -lt 7 -o \ 1733 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then 1734 if [ -z "$DMAKE_VERSION" ]; then 1735 echo "$MAKE is missing." 1736 exit 1 1737 fi 1738 echo `whence $MAKE`" version is:" 1739 echo " ${DMAKE_VERSION}" 1740 cat <<EOF 1741 1742This version may not be safe for use. Either set TEAMWARE to a better 1743path or (if you really want to use this version of dmake anyway), add 1744the following to your environment to disable this check: 1745 1746 CHECK_DMAKE=n 1747EOF 1748 exit 1 1749fi 1750export PATH 1751export MAKE 1752 1753# 1754# Make sure the crypto tarball is available if it's needed. 1755# 1756 1757# Echo the non-DEBUG name corresponding to the given crypto tarball path. 1758function ndcrypto { 1759 typeset dir file 1760 1761 if [ -z "$1" ]; then 1762 echo "" 1763 return 1764 fi 1765 1766 dir=$(dirname "$1") 1767 file=$(basename "$1" ".$MACH.tar.bz2") 1768 1769 echo "$dir/$file-nd.$MACH.tar.bz2" 1770} 1771 1772# Return 0 (success) if the required crypto tarball(s) are present. 1773function crypto_is_present { 1774 if [ -z "$ON_CRYPTO_BINS" ]; then 1775 echo "ON_CRYPTO_BINS is null or not set." 1776 return 1 1777 fi 1778 if [ "$D_FLAG" = y ]; then 1779 if [ ! -f "$ON_CRYPTO_BINS" ]; then 1780 echo "DEBUG crypto tarball is unavailable." 1781 return 1 1782 fi 1783 fi 1784 if [ "$F_FLAG" = n ]; then 1785 if [ ! -f $(ndcrypto "$ON_CRYPTO_BINS") ]; then 1786 echo "Non-DEBUG crypto tarball is unavailable." 1787 return 1 1788 fi 1789 fi 1790 1791 return 0 1792} 1793 1794# 1795# Canonicalize ON_CRYPTO_BINS, just in case it was set to the -nd 1796# tarball. 1797# 1798if [ -n "$ON_CRYPTO_BINS" ]; then 1799 export ON_CRYPTO_BINS=$(echo "$ON_CRYPTO_BINS" | 1800 sed -e s/-nd.$MACH.tar/.$MACH.tar/) 1801fi 1802 1803if [[ "$O_FLAG" = y && -z "$CODESIGN_USER" ]]; then 1804 if ! crypto_is_present; then 1805 echo "OpenSolaris deliveries need signed crypto." 1806 exit 1 1807 fi 1808fi 1809 1810if [ "${SUNWSPRO}" != "" ]; then 1811 PATH="${SUNWSPRO}/bin:$PATH" 1812 export PATH 1813fi 1814 1815hostname=$(uname -n) 1816if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 1817then 1818 maxjobs= 1819 if [[ -f $HOME/.make.machines ]] 1820 then 1821 # Note: there is a hard tab and space character in the []s 1822 # below. 1823 egrep -i "^[ ]*$hostname[ \.]" \ 1824 $HOME/.make.machines | read host jobs 1825 maxjobs=${jobs##*=} 1826 fi 1827 1828 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 1829 then 1830 # default 1831 maxjobs=4 1832 fi 1833 1834 export DMAKE_MAX_JOBS=$maxjobs 1835fi 1836 1837DMAKE_MODE=parallel; 1838export DMAKE_MODE 1839 1840if [ -z "${ROOT}" ]; then 1841 echo "ROOT must be set." 1842 exit 1 1843fi 1844 1845# 1846# if -V flag was given, reset VERSION to V_ARG 1847# 1848if [ "$V_FLAG" = "y" ]; then 1849 VERSION=$V_ARG 1850fi 1851 1852# 1853# Check for IHV root for copying ihv proto area 1854# 1855if [ "$X_FLAG" = "y" ]; then 1856 if [ "$IA32_IHV_ROOT" = "" ]; then 1857 echo "IA32_IHV_ROOT: must be set for copying ihv proto" 1858 args_ok=n 1859 fi 1860 if [ ! -d "$IA32_IHV_ROOT" ]; then 1861 echo "$IA32_IHV_ROOT: not found" 1862 args_ok=n 1863 fi 1864 if [ "$IA32_IHV_WS" = "" ]; then 1865 echo "IA32_IHV_WS: must be set for copying ihv proto" 1866 args_ok=n 1867 fi 1868 if [ ! -d "$IA32_IHV_WS" ]; then 1869 echo "$IA32_IHV_WS: not found" 1870 args_ok=n 1871 fi 1872fi 1873 1874# Append source version 1875if [ "$SE_FLAG" = "y" ]; then 1876 VERSION="${VERSION}:EXPORT" 1877fi 1878 1879if [ "$SD_FLAG" = "y" ]; then 1880 VERSION="${VERSION}:DOMESTIC" 1881fi 1882 1883if [ "$SH_FLAG" = "y" ]; then 1884 VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT" 1885fi 1886 1887if [ "$SO_FLAG" = "y" ]; then 1888 VERSION="${VERSION}:OPEN_ONLY" 1889fi 1890 1891TMPDIR="/tmp/nightly.tmpdir.$$" 1892export TMPDIR 1893rm -rf ${TMPDIR} 1894mkdir -p $TMPDIR || exit 1 1895chmod 777 $TMPDIR 1896 1897# 1898# Keep elfsign's use of pkcs11_softtoken from looking in the user home 1899# directory, which doesn't always work. Needed until all build machines 1900# have the fix for 6271754 1901# 1902SOFTTOKEN_DIR=$TMPDIR 1903export SOFTTOKEN_DIR 1904 1905# 1906# Tools should only be built non-DEBUG. Keep track of the tools proto 1907# area path relative to $TOOLS, because the latter changes in an 1908# export build. 1909# 1910# TOOLS_PROTO is included below for builds other than usr/src/tools 1911# that look for this location. For usr/src/tools, this will be 1912# overridden on the $MAKE command line in build_tools(). 1913# 1914TOOLS=${SRC}/tools 1915TOOLS_PROTO_REL=proto/root_${MACH}-nd 1916TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1917 1918 1919unset CFLAGS LD_LIBRARY_PATH LDFLAGS 1920 1921# create directories that are automatically removed if the nightly script 1922# fails to start correctly 1923function newdir { 1924 dir=$1 1925 toadd= 1926 while [ ! -d $dir ]; do 1927 toadd="$dir $toadd" 1928 dir=`dirname $dir` 1929 done 1930 torm= 1931 newlist= 1932 for dir in $toadd; do 1933 if staffer mkdir $dir; then 1934 newlist="$ISUSER $dir $newlist" 1935 torm="$dir $torm" 1936 else 1937 [ -z "$torm" ] || staffer rmdir $torm 1938 return 1 1939 fi 1940 done 1941 newdirlist="$newlist $newdirlist" 1942 return 0 1943} 1944newdirlist= 1945 1946[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 1947 1948# since this script assumes the build is from full source, it nullifies 1949# variables likely to have been set by a "ws" script; nullification 1950# confines the search space for headers and libraries to the proto area 1951# built from this immediate source. 1952ENVLDLIBS1= 1953ENVLDLIBS2= 1954ENVLDLIBS3= 1955ENVCPPFLAGS1= 1956ENVCPPFLAGS2= 1957ENVCPPFLAGS3= 1958ENVCPPFLAGS4= 1959PARENT_ROOT= 1960 1961export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1962 PARENT_ROOT 1963 1964CPIODIR_ORIG=$CPIODIR 1965PKGARCHIVE_ORIG=$PKGARCHIVE 1966IA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS 1967 1968# 1969# Juggle the logs and optionally send mail on completion. 1970# 1971 1972function logshuffle { 1973 LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 1974 if [ -f $LLOG -o -d $LLOG ]; then 1975 LLOG=$LLOG.$$ 1976 fi 1977 mkdir $LLOG 1978 export LLOG 1979 1980 if [ "$build_ok" = "y" ]; then 1981 mv $ATLOG/proto_list_${MACH} $LLOG 1982 1983 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 1984 mv $ATLOG/proto_list_tools_${MACH} $LLOG 1985 fi 1986 1987 if [ -f $TMPDIR/wsdiff.results ]; then 1988 mv $TMPDIR/wsdiff.results $LLOG 1989 fi 1990 1991 if [ -f $TMPDIR/wsdiff-nd.results ]; then 1992 mv $TMPDIR/wsdiff-nd.results $LLOG 1993 fi 1994 fi 1995 1996 # 1997 # Now that we're about to send mail, it's time to check the noise 1998 # file. In the event that an error occurs beyond this point, it will 1999 # be recorded in the nightly.log file, but nowhere else. This would 2000 # include only errors that cause the copying of the noise log to fail 2001 # or the mail itself not to be sent. 2002 # 2003 2004 exec >>$LOGFILE 2>&1 2005 if [ -s $build_noise_file ]; then 2006 echo "\n==== Nightly build noise ====\n" | 2007 tee -a $LOGFILE >>$mail_msg_file 2008 cat $build_noise_file >>$LOGFILE 2009 cat $build_noise_file >>$mail_msg_file 2010 echo | tee -a $LOGFILE >>$mail_msg_file 2011 fi 2012 rm -f $build_noise_file 2013 2014 case "$build_ok" in 2015 y) 2016 state=Completed 2017 ;; 2018 i) 2019 state=Interrupted 2020 ;; 2021 *) 2022 state=Failed 2023 ;; 2024 esac 2025 NIGHTLY_STATUS=$state 2026 export NIGHTLY_STATUS 2027 2028 run_hook POST_NIGHTLY $state 2029 run_hook SYS_POST_NIGHTLY $state 2030 2031 cat $build_time_file $build_environ_file $mail_msg_file \ 2032 > ${LLOG}/mail_msg 2033 if [ "$m_FLAG" = "y" ]; then 2034 cat ${LLOG}/mail_msg | /usr/bin/mailx -s \ 2035 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 2036 ${MAILTO} 2037 fi 2038 2039 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 2040 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 2041 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 2042 fi 2043 2044 mv $LOGFILE $LLOG 2045} 2046 2047# 2048# Remove the locks and temporary files on any exit 2049# 2050function cleanup { 2051 logshuffle 2052 2053 [ -z "$lockfile" ] || staffer rm -f $lockfile 2054 [ -z "$atloglockfile" ] || rm -f $atloglockfile 2055 [ -z "$ulockfile" ] || staffer rm -f $ulockfile 2056 [ -z "$Ulockfile" ] || rm -f $Ulockfile 2057 2058 set -- $newdirlist 2059 while [ $# -gt 0 ]; do 2060 ISUSER=$1 staffer rmdir $2 2061 shift; shift 2062 done 2063 rm -rf $TMPDIR 2064} 2065 2066function cleanup_signal { 2067 build_ok=i 2068 # this will trigger cleanup(), above. 2069 exit 1 2070} 2071 2072trap cleanup 0 2073trap cleanup_signal 1 2 3 15 2074 2075# 2076# Generic lock file processing -- make sure that the lock file doesn't 2077# exist. If it does, it should name the build host and PID. If it 2078# doesn't, then make sure we can create it. Clean up locks that are 2079# known to be stale (assumes host name is unique among build systems 2080# for the workspace). 2081# 2082function create_lock { 2083 lockf=$1 2084 lockvar=$2 2085 2086 ldir=`dirname $lockf` 2087 [ -d $ldir ] || newdir $ldir || exit 1 2088 eval $lockvar=$lockf 2089 2090 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 2091 basews=`basename $CODEMGR_WS` 2092 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 2093 if [ "$host" != "$hostname" ]; then 2094 echo "$MACH build of $basews apparently" \ 2095 "already started by $user on $host as $pid." 2096 exit 1 2097 elif kill -s 0 $pid 2>/dev/null; then 2098 echo "$MACH build of $basews already started" \ 2099 "by $user as $pid." 2100 exit 1 2101 else 2102 # stale lock; clear it out and try again 2103 rm -f $lockf 2104 fi 2105 done 2106} 2107 2108# 2109# Return the list of interesting proto areas, depending on the current 2110# options. 2111# 2112function allprotos { 2113 roots="$ROOT $TOOLS_PROTO" 2114 if [ $O_FLAG = y ]; then 2115 # OpenSolaris deliveries require separate proto areas. 2116 [ $D_FLAG = y ] && roots="$roots $ROOT-open" 2117 [ $F_FLAG = n ] && roots="$roots $ROOT-open-nd" 2118 fi 2119 if [[ $D_FLAG = y && $F_FLAG = n ]]; then 2120 [ $MULTI_PROTO = yes ] && roots="$roots $ROOT-nd" 2121 fi 2122 2123 echo $roots 2124} 2125 2126# Ensure no other instance of this script is running on this host. 2127# LOCKNAME can be set in <env_file>, and is by default, but is not 2128# required due to the use of $ATLOG below. 2129if [ -n "$LOCKNAME" ]; then 2130 create_lock /tmp/$LOCKNAME "lockfile" 2131fi 2132# 2133# Create from one, two, or three other locks: 2134# $ATLOG/nightly.lock 2135# - protects against multiple builds in same workspace 2136# $PARENT_WS/usr/src/nightly.$MACH.lock 2137# - protects against multiple 'u' copy-backs 2138# $NIGHTLY_PARENT_ROOT/nightly.lock 2139# - protects against multiple 'U' copy-backs 2140# 2141# Overriding ISUSER to 1 causes the lock to be created as root if the 2142# script is run as root. The default is to create it as $STAFFER. 2143ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 2144if [ "$u_FLAG" = "y" ]; then 2145 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 2146fi 2147if [ "$U_FLAG" = "y" ]; then 2148 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 2149 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 2150fi 2151 2152# Locks have been taken, so we're doing a build and we're committed to 2153# the directories we may have created so far. 2154newdirlist= 2155 2156# 2157# Create mail_msg_file 2158# 2159mail_msg_file="${TMPDIR}/mail_msg" 2160touch $mail_msg_file 2161build_time_file="${TMPDIR}/build_time" 2162build_environ_file="${TMPDIR}/build_environ" 2163touch $build_environ_file 2164# 2165# Move old LOGFILE aside 2166# ATLOG directory already made by 'create_lock' above 2167# 2168if [ -f $LOGFILE ]; then 2169 mv -f $LOGFILE ${LOGFILE}- 2170fi 2171# 2172# Build OsNet source 2173# 2174START_DATE=`date` 2175SECONDS=0 2176echo "\n==== Nightly $maketype build started: $START_DATE ====" \ 2177 | tee -a $LOGFILE > $build_time_file 2178 2179echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 2180 tee -a $mail_msg_file >> $LOGFILE 2181 2182# make sure we log only to the nightly build file 2183build_noise_file="${TMPDIR}/build_noise" 2184exec </dev/null >$build_noise_file 2>&1 2185 2186run_hook SYS_PRE_NIGHTLY 2187run_hook PRE_NIGHTLY 2188 2189echo "\n==== list of environment variables ====\n" >> $LOGFILE 2190env >> $LOGFILE 2191 2192echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 2193 2194if [ "$P_FLAG" = "y" ]; then 2195 obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE 2196fi 2197 2198if [ "$T_FLAG" = "y" ]; then 2199 obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE 2200fi 2201 2202if is_source_build; then 2203 if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then 2204 echo "WARNING: the -S flags do not support incremental" \ 2205 "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE 2206 i_FLAG=n 2207 i_CMD_LINE_FLAG=n 2208 fi 2209 if [ "$N_FLAG" = "n" ]; then 2210 echo "WARNING: the -S flags do not support protocmp;" \ 2211 "protocmp disabled\n" | \ 2212 tee -a $mail_msg_file >> $LOGFILE 2213 N_FLAG=y 2214 fi 2215 if [ "$l_FLAG" = "y" ]; then 2216 echo "WARNING: the -S flags do not support lint;" \ 2217 "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE 2218 l_FLAG=n 2219 fi 2220 if [ "$C_FLAG" = "y" ]; then 2221 echo "WARNING: the -S flags do not support cstyle;" \ 2222 "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE 2223 C_FLAG=n 2224 fi 2225else 2226 if [ "$N_FLAG" = "y" ]; then 2227 if [ "$p_FLAG" = "y" ]; then 2228 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 2229WARNING: the p option (create packages) is set, but so is the N option (do 2230 not run protocmp); this is dangerous; you should unset the N option 2231EOF 2232 else 2233 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 2234Warning: the N option (do not run protocmp) is set; it probably shouldn't be 2235EOF 2236 fi 2237 echo "" | tee -a $mail_msg_file >> $LOGFILE 2238 fi 2239fi 2240 2241if [ "$O_FLAG" = "y" -a "$a_FLAG" = "n" ]; then 2242 echo "WARNING: OpenSolaris deliveries (-O) require archives;" \ 2243 "enabling the -a flag." | tee -a $mail_msg_file >> $LOGFILE 2244 a_FLAG=y 2245fi 2246 2247if [ "$a_FLAG" = "y" -a "$D_FLAG" = "n" -a "$F_FLAG" = "y" ]; then 2248 echo "WARNING: Neither DEBUG nor non-DEBUG build requested, but the" \ 2249 "'a' option was set." | tee -a $mail_msg_file >> $LOGFILE 2250fi 2251 2252if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 2253 # 2254 # In the past we just complained but went ahead with the lint 2255 # pass, even though the proto area was built non-DEBUG. It's 2256 # unlikely that non-DEBUG headers will make a difference, but 2257 # rather than assuming it's a safe combination, force the user 2258 # to specify a DEBUG build. 2259 # 2260 echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 2261 | tee -a $mail_msg_file >> $LOGFILE 2262 l_FLAG=n 2263fi 2264 2265if [ "$f_FLAG" = "y" ]; then 2266 if [ "$i_FLAG" = "y" ]; then 2267 echo "WARNING: the -f flag cannot be used during incremental" \ 2268 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 2269 f_FLAG=n 2270 fi 2271 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 2272 echo "WARNING: the -f flag requires -l, and -p;" \ 2273 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 2274 f_FLAG=n 2275 fi 2276fi 2277 2278if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 2279 echo "WARNING: -w specified, but $ROOT does not exist;" \ 2280 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 2281 w_FLAG=n 2282fi 2283 2284if [ "$t_FLAG" = "n" ]; then 2285 # 2286 # We're not doing a tools build, so make sure elfsign(1) is 2287 # new enough to safely sign non-crypto binaries. We test 2288 # debugging output from elfsign to detect the old version. 2289 # 2290 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 2291 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 2292 | egrep algorithmOID` 2293 if [ -z "$newelfsigntest" ]; then 2294 echo "WARNING: /usr/bin/elfsign out of date;" \ 2295 "will only sign crypto modules\n" | \ 2296 tee -a $mail_msg_file >> $LOGFILE 2297 export ELFSIGN_OBJECT=true 2298 elif [ "$VERIFY_ELFSIGN" = "y" ]; then 2299 echo "WARNING: VERIFY_ELFSIGN=y requires" \ 2300 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 2301 tee -a $mail_msg_file >> $LOGFILE 2302 fi 2303fi 2304 2305[ "$O_FLAG" = y ] && MULTI_PROTO=yes 2306 2307case $MULTI_PROTO in 2308yes|no) ;; 2309*) 2310 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 2311 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 2312 echo "Setting MULTI_PROTO to \"no\".\n" | \ 2313 tee -a $mail_msg_file >> $LOGFILE 2314 export MULTI_PROTO=no 2315 ;; 2316esac 2317 2318# If CODESIGN_USER is set, we'll want the crypto that we just built. 2319if [[ -n "$CODESIGN_USER" && -n "$ON_CRYPTO_BINS" ]]; then 2320 echo "Clearing ON_CRYPTO_BINS for signing build." >> "$LOGFILE" 2321 unset ON_CRYPTO_BINS 2322fi 2323 2324echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 2325echo $VERSION | tee -a $mail_msg_file >> $LOGFILE 2326 2327# Save the current proto area if we're comparing against the last build 2328if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 2329 if [ -d "$ROOT.prev" ]; then 2330 rm -rf $ROOT.prev 2331 fi 2332 mv $ROOT $ROOT.prev 2333fi 2334 2335# Same for non-DEBUG proto area 2336if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 2337 if [ -d "$ROOT-nd.prev" ]; then 2338 rm -rf $ROOT-nd.prev 2339 fi 2340 mv $ROOT-nd $ROOT-nd.prev 2341fi 2342 2343# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 2344function wstypes { 2345 typeset parent_type child_type junk 2346 2347 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 2348 | read parent_type junk 2349 if [[ -z "$parent_type" || "$parent_type" == unknown ]]; then 2350 # Probe BRINGOVER_WS to determine its type 2351 if [[ $BRINGOVER_WS == svn*://* ]]; then 2352 parent_type="subversion" 2353 elif [[ $BRINGOVER_WS == file://* ]] && 2354 egrep -s "This is a Subversion repository" \ 2355 ${BRINGOVER_WS#file://}/README.txt 2> /dev/null; then 2356 parent_type="subversion" 2357 elif [[ $BRINGOVER_WS == ssh://* ]]; then 2358 parent_type="mercurial" 2359 elif svn info $BRINGOVER_WS > /dev/null 2>&1; then 2360 parent_type="subversion" 2361 elif [[ $BRINGOVER_WS == http://* ]] && \ 2362 http_get "$BRINGOVER_WS/?cmd=heads" | \ 2363 egrep -s "application/mercurial" 2> /dev/null; then 2364 parent_type="mercurial" 2365 else 2366 parent_type="none" 2367 fi 2368 fi 2369 2370 # Probe CODEMGR_WS to determine its type 2371 if [[ -d $CODEMGR_WS ]]; then 2372 $WHICH_SCM | read child_type junk || exit 1 2373 fi 2374 2375 # fold both unsupported and unrecognized results into "none" 2376 case "$parent_type" in 2377 none|subversion|teamware|mercurial) 2378 ;; 2379 *) parent_type=none 2380 ;; 2381 esac 2382 case "$child_type" in 2383 none|subversion|teamware|mercurial) 2384 ;; 2385 *) child_type=none 2386 ;; 2387 esac 2388 2389 echo $child_type $parent_type 2390} 2391 2392wstypes | read SCM_TYPE PARENT_SCM_TYPE 2393export SCM_TYPE PARENT_SCM_TYPE 2394 2395# 2396# Decide whether to clobber 2397# 2398if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 2399 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 2400 2401 cd $SRC 2402 # remove old clobber file 2403 rm -f $SRC/clobber.out 2404 rm -f $SRC/clobber-${MACH}.out 2405 2406 # Remove all .make.state* files, just in case we are restarting 2407 # the build after having interrupted a previous 'make clobber'. 2408 find . \( -name SCCS -o -name .hg -o -name .svn \ 2409 -o -name 'interfaces.*' \) -prune \ 2410 -o -name '.make.*' -print | xargs rm -f 2411 2412 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 2413 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 2414 grep "$MAKE:" $SRC/clobber-${MACH}.out | 2415 egrep -v "Ignoring unknown host" \ 2416 >> $mail_msg_file 2417 2418 if [[ "$t_FLAG" = "y" || "$O_FLAG" = "y" ]]; then 2419 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 2420 cd ${TOOLS} 2421 rm -f ${TOOLS}/clobber-${MACH}.out 2422 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 2423 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 2424 echo "\n==== Make tools clobber ERRORS ====\n" \ 2425 >> $mail_msg_file 2426 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 2427 >> $mail_msg_file 2428 rm -rf ${TOOLS_PROTO} 2429 mkdir -p ${TOOLS_PROTO} 2430 fi 2431 2432 rm -rf `allprotos` 2433 2434 # Get back to a clean workspace as much as possible to catch 2435 # problems that only occur on fresh workspaces. 2436 # Remove all .make.state* files, libraries, and .o's that may 2437 # have been omitted from clobber. A couple of libraries are 2438 # under source code control, so leave them alone. 2439 # We should probably blow away temporary directories too. 2440 cd $SRC 2441 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 2442 -o -name 'interfaces.*' \) -prune -o \ 2443 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 2444 -name '*.o' \) -print | \ 2445 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 2446else 2447 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 2448fi 2449 2450type bringover_teamware > /dev/null 2>&1 || function bringover_teamware { 2451 # sleep on the parent workspace's lock 2452 while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks 2453 do 2454 sleep 120 2455 done 2456 2457 if [[ -z $BRINGOVER ]]; then 2458 BRINGOVER=$TEAMWARE/bin/bringover 2459 fi 2460 2461 staffer $BRINGOVER -c "nightly update" -p $BRINGOVER_WS \ 2462 -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 || 2463 touch $TMPDIR/bringover_failed 2464 2465 staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1 2466 if [ -s $TMPDIR/bringovercheck.out ]; then 2467 echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n" 2468 cat $TMPDIR/bringovercheck.out 2469 fi 2470} 2471 2472type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 2473 typeset -x PATH=$PATH 2474 2475 # If the repository doesn't exist yet, then we want to populate it. 2476 if [[ ! -d $CODEMGR_WS/.hg ]]; then 2477 staffer hg init $CODEMGR_WS 2478 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 2479 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 2480 touch $TMPDIR/new_repository 2481 fi 2482 2483 # 2484 # If the user set CLOSED_BRINGOVER_WS and didn't set CLOSED_IS_PRESENT 2485 # to "no," then we'll want to initialise the closed repository 2486 # 2487 # We use $orig_closed_is_present instead of $CLOSED_IS_PRESENT, 2488 # because for newly-created source trees, the latter will be "no" 2489 # until after the bringover completes. 2490 # 2491 if [[ "$orig_closed_is_present" != "no" && \ 2492 -n "$CLOSED_BRINGOVER_WS" && \ 2493 ! -d $CODEMGR_WS/usr/closed/.hg ]]; then 2494 staffer mkdir -p $CODEMGR_WS/usr/closed 2495 staffer hg init $CODEMGR_WS/usr/closed 2496 staffer echo "[paths]" > $CODEMGR_WS/usr/closed/.hg/hgrc 2497 staffer echo "default=$CLOSED_BRINGOVER_WS" >> $CODEMGR_WS/usr/closed/.hg/hgrc 2498 touch $TMPDIR/new_closed 2499 export CLOSED_IS_PRESENT=yes 2500 fi 2501 2502 typeset -x HGMERGE="/bin/false" 2503 2504 # 2505 # If the user has changes, regardless of whether those changes are 2506 # committed, and regardless of whether those changes conflict, then 2507 # we'll attempt to merge them either implicitly (uncommitted) or 2508 # explicitly (committed). 2509 # 2510 # These are the messages we'll use to help clarify mercurial output 2511 # in those cases. 2512 # 2513 typeset mergefailmsg="\ 2514***\n\ 2515*** nightly was unable to automatically merge your changes. You should\n\ 2516*** redo the full merge manually, following the steps outlined by mercurial\n\ 2517*** above, then restart nightly.\n\ 2518***\n" 2519 typeset mergepassmsg="\ 2520***\n\ 2521*** nightly successfully merged your changes. This means that your working\n\ 2522*** directory has been updated, but those changes are not yet committed.\n\ 2523*** After nightly completes, you should validate the results of the merge,\n\ 2524*** then use hg commit manually.\n\ 2525***\n" 2526 2527 # 2528 # For each repository in turn: 2529 # 2530 # 1. Do the pull. If this fails, dump the output and bail out. 2531 # 2532 # 2. If the pull resulted in an extra head, do an explicit merge. 2533 # If this fails, dump the output and bail out. 2534 # 2535 # Because we can't rely on Mercurial to exit with a failure code 2536 # when a merge fails (Mercurial issue #186), we must grep the 2537 # output of pull/merge to check for attempted and/or failed merges. 2538 # 2539 # 3. If a merge failed, set the message and fail the bringover. 2540 # 2541 # 4. Otherwise, if a merge succeeded, set the message 2542 # 2543 # 5. Dump the output, and any message from step 3 or 4. 2544 # 2545 2546 typeset HG_SOURCE=$BRINGOVER_WS 2547 if [ ! -f $TMPDIR/new_repository ]; then 2548 HG_SOURCE=$TMPDIR/open_bundle.hg 2549 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 2550 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 2551 2552 # 2553 # If there are no incoming changesets, then incoming will 2554 # fail, and there will be no bundle file. Reset the source, 2555 # to allow the remaining logic to complete with no false 2556 # negatives. (Unlike incoming, pull will return success 2557 # for the no-change case.) 2558 # 2559 if (( $? != 0 )); then 2560 HG_SOURCE=$BRINGOVER_WS 2561 fi 2562 fi 2563 2564 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 2565 > $TMPDIR/pull_open.out 2>&1 2566 if (( $? != 0 )); then 2567 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 2568 cat $TMPDIR/pull_open.out 2569 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 2570 printf "$mergefailmsg" 2571 fi 2572 touch $TMPDIR/bringover_failed 2573 return 2574 fi 2575 2576 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 2577 staffer hg --cwd $CODEMGR_WS merge \ 2578 >> $TMPDIR/pull_open.out 2>&1 2579 if (( $? != 0 )); then 2580 printf "%s: merge failed as follows:\n\n" \ 2581 "$CODEMGR_WS" 2582 cat $TMPDIR/pull_open.out 2583 if grep "^merging.*failed" $TMPDIR/pull_open.out \ 2584 > /dev/null 2>&1; then 2585 printf "$mergefailmsg" 2586 fi 2587 touch $TMPDIR/bringover_failed 2588 return 2589 fi 2590 fi 2591 2592 printf "updated %s with the following results:\n" "$CODEMGR_WS" 2593 cat $TMPDIR/pull_open.out 2594 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 2595 printf "$mergepassmsg" 2596 fi 2597 printf "\n" 2598 2599 # 2600 # We only want to update usr/closed if it exists, and we haven't been 2601 # told not to via $CLOSED_IS_PRESENT, and we actually know where to 2602 # pull from ($CLOSED_BRINGOVER_WS). 2603 # 2604 if [[ $CLOSED_IS_PRESENT = yes && \ 2605 -d $CODEMGR_WS/usr/closed/.hg && \ 2606 -n $CLOSED_BRINGOVER_WS ]]; then 2607 2608 HG_SOURCE=$CLOSED_BRINGOVER_WS 2609 if [ ! -f $TMPDIR/new_closed ]; then 2610 HG_SOURCE=$TMPDIR/closed_bundle.hg 2611 staffer hg --cwd $CODEMGR_WS/usr/closed incoming \ 2612 --bundle $HG_SOURCE -v $CLOSED_BRINGOVER_WS \ 2613 > $TMPDIR/incoming_closed.out 2614 2615 # 2616 # If there are no incoming changesets, then incoming will 2617 # fail, and there will be no bundle file. Reset the source, 2618 # to allow the remaining logic to complete with no false 2619 # negatives. (Unlike incoming, pull will return success 2620 # for the no-change case.) 2621 # 2622 if (( $? != 0 )); then 2623 HG_SOURCE=$CLOSED_BRINGOVER_WS 2624 fi 2625 fi 2626 2627 staffer hg --cwd $CODEMGR_WS/usr/closed pull -u \ 2628 $HG_SOURCE > $TMPDIR/pull_closed.out 2>&1 2629 if (( $? != 0 )); then 2630 printf "closed pull failed as follows:\n\n" 2631 cat $TMPDIR/pull_closed.out 2632 if grep "^merging.*failed" $TMPDIR/pull_closed.out \ 2633 > /dev/null 2>&1; then 2634 printf "$mergefailmsg" 2635 fi 2636 touch $TMPDIR/bringover_failed 2637 return 2638 fi 2639 2640 if grep "not updating" $TMPDIR/pull_closed.out > /dev/null 2>&1; then 2641 staffer hg --cwd $CODEMGR_WS/usr/closed merge \ 2642 >> $TMPDIR/pull_closed.out 2>&1 2643 if (( $? != 0 )); then 2644 printf "closed merge failed as follows:\n\n" 2645 cat $TMPDIR/pull_closed.out 2646 if grep "^merging.*failed" $TMPDIR/pull_closed.out > /dev/null 2>&1; then 2647 printf "$mergefailmsg" 2648 fi 2649 touch $TMPDIR/bringover_failed 2650 return 2651 fi 2652 fi 2653 2654 printf "updated %s with the following results:\n" \ 2655 "$CODEMGR_WS/usr/closed" 2656 cat $TMPDIR/pull_closed.out 2657 if grep "^merging" $TMPDIR/pull_closed.out > /dev/null 2>&1; then 2658 printf "$mergepassmsg" 2659 fi 2660 fi 2661 2662 # 2663 # Per-changeset output is neither useful nor manageable for a 2664 # newly-created repository. 2665 # 2666 if [ -f $TMPDIR/new_repository ]; then 2667 return 2668 fi 2669 2670 printf "\nadded the following changesets to open repository:\n" 2671 cat $TMPDIR/incoming_open.out 2672 2673 # 2674 # The closed repository could have been newly created, even though 2675 # the open one previously existed... 2676 # 2677 if [ -f $TMPDIR/new_closed ]; then 2678 return 2679 fi 2680 2681 if [ -f $TMPDIR/incoming_closed.out ]; then 2682 printf "\nadded the following changesets to closed repository:\n" 2683 cat $TMPDIR/incoming_closed.out 2684 fi 2685} 2686 2687type bringover_subversion > /dev/null 2>&1 || function bringover_subversion { 2688 typeset -x PATH=$PATH 2689 2690 if [[ ! -d $CODEMGR_WS/.svn ]]; then 2691 staffer svn checkout $BRINGOVER_WS $CODEMGR_WS || 2692 touch $TMPDIR/bringover_failed 2693 else 2694 typeset root 2695 root=$(staffer svn info $CODEMGR_WS | 2696 nawk '/^Repository Root:/ {print $NF}') 2697 if [[ $root != $BRINGOVER_WS ]]; then 2698 # We fail here because there's no way to update 2699 # from a named repo. 2700 cat <<-EOF 2701 \$BRINGOVER_WS doesn't match repository root: 2702 \$BRINGOVER_WS: $BRINGOVER_WS 2703 Repository root: $root 2704 EOF 2705 touch $TMPDIR/bringover_failed 2706 else 2707 # If a conflict happens, svn still exits 0. 2708 staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out || 2709 touch $TMPDIR/bringover_failed 2710 if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then 2711 touch $TMPDIR/bringover_failed 2712 fi 2713 fi 2714 fi 2715} 2716 2717type bringover_none > /dev/null 2>&1 || function bringover_none { 2718 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 2719 touch $TMPDIR/bringover_failed 2720} 2721 2722# Parse the URL. 2723# The other way to deal with empty components is to echo a string that can 2724# be eval'ed by the caller to associate values (possibly empty) with 2725# variables. In that case, passing in a printf string would let the caller 2726# choose the variable names. 2727function parse_url { 2728 typeset url method host port path 2729 2730 url=$1 2731 method=${url%%://*} 2732 host=${url#$method://} 2733 path=${host#*/} 2734 host=${host%%/*} 2735 if [[ $host == *:* ]]; then 2736 port=${host#*:} 2737 host=${host%:*} 2738 fi 2739 2740 # method can never be empty. host can only be empty if method is 2741 # file, and that implies it's localhost. path can default to / if 2742 # it's otherwise empty, leaving port as the only component without 2743 # a default, so it has to go last. 2744 echo $method ${host:-localhost} ${path:-/} $port 2745} 2746 2747function http_get { 2748 typeset url method host port path 2749 2750 url=$1 2751 2752 if [[ -n $http_proxy ]]; then 2753 parse_url $http_proxy | read method host path port 2754 echo "GET $url HTTP/1.0\r\n" | 2755 mconnect -p ${port:-8080} $host 2756 else 2757 parse_url $url | read method host path port 2758 echo "GET $path HTTP/1.0\r\n" | 2759 mconnect -p ${port:-80} $host 2760 fi 2761} 2762 2763# 2764# Decide whether to bringover to the codemgr workspace 2765# 2766if [ "$n_FLAG" = "n" ]; then 2767 2768 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 2769 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 2770 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 2771 exit 1 2772 fi 2773 2774 run_hook PRE_BRINGOVER 2775 2776 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 2777 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 2778 2779 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 2780 tee -a $mail_msg_file >> $LOGFILE 2781 2782 if [ -f $TMPDIR/bringover_failed ]; then 2783 rm -f $TMPDIR/bringover_failed 2784 build_ok=n 2785 echo "trouble with bringover, quitting at `date`." | 2786 tee -a $mail_msg_file >> $LOGFILE 2787 exit 1 2788 fi 2789 2790 # 2791 # It's possible that we used the bringover above to create 2792 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 2793 # but should now be the same as $BRINGOVER_WS. 2794 # 2795 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 2796 2797 run_hook POST_BRINGOVER 2798 2799 # 2800 # Possible transition from pre-split workspace to split 2801 # workspace. See if the bringover changed anything. 2802 # 2803 CLOSED_IS_PRESENT="$orig_closed_is_present" 2804 check_closed_tree 2805else 2806 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 2807fi 2808 2809if [ "$CLOSED_IS_PRESENT" = no ]; then 2810 # 2811 # Not all consolidations have a closed tree, and even if they 2812 # did, they wouldn't necessarily have signed crypto. But if 2813 # the current source base does have signed crypto and it can't 2814 # be generated, error out, rather than silently building 2815 # unusable binaries. 2816 # 2817 grep -s ELFSIGN_CRYPTO "$SRC/Makefile.master" > /dev/null 2818 if (( $? == 0 )); then 2819 crypto_is_present >> "$LOGFILE" 2820 if (( $? != 0 )); then 2821 build_ok=n 2822 echo "A crypto tarball must be provided when" \ 2823 "there is no closed tree." | 2824 tee -a "$mail_msg_file" >> "$LOGFILE" 2825 exit 1 2826 fi 2827 fi 2828fi 2829 2830echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 2831 2832# System 2833whence uname | tee -a $build_environ_file >> $LOGFILE 2834uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 2835echo | tee -a $build_environ_file >> $LOGFILE 2836 2837# nightly 2838echo "$0 $@" | tee -a $build_environ_file >> $LOGFILE 2839if [[ $nightly_path = "/opt/onbld/bin/nightly" ]] && 2840 # 2841 # XXX This should work with ips legacy pkginfo for now, but will 2842 # fall apart when we stop updating that. 2843 # 2844 pkginfo SUNWonbld > /dev/null 2>&1 ; then 2845 pkginfo -l SUNWonbld | egrep "PKGINST:|VERSION:|PSTAMP:" 2846else 2847 echo "$nightly_ls" 2848fi | tee -a $build_environ_file >> $LOGFILE 2849echo | tee -a $build_environ_file >> $LOGFILE 2850 2851# make 2852whence $MAKE | tee -a $build_environ_file >> $LOGFILE 2853$MAKE -v | tee -a $build_environ_file >> $LOGFILE 2854echo "number of concurrent jobs = $DMAKE_MAX_JOBS" | 2855 tee -a $build_environ_file >> $LOGFILE 2856 2857# 2858# Report the compiler versions. 2859# 2860 2861if [[ ! -f $SRC/Makefile ]]; then 2862 build_ok=n 2863 echo "\nUnable to find \"Makefile\" in $SRC." | \ 2864 tee -a $build_environ_file >> $LOGFILE 2865 exit 1 2866fi 2867 2868( cd $SRC 2869 for target in cc-version cc64-version java-version; do 2870 echo 2871 # 2872 # Put statefile somewhere we know we can write to rather than trip 2873 # over a read-only $srcroot. 2874 # 2875 rm -f $TMPDIR/make-state 2876 export SRC 2877 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 2878 continue 2879 fi 2880 touch $TMPDIR/nocompiler 2881 done 2882 echo 2883) | tee -a $build_environ_file >> $LOGFILE 2884 2885if [ -f $TMPDIR/nocompiler ]; then 2886 rm -f $TMPDIR/nocompiler 2887 build_ok=n 2888 echo "Aborting due to missing compiler." | 2889 tee -a $build_environ_file >> $LOGFILE 2890 exit 1 2891fi 2892 2893# as 2894whence as | tee -a $build_environ_file >> $LOGFILE 2895as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 2896echo | tee -a $build_environ_file >> $LOGFILE 2897 2898# Check that we're running a capable link-editor 2899whence ld | tee -a $build_environ_file >> $LOGFILE 2900LDVER=`ld -V 2>&1` 2901echo $LDVER | tee -a $build_environ_file >> $LOGFILE 2902LDVER=`echo $LDVER | sed -e "s/.*-1\.//" -e "s/:.*//"` 2903if [ `expr $LDVER \< 422` -eq 1 ]; then 2904 echo "The link-editor needs to be at version 422 or higher to build" | \ 2905 tee -a $build_environ_file >> $LOGFILE 2906 echo "the latest stuff. Hope your build works." | \ 2907 tee -a $build_environ_file >> $LOGFILE 2908fi 2909 2910# 2911# Build and use the workspace's tools if requested 2912# 2913if [[ "$t_FLAG" = "y" || "$O_FLAG" = y ]]; then 2914 set_non_debug_build_flags 2915 2916 build_tools ${TOOLS_PROTO} 2917 if [[ $? != 0 && "$t_FLAG" = y ]]; then 2918 use_tools $TOOLS_PROTO 2919 fi 2920fi 2921 2922# 2923# copy ihv proto area in addition to the build itself 2924# 2925if [ "$X_FLAG" = "y" ]; then 2926 copy_ihv_proto 2927fi 2928 2929if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then 2930 echo "\n==== NOT Building base OS-Net source ====\n" | \ 2931 tee -a $LOGFILE >> $mail_msg_file 2932else 2933 # timestamp the start of the normal build; the findunref tool uses it. 2934 touch $SRC/.build.tstamp 2935 2936 normal_build 2937fi 2938 2939# 2940# Generate the THIRDPARTYLICENSE files if needed. This is done after 2941# the build, so that dynamically-created license files are there. 2942# It's done before findunref to help identify license files that need 2943# to be added to tools/opensolaris/license-list. 2944# 2945if [ "$O_FLAG" = y -a "$build_ok" = y ]; then 2946 echo "\n==== Generating THIRDPARTYLICENSE files ====\n" | 2947 tee -a "$mail_msg_file" >> "$LOGFILE" 2948 2949 mktpl usr/src/tools/opensolaris/license-list >> "$LOGFILE" 2>&1 2950 if (( $? != 0 )) ; then 2951 echo "Couldn't create THIRDPARTYLICENSE files" | 2952 tee -a "$mail_msg_file" >> "$LOGFILE" 2953 fi 2954fi 2955 2956# 2957# If OpenSolaris deliverables were requested, do the open-only build 2958# now, so that it happens at roughly the same point as the source 2959# product builds. This lets us take advantage of checks that come 2960# later (e.g., the core file check). 2961# 2962if [ "$O_FLAG" = y -a "$build_ok" = y ]; then 2963 # 2964 # Generate skeleton (minimal) closed binaries for open-only 2965 # build. There's no need to distinguish DEBUG from non-DEBUG 2966 # binaries, but it simplifies file management to have separate 2967 # trees. 2968 # 2969 2970 echo "\n==== Generating skeleton closed binaries for" \ 2971 "open-only build ====\n" | \ 2972 tee -a $LOGFILE >> $mail_msg_file 2973 2974 rm -rf $CODEMGR_WS/closed.skel 2975 if [ "$D_FLAG" = y ]; then 2976 mkclosed $MACH $ROOT $CODEMGR_WS/closed.skel/root_$MACH \ 2977 >>$LOGFILE 2>&1 2978 if (( $? != 0 )) ; then 2979 echo "Couldn't create skeleton DEBUG closed binaries." | 2980 tee -a $mail_msg_file >> $LOGFILE 2981 fi 2982 fi 2983 if [ "$F_FLAG" = n ]; then 2984 mkclosed $MACH $ROOT-nd $CODEMGR_WS/closed.skel/root_$MACH-nd \ 2985 >>$LOGFILE 2>&1 2986 if (( $? != 0 )) ; then 2987 echo "Couldn't create skeleton non-DEBUG closed binaries." | 2988 tee -a $mail_msg_file >> $LOGFILE 2989 fi 2990 fi 2991 2992 ORIG_CLOSED_IS_PRESENT=$CLOSED_IS_PRESENT 2993 export CLOSED_IS_PRESENT=no 2994 2995 ORIG_ON_CLOSED_BINS="$ON_CLOSED_BINS" 2996 export ON_CLOSED_BINS=$CODEMGR_WS/closed.skel 2997 2998 normal_build -O 2999 3000 ON_CLOSED_BINS=$ORIG_ON_CLOSED_BINS 3001 CLOSED_IS_PRESENT=$ORIG_CLOSED_IS_PRESENT 3002fi 3003 3004ORIG_SRC=$SRC 3005BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 3006 3007if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 3008 save_binaries 3009fi 3010 3011 3012# EXPORT_SRC comes after CRYPT_SRC since a domestic build will need 3013# $SRC pointing to the export_source usr/src. 3014 3015if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 3016 if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then 3017 set_up_source_build ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC 3018 fi 3019 3020 if [ $build_ok = y ]; then 3021 set_up_source_build ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC 3022 fi 3023fi 3024 3025if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then 3026 # drop the crypt files in place. 3027 cd ${EXPORT_SRC} 3028 echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \ 3029 >> ${LOGFILE} 3030 zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \ 3031 cpio -idmucvB 2>/dev/null >> ${LOGFILE} 3032 if [ "$?" = "0" ]; then 3033 echo "\n==== DOMESTIC extraction succeeded ====\n" \ 3034 >> $mail_msg_file 3035 else 3036 echo "\n==== DOMESTIC extraction failed ====\n" \ 3037 >> $mail_msg_file 3038 fi 3039 3040fi 3041 3042if [ "$SO_FLAG" = "y" -a $build_ok = y ]; then 3043 # 3044 # Copy the open sources into their own tree, set up the closed 3045 # binaries, and set up the environment. The build looks for 3046 # the closed binaries in a location that depends on whether 3047 # it's a DEBUG build, so we might need to make two copies. 3048 # 3049 # If copy_source fails, it will have already generated an 3050 # error message and set build_ok=n, so we don't need to worry 3051 # about that here. 3052 # 3053 copy_source $CODEMGR_WS $OPEN_SRCDIR OPEN_SOURCE usr/src 3054fi 3055 3056if [ "$SO_FLAG" = "y" -a $build_ok = y ]; then 3057 SRC=$OPEN_SRCDIR/usr/src 3058 3059 # Try not to clobber any user-provided closed binaries. 3060 export ON_CLOSED_BINS=$CODEMGR_WS/closed$$ 3061 3062 echo "\n==== Copying skeleton closed binaries to" \ 3063 "$ON_CLOSED_BINS ====\n" | \ 3064 tee -a $mail_msg_file >> $LOGFILE 3065 3066 if [ "$D_FLAG" = y ]; then 3067 mkclosed $MACH $ROOT $ON_CLOSED_BINS/root_$MACH >>$LOGFILE 2>&1 3068 if (( $? != 0 )) ; then 3069 build_ok=n 3070 echo "Couldn't create DEBUG closed binaries." | 3071 tee -a $mail_msg_file >> $LOGFILE 3072 fi 3073 fi 3074 if [ "$F_FLAG" = n ]; then 3075 root=$ROOT 3076 [ "$MULTI_PROTO" = yes ] && root=$ROOT-nd 3077 mkclosed $MACH $root $ON_CLOSED_BINS/root_$MACH-nd \ 3078 >>$LOGFILE 2>&1 3079 if (( $? != 0 )) ; then 3080 build_ok=n 3081 echo "Couldn't create non-DEBUG closed binaries." | 3082 tee -a $mail_msg_file >> $LOGFILE 3083 fi 3084 fi 3085 3086 export CLOSED_IS_PRESENT=no 3087fi 3088 3089if is_source_build && [ $build_ok = y ] ; then 3090 # remove proto area(s) here, since we don't clobber 3091 rm -rf `allprotos` 3092 if [ "$t_FLAG" = "y" ]; then 3093 set_non_debug_build_flags 3094 ORIG_TOOLS=$TOOLS 3095 # 3096 # SRC was set earlier to point to the source build 3097 # source tree (e.g., $EXPORT_SRC). 3098 # 3099 TOOLS=${SRC}/tools 3100 build_tools ${TOOLS}/${TOOLS_PROTO_REL} 3101 TOOLS=$ORIG_TOOLS 3102 fi 3103 3104 export EXPORT_RELEASE_BUILD ; EXPORT_RELEASE_BUILD=# 3105 normal_build 3106fi 3107 3108if [[ "$SO_FLAG" = "y" && "$build_ok" = "y" ]]; then 3109 rm -rf $ON_CLOSED_BINS 3110fi 3111 3112# 3113# There are several checks that need to look at the proto area, but 3114# they only need to look at one, and they don't care whether it's 3115# DEBUG or non-DEBUG. 3116# 3117if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 3118 checkroot=$ROOT-nd 3119else 3120 checkroot=$ROOT 3121fi 3122 3123if [ "$build_ok" = "y" ]; then 3124 echo "\n==== Creating protolist system file at `date` ====" \ 3125 >> $LOGFILE 3126 protolist $checkroot > $ATLOG/proto_list_${MACH} 3127 echo "==== protolist system file created at `date` ====\n" \ 3128 >> $LOGFILE 3129 3130 if [ "$N_FLAG" != "y" ]; then 3131 3132 E1= 3133 f1= 3134 if [ -d "$SRC/pkgdefs" ]; then 3135 f1="$SRC/pkgdefs/etc/exception_list_$MACH" 3136 if [ "$X_FLAG" = "y" ]; then 3137 f1="$f1 $IA32_IHV_WS/usr/src/pkgdefs/etc/exception_list_$MACH" 3138 fi 3139 fi 3140 3141 for f in $f1; do 3142 if [ -f "$f" ]; then 3143 E1="$E1 -e $f" 3144 fi 3145 done 3146 3147 E2= 3148 f2= 3149 if [ -d "$SRC/pkg" ]; then 3150 f2="$f2 exceptions/packaging" 3151 if [ "$CLOSED_IS_PRESENT" = "no" ]; then 3152 f2="$f2 exceptions/packaging.open" 3153 else 3154 f2="$f2 exceptions/packaging.closed" 3155 fi 3156 fi 3157 3158 for f in $f2; do 3159 if [ -f "$f" ]; then 3160 E2="$E2 -e $f" 3161 fi 3162 done 3163 3164 if [ -f "$REF_PROTO_LIST" ]; then 3165 # 3166 # For builds that copy the IHV proto area (-X), add the 3167 # IHV proto list to the reference list if the reference 3168 # was built without -X. 3169 # 3170 # For builds that don't copy the IHV proto area, add the 3171 # IHV proto list to the build's proto list if the 3172 # reference was built with -X. 3173 # 3174 # Use the presence of the first file entry of the cached 3175 # IHV proto list in the reference list to determine 3176 # whether it was built with -X or not. 3177 # 3178 IHV_REF_PROTO_LIST=$SRC/pkgdefs/etc/proto_list_ihv_$MACH 3179 grepfor=$(nawk '$1 == "f" { print $2; exit }' \ 3180 $IHV_REF_PROTO_LIST 2> /dev/null) 3181 if [ $? = 0 -a -n "$grepfor" ]; then 3182 if [ "$X_FLAG" = "y" ]; then 3183 grep -w "$grepfor" \ 3184 $REF_PROTO_LIST > /dev/null 3185 if [ ! "$?" = "0" ]; then 3186 REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST" 3187 fi 3188 else 3189 grep -w "$grepfor" \ 3190 $REF_PROTO_LIST > /dev/null 3191 if [ "$?" = "0" ]; then 3192 IHV_PROTO_LIST="$IHV_REF_PROTO_LIST" 3193 fi 3194 fi 3195 fi 3196 fi 3197 fi 3198 3199 if [ "$N_FLAG" != "y" -a -d $SRC/pkgdefs ]; then 3200 echo "\n==== Impact on SVr4 packages ====\n" >> $mail_msg_file 3201 if [ "$CLOSED_IS_PRESENT" = "no" ]; then 3202 # 3203 # Traditional SVr4 packages builds don't get along well 3204 # with open-only builds. 3205 # 3206 echo "Skipping: $CLOSED_IS_PRESENT = no" \ 3207 >> $mail_msg_file 3208 else 3209 # 3210 # Compare the build's proto list with current package 3211 # definitions to audit the quality of package 3212 # definitions and makefile install targets. Use the 3213 # current exception list. 3214 # 3215 PKGDEFS_LIST="" 3216 for d in $abssrcdirs; do 3217 if [ -d $d/pkgdefs ]; then 3218 PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs" 3219 fi 3220 done 3221 if [ "$X_FLAG" = "y" -a \ 3222 -d $IA32_IHV_WS/usr/src/pkgdefs ]; then 3223 PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs" 3224 fi 3225 $PROTOCMPTERSE \ 3226 "Files missing from the proto area:" \ 3227 "Files missing from packages:" \ 3228 "Inconsistencies between pkgdefs and proto area:" \ 3229 ${E1} \ 3230 ${PKGDEFS_LIST} \ 3231 $ATLOG/proto_list_${MACH} \ 3232 >> $mail_msg_file 3233 fi 3234 fi 3235 3236 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 3237 echo "\n==== Validating manifests against proto area ====\n" \ 3238 >> $mail_msg_file 3239 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) \ 3240 >> $mail_msg_file 3241 3242 fi 3243 3244 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 3245 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 3246 if [ -n "$E2" ]; then 3247 ELIST=$E2 3248 else 3249 ELIST=$E1 3250 fi 3251 $PROTOCMPTERSE \ 3252 "Files in yesterday's proto area, but not today's:" \ 3253 "Files in today's proto area, but not yesterday's:" \ 3254 "Files that changed between yesterday and today:" \ 3255 ${ELIST} \ 3256 -d $REF_PROTO_LIST \ 3257 $REF_IHV_PROTO \ 3258 $ATLOG/proto_list_${MACH} \ 3259 $IHV_PROTO_LIST \ 3260 >> $mail_msg_file 3261 fi 3262fi 3263 3264if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 3265 staffer cp $ATLOG/proto_list_${MACH} \ 3266 $PARENT_WS/usr/src/proto_list_${MACH} 3267fi 3268 3269# Update parent proto area if necessary. This is done now 3270# so that the proto area has either DEBUG or non-DEBUG kernels. 3271# Note that this clears out the lock file, so we can dispense with 3272# the variable now. 3273if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 3274 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 3275 tee -a $LOGFILE >> $mail_msg_file 3276 rm -rf $NIGHTLY_PARENT_ROOT/* 3277 unset Ulockfile 3278 mkdir -p $NIGHTLY_PARENT_ROOT 3279 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 3280 ( cd $ROOT; tar cf - . | 3281 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 3282 tee -a $mail_msg_file >> $LOGFILE 3283 fi 3284 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 3285 rm -rf $NIGHTLY_PARENT_ROOT-nd/* 3286 mkdir -p $NIGHTLY_PARENT_ROOT-nd 3287 cd $ROOT-nd 3288 ( tar cf - . | 3289 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 3290 tee -a $mail_msg_file >> $LOGFILE 3291 fi 3292 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 3293 tee -a $LOGFILE >> $mail_msg_file 3294 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 3295 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 3296 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 3297 ( cd $TOOLS_PROTO; tar cf - . | 3298 ( cd $NIGHTLY_PARENT_TOOLS_ROOT; umask 0; tar xpf - ) ) 2>&1 | 3299 tee -a $mail_msg_file >> $LOGFILE 3300 fi 3301fi 3302 3303# 3304# ELF verification: ABI (-A) and runtime (-r) checks 3305# 3306if [[ ($build_ok = y) && ( ($A_FLAG = y) || ($r_FLAG = y) ) ]]; then 3307 # Directory ELF-data.$MACH holds the files produced by these tests. 3308 elf_ddir=$SRC/ELF-data.$MACH 3309 3310 # If there is a previous ELF-data backup directory, remove it. Then, 3311 # rotate current ELF-data directory into its place and create a new 3312 # empty directory 3313 rm -rf $elf_ddir.ref 3314 if [[ -d $elf_ddir ]]; then 3315 mv $elf_ddir $elf_ddir.ref 3316 fi 3317 mkdir -p $elf_ddir 3318 3319 # Call find_elf to produce a list of the ELF objects in the proto area. 3320 # This list is passed to check_rtime and interface_check, preventing 3321 # them from separately calling find_elf to do the same work twice. 3322 find_elf -fr $checkroot > $elf_ddir/object_list 3323 3324 if [[ $A_FLAG = y ]]; then 3325 echo "\n==== Check versioning and ABI information ====\n" | \ 3326 tee -a $LOGFILE >> $mail_msg_file 3327 3328 # Produce interface description for the proto. Report errors. 3329 interface_check -o -w $elf_ddir -f object_list \ 3330 -i interface -E interface.err 3331 if [[ -s $elf_ddir/interface.err ]]; then 3332 tee -a $LOGFILE < $elf_ddir/interface.err \ 3333 >> $mail_msg_file 3334 fi 3335 3336 echo "\n==== Compare versioning and ABI information to" \ 3337 "baseline ====\n" | tee -a $LOGFILE >> $mail_msg_file 3338 3339 # Compare new interface to baseline interface. Report errors. 3340 interface_cmp -d -o $SRC/tools/abi/interface.$MACH \ 3341 $elf_ddir/interface > $elf_ddir/interface.cmp 3342 if [[ -s $elf_ddir/interface.cmp ]]; then 3343 tee -a $LOGFILE < $elf_ddir/interface.cmp \ 3344 >> $mail_msg_file 3345 fi 3346 fi 3347 3348 if [[ $r_FLAG = y ]]; then 3349 echo "\n==== Check ELF runtime attributes ====\n" | \ 3350 tee -a $LOGFILE >> $mail_msg_file 3351 3352 # If we're doing a DEBUG build the proto area will be left 3353 # with debuggable objects, thus don't assert -s. 3354 if [[ $D_FLAG = y ]]; then 3355 rtime_sflag="" 3356 else 3357 rtime_sflag="-s" 3358 fi 3359 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 3360 -D object_list -f object_list -E runtime.err \ 3361 -I runtime.attr.raw 3362 3363 # check_rtime -I output needs to be sorted in order to 3364 # compare it to that from previous builds. 3365 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 3366 rm $elf_ddir/runtime.attr.raw 3367 3368 # Report errors 3369 if [[ -s $elf_ddir/runtime.err ]]; then 3370 tee -a $LOGFILE < $elf_ddir/runtime.err \ 3371 >> $mail_msg_file 3372 fi 3373 3374 # If there is an ELF-data directory from a previous build, 3375 # then diff the attr files. These files contain information 3376 # about dependencies, versioning, and runpaths. There is some 3377 # overlap with the ABI checking done above, but this also 3378 # flushes out non-ABI interface differences along with the 3379 # other information. 3380 echo "\n==== Diff ELF runtime attributes" \ 3381 "(since last build) ====\n" | \ 3382 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 3383 3384 if [[ -f $elf_ddir.ref/runtime.attr ]]; then 3385 diff $elf_ddir.ref/runtime.attr \ 3386 $elf_ddir/runtime.attr \ 3387 >> $mail_msg_file 3388 fi 3389 fi 3390fi 3391 3392# DEBUG lint of kernel begins 3393 3394if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 3395 if [ "$LINTDIRS" = "" ]; then 3396 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 3397 LINTDIRS="$SRC y" 3398 fi 3399 set $LINTDIRS 3400 while [ $# -gt 0 ]; do 3401 dolint $1 $2; shift; shift 3402 done 3403else 3404 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 3405fi 3406 3407# "make check" begins 3408 3409if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 3410 # remove old check.out 3411 rm -f $SRC/check.out 3412 3413 rm -f $SRC/check-${MACH}.out 3414 cd $SRC 3415 $MAKE -ek check 2>&1 | tee -a $SRC/check-${MACH}.out >> $LOGFILE 3416 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 3417 3418 grep ":" $SRC/check-${MACH}.out | 3419 egrep -v "Ignoring unknown host" | \ 3420 sort | uniq >> $mail_msg_file 3421else 3422 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 3423fi 3424 3425echo "\n==== Find core files ====\n" | \ 3426 tee -a $LOGFILE >> $mail_msg_file 3427 3428find $abssrcdirs -name core -a -type f -exec file {} \; | \ 3429 tee -a $LOGFILE >> $mail_msg_file 3430 3431if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 3432 echo "\n==== Diff unreferenced files (since last build) ====\n" \ 3433 | tee -a $LOGFILE >>$mail_msg_file 3434 rm -f $SRC/unref-${MACH}.ref 3435 if [ -f $SRC/unref-${MACH}.out ]; then 3436 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 3437 fi 3438 3439 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 3440 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 3441 sort > $SRC/unref-${MACH}.out 3442 3443 if [ ! -f $SRC/unref-${MACH}.ref ]; then 3444 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 3445 fi 3446 3447 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 3448fi 3449 3450# 3451# Generate the OpenSolaris deliverables if requested. Some of these 3452# steps need to come after findunref and are commented below. 3453# 3454 3455# 3456# Copy an input crypto tarball to the canonical destination (with 3457# datestamp), and point the non-stamped symlink at it. 3458# Usage: copycrypto from_path suffix 3459# Returns 0 if successful, non-zero if not. 3460# 3461function copycrypto { 3462 typeset from=$1 3463 typeset suffix=$2 3464 typeset to=$(cryptodest "$suffix").bz2 3465 typeset -i stat 3466 cp "$from" "$to" 3467 stat=$? 3468 if (( $stat == 0 )); then 3469 cryptolink "$to" "$suffix" 3470 stat=$? 3471 fi 3472 return $stat 3473} 3474 3475# 3476# Pass through the crypto tarball(s) that we were given, putting it in 3477# the same place that crypto_from_proto puts things. 3478# 3479function crypto_passthrough { 3480 echo "Reusing $ON_CRYPTO_BINS for crypto tarball(s)..." >> "$LOGFILE" 3481 if [ "$D_FLAG" = y ]; then 3482 copycrypto "$ON_CRYPTO_BINS" "" >> "$LOGFILE" 2>&1 3483 if (( $? != 0 )) ; then 3484 echo "Couldn't create DEBUG crypto tarball." | 3485 tee -a "$mail_msg_file" >> "$LOGFILE" 3486 fi 3487 fi 3488 if [ "$F_FLAG" = n ]; then 3489 copycrypto $(ndcrypto "$ON_CRYPTO_BINS") "-nd" \ 3490 >> "$LOGFILE" 2>&1 3491 if (( $? != 0 )) ; then 3492 echo "Couldn't create non-DEBUG crypto tarball." | 3493 tee -a "$mail_msg_file" >> "$LOGFILE" 3494 fi 3495 fi 3496} 3497 3498if [ "$O_FLAG" = y -a "$build_ok" = y ]; then 3499 echo "\n==== Generating OpenSolaris tarballs ====\n" | \ 3500 tee -a $mail_msg_file >> $LOGFILE 3501 3502 cd $CODEMGR_WS 3503 3504 # 3505 # This step grovels through the package manifests, so it 3506 # must come after findunref. 3507 # 3508 # We assume no DEBUG vs non-DEBUG package content variation 3509 # here; if that changes, then the "make all" in $SRC/pkg will 3510 # need to be moved into the conditionals and repeated for each 3511 # different build. 3512 # 3513 echo "Generating closed binaries tarball(s)..." >> $LOGFILE 3514 closed_basename=on-closed-bins 3515 if [ "$D_FLAG" = y ]; then 3516 bindrop "$ROOT" "$ROOT-open" "$closed_basename" \ 3517 >>"$LOGFILE" 2>&1 3518 if (( $? != 0 )) ; then 3519 echo "Couldn't create DEBUG closed binaries." | 3520 tee -a $mail_msg_file >> $LOGFILE 3521 fi 3522 fi 3523 if [ "$F_FLAG" = n ]; then 3524 bindrop -n "$ROOT-nd" "$ROOT-open-nd" "$closed_basename-nd" \ 3525 >>"$LOGFILE" 2>&1 3526 if (( $? != 0 )) ; then 3527 echo "Couldn't create non-DEBUG closed binaries." | 3528 tee -a $mail_msg_file >> $LOGFILE 3529 fi 3530 fi 3531 3532 echo "Generating onbld tools tarball..." >> $LOGFILE 3533 PKGARCHIVE=$PKGARCHIVE_ORIG 3534 onblddrop >> $LOGFILE 2>&1 3535 if (( $? != 0 )) ; then 3536 echo "Couldn't create onbld tools tarball." | 3537 tee -a $mail_msg_file >> $LOGFILE 3538 fi 3539 3540 echo "Generating README.opensolaris..." >> $LOGFILE 3541 cat $SRC/tools/opensolaris/README.opensolaris.tmpl | \ 3542 mkreadme_osol $CODEMGR_WS/README.opensolaris >> $LOGFILE 2>&1 3543 if (( $? != 0 )) ; then 3544 echo "Couldn't create README.opensolaris." | 3545 tee -a $mail_msg_file >> $LOGFILE 3546 fi 3547 3548 # This step walks the source tree, so it must come after 3549 # findunref. It depends on README.opensolaris. 3550 echo "Generating source tarball..." >> $LOGFILE 3551 sdrop >>$LOGFILE 2>&1 3552 if (( $? != 0 )) ; then 3553 echo "Couldn't create source tarball." | 3554 tee -a "$mail_msg_file" >> "$LOGFILE" 3555 fi 3556 3557 # This step depends on the closed binaries tarballs. 3558 echo "Generating BFU tarball(s)..." >> $LOGFILE 3559 if [ "$D_FLAG" = y ]; then 3560 makebfu_filt bfudrop "$ROOT-open" \ 3561 "$closed_basename.$MACH.tar.bz2" nightly-osol 3562 if (( $? != 0 )) ; then 3563 echo "Couldn't create DEBUG archives tarball." | 3564 tee -a $mail_msg_file >> $LOGFILE 3565 fi 3566 fi 3567 if [ "$F_FLAG" = n ]; then 3568 makebfu_filt bfudrop -n "$ROOT-open-nd" \ 3569 "$closed_basename-nd.$MACH.tar.bz2" nightly-osol-nd 3570 if (( $? != 0 )) ; then 3571 echo "Couldn't create non-DEBUG archives tarball." | 3572 tee -a $mail_msg_file >> $LOGFILE 3573 fi 3574 fi 3575 3576 if [ -n "$ON_CRYPTO_BINS" ]; then 3577 crypto_passthrough 3578 fi 3579fi 3580 3581# Verify that the usual lists of files, such as exception lists, 3582# contain only valid references to files. If the build has failed, 3583# then don't check the proto area. 3584CHECK_PATHS=${CHECK_PATHS:-y} 3585if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 3586 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 3587 >>$mail_msg_file 3588 arg=-b 3589 [ "$build_ok" = y ] && arg= 3590 checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file 3591fi 3592 3593if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 3594 echo "\n==== Impact on file permissions ====\n" \ 3595 >> $mail_msg_file 3596 3597 abspkgdefs= 3598 abspkg= 3599 for d in $abssrcdirs; do 3600 if [ -d "$d/pkgdefs" ]; then 3601 abspkgdefs="$abspkgdefs $d" 3602 fi 3603 if [ -d "$d/pkg" ]; then 3604 abspkg="$abspkg $d" 3605 fi 3606 done 3607 3608 if [ -n "$abspkgdefs" ]; then 3609 pmodes -qvdP \ 3610 `find $abspkgdefs -name pkginfo.tmpl -print -o \ 3611 -name .del\* -prune | sed -e 's:/pkginfo.tmpl$::' | \ 3612 sort -u` >> $mail_msg_file 3613 fi 3614 3615 if [ -n "$abspkg" ]; then 3616 for d in "$abspkg"; do 3617 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 3618 done 3619 fi 3620fi 3621 3622if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 3623 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 3624 do_wsdiff DEBUG $ROOT.prev $ROOT 3625 fi 3626 3627 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 3628 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 3629 fi 3630fi 3631 3632END_DATE=`date` 3633echo "==== Nightly $maketype build completed: $END_DATE ====" | \ 3634 tee -a $LOGFILE >> $build_time_file 3635 3636typeset -i10 hours 3637typeset -Z2 minutes 3638typeset -Z2 seconds 3639 3640elapsed_time=$SECONDS 3641((hours = elapsed_time / 3600 )) 3642((minutes = elapsed_time / 60 % 60)) 3643((seconds = elapsed_time % 60)) 3644 3645echo "\n==== Total build time ====" | \ 3646 tee -a $LOGFILE >> $build_time_file 3647echo "\nreal ${hours}:${minutes}:${seconds}" | \ 3648 tee -a $LOGFILE >> $build_time_file 3649 3650if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 3651 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 3652 3653 # 3654 # Produce a master list of unreferenced files -- ideally, we'd 3655 # generate the master just once after all of the nightlies 3656 # have finished, but there's no simple way to know when that 3657 # will be. Instead, we assume that we're the last nightly to 3658 # finish and merge all of the unref-${MACH}.out files in 3659 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 3660 # finish, then this file will be the authoritative master 3661 # list. Otherwise, another ${MACH}'s nightly will eventually 3662 # overwrite ours with its own master, but in the meantime our 3663 # temporary "master" will be no worse than any older master 3664 # which was already on the parent. 3665 # 3666 3667 set -- $PARENT_WS/usr/src/unref-*.out 3668 cp "$1" ${TMPDIR}/unref.merge 3669 shift 3670 3671 for unreffile; do 3672 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 3673 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 3674 done 3675 3676 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 3677fi 3678 3679# 3680# All done save for the sweeping up. 3681# (whichever exit we hit here will trigger the "cleanup" trap which 3682# optionally sends mail on completion). 3683# 3684if [ "$build_ok" = "y" ]; then 3685 exit 0 3686fi 3687exit 1 3688