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