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 (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 25# Copyright 2008, 2010, Richard Lowe 26# Copyright 2011 Nexenta Systems, Inc. All rights reserved. 27# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> 28# Copyright 2020 Joyent, Inc. 29# 30# Based on the nightly script from the integration folks, 31# Mostly modified and owned by mike_s. 32# Changes also by kjc, dmk. 33# 34# BRINGOVER_WS may be specified in the env file. 35# The default is the old behavior of CLONE_WS 36# 37# -i on the command line, means fast options, so when it's on the 38# command line (only), lint and check builds are skipped no matter what 39# the setting of their individual flags are in NIGHTLY_OPTIONS. 40# 41# LINTDIRS can be set in the env file, format is a list of: 42# 43# /dirname-to-run-lint-on flag 44# 45# Where flag is: y - enable lint noise diff output 46# n - disable lint noise diff output 47# 48# For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y" 49# 50# OPTHOME may be set in the environment to override /opt 51# 52 53# 54# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 55# under certain circumstances, which can really screw things up; unset it. 56# 57unset CDPATH 58 59# Get the absolute path of the nightly script that the user invoked. This 60# may be a relative path, and we need to do this before changing directory. 61nightly_path=`whence $0` 62 63# 64# Keep track of where we found nightly so we can invoke the matching 65# which_scm script. If that doesn't work, don't go guessing, just rely 66# on the $PATH settings, which will generally give us either /opt/onbld 67# or the user's workspace. 68# 69WHICH_SCM=$(dirname $nightly_path)/which_scm 70if [[ ! -x $WHICH_SCM ]]; then 71 WHICH_SCM=which_scm 72fi 73 74function fatal_error 75{ 76 print -u2 "nightly: $*" 77 exit 1 78} 79 80# 81# Function to do a DEBUG and non-DEBUG build. Needed because we might 82# need to do another for the source build, and since we only deliver DEBUG or 83# non-DEBUG packages. 84# 85# usage: normal_build 86# 87function normal_build { 88 89 typeset orig_p_FLAG="$p_FLAG" 90 typeset crypto_signer="$CODESIGN_USER" 91 92 suffix="" 93 94 # non-DEBUG build begins 95 96 if [ "$F_FLAG" = "n" ]; then 97 set_non_debug_build_flags 98 CODESIGN_USER="$crypto_signer" \ 99 build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 100 else 101 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 102 fi 103 104 # non-DEBUG build ends 105 106 # DEBUG build begins 107 108 if [ "$D_FLAG" = "y" ]; then 109 set_debug_build_flags 110 CODESIGN_USER="$crypto_signer" \ 111 build "DEBUG" "$suffix" "" "$MULTI_PROTO" 112 else 113 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 114 fi 115 116 # DEBUG build ends 117 118 p_FLAG="$orig_p_FLAG" 119} 120 121# 122# usage: run_hook HOOKNAME ARGS... 123# 124# If variable "$HOOKNAME" is defined, insert a section header into 125# our logs and then run the command with ARGS 126# 127function run_hook { 128 HOOKNAME=$1 129 eval HOOKCMD=\$$HOOKNAME 130 shift 131 132 if [ -n "$HOOKCMD" ]; then 133 ( 134 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 135 ( $HOOKCMD "$@" 2>&1 ) 136 if [ "$?" -ne 0 ]; then 137 # Let exit status propagate up 138 touch $TMPDIR/abort 139 fi 140 ) | tee -a $mail_msg_file >> $LOGFILE 141 142 if [ -f $TMPDIR/abort ]; then 143 build_ok=n 144 echo "\nAborting at request of $HOOKNAME" | 145 tee -a $mail_msg_file >> $LOGFILE 146 exit 1 147 fi 148 fi 149} 150 151# Return library search directive as function of given root. 152function myldlibs { 153 echo "-L$1/lib -L$1/usr/lib" 154} 155 156# Return header search directive as function of given root. 157function myheaders { 158 echo "-I$1/usr/include" 159} 160 161# 162# Function to do the build, including package generation. 163# usage: build LABEL SUFFIX ND MULTIPROTO 164# - LABEL is used to tag build output. 165# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 166# open-only vs full tree). 167# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 168# - If MULTIPROTO is "yes", it means to name the proto area according to 169# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 170# 171function build { 172 LABEL=$1 173 SUFFIX=$2 174 ND=$3 175 MULTIPROTO=$4 176 INSTALLOG=install${SUFFIX}-${MACH} 177 NOISE=noise${SUFFIX}-${MACH} 178 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 179 180 ORIGROOT=$ROOT 181 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 182 183 export ENVLDLIBS1=`myldlibs $ROOT` 184 export ENVCPPFLAGS1=`myheaders $ROOT` 185 186 this_build_ok=y 187 # 188 # Build OS-Networking source 189 # 190 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 191 >> $LOGFILE 192 193 rm -f $SRC/${INSTALLOG}.out 194 cd $SRC 195 /bin/time $MAKE -e install 2>&1 | \ 196 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 197 198 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 199 egrep ":" $SRC/${INSTALLOG}.out | 200 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 201 egrep -v "Ignoring unknown host" | \ 202 egrep -v "cc .* -o error " | \ 203 egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 204 >> $mail_msg_file 205 if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 206 build_ok=n 207 this_build_ok=n 208 fi 209 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 210 >> $mail_msg_file 211 if [ "$?" = "0" ]; then 212 build_ok=n 213 this_build_ok=n 214 fi 215 216 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 217 egrep -i warning: $SRC/${INSTALLOG}.out \ 218 | egrep -v '^tic:' \ 219 | egrep -v "symbol (\`|')timezone' has differing types:" \ 220 | egrep -v "parameter <PSTAMP> set to" \ 221 | egrep -v "Ignoring unknown host" \ 222 | egrep -v "redefining segment flags attribute for" \ 223 | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 224 if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 225 build_ok=n 226 this_build_ok=n 227 fi 228 229 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 230 >> $LOGFILE 231 232 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 233 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 234 235 if [ "$i_FLAG" = "n" ]; then 236 rm -f $SRC/${NOISE}.ref 237 if [ -f $SRC/${NOISE}.out ]; then 238 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 239 fi 240 grep : $SRC/${INSTALLOG}.out \ 241 | egrep -v '^/' \ 242 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 243 | egrep -v '^tic:' \ 244 | egrep -v '^mcs' \ 245 | egrep -v '^LD_LIBRARY_PATH=' \ 246 | egrep -v 'ar: creating' \ 247 | egrep -v 'ar: writing' \ 248 | egrep -v 'conflicts:' \ 249 | egrep -v ':saved created' \ 250 | egrep -v '^stty.*c:' \ 251 | egrep -v '^mfgname.c:' \ 252 | egrep -v '^uname-i.c:' \ 253 | egrep -v '^volumes.c:' \ 254 | egrep -v '^lint library construction:' \ 255 | egrep -v 'tsort: INFORM:' \ 256 | egrep -v 'stripalign:' \ 257 | egrep -v 'chars, width' \ 258 | egrep -v "symbol (\`|')timezone' has differing types:" \ 259 | egrep -v 'PSTAMP' \ 260 | egrep -v '|%WHOANDWHERE%|' \ 261 | egrep -v '^Manifying' \ 262 | egrep -v 'Ignoring unknown host' \ 263 | egrep -v 'Processing method:' \ 264 | egrep -v '^Writing' \ 265 | egrep -v 'spellin1:' \ 266 | egrep -v '^adding:' \ 267 | egrep -v "^echo 'msgid" \ 268 | egrep -v '^echo ' \ 269 | egrep -v '\.c:$' \ 270 | egrep -v '^Adding file:' \ 271 | egrep -v 'CLASSPATH=' \ 272 | egrep -v '\/var\/mail\/:saved' \ 273 | egrep -v -- '-DUTS_VERSION=' \ 274 | egrep -v '^Running Mkbootstrap' \ 275 | egrep -v '^Applet length read:' \ 276 | egrep -v 'bytes written:' \ 277 | egrep -v '^File:SolarisAuthApplet.bin' \ 278 | egrep -v -i 'jibversion' \ 279 | egrep -v '^Output size:' \ 280 | egrep -v '^Solo size statistics:' \ 281 | egrep -v '^Using ROM API Version' \ 282 | egrep -v '^Zero Signature length:' \ 283 | egrep -v '^Note \(probably harmless\):' \ 284 | egrep -v '::' \ 285 | egrep -v -- '-xcache' \ 286 | egrep -v '^\+' \ 287 | egrep -v '^cc1: note: -fwritable-strings' \ 288 | egrep -v 'svccfg-native -s svc:/' \ 289 | sort | uniq >$SRC/${NOISE}.out 290 if [ ! -f $SRC/${NOISE}.ref ]; then 291 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 292 fi 293 echo "\n==== Build noise differences ($LABEL) ====\n" \ 294 >>$mail_msg_file 295 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 296 fi 297 298 # 299 # Re-sign selected binaries using signing server 300 # (gatekeeper builds only) 301 # 302 if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 303 echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 304 signing_file="${TMPDIR}/signing" 305 rm -f ${signing_file} 306 export CODESIGN_USER 307 signproto $SRC/tools/codesign/creds 2>&1 | \ 308 tee -a ${signing_file} >> $LOGFILE 309 echo "\n==== Finished signing proto area at `date` ====\n" \ 310 >> $LOGFILE 311 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 312 >> $mail_msg_file 313 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 314 if (( $? == 0 )) ; then 315 build_ok=n 316 this_build_ok=n 317 fi 318 fi 319 320 # 321 # Building Packages 322 # 323 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 324 if [ -d $SRC/pkg ]; then 325 echo "\n==== Creating $LABEL packages at `date` ====\n" \ 326 >> $LOGFILE 327 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 328 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 329 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 330 331 rm -f $SRC/pkg/${INSTALLOG}.out 332 cd $SRC/pkg 333 /bin/time $MAKE -e install 2>&1 | \ 334 tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 335 336 echo "\n==== package build errors ($LABEL) ====\n" \ 337 >> $mail_msg_file 338 339 egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 340 grep ':' | \ 341 grep -v PSTAMP | \ 342 egrep -v "Ignoring unknown host" | \ 343 tee $TMPDIR/package >> $mail_msg_file 344 if [[ -s $TMPDIR/package ]]; then 345 build_extras_ok=n 346 this_build_ok=n 347 fi 348 else 349 # 350 # Handle it gracefully if -p was set but there so 351 # no pkg directory. 352 # 353 echo "\n==== No $LABEL packages to build ====\n" \ 354 >> $LOGFILE 355 fi 356 else 357 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 358 fi 359 360 ROOT=$ORIGROOT 361} 362 363# Usage: dolint /dir y|n 364# Arg. 2 is a flag to turn on/off the lint diff output 365function dolint { 366 if [ ! -d "$1" ]; then 367 echo "dolint error: $1 is not a directory" 368 exit 1 369 fi 370 371 if [ "$2" != "y" -a "$2" != "n" ]; then 372 echo "dolint internal error: $2 should be 'y' or 'n'" 373 exit 1 374 fi 375 376 lintdir=$1 377 dodiff=$2 378 base=`basename $lintdir` 379 LINTOUT=$lintdir/lint-${MACH}.out 380 LINTNOISE=$lintdir/lint-noise-${MACH} 381 export ENVLDLIBS1=`myldlibs $ROOT` 382 export ENVCPPFLAGS1=`myheaders $ROOT` 383 384 set_debug_build_flags 385 386 # 387 # '$MAKE lint' in $lintdir 388 # 389 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 390 391 # remove old lint.out 392 rm -f $lintdir/lint.out $lintdir/lint-noise.out 393 if [ -f $lintdir/lint-noise.ref ]; then 394 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 395 fi 396 397 rm -f $LINTOUT 398 cd $lintdir 399 # 400 # Remove all .ln files to ensure a full reference file 401 # 402 rm -f Nothing_to_remove \ 403 `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \ 404 -prune -o -type f -name '*.ln' -print ` 405 406 /bin/time $MAKE -ek lint 2>&1 | \ 407 tee -a $LINTOUT >> $LOGFILE 408 409 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 410 411 grep "$MAKE:" $LINTOUT | 412 egrep -v "Ignoring unknown host" | \ 413 tee $TMPDIR/lint_errs >> $mail_msg_file 414 if [[ -s $TMPDIR/lint_errs ]]; then 415 build_extras_ok=n 416 fi 417 418 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 419 420 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 421 >>$mail_msg_file 422 tail -3 $LINTOUT >>$mail_msg_file 423 424 rm -f ${LINTNOISE}.ref 425 if [ -f ${LINTNOISE}.out ]; then 426 mv ${LINTNOISE}.out ${LINTNOISE}.ref 427 fi 428 grep : $LINTOUT | \ 429 egrep -v '^(real|user|sys)' | 430 egrep -v '(library construction)' | \ 431 egrep -v ': global crosschecks' | \ 432 egrep -v 'Ignoring unknown host' | \ 433 egrep -v '\.c:$' | \ 434 sort | uniq > ${LINTNOISE}.out 435 if [ ! -f ${LINTNOISE}.ref ]; then 436 cp ${LINTNOISE}.out ${LINTNOISE}.ref 437 fi 438 439 if [ "$dodiff" != "n" ]; then 440 echo "\n==== lint warnings $base ====\n" \ 441 >>$mail_msg_file 442 # should be none, though there are a few that were filtered out 443 # above 444 egrep -i '(warning|lint):' ${LINTNOISE}.out \ 445 | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file 446 if [[ -s $TMPDIR/lint_warns ]]; then 447 build_extras_ok=n 448 fi 449 echo "\n==== lint noise differences $base ====\n" \ 450 >> $mail_msg_file 451 diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 452 >> $mail_msg_file 453 fi 454} 455 456# 457# Build and install the onbld tools. 458# 459# usage: build_tools DESTROOT 460# 461# returns non-zero status if the build was successful. 462# 463function build_tools { 464 DESTROOT=$1 465 466 INSTALLOG=install-${MACH} 467 468 echo "\n==== Building tools at `date` ====\n" \ 469 >> $LOGFILE 470 471 rm -f ${TOOLS}/${INSTALLOG}.out 472 cd ${TOOLS} 473 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 474 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 475 476 echo "\n==== Tools build errors ====\n" >> $mail_msg_file 477 478 egrep ":" ${TOOLS}/${INSTALLOG}.out | 479 egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 480 egrep -v "Ignoring unknown host" | \ 481 egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 482 483 if [[ -s $TMPDIR/tools_errors ]]; then 484 return 1 485 fi 486 return 0 487} 488 489# 490# Set up to use locally installed tools. 491# 492# usage: use_tools TOOLSROOT 493# 494function use_tools { 495 TOOLSROOT=$1 496 497 # 498 # If we're not building ON workspace, then the TOOLSROOT 499 # settings here are clearly ignored by the workspace 500 # makefiles, prepending nonexistent directories to PATH is 501 # harmless, and we clearly do not wish to override 502 # ONBLD_TOOLS. 503 # 504 # If we're building an ON workspace, then the prepended PATH 505 # elements should supercede the preexisting ONBLD_TOOLS paths, 506 # and we want to override ONBLD_TOOLS to catch the tools that 507 # don't have specific path env vars here. 508 # 509 # So the only conditional behavior is overriding ONBLD_TOOLS, 510 # and we check for "an ON workspace" by looking for 511 # ${TOOLSROOT}/opt/onbld. 512 # 513 514 STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs 515 export STABS 516 CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs 517 export CTFSTABS 518 GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets 519 export GENOFFSETS 520 521 CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert 522 export CTFCONVERT 523 CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge 524 export CTFMERGE 525 526 if [ "$VERIFY_ELFSIGN" = "y" ]; then 527 ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 528 else 529 ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 530 fi 531 export ELFSIGN 532 533 PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 534 PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 535 export PATH 536 537 if [ -d "${TOOLSROOT}/opt/onbld" ]; then 538 ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 539 export ONBLD_TOOLS 540 fi 541 542 echo "\n==== New environment settings. ====\n" >> $LOGFILE 543 echo "STABS=${STABS}" >> $LOGFILE 544 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 545 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 546 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 547 echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 548 echo "PATH=${PATH}" >> $LOGFILE 549 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 550} 551 552function staffer { 553 if [ $ISUSER -ne 0 ]; then 554 "$@" 555 else 556 arg="\"$1\"" 557 shift 558 for i 559 do 560 arg="$arg \"$i\"" 561 done 562 eval su $STAFFER -c \'$arg\' 563 fi 564} 565 566# 567# Verify that the closed bins are present 568# 569function check_closed_bins { 570 if [[ ! -d "$ON_CLOSED_BINS" ]]; then 571 echo "ON_CLOSED_BINS must point to the closed binaries tree." 572 build_ok=n 573 exit 1 574 fi 575} 576 577# 578# wrapper over wsdiff. 579# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 580# 581function do_wsdiff { 582 label=$1 583 oldproto=$2 584 newproto=$3 585 results=$4 586 587 wsdiff="wsdiff" 588 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 589 590 echo "\n==== Getting object changes since last build at `date`" \ 591 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 592 $wsdiff -s -r ${TMPDIR}/$results $oldproto $newproto 2>&1 | \ 593 tee -a $LOGFILE >> $mail_msg_file 594 echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 595 tee -a $LOGFILE >> $mail_msg_file 596} 597 598# 599# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 600# together. 601# 602 603function set_non_debug_build_flags { 604 export RELEASE_BUILD ; RELEASE_BUILD= 605 unset EXTRA_OPTIONS 606 unset EXTRA_CFLAGS 607} 608 609function set_debug_build_flags { 610 unset RELEASE_BUILD 611 unset EXTRA_OPTIONS 612 unset EXTRA_CFLAGS 613} 614 615 616MACH=`uname -p` 617 618if [ "$OPTHOME" = "" ]; then 619 OPTHOME=/opt 620 export OPTHOME 621fi 622 623USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 624 625Where: 626 -i Fast incremental options (no clobber, lint, check) 627 -n Do not do a bringover 628 +t Use the build tools in $ONBLD_TOOLS/bin 629 -V VERS set the build version string to VERS 630 631 <env_file> file in Bourne shell syntax that sets and exports 632 variables that configure the operation of this script and many of 633 the scripts this one calls. If <env_file> does not exist, 634 it will be looked for in $OPTHOME/onbld/env. 635 636non-DEBUG is the default build type. Build options can be set in the 637NIGHTLY_OPTIONS variable in the <env_file> as follows: 638 639 -A check for ABI differences in .so files 640 -C check for cstyle/hdrchk errors 641 -D do a build with DEBUG on 642 -F do _not_ do a non-DEBUG build 643 -G gate keeper default group of options (-au) 644 -I integration engineer default group of options (-ampu) 645 -M do not run pmodes (safe file permission checker) 646 -N do not run protocmp 647 -R default group of options for building a release (-mp) 648 -U update proto area in the parent 649 -V VERS set the build version string to VERS 650 -f find unreferenced files 651 -i do an incremental build (no "make clobber") 652 -l do "make lint" in $LINTDIRS (default: $SRC y) 653 -m send mail to $MAILTO at end of build 654 -n do not do a bringover 655 -p create packages 656 -r check ELF runtime attributes in the proto area 657 -t build and use the tools in $SRC/tools (default setting) 658 +t Use the build tools in $ONBLD_TOOLS/bin 659 -u update proto_list_$MACH and friends in the parent workspace; 660 when used with -f, also build an unrefmaster.out in the parent 661 -w report on differences between previous and current proto areas 662' 663# 664# A log file will be generated under the name $LOGFILE 665# for partially completed build and log.`date '+%F'` 666# in the same directory for fully completed builds. 667# 668 669# default values for low-level FLAGS; G I R are group FLAGS 670A_FLAG=n 671C_FLAG=n 672D_FLAG=n 673F_FLAG=n 674f_FLAG=n 675i_FLAG=n; i_CMD_LINE_FLAG=n 676l_FLAG=n 677M_FLAG=n 678m_FLAG=n 679N_FLAG=n 680n_FLAG=n 681p_FLAG=n 682r_FLAG=n 683t_FLAG=y 684U_FLAG=n 685u_FLAG=n 686V_FLAG=n 687w_FLAG=n 688W_FLAG=n 689# 690build_ok=y 691build_extras_ok=y 692 693# 694# examine arguments 695# 696 697OPTIND=1 698while getopts +intV:W FLAG 699do 700 case $FLAG in 701 i ) i_FLAG=y; i_CMD_LINE_FLAG=y 702 ;; 703 n ) n_FLAG=y 704 ;; 705 +t ) t_FLAG=n 706 ;; 707 V ) V_FLAG=y 708 V_ARG="$OPTARG" 709 ;; 710 W ) W_FLAG=y 711 ;; 712 \? ) echo "$USAGE" 713 exit 1 714 ;; 715 esac 716done 717 718# correct argument count after options 719shift `expr $OPTIND - 1` 720 721# test that the path to the environment-setting file was given 722if [ $# -ne 1 ]; then 723 echo "$USAGE" 724 exit 1 725fi 726 727# check if user is running nightly as root 728# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 729# when root invokes nightly. 730/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 731ISUSER=$?; export ISUSER 732 733# 734# force locale to C 735LANG=C; export LANG 736LC_ALL=C; export LC_ALL 737LC_COLLATE=C; export LC_COLLATE 738LC_CTYPE=C; export LC_CTYPE 739LC_MESSAGES=C; export LC_MESSAGES 740LC_MONETARY=C; export LC_MONETARY 741LC_NUMERIC=C; export LC_NUMERIC 742LC_TIME=C; export LC_TIME 743 744# clear environment variables we know to be bad for the build 745unset LD_OPTIONS 746unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 747unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 748unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 749unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 750unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 751unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 752unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 753unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 754unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 755unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 756unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 757unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 758unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 759unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 760unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 761unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 762unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 763unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 764unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 765unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 766 767unset CONFIG 768unset GROUP 769unset OWNER 770unset REMOTE 771unset ENV 772unset ARCH 773unset CLASSPATH 774unset NAME 775 776# 777# To get ONBLD_TOOLS from the environment, it must come from the env file. 778# If it comes interactively, it is generally TOOLS_PROTO, which will be 779# clobbered before the compiler version checks, which will therefore fail. 780# 781unset ONBLD_TOOLS 782 783# 784# Setup environmental variables 785# 786if [ -f /etc/nightly.conf ]; then 787 . /etc/nightly.conf 788fi 789 790if [ -f $1 ]; then 791 if [[ $1 = */* ]]; then 792 . $1 793 else 794 . ./$1 795 fi 796else 797 if [ -f $OPTHOME/onbld/env/$1 ]; then 798 . $OPTHOME/onbld/env/$1 799 else 800 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 801 exit 1 802 fi 803fi 804 805# Check if we have sufficient data to continue... 806[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 807if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 808 # Check if the gate data are valid if we don't do a "bringover" below 809 [[ -d "${CODEMGR_WS}" ]] || \ 810 fatal_error "Error: ${CODEMGR_WS} is not a directory." 811 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 812 fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 813fi 814 815# 816# place ourselves in a new task, respecting BUILD_PROJECT if set. 817# 818if [ -z "$BUILD_PROJECT" ]; then 819 /usr/bin/newtask -c $$ 820else 821 /usr/bin/newtask -c $$ -p $BUILD_PROJECT 822fi 823 824ps -o taskid= -p $$ | read build_taskid 825ps -o project= -p $$ | read build_project 826 827# 828# See if NIGHTLY_OPTIONS is set 829# 830if [ "$NIGHTLY_OPTIONS" = "" ]; then 831 NIGHTLY_OPTIONS="-aBm" 832fi 833 834# 835# If BRINGOVER_WS was not specified, let it default to CLONE_WS 836# 837if [ "$BRINGOVER_WS" = "" ]; then 838 BRINGOVER_WS=$CLONE_WS 839fi 840 841# 842# If BRINGOVER_FILES was not specified, default to usr 843# 844if [ "$BRINGOVER_FILES" = "" ]; then 845 BRINGOVER_FILES="usr" 846fi 847 848check_closed_bins 849 850# 851# Note: changes to the option letters here should also be applied to the 852# bldenv script. `d' is listed for backward compatibility. 853# 854NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 855OPTIND=1 856while getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 857do 858 case $FLAG in 859 A ) A_FLAG=y 860 ;; 861 B ) D_FLAG=y 862 ;; # old version of D 863 C ) C_FLAG=y 864 ;; 865 D ) D_FLAG=y 866 ;; 867 F ) F_FLAG=y 868 ;; 869 f ) f_FLAG=y 870 ;; 871 G ) u_FLAG=y 872 ;; 873 I ) m_FLAG=y 874 p_FLAG=y 875 u_FLAG=y 876 ;; 877 i ) i_FLAG=y 878 ;; 879 l ) l_FLAG=y 880 ;; 881 M ) M_FLAG=y 882 ;; 883 m ) m_FLAG=y 884 ;; 885 N ) N_FLAG=y 886 ;; 887 n ) n_FLAG=y 888 ;; 889 p ) p_FLAG=y 890 ;; 891 R ) m_FLAG=y 892 p_FLAG=y 893 ;; 894 r ) r_FLAG=y 895 ;; 896 +t ) t_FLAG=n 897 ;; 898 U ) if [ -z "${PARENT_ROOT}" ]; then 899 echo "PARENT_ROOT must be set if the U flag is" \ 900 "present in NIGHTLY_OPTIONS." 901 exit 1 902 fi 903 NIGHTLY_PARENT_ROOT=$PARENT_ROOT 904 if [ -n "${PARENT_TOOLS_ROOT}" ]; then 905 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 906 fi 907 U_FLAG=y 908 ;; 909 u ) u_FLAG=y 910 ;; 911 w ) w_FLAG=y 912 ;; 913 W ) W_FLAG=y 914 ;; 915 \? ) echo "$USAGE" 916 exit 1 917 ;; 918 esac 919done 920 921if [ $ISUSER -ne 0 ]; then 922 # Set default value for STAFFER, if needed. 923 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 924 STAFFER=`/usr/xpg4/bin/id -un` 925 export STAFFER 926 fi 927fi 928 929if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 930 MAILTO=$STAFFER 931 export MAILTO 932fi 933 934PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 935PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 936PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 937export PATH 938 939# roots of source trees, both relative to $SRC and absolute. 940relsrcdirs="." 941abssrcdirs="$SRC" 942 943PROTOCMPTERSE="protocmp.terse -gu" 944POUND_SIGN="#" 945# have we set RELEASE_DATE in our env file? 946if [ -z "$RELEASE_DATE" ]; then 947 RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 948fi 949BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 950BASEWSDIR=$(basename $CODEMGR_WS) 951DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 952 953# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 954# by avoiding repeated shell invocations to evaluate Makefile.master 955# definitions. 956export POUND_SIGN RELEASE_DATE DEV_CM 957 958maketype="distributed" 959if [[ -z "$MAKE" ]]; then 960 MAKE=dmake 961elif [[ ! -x "$MAKE" ]]; then 962 echo "\$MAKE is set to garbage in the environment" 963 exit 1 964fi 965export PATH 966export MAKE 967 968if [ "${SUNWSPRO}" != "" ]; then 969 PATH="${SUNWSPRO}/bin:$PATH" 970 export PATH 971fi 972 973hostname=$(uname -n) 974if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 975then 976 maxjobs= 977 if [[ -f $HOME/.make.machines ]] 978 then 979 # Note: there is a hard tab and space character in the []s 980 # below. 981 egrep -i "^[ ]*$hostname[ \.]" \ 982 $HOME/.make.machines | read host jobs 983 maxjobs=${jobs##*=} 984 fi 985 986 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 987 then 988 # default 989 maxjobs=4 990 fi 991 992 export DMAKE_MAX_JOBS=$maxjobs 993fi 994 995DMAKE_MODE=parallel; 996export DMAKE_MODE 997 998if [ -z "${ROOT}" ]; then 999 echo "ROOT must be set." 1000 exit 1 1001fi 1002 1003# 1004# if -V flag was given, reset VERSION to V_ARG 1005# 1006if [ "$V_FLAG" = "y" ]; then 1007 VERSION=$V_ARG 1008fi 1009 1010TMPDIR="/tmp/nightly.tmpdir.$$" 1011export TMPDIR 1012rm -rf ${TMPDIR} 1013mkdir -p $TMPDIR || exit 1 1014chmod 777 $TMPDIR 1015 1016# 1017# Keep elfsign's use of pkcs11_softtoken from looking in the user home 1018# directory, which doesn't always work. Needed until all build machines 1019# have the fix for 6271754 1020# 1021SOFTTOKEN_DIR=$TMPDIR 1022export SOFTTOKEN_DIR 1023 1024# 1025# Tools should only be built non-DEBUG. Keep track of the tools proto 1026# area path relative to $TOOLS, because the latter changes in an 1027# export build. 1028# 1029# TOOLS_PROTO is included below for builds other than usr/src/tools 1030# that look for this location. For usr/src/tools, this will be 1031# overridden on the $MAKE command line in build_tools(). 1032# 1033TOOLS=${SRC}/tools 1034TOOLS_PROTO_REL=proto/root_${MACH}-nd 1035TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1036 1037unset CFLAGS LD_LIBRARY_PATH LDFLAGS 1038 1039# create directories that are automatically removed if the nightly script 1040# fails to start correctly 1041function newdir { 1042 dir=$1 1043 toadd= 1044 while [ ! -d $dir ]; do 1045 toadd="$dir $toadd" 1046 dir=`dirname $dir` 1047 done 1048 torm= 1049 newlist= 1050 for dir in $toadd; do 1051 if staffer mkdir $dir; then 1052 newlist="$ISUSER $dir $newlist" 1053 torm="$dir $torm" 1054 else 1055 [ -z "$torm" ] || staffer rmdir $torm 1056 return 1 1057 fi 1058 done 1059 newdirlist="$newlist $newdirlist" 1060 return 0 1061} 1062newdirlist= 1063 1064[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 1065 1066# since this script assumes the build is from full source, it nullifies 1067# variables likely to have been set by a "ws" script; nullification 1068# confines the search space for headers and libraries to the proto area 1069# built from this immediate source. 1070ENVLDLIBS1= 1071ENVLDLIBS2= 1072ENVLDLIBS3= 1073ENVCPPFLAGS1= 1074ENVCPPFLAGS2= 1075ENVCPPFLAGS3= 1076ENVCPPFLAGS4= 1077PARENT_ROOT= 1078 1079export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1080 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 1081 1082PKGARCHIVE_ORIG=$PKGARCHIVE 1083 1084# 1085# Juggle the logs and optionally send mail on completion. 1086# 1087 1088function logshuffle { 1089 LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 1090 if [ -f $LLOG -o -d $LLOG ]; then 1091 LLOG=$LLOG.$$ 1092 fi 1093 mkdir $LLOG 1094 export LLOG 1095 1096 if [ "$build_ok" = "y" ]; then 1097 mv $ATLOG/proto_list_${MACH} $LLOG 1098 1099 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 1100 mv $ATLOG/proto_list_tools_${MACH} $LLOG 1101 fi 1102 1103 if [ -f $TMPDIR/wsdiff.results ]; then 1104 mv $TMPDIR/wsdiff.results $LLOG 1105 fi 1106 1107 if [ -f $TMPDIR/wsdiff-nd.results ]; then 1108 mv $TMPDIR/wsdiff-nd.results $LLOG 1109 fi 1110 1111 if [ -f $TMPDIR/wsdiff-tools.results ]; then 1112 mv $TMPDIR/wsdiff-tools.results $LLOG 1113 fi 1114 fi 1115 1116 # 1117 # Now that we're about to send mail, it's time to check the noise 1118 # file. In the event that an error occurs beyond this point, it will 1119 # be recorded in the nightly.log file, but nowhere else. This would 1120 # include only errors that cause the copying of the noise log to fail 1121 # or the mail itself not to be sent. 1122 # 1123 1124 exec >>$LOGFILE 2>&1 1125 if [ -s $build_noise_file ]; then 1126 echo "\n==== Nightly build noise ====\n" | 1127 tee -a $LOGFILE >>$mail_msg_file 1128 cat $build_noise_file >>$LOGFILE 1129 cat $build_noise_file >>$mail_msg_file 1130 echo | tee -a $LOGFILE >>$mail_msg_file 1131 fi 1132 rm -f $build_noise_file 1133 1134 case "$build_ok" in 1135 y) 1136 state=Completed 1137 ;; 1138 i) 1139 state=Interrupted 1140 ;; 1141 *) 1142 state=Failed 1143 ;; 1144 esac 1145 1146 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 1147 state=Failed 1148 fi 1149 1150 NIGHTLY_STATUS=$state 1151 export NIGHTLY_STATUS 1152 1153 run_hook POST_NIGHTLY $state 1154 run_hook SYS_POST_NIGHTLY $state 1155 1156 # 1157 # mailx(1) sets From: based on the -r flag 1158 # if it is given. 1159 # 1160 mailx_r= 1161 if [[ -n "${MAILFROM}" ]]; then 1162 mailx_r="-r ${MAILFROM}" 1163 fi 1164 1165 cat $build_time_file $build_environ_file $mail_msg_file \ 1166 > ${LLOG}/mail_msg 1167 if [ "$m_FLAG" = "y" ]; then 1168 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 1169 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 1170 ${MAILTO} 1171 fi 1172 1173 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1174 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 1175 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 1176 fi 1177 1178 mv $LOGFILE $LLOG 1179} 1180 1181# 1182# Remove the locks and temporary files on any exit 1183# 1184function cleanup { 1185 logshuffle 1186 1187 [ -z "$lockfile" ] || staffer rm -f $lockfile 1188 [ -z "$atloglockfile" ] || rm -f $atloglockfile 1189 [ -z "$ulockfile" ] || staffer rm -f $ulockfile 1190 [ -z "$Ulockfile" ] || rm -f $Ulockfile 1191 1192 set -- $newdirlist 1193 while [ $# -gt 0 ]; do 1194 ISUSER=$1 staffer rmdir $2 1195 shift; shift 1196 done 1197 rm -rf $TMPDIR 1198} 1199 1200function cleanup_signal { 1201 build_ok=i 1202 # this will trigger cleanup(), above. 1203 exit 1 1204} 1205 1206trap cleanup 0 1207trap cleanup_signal 1 2 3 15 1208 1209# 1210# Generic lock file processing -- make sure that the lock file doesn't 1211# exist. If it does, it should name the build host and PID. If it 1212# doesn't, then make sure we can create it. Clean up locks that are 1213# known to be stale (assumes host name is unique among build systems 1214# for the workspace). 1215# 1216function create_lock { 1217 lockf=$1 1218 lockvar=$2 1219 1220 ldir=`dirname $lockf` 1221 [ -d $ldir ] || newdir $ldir || exit 1 1222 eval $lockvar=$lockf 1223 1224 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 1225 basews=`basename $CODEMGR_WS` 1226 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 1227 if [ "$host" != "$hostname" ]; then 1228 echo "$MACH build of $basews apparently" \ 1229 "already started by $user on $host as $pid." 1230 exit 1 1231 elif kill -s 0 $pid 2>/dev/null; then 1232 echo "$MACH build of $basews already started" \ 1233 "by $user as $pid." 1234 exit 1 1235 else 1236 # stale lock; clear it out and try again 1237 rm -f $lockf 1238 fi 1239 done 1240} 1241 1242# 1243# Return the list of interesting proto areas, depending on the current 1244# options. 1245# 1246function allprotos { 1247 typeset roots="$ROOT" 1248 1249 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1250 roots="$roots $ROOT-nd" 1251 fi 1252 1253 echo $roots 1254} 1255 1256# Ensure no other instance of this script is running on this host. 1257# LOCKNAME can be set in <env_file>, and is by default, but is not 1258# required due to the use of $ATLOG below. 1259if [ -n "$LOCKNAME" ]; then 1260 create_lock /tmp/$LOCKNAME "lockfile" 1261fi 1262# 1263# Create from one, two, or three other locks: 1264# $ATLOG/nightly.lock 1265# - protects against multiple builds in same workspace 1266# $PARENT_WS/usr/src/nightly.$MACH.lock 1267# - protects against multiple 'u' copy-backs 1268# $NIGHTLY_PARENT_ROOT/nightly.lock 1269# - protects against multiple 'U' copy-backs 1270# 1271# Overriding ISUSER to 1 causes the lock to be created as root if the 1272# script is run as root. The default is to create it as $STAFFER. 1273ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 1274if [ "$u_FLAG" = "y" ]; then 1275 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 1276fi 1277if [ "$U_FLAG" = "y" ]; then 1278 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 1279 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 1280fi 1281 1282# Locks have been taken, so we're doing a build and we're committed to 1283# the directories we may have created so far. 1284newdirlist= 1285 1286# 1287# Create mail_msg_file 1288# 1289mail_msg_file="${TMPDIR}/mail_msg" 1290touch $mail_msg_file 1291build_time_file="${TMPDIR}/build_time" 1292build_environ_file="${TMPDIR}/build_environ" 1293touch $build_environ_file 1294# 1295# Move old LOGFILE aside 1296# ATLOG directory already made by 'create_lock' above 1297# 1298if [ -f $LOGFILE ]; then 1299 mv -f $LOGFILE ${LOGFILE}- 1300fi 1301# 1302# Build OsNet source 1303# 1304START_DATE=`date` 1305SECONDS=0 1306echo "\n==== Nightly $maketype build started: $START_DATE ====" \ 1307 | tee -a $LOGFILE > $build_time_file 1308 1309echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1310 tee -a $mail_msg_file >> $LOGFILE 1311 1312# make sure we log only to the nightly build file 1313build_noise_file="${TMPDIR}/build_noise" 1314exec </dev/null >$build_noise_file 2>&1 1315 1316run_hook SYS_PRE_NIGHTLY 1317run_hook PRE_NIGHTLY 1318 1319echo "\n==== list of environment variables ====\n" >> $LOGFILE 1320env >> $LOGFILE 1321 1322echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 1323 1324if [ "$N_FLAG" = "y" ]; then 1325 if [ "$p_FLAG" = "y" ]; then 1326 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1327WARNING: the p option (create packages) is set, but so is the N option (do 1328 not run protocmp); this is dangerous; you should unset the N option 1329EOF 1330 else 1331 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1332Warning: the N option (do not run protocmp) is set; it probably shouldn't be 1333EOF 1334 fi 1335 echo "" | tee -a $mail_msg_file >> $LOGFILE 1336fi 1337 1338if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 1339 # 1340 # In the past we just complained but went ahead with the lint 1341 # pass, even though the proto area was built non-DEBUG. It's 1342 # unlikely that non-DEBUG headers will make a difference, but 1343 # rather than assuming it's a safe combination, force the user 1344 # to specify a DEBUG build. 1345 # 1346 echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 1347 | tee -a $mail_msg_file >> $LOGFILE 1348 l_FLAG=n 1349fi 1350 1351if [ "$f_FLAG" = "y" ]; then 1352 if [ "$i_FLAG" = "y" ]; then 1353 echo "WARNING: the -f flag cannot be used during incremental" \ 1354 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1355 f_FLAG=n 1356 fi 1357 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 1358 echo "WARNING: the -f flag requires -l, and -p;" \ 1359 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1360 f_FLAG=n 1361 fi 1362fi 1363 1364if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 1365 echo "WARNING: -w specified, but $ROOT does not exist;" \ 1366 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 1367 w_FLAG=n 1368fi 1369 1370if [ "$t_FLAG" = "n" ]; then 1371 # 1372 # We're not doing a tools build, so make sure elfsign(1) is 1373 # new enough to safely sign non-crypto binaries. We test 1374 # debugging output from elfsign to detect the old version. 1375 # 1376 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 1377 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 1378 | egrep algorithmOID` 1379 if [ -z "$newelfsigntest" ]; then 1380 echo "WARNING: /usr/bin/elfsign out of date;" \ 1381 "will only sign crypto modules\n" | \ 1382 tee -a $mail_msg_file >> $LOGFILE 1383 export ELFSIGN_OBJECT=true 1384 elif [ "$VERIFY_ELFSIGN" = "y" ]; then 1385 echo "WARNING: VERIFY_ELFSIGN=y requires" \ 1386 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 1387 tee -a $mail_msg_file >> $LOGFILE 1388 fi 1389fi 1390 1391case $MULTI_PROTO in 1392yes|no) ;; 1393*) 1394 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 1395 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 1396 echo "Setting MULTI_PROTO to \"no\".\n" | \ 1397 tee -a $mail_msg_file >> $LOGFILE 1398 export MULTI_PROTO=no 1399 ;; 1400esac 1401 1402echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 1403echo $VERSION | tee -a $mail_msg_file >> $LOGFILE 1404 1405# Save the current proto area if we're comparing against the last build 1406if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 1407 if [ -d "$ROOT.prev" ]; then 1408 rm -rf $ROOT.prev 1409 fi 1410 mv $ROOT $ROOT.prev 1411fi 1412 1413# Same for non-DEBUG proto area 1414if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 1415 if [ -d "$ROOT-nd.prev" ]; then 1416 rm -rf $ROOT-nd.prev 1417 fi 1418 mv $ROOT-nd $ROOT-nd.prev 1419fi 1420 1421# Same for tools proto area 1422if [ "$w_FLAG" = "y" -a "$t_FLAG" == "y" -a -d "$TOOLS_PROTO" ]; then 1423 if [ -d "$TOOLS_PROTO.prev" ]; then 1424 rm -rf $TOOLS_PROTO.prev 1425 fi 1426 mv $TOOLS_PROTO $TOOLS_PROTO.prev 1427fi 1428 1429# 1430# Echo the SCM type of the parent workspace, this can't just be which_scm 1431# as that does not know how to identify various network repositories. 1432# 1433function parent_wstype { 1434 typeset scm_type junk 1435 1436 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1437 | read scm_type junk 1438 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 1439 # Probe BRINGOVER_WS to determine its type 1440 if [[ $BRINGOVER_WS == ssh://* ]]; then 1441 scm_type="mercurial" 1442 elif [[ $BRINGOVER_WS == http://* ]] && \ 1443 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 1444 egrep -s "application/mercurial" 2> /dev/null; then 1445 scm_type="mercurial" 1446 else 1447 scm_type="none" 1448 fi 1449 fi 1450 1451 # fold both unsupported and unrecognized results into "none" 1452 case "$scm_type" in 1453 mercurial) 1454 ;; 1455 *) scm_type=none 1456 ;; 1457 esac 1458 1459 echo $scm_type 1460} 1461 1462# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1463function child_wstype { 1464 typeset scm_type junk 1465 1466 # Probe CODEMGR_WS to determine its type 1467 if [[ -d $CODEMGR_WS ]]; then 1468 $WHICH_SCM | read scm_type junk || exit 1 1469 fi 1470 1471 case "$scm_type" in 1472 none|git|mercurial) 1473 ;; 1474 *) scm_type=none 1475 ;; 1476 esac 1477 1478 echo $scm_type 1479} 1480 1481SCM_TYPE=$(child_wstype) 1482 1483# 1484# Decide whether to clobber 1485# 1486if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 1487 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 1488 1489 cd $SRC 1490 # remove old clobber file 1491 rm -f $SRC/clobber.out 1492 rm -f $SRC/clobber-${MACH}.out 1493 1494 # Remove all .make.state* files, just in case we are restarting 1495 # the build after having interrupted a previous 'make clobber'. 1496 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1497 -o -name 'interfaces.*' \) -prune \ 1498 -o -name '.make.*' -print | xargs rm -f 1499 1500 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 1501 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 1502 grep "$MAKE:" $SRC/clobber-${MACH}.out | 1503 egrep -v "Ignoring unknown host" | \ 1504 tee $TMPDIR/clobber_errs >> $mail_msg_file 1505 1506 if [[ -s $TMPDIR/clobber_errs ]]; then 1507 build_extras_ok=n 1508 fi 1509 1510 if [[ "$t_FLAG" = "y" ]]; then 1511 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 1512 cd ${TOOLS} 1513 rm -f ${TOOLS}/clobber-${MACH}.out 1514 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 1515 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 1516 echo "\n==== Make tools clobber ERRORS ====\n" \ 1517 >> $mail_msg_file 1518 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1519 >> $mail_msg_file 1520 if (( $? == 0 )); then 1521 build_extras_ok=n 1522 fi 1523 rm -rf ${TOOLS_PROTO} 1524 mkdir -p ${TOOLS_PROTO} 1525 fi 1526 1527 typeset roots=$(allprotos) 1528 echo "\n\nClearing $roots" >> "$LOGFILE" 1529 rm -rf $roots 1530 1531 # Get back to a clean workspace as much as possible to catch 1532 # problems that only occur on fresh workspaces. 1533 # Remove all .make.state* files, libraries, and .o's that may 1534 # have been omitted from clobber. A couple of libraries are 1535 # under source code control, so leave them alone. 1536 # We should probably blow away temporary directories too. 1537 cd $SRC 1538 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 1539 -o -name .git -o -name 'interfaces.*' \) -prune -o \ 1540 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1541 -name '*.o' \) -print | \ 1542 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 1543else 1544 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 1545fi 1546 1547type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1548 typeset -x PATH=$PATH 1549 1550 # If the repository doesn't exist yet, then we want to populate it. 1551 if [[ ! -d $CODEMGR_WS/.hg ]]; then 1552 staffer hg init $CODEMGR_WS 1553 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 1554 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1555 touch $TMPDIR/new_repository 1556 fi 1557 1558 typeset -x HGMERGE="/bin/false" 1559 1560 # 1561 # If the user has changes, regardless of whether those changes are 1562 # committed, and regardless of whether those changes conflict, then 1563 # we'll attempt to merge them either implicitly (uncommitted) or 1564 # explicitly (committed). 1565 # 1566 # These are the messages we'll use to help clarify mercurial output 1567 # in those cases. 1568 # 1569 typeset mergefailmsg="\ 1570***\n\ 1571*** nightly was unable to automatically merge your changes. You should\n\ 1572*** redo the full merge manually, following the steps outlined by mercurial\n\ 1573*** above, then restart nightly.\n\ 1574***\n" 1575 typeset mergepassmsg="\ 1576***\n\ 1577*** nightly successfully merged your changes. This means that your working\n\ 1578*** directory has been updated, but those changes are not yet committed.\n\ 1579*** After nightly completes, you should validate the results of the merge,\n\ 1580*** then use hg commit manually.\n\ 1581***\n" 1582 1583 # 1584 # For each repository in turn: 1585 # 1586 # 1. Do the pull. If this fails, dump the output and bail out. 1587 # 1588 # 2. If the pull resulted in an extra head, do an explicit merge. 1589 # If this fails, dump the output and bail out. 1590 # 1591 # Because we can't rely on Mercurial to exit with a failure code 1592 # when a merge fails (Mercurial issue #186), we must grep the 1593 # output of pull/merge to check for attempted and/or failed merges. 1594 # 1595 # 3. If a merge failed, set the message and fail the bringover. 1596 # 1597 # 4. Otherwise, if a merge succeeded, set the message 1598 # 1599 # 5. Dump the output, and any message from step 3 or 4. 1600 # 1601 1602 typeset HG_SOURCE=$BRINGOVER_WS 1603 if [ ! -f $TMPDIR/new_repository ]; then 1604 HG_SOURCE=$TMPDIR/open_bundle.hg 1605 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1606 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1607 1608 # 1609 # If there are no incoming changesets, then incoming will 1610 # fail, and there will be no bundle file. Reset the source, 1611 # to allow the remaining logic to complete with no false 1612 # negatives. (Unlike incoming, pull will return success 1613 # for the no-change case.) 1614 # 1615 if (( $? != 0 )); then 1616 HG_SOURCE=$BRINGOVER_WS 1617 fi 1618 fi 1619 1620 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 1621 > $TMPDIR/pull_open.out 2>&1 1622 if (( $? != 0 )); then 1623 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 1624 cat $TMPDIR/pull_open.out 1625 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 1626 printf "$mergefailmsg" 1627 fi 1628 touch $TMPDIR/bringover_failed 1629 return 1630 fi 1631 1632 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 1633 staffer hg --cwd $CODEMGR_WS merge \ 1634 >> $TMPDIR/pull_open.out 2>&1 1635 if (( $? != 0 )); then 1636 printf "%s: merge failed as follows:\n\n" \ 1637 "$CODEMGR_WS" 1638 cat $TMPDIR/pull_open.out 1639 if grep "^merging.*failed" $TMPDIR/pull_open.out \ 1640 > /dev/null 2>&1; then 1641 printf "$mergefailmsg" 1642 fi 1643 touch $TMPDIR/bringover_failed 1644 return 1645 fi 1646 fi 1647 1648 printf "updated %s with the following results:\n" "$CODEMGR_WS" 1649 cat $TMPDIR/pull_open.out 1650 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 1651 printf "$mergepassmsg" 1652 fi 1653 printf "\n" 1654 1655 # 1656 # Per-changeset output is neither useful nor manageable for a 1657 # newly-created repository. 1658 # 1659 if [ -f $TMPDIR/new_repository ]; then 1660 return 1661 fi 1662 1663 printf "\nadded the following changesets to open repository:\n" 1664 cat $TMPDIR/incoming_open.out 1665} 1666 1667type bringover_none > /dev/null 2>&1 || function bringover_none { 1668 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1669 touch $TMPDIR/bringover_failed 1670} 1671 1672# 1673# Decide whether to bringover to the codemgr workspace 1674# 1675if [ "$n_FLAG" = "n" ]; then 1676 PARENT_SCM_TYPE=$(parent_wstype) 1677 1678 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1679 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1680 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 1681 exit 1 1682 fi 1683 1684 run_hook PRE_BRINGOVER 1685 1686 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1687 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1688 1689 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 1690 tee -a $mail_msg_file >> $LOGFILE 1691 1692 if [ -f $TMPDIR/bringover_failed ]; then 1693 rm -f $TMPDIR/bringover_failed 1694 build_ok=n 1695 echo "trouble with bringover, quitting at `date`." | 1696 tee -a $mail_msg_file >> $LOGFILE 1697 exit 1 1698 fi 1699 1700 # 1701 # It's possible that we used the bringover above to create 1702 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 1703 # but should now be the same as $BRINGOVER_WS. 1704 # 1705 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 1706 1707 run_hook POST_BRINGOVER 1708 1709 check_closed_bins 1710 1711else 1712 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 1713fi 1714 1715# Safeguards 1716[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 1717[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 1718[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 1719 1720echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 1721 1722# System 1723whence uname | tee -a $build_environ_file >> $LOGFILE 1724uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 1725echo | tee -a $build_environ_file >> $LOGFILE 1726 1727# make 1728whence $MAKE | tee -a $build_environ_file >> $LOGFILE 1729$MAKE -v | tee -a $build_environ_file >> $LOGFILE 1730echo "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1731 tee -a $build_environ_file >> $LOGFILE 1732 1733# 1734# Report the compiler versions. 1735# 1736 1737if [[ ! -f $SRC/Makefile ]]; then 1738 build_ok=n 1739 echo "\nUnable to find \"Makefile\" in $SRC." | \ 1740 tee -a $build_environ_file >> $LOGFILE 1741 exit 1 1742fi 1743 1744( cd $SRC 1745 for target in cc-version cc64-version java-version; do 1746 echo 1747 # 1748 # Put statefile somewhere we know we can write to rather than trip 1749 # over a read-only $srcroot. 1750 # 1751 rm -f $TMPDIR/make-state 1752 export SRC 1753 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1754 continue 1755 fi 1756 touch $TMPDIR/nocompiler 1757 done 1758 echo 1759) | tee -a $build_environ_file >> $LOGFILE 1760 1761if [ -f $TMPDIR/nocompiler ]; then 1762 rm -f $TMPDIR/nocompiler 1763 build_ok=n 1764 echo "Aborting due to missing compiler." | 1765 tee -a $build_environ_file >> $LOGFILE 1766 exit 1 1767fi 1768 1769# as 1770whence as | tee -a $build_environ_file >> $LOGFILE 1771as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 1772echo | tee -a $build_environ_file >> $LOGFILE 1773 1774# Check that we're running a capable link-editor 1775whence ld | tee -a $build_environ_file >> $LOGFILE 1776LDVER=`ld -V 2>&1` 1777echo $LDVER | tee -a $build_environ_file >> $LOGFILE 1778LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 1779if [ `expr $LDVER \< 422` -eq 1 ]; then 1780 echo "The link-editor needs to be at version 422 or higher to build" | \ 1781 tee -a $build_environ_file >> $LOGFILE 1782 echo "the latest stuff. Hope your build works." | \ 1783 tee -a $build_environ_file >> $LOGFILE 1784fi 1785 1786# 1787# Build and use the workspace's tools if requested 1788# 1789if [[ "$t_FLAG" = "y" ]]; then 1790 set_non_debug_build_flags 1791 1792 build_tools ${TOOLS_PROTO} 1793 if (( $? != 0 )); then 1794 build_ok=n 1795 else 1796 use_tools $TOOLS_PROTO 1797 fi 1798fi 1799 1800# timestamp the start of the normal build; the findunref tool uses it. 1801touch $SRC/.build.tstamp 1802 1803normal_build 1804 1805ORIG_SRC=$SRC 1806BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 1807 1808 1809# 1810# There are several checks that need to look at the proto area, but 1811# they only need to look at one, and they don't care whether it's 1812# DEBUG or non-DEBUG. 1813# 1814if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 1815 checkroot=$ROOT-nd 1816else 1817 checkroot=$ROOT 1818fi 1819 1820if [ "$build_ok" = "y" ]; then 1821 echo "\n==== Creating protolist system file at `date` ====" \ 1822 >> $LOGFILE 1823 protolist $checkroot > $ATLOG/proto_list_${MACH} 1824 echo "==== protolist system file created at `date` ====\n" \ 1825 >> $LOGFILE 1826 1827 if [ "$N_FLAG" != "y" ]; then 1828 1829 E1= 1830 f1= 1831 for f in $f1; do 1832 if [ -f "$f" ]; then 1833 E1="$E1 -e $f" 1834 fi 1835 done 1836 1837 E2= 1838 f2= 1839 if [ -d "$SRC/pkg" ]; then 1840 f2="$f2 exceptions/packaging" 1841 fi 1842 1843 for f in $f2; do 1844 if [ -f "$f" ]; then 1845 E2="$E2 -e $f" 1846 fi 1847 done 1848 fi 1849 1850 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 1851 echo "\n==== Validating manifests against proto area ====\n" \ 1852 >> $mail_msg_file 1853 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1854 tee $TMPDIR/protocmp_noise >> $mail_msg_file 1855 if [[ -s $TMPDIR/protocmp_noise ]]; then 1856 build_extras_ok=n 1857 fi 1858 fi 1859 1860 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 1861 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 1862 if [ -n "$E2" ]; then 1863 ELIST=$E2 1864 else 1865 ELIST=$E1 1866 fi 1867 $PROTOCMPTERSE \ 1868 "Files in yesterday's proto area, but not today's:" \ 1869 "Files in today's proto area, but not yesterday's:" \ 1870 "Files that changed between yesterday and today:" \ 1871 ${ELIST} \ 1872 -d $REF_PROTO_LIST \ 1873 $ATLOG/proto_list_${MACH} \ 1874 >> $mail_msg_file 1875 fi 1876fi 1877 1878if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 1879 "$build_extras_ok" == "y" ]]; then 1880 staffer cp $ATLOG/proto_list_${MACH} \ 1881 $PARENT_WS/usr/src/proto_list_${MACH} 1882fi 1883 1884# Update parent proto area if necessary. This is done now 1885# so that the proto area has either DEBUG or non-DEBUG kernels. 1886# Note that this clears out the lock file, so we can dispense with 1887# the variable now. 1888if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 1889 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 1890 tee -a $LOGFILE >> $mail_msg_file 1891 rm -rf $NIGHTLY_PARENT_ROOT/* 1892 unset Ulockfile 1893 mkdir -p $NIGHTLY_PARENT_ROOT 1894 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1895 ( cd $ROOT; tar cf - . | 1896 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 1897 tee -a $mail_msg_file >> $LOGFILE 1898 fi 1899 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 1900 rm -rf $NIGHTLY_PARENT_ROOT-nd/* 1901 mkdir -p $NIGHTLY_PARENT_ROOT-nd 1902 cd $ROOT-nd 1903 ( tar cf - . | 1904 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 1905 tee -a $mail_msg_file >> $LOGFILE 1906 fi 1907 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 1908 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 1909 tee -a $LOGFILE >> $mail_msg_file 1910 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 1911 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 1912 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1913 ( cd $TOOLS_PROTO; tar cf - . | 1914 ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 1915 umask 0; tar xpf - ) ) 2>&1 | 1916 tee -a $mail_msg_file >> $LOGFILE 1917 fi 1918 fi 1919fi 1920 1921# 1922# ELF verification: ABI (-A) and runtime (-r) checks 1923# 1924if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 1925 # Directory ELF-data.$MACH holds the files produced by these tests. 1926 elf_ddir=$SRC/ELF-data.$MACH 1927 1928 # If there is a previous ELF-data backup directory, remove it. Then, 1929 # rotate current ELF-data directory into its place and create a new 1930 # empty directory 1931 rm -rf $elf_ddir.ref 1932 if [[ -d $elf_ddir ]]; then 1933 mv $elf_ddir $elf_ddir.ref 1934 fi 1935 mkdir -p $elf_ddir 1936 1937 # Call find_elf to produce a list of the ELF objects in the proto area. 1938 # This list is passed to check_rtime and interface_check, preventing 1939 # them from separately calling find_elf to do the same work twice. 1940 find_elf -fr $checkroot > $elf_ddir/object_list 1941 1942 if [[ $A_FLAG = y ]]; then 1943 echo "\n==== Check versioning and ABI information ====\n" | \ 1944 tee -a $LOGFILE >> $mail_msg_file 1945 1946 # Produce interface description for the proto. Report errors. 1947 interface_check -o -w $elf_ddir -f object_list \ 1948 -i interface -E interface.err 1949 if [[ -s $elf_ddir/interface.err ]]; then 1950 tee -a $LOGFILE < $elf_ddir/interface.err \ 1951 >> $mail_msg_file 1952 build_extras_ok=n 1953 fi 1954 1955 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 1956 # description file to that from the baseline gate. Issue a 1957 # warning if the baseline is not present, and keep going. 1958 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 1959 base_ifile="$ELF_DATA_BASELINE_DIR/interface" 1960 1961 echo "\n==== Compare versioning and ABI information" \ 1962 "to baseline ====\n" | \ 1963 tee -a $LOGFILE >> $mail_msg_file 1964 echo "Baseline: $base_ifile\n" >> $LOGFILE 1965 1966 if [[ -f $base_ifile ]]; then 1967 interface_cmp -d -o $base_ifile \ 1968 $elf_ddir/interface > $elf_ddir/interface.cmp 1969 if [[ -s $elf_ddir/interface.cmp ]]; then 1970 echo | tee -a $LOGFILE >> $mail_msg_file 1971 tee -a $LOGFILE < \ 1972 $elf_ddir/interface.cmp \ 1973 >> $mail_msg_file 1974 build_extras_ok=n 1975 fi 1976 else 1977 echo "baseline not available. comparison" \ 1978 "skipped" | \ 1979 tee -a $LOGFILE >> $mail_msg_file 1980 fi 1981 1982 fi 1983 fi 1984 1985 if [[ $r_FLAG = y ]]; then 1986 echo "\n==== Check ELF runtime attributes ====\n" | \ 1987 tee -a $LOGFILE >> $mail_msg_file 1988 1989 # If we're doing a DEBUG build the proto area will be left 1990 # with debuggable objects, thus don't assert -s. 1991 if [[ $D_FLAG = y ]]; then 1992 rtime_sflag="" 1993 else 1994 rtime_sflag="-s" 1995 fi 1996 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 1997 -D object_list -f object_list -E runtime.err \ 1998 -I runtime.attr.raw 1999 if (( $? != 0 )); then 2000 build_extras_ok=n 2001 fi 2002 2003 # check_rtime -I output needs to be sorted in order to 2004 # compare it to that from previous builds. 2005 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 2006 rm $elf_ddir/runtime.attr.raw 2007 2008 # Report errors 2009 if [[ -s $elf_ddir/runtime.err ]]; then 2010 tee -a $LOGFILE < $elf_ddir/runtime.err \ 2011 >> $mail_msg_file 2012 build_extras_ok=n 2013 fi 2014 2015 # If there is an ELF-data directory from a previous build, 2016 # then diff the attr files. These files contain information 2017 # about dependencies, versioning, and runpaths. There is some 2018 # overlap with the ABI checking done above, but this also 2019 # flushes out non-ABI interface differences along with the 2020 # other information. 2021 echo "\n==== Diff ELF runtime attributes" \ 2022 "(since last build) ====\n" | \ 2023 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 2024 2025 if [[ -f $elf_ddir.ref/runtime.attr ]]; then 2026 diff $elf_ddir.ref/runtime.attr \ 2027 $elf_ddir/runtime.attr \ 2028 >> $mail_msg_file 2029 fi 2030 fi 2031 2032 # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 2033 if [[ "$u_FLAG" = "y" ]]; then 2034 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 2035 2036 # If parent lacks the ELF-data.$MACH directory, create it 2037 if [[ ! -d $p_elf_ddir ]]; then 2038 staffer mkdir -p $p_elf_ddir 2039 fi 2040 2041 # These files are used asynchronously by other builds for ABI 2042 # verification, as above for the -A option. As such, we require 2043 # the file replacement to be atomic. Copy the data to a temp 2044 # file in the same filesystem and then rename into place. 2045 ( 2046 cd $elf_ddir 2047 for elf_dfile in *; do 2048 staffer cp $elf_dfile \ 2049 ${p_elf_ddir}/${elf_dfile}.new 2050 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 2051 ${p_elf_ddir}/${elf_dfile} 2052 done 2053 ) 2054 fi 2055fi 2056 2057# DEBUG lint of kernel begins 2058 2059if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 2060 if [ "$LINTDIRS" = "" ]; then 2061 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 2062 LINTDIRS="$SRC y" 2063 fi 2064 set $LINTDIRS 2065 while [ $# -gt 0 ]; do 2066 dolint $1 $2; shift; shift 2067 done 2068else 2069 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 2070fi 2071 2072# "make check" begins 2073 2074if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 2075 # remove old check.out 2076 rm -f $SRC/check.out 2077 2078 rm -f $SRC/check-${MACH}.out 2079 cd $SRC 2080 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 2081 >> $LOGFILE 2082 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 2083 2084 grep ":" $SRC/check-${MACH}.out | 2085 egrep -v "Ignoring unknown host" | \ 2086 sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 2087 2088 if [[ -s $TMPDIR/check_errors ]]; then 2089 build_extras_ok=n 2090 fi 2091else 2092 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 2093fi 2094 2095echo "\n==== Find core files ====\n" | \ 2096 tee -a $LOGFILE >> $mail_msg_file 2097 2098find $abssrcdirs -name core -a -type f -exec file {} \; | \ 2099 tee -a $LOGFILE >> $mail_msg_file 2100 2101if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2102 echo "\n==== Diff unreferenced files (since last build) ====\n" \ 2103 | tee -a $LOGFILE >>$mail_msg_file 2104 rm -f $SRC/unref-${MACH}.ref 2105 if [ -f $SRC/unref-${MACH}.out ]; then 2106 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2107 fi 2108 2109 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 2110 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 2111 sort > $SRC/unref-${MACH}.out 2112 2113 if [ ! -f $SRC/unref-${MACH}.ref ]; then 2114 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2115 fi 2116 2117 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 2118fi 2119 2120# Verify that the usual lists of files, such as exception lists, 2121# contain only valid references to files. If the build has failed, 2122# then don't check the proto area. 2123CHECK_PATHS=${CHECK_PATHS:-y} 2124if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 2125 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 2126 >>$mail_msg_file 2127 arg=-b 2128 [ "$build_ok" = y ] && arg= 2129 checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 2130 if [[ -s $SRC/check-paths.out ]]; then 2131 tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 2132 build_extras_ok=n 2133 fi 2134fi 2135 2136if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2137 echo "\n==== Impact on file permissions ====\n" \ 2138 >> $mail_msg_file 2139 2140 abspkg= 2141 for d in $abssrcdirs; do 2142 if [ -d "$d/pkg" ]; then 2143 abspkg="$abspkg $d" 2144 fi 2145 done 2146 2147 if [ -n "$abspkg" ]; then 2148 for d in "$abspkg"; do 2149 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 2150 done 2151 fi 2152fi 2153 2154if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 2155 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 2156 do_wsdiff DEBUG $ROOT.prev $ROOT wsdiff.results 2157 fi 2158 2159 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 2160 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd wsdiff-nd.results 2161 fi 2162 2163 if [[ "$t_FLAG" == "y" ]]; then 2164 do_wsdiff tools $TOOLS_PROTO.prev $TOOLS_PROTO wsdiff-tools.results 2165 fi 2166fi 2167 2168END_DATE=`date` 2169echo "==== Nightly $maketype build completed: $END_DATE ====" | \ 2170 tee -a $LOGFILE >> $build_time_file 2171 2172typeset -i10 hours 2173typeset -Z2 minutes 2174typeset -Z2 seconds 2175 2176elapsed_time=$SECONDS 2177((hours = elapsed_time / 3600 )) 2178((minutes = elapsed_time / 60 % 60)) 2179((seconds = elapsed_time % 60)) 2180 2181echo "\n==== Total build time ====" | \ 2182 tee -a $LOGFILE >> $build_time_file 2183echo "\nreal ${hours}:${minutes}:${seconds}" | \ 2184 tee -a $LOGFILE >> $build_time_file 2185 2186if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2187 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 2188 2189 # 2190 # Produce a master list of unreferenced files -- ideally, we'd 2191 # generate the master just once after all of the nightlies 2192 # have finished, but there's no simple way to know when that 2193 # will be. Instead, we assume that we're the last nightly to 2194 # finish and merge all of the unref-${MACH}.out files in 2195 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 2196 # finish, then this file will be the authoritative master 2197 # list. Otherwise, another ${MACH}'s nightly will eventually 2198 # overwrite ours with its own master, but in the meantime our 2199 # temporary "master" will be no worse than any older master 2200 # which was already on the parent. 2201 # 2202 2203 set -- $PARENT_WS/usr/src/unref-*.out 2204 cp "$1" ${TMPDIR}/unref.merge 2205 shift 2206 2207 for unreffile; do 2208 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 2209 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 2210 done 2211 2212 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 2213fi 2214 2215# 2216# All done save for the sweeping up. 2217# (whichever exit we hit here will trigger the "cleanup" trap which 2218# optionally sends mail on completion). 2219# 2220if [[ "$build_ok" == "y" ]]; then 2221 if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 2222 exit 0 2223 fi 2224fi 2225 2226exit 1 2227