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 926if [ $ISUSER -ne 0 ]; then 927 # Set default value for STAFFER, if needed. 928 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 929 STAFFER=`/usr/xpg4/bin/id -un` 930 export STAFFER 931 fi 932fi 933 934if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 935 MAILTO=$STAFFER 936 export MAILTO 937fi 938 939PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 940PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 941PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 942export PATH 943 944# roots of source trees, both relative to $SRC and absolute. 945relsrcdirs="." 946abssrcdirs="$SRC" 947 948PROTOCMPTERSE="protocmp.terse -gu" 949POUND_SIGN="#" 950# have we set RELEASE_DATE in our env file? 951if [ -z "$RELEASE_DATE" ]; then 952 RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 953fi 954BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 955BASEWSDIR=$(basename $CODEMGR_WS) 956DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 957 958# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 959# by avoiding repeated shell invocations to evaluate Makefile.master 960# definitions. 961export POUND_SIGN RELEASE_DATE DEV_CM 962 963maketype="distributed" 964if [[ -z "$MAKE" ]]; then 965 MAKE=dmake 966elif [[ ! -x "$MAKE" ]]; then 967 echo "\$MAKE is set to garbage in the environment" 968 exit 1 969fi 970export PATH 971export MAKE 972 973if [ "${SUNWSPRO}" != "" ]; then 974 PATH="${SUNWSPRO}/bin:$PATH" 975 export PATH 976fi 977 978hostname=$(uname -n) 979if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 980then 981 maxjobs= 982 if [[ -f $HOME/.make.machines ]] 983 then 984 # Note: there is a hard tab and space character in the []s 985 # below. 986 egrep -i "^[ ]*$hostname[ \.]" \ 987 $HOME/.make.machines | read host jobs 988 maxjobs=${jobs##*=} 989 fi 990 991 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 992 then 993 # default 994 maxjobs=4 995 fi 996 997 export DMAKE_MAX_JOBS=$maxjobs 998fi 999 1000DMAKE_MODE=parallel; 1001export DMAKE_MODE 1002 1003if [ -z "${ROOT}" ]; then 1004 echo "ROOT must be set." 1005 exit 1 1006fi 1007 1008# 1009# if -V flag was given, reset VERSION to V_ARG 1010# 1011if [ "$V_FLAG" = "y" ]; then 1012 VERSION=$V_ARG 1013fi 1014 1015TMPDIR="/tmp/nightly.tmpdir.$$" 1016export TMPDIR 1017rm -rf ${TMPDIR} 1018mkdir -p $TMPDIR || exit 1 1019chmod 777 $TMPDIR 1020 1021# 1022# Keep elfsign's use of pkcs11_softtoken from looking in the user home 1023# directory, which doesn't always work. Needed until all build machines 1024# have the fix for 6271754 1025# 1026SOFTTOKEN_DIR=$TMPDIR 1027export SOFTTOKEN_DIR 1028 1029# 1030# Tools should only be built non-DEBUG. Keep track of the tools proto 1031# area path relative to $TOOLS, because the latter changes in an 1032# export build. 1033# 1034# TOOLS_PROTO is included below for builds other than usr/src/tools 1035# that look for this location. For usr/src/tools, this will be 1036# overridden on the $MAKE command line in build_tools(). 1037# 1038TOOLS=${SRC}/tools 1039TOOLS_PROTO_REL=proto/root_${MACH}-nd 1040TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1041 1042unset CFLAGS LD_LIBRARY_PATH LDFLAGS 1043 1044# create directories that are automatically removed if the nightly script 1045# fails to start correctly 1046function newdir { 1047 dir=$1 1048 toadd= 1049 while [ ! -d $dir ]; do 1050 toadd="$dir $toadd" 1051 dir=`dirname $dir` 1052 done 1053 torm= 1054 newlist= 1055 for dir in $toadd; do 1056 if staffer mkdir $dir; then 1057 newlist="$ISUSER $dir $newlist" 1058 torm="$dir $torm" 1059 else 1060 [ -z "$torm" ] || staffer rmdir $torm 1061 return 1 1062 fi 1063 done 1064 newdirlist="$newlist $newdirlist" 1065 return 0 1066} 1067newdirlist= 1068 1069[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 1070 1071# since this script assumes the build is from full source, it nullifies 1072# variables likely to have been set by a "ws" script; nullification 1073# confines the search space for headers and libraries to the proto area 1074# built from this immediate source. 1075ENVLDLIBS1= 1076ENVLDLIBS2= 1077ENVLDLIBS3= 1078ENVCPPFLAGS1= 1079ENVCPPFLAGS2= 1080ENVCPPFLAGS3= 1081ENVCPPFLAGS4= 1082PARENT_ROOT= 1083 1084export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1085 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 1086 1087PKGARCHIVE_ORIG=$PKGARCHIVE 1088 1089# 1090# Juggle the logs and optionally send mail on completion. 1091# 1092 1093function logshuffle { 1094 LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 1095 if [ -f $LLOG -o -d $LLOG ]; then 1096 LLOG=$LLOG.$$ 1097 fi 1098 mkdir $LLOG 1099 export LLOG 1100 1101 if [ "$build_ok" = "y" ]; then 1102 mv $ATLOG/proto_list_${MACH} $LLOG 1103 1104 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 1105 mv $ATLOG/proto_list_tools_${MACH} $LLOG 1106 fi 1107 1108 if [ -f $TMPDIR/wsdiff.results ]; then 1109 mv $TMPDIR/wsdiff.results $LLOG 1110 fi 1111 1112 if [ -f $TMPDIR/wsdiff-nd.results ]; then 1113 mv $TMPDIR/wsdiff-nd.results $LLOG 1114 fi 1115 1116 if [ -f $TMPDIR/wsdiff-tools.results ]; then 1117 mv $TMPDIR/wsdiff-tools.results $LLOG 1118 fi 1119 fi 1120 1121 # 1122 # Now that we're about to send mail, it's time to check the noise 1123 # file. In the event that an error occurs beyond this point, it will 1124 # be recorded in the nightly.log file, but nowhere else. This would 1125 # include only errors that cause the copying of the noise log to fail 1126 # or the mail itself not to be sent. 1127 # 1128 1129 exec >>$LOGFILE 2>&1 1130 if [ -s $build_noise_file ]; then 1131 echo "\n==== Nightly build noise ====\n" | 1132 tee -a $LOGFILE >>$mail_msg_file 1133 cat $build_noise_file >>$LOGFILE 1134 cat $build_noise_file >>$mail_msg_file 1135 echo | tee -a $LOGFILE >>$mail_msg_file 1136 fi 1137 rm -f $build_noise_file 1138 1139 case "$build_ok" in 1140 y) 1141 state=Completed 1142 ;; 1143 i) 1144 state=Interrupted 1145 ;; 1146 *) 1147 state=Failed 1148 ;; 1149 esac 1150 1151 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 1152 state=Failed 1153 fi 1154 1155 NIGHTLY_STATUS=$state 1156 export NIGHTLY_STATUS 1157 1158 run_hook POST_NIGHTLY $state 1159 run_hook SYS_POST_NIGHTLY $state 1160 1161 # 1162 # mailx(1) sets From: based on the -r flag 1163 # if it is given. 1164 # 1165 mailx_r= 1166 if [[ -n "${MAILFROM}" ]]; then 1167 mailx_r="-r ${MAILFROM}" 1168 fi 1169 1170 cat $build_time_file $build_environ_file $mail_msg_file \ 1171 > ${LLOG}/mail_msg 1172 if [ "$m_FLAG" = "y" ]; then 1173 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 1174 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 1175 ${MAILTO} 1176 fi 1177 1178 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1179 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 1180 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 1181 fi 1182 1183 mv $LOGFILE $LLOG 1184} 1185 1186# 1187# Remove the locks and temporary files on any exit 1188# 1189function cleanup { 1190 logshuffle 1191 1192 [ -z "$lockfile" ] || staffer rm -f $lockfile 1193 [ -z "$atloglockfile" ] || rm -f $atloglockfile 1194 [ -z "$ulockfile" ] || staffer rm -f $ulockfile 1195 [ -z "$Ulockfile" ] || rm -f $Ulockfile 1196 1197 set -- $newdirlist 1198 while [ $# -gt 0 ]; do 1199 ISUSER=$1 staffer rmdir $2 1200 shift; shift 1201 done 1202 rm -rf $TMPDIR 1203} 1204 1205function cleanup_signal { 1206 build_ok=i 1207 # this will trigger cleanup(), above. 1208 exit 1 1209} 1210 1211trap cleanup 0 1212trap cleanup_signal 1 2 3 15 1213 1214# 1215# Generic lock file processing -- make sure that the lock file doesn't 1216# exist. If it does, it should name the build host and PID. If it 1217# doesn't, then make sure we can create it. Clean up locks that are 1218# known to be stale (assumes host name is unique among build systems 1219# for the workspace). 1220# 1221function create_lock { 1222 lockf=$1 1223 lockvar=$2 1224 1225 ldir=`dirname $lockf` 1226 [ -d $ldir ] || newdir $ldir || exit 1 1227 eval $lockvar=$lockf 1228 1229 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 1230 basews=`basename $CODEMGR_WS` 1231 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 1232 if [ "$host" != "$hostname" ]; then 1233 echo "$MACH build of $basews apparently" \ 1234 "already started by $user on $host as $pid." 1235 exit 1 1236 elif kill -s 0 $pid 2>/dev/null; then 1237 echo "$MACH build of $basews already started" \ 1238 "by $user as $pid." 1239 exit 1 1240 else 1241 # stale lock; clear it out and try again 1242 rm -f $lockf 1243 fi 1244 done 1245} 1246 1247# 1248# Return the list of interesting proto areas, depending on the current 1249# options. 1250# 1251function allprotos { 1252 typeset roots="$ROOT" 1253 1254 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1255 roots="$roots $ROOT-nd" 1256 fi 1257 1258 echo $roots 1259} 1260 1261# Ensure no other instance of this script is running on this host. 1262# LOCKNAME can be set in <env_file>, and is by default, but is not 1263# required due to the use of $ATLOG below. 1264if [ -n "$LOCKNAME" ]; then 1265 create_lock /tmp/$LOCKNAME "lockfile" 1266fi 1267# 1268# Create from one, two, or three other locks: 1269# $ATLOG/nightly.lock 1270# - protects against multiple builds in same workspace 1271# $PARENT_WS/usr/src/nightly.$MACH.lock 1272# - protects against multiple 'u' copy-backs 1273# $NIGHTLY_PARENT_ROOT/nightly.lock 1274# - protects against multiple 'U' copy-backs 1275# 1276# Overriding ISUSER to 1 causes the lock to be created as root if the 1277# script is run as root. The default is to create it as $STAFFER. 1278ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 1279if [ "$u_FLAG" = "y" ]; then 1280 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 1281fi 1282if [ "$U_FLAG" = "y" ]; then 1283 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 1284 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 1285fi 1286 1287# Locks have been taken, so we're doing a build and we're committed to 1288# the directories we may have created so far. 1289newdirlist= 1290 1291# 1292# Create mail_msg_file 1293# 1294mail_msg_file="${TMPDIR}/mail_msg" 1295touch $mail_msg_file 1296build_time_file="${TMPDIR}/build_time" 1297build_environ_file="${TMPDIR}/build_environ" 1298touch $build_environ_file 1299# 1300# Move old LOGFILE aside 1301# ATLOG directory already made by 'create_lock' above 1302# 1303if [ -f $LOGFILE ]; then 1304 mv -f $LOGFILE ${LOGFILE}- 1305fi 1306# 1307# Build OsNet source 1308# 1309START_DATE=`date` 1310SECONDS=0 1311echo "\n==== Nightly $maketype build started: $START_DATE ====" \ 1312 | tee -a $LOGFILE > $build_time_file 1313 1314echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1315 tee -a $mail_msg_file >> $LOGFILE 1316 1317# make sure we log only to the nightly build file 1318build_noise_file="${TMPDIR}/build_noise" 1319exec </dev/null >$build_noise_file 2>&1 1320 1321run_hook SYS_PRE_NIGHTLY 1322run_hook PRE_NIGHTLY 1323 1324echo "\n==== list of environment variables ====\n" >> $LOGFILE 1325env >> $LOGFILE 1326 1327echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 1328 1329if [ "$N_FLAG" = "y" ]; then 1330 if [ "$p_FLAG" = "y" ]; then 1331 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1332WARNING: the p option (create packages) is set, but so is the N option (do 1333 not run protocmp); this is dangerous; you should unset the N option 1334EOF 1335 else 1336 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1337Warning: the N option (do not run protocmp) is set; it probably shouldn't be 1338EOF 1339 fi 1340 echo "" | tee -a $mail_msg_file >> $LOGFILE 1341fi 1342 1343if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 1344 # 1345 # In the past we just complained but went ahead with the lint 1346 # pass, even though the proto area was built non-DEBUG. It's 1347 # unlikely that non-DEBUG headers will make a difference, but 1348 # rather than assuming it's a safe combination, force the user 1349 # to specify a DEBUG build. 1350 # 1351 echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 1352 | tee -a $mail_msg_file >> $LOGFILE 1353 l_FLAG=n 1354fi 1355 1356if [ "$f_FLAG" = "y" ]; then 1357 if [ "$i_FLAG" = "y" ]; then 1358 echo "WARNING: the -f flag cannot be used during incremental" \ 1359 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1360 f_FLAG=n 1361 fi 1362 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 1363 echo "WARNING: the -f flag requires -l, and -p;" \ 1364 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1365 f_FLAG=n 1366 fi 1367fi 1368 1369if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 1370 echo "WARNING: -w specified, but $ROOT does not exist;" \ 1371 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 1372 w_FLAG=n 1373fi 1374 1375if [ "$t_FLAG" = "n" ]; then 1376 # 1377 # We're not doing a tools build, so make sure elfsign(1) is 1378 # new enough to safely sign non-crypto binaries. We test 1379 # debugging output from elfsign to detect the old version. 1380 # 1381 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 1382 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 1383 | egrep algorithmOID` 1384 if [ -z "$newelfsigntest" ]; then 1385 echo "WARNING: /usr/bin/elfsign out of date;" \ 1386 "will only sign crypto modules\n" | \ 1387 tee -a $mail_msg_file >> $LOGFILE 1388 export ELFSIGN_OBJECT=true 1389 elif [ "$VERIFY_ELFSIGN" = "y" ]; then 1390 echo "WARNING: VERIFY_ELFSIGN=y requires" \ 1391 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 1392 tee -a $mail_msg_file >> $LOGFILE 1393 fi 1394fi 1395 1396case $MULTI_PROTO in 1397yes|no) ;; 1398*) 1399 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 1400 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 1401 echo "Setting MULTI_PROTO to \"no\".\n" | \ 1402 tee -a $mail_msg_file >> $LOGFILE 1403 export MULTI_PROTO=no 1404 ;; 1405esac 1406 1407echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 1408echo $VERSION | tee -a $mail_msg_file >> $LOGFILE 1409 1410# Save the current proto area if we're comparing against the last build 1411if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 1412 if [ -d "$ROOT.prev" ]; then 1413 rm -rf $ROOT.prev 1414 fi 1415 mv $ROOT $ROOT.prev 1416fi 1417 1418# Same for non-DEBUG proto area 1419if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 1420 if [ -d "$ROOT-nd.prev" ]; then 1421 rm -rf $ROOT-nd.prev 1422 fi 1423 mv $ROOT-nd $ROOT-nd.prev 1424fi 1425 1426# Same for tools proto area 1427if [ "$w_FLAG" = "y" -a "$t_FLAG" == "y" -a -d "$TOOLS_PROTO" ]; then 1428 if [ -d "$TOOLS_PROTO.prev" ]; then 1429 rm -rf $TOOLS_PROTO.prev 1430 fi 1431 mv $TOOLS_PROTO $TOOLS_PROTO.prev 1432fi 1433 1434# 1435# Echo the SCM type of the parent workspace, this can't just be which_scm 1436# as that does not know how to identify various network repositories. 1437# 1438function parent_wstype { 1439 typeset scm_type junk 1440 1441 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1442 | read scm_type junk 1443 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 1444 # Probe BRINGOVER_WS to determine its type 1445 if [[ $BRINGOVER_WS == ssh://* ]]; then 1446 scm_type="mercurial" 1447 elif [[ $BRINGOVER_WS == http://* ]] && \ 1448 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 1449 egrep -s "application/mercurial" 2> /dev/null; then 1450 scm_type="mercurial" 1451 else 1452 scm_type="none" 1453 fi 1454 fi 1455 1456 # fold both unsupported and unrecognized results into "none" 1457 case "$scm_type" in 1458 mercurial) 1459 ;; 1460 *) scm_type=none 1461 ;; 1462 esac 1463 1464 echo $scm_type 1465} 1466 1467# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1468function child_wstype { 1469 typeset scm_type junk 1470 1471 # Probe CODEMGR_WS to determine its type 1472 if [[ -d $CODEMGR_WS ]]; then 1473 $WHICH_SCM | read scm_type junk || exit 1 1474 fi 1475 1476 case "$scm_type" in 1477 none|git|mercurial) 1478 ;; 1479 *) scm_type=none 1480 ;; 1481 esac 1482 1483 echo $scm_type 1484} 1485 1486SCM_TYPE=$(child_wstype) 1487 1488# 1489# Decide whether to clobber 1490# 1491if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 1492 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 1493 1494 cd $SRC 1495 # remove old clobber file 1496 rm -f $SRC/clobber.out 1497 rm -f $SRC/clobber-${MACH}.out 1498 1499 # Remove all .make.state* files, just in case we are restarting 1500 # the build after having interrupted a previous 'make clobber'. 1501 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1502 -o -name 'interfaces.*' \) -prune \ 1503 -o -name '.make.*' -print | xargs rm -f 1504 1505 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 1506 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 1507 grep "$MAKE:" $SRC/clobber-${MACH}.out | 1508 egrep -v "Ignoring unknown host" | \ 1509 tee $TMPDIR/clobber_errs >> $mail_msg_file 1510 1511 if [[ -s $TMPDIR/clobber_errs ]]; then 1512 build_extras_ok=n 1513 fi 1514 1515 if [[ "$t_FLAG" = "y" ]]; then 1516 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 1517 cd ${TOOLS} 1518 rm -f ${TOOLS}/clobber-${MACH}.out 1519 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 1520 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 1521 echo "\n==== Make tools clobber ERRORS ====\n" \ 1522 >> $mail_msg_file 1523 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1524 >> $mail_msg_file 1525 if (( $? == 0 )); then 1526 build_extras_ok=n 1527 fi 1528 rm -rf ${TOOLS_PROTO} 1529 mkdir -p ${TOOLS_PROTO} 1530 fi 1531 1532 typeset roots=$(allprotos) 1533 echo "\n\nClearing $roots" >> "$LOGFILE" 1534 rm -rf $roots 1535 1536 # Get back to a clean workspace as much as possible to catch 1537 # problems that only occur on fresh workspaces. 1538 # Remove all .make.state* files, libraries, and .o's that may 1539 # have been omitted from clobber. A couple of libraries are 1540 # under source code control, so leave them alone. 1541 # We should probably blow away temporary directories too. 1542 cd $SRC 1543 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 1544 -o -name .git -o -name 'interfaces.*' \) -prune -o \ 1545 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1546 -name '*.o' \) -print | \ 1547 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 1548else 1549 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 1550fi 1551 1552type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1553 typeset -x PATH=$PATH 1554 1555 # If the repository doesn't exist yet, then we want to populate it. 1556 if [[ ! -d $CODEMGR_WS/.hg ]]; then 1557 staffer hg init $CODEMGR_WS 1558 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 1559 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1560 touch $TMPDIR/new_repository 1561 fi 1562 1563 typeset -x HGMERGE="/bin/false" 1564 1565 # 1566 # If the user has changes, regardless of whether those changes are 1567 # committed, and regardless of whether those changes conflict, then 1568 # we'll attempt to merge them either implicitly (uncommitted) or 1569 # explicitly (committed). 1570 # 1571 # These are the messages we'll use to help clarify mercurial output 1572 # in those cases. 1573 # 1574 typeset mergefailmsg="\ 1575***\n\ 1576*** nightly was unable to automatically merge your changes. You should\n\ 1577*** redo the full merge manually, following the steps outlined by mercurial\n\ 1578*** above, then restart nightly.\n\ 1579***\n" 1580 typeset mergepassmsg="\ 1581***\n\ 1582*** nightly successfully merged your changes. This means that your working\n\ 1583*** directory has been updated, but those changes are not yet committed.\n\ 1584*** After nightly completes, you should validate the results of the merge,\n\ 1585*** then use hg commit manually.\n\ 1586***\n" 1587 1588 # 1589 # For each repository in turn: 1590 # 1591 # 1. Do the pull. If this fails, dump the output and bail out. 1592 # 1593 # 2. If the pull resulted in an extra head, do an explicit merge. 1594 # If this fails, dump the output and bail out. 1595 # 1596 # Because we can't rely on Mercurial to exit with a failure code 1597 # when a merge fails (Mercurial issue #186), we must grep the 1598 # output of pull/merge to check for attempted and/or failed merges. 1599 # 1600 # 3. If a merge failed, set the message and fail the bringover. 1601 # 1602 # 4. Otherwise, if a merge succeeded, set the message 1603 # 1604 # 5. Dump the output, and any message from step 3 or 4. 1605 # 1606 1607 typeset HG_SOURCE=$BRINGOVER_WS 1608 if [ ! -f $TMPDIR/new_repository ]; then 1609 HG_SOURCE=$TMPDIR/open_bundle.hg 1610 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1611 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1612 1613 # 1614 # If there are no incoming changesets, then incoming will 1615 # fail, and there will be no bundle file. Reset the source, 1616 # to allow the remaining logic to complete with no false 1617 # negatives. (Unlike incoming, pull will return success 1618 # for the no-change case.) 1619 # 1620 if (( $? != 0 )); then 1621 HG_SOURCE=$BRINGOVER_WS 1622 fi 1623 fi 1624 1625 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 1626 > $TMPDIR/pull_open.out 2>&1 1627 if (( $? != 0 )); then 1628 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 1629 cat $TMPDIR/pull_open.out 1630 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 1631 printf "$mergefailmsg" 1632 fi 1633 touch $TMPDIR/bringover_failed 1634 return 1635 fi 1636 1637 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 1638 staffer hg --cwd $CODEMGR_WS merge \ 1639 >> $TMPDIR/pull_open.out 2>&1 1640 if (( $? != 0 )); then 1641 printf "%s: merge failed as follows:\n\n" \ 1642 "$CODEMGR_WS" 1643 cat $TMPDIR/pull_open.out 1644 if grep "^merging.*failed" $TMPDIR/pull_open.out \ 1645 > /dev/null 2>&1; then 1646 printf "$mergefailmsg" 1647 fi 1648 touch $TMPDIR/bringover_failed 1649 return 1650 fi 1651 fi 1652 1653 printf "updated %s with the following results:\n" "$CODEMGR_WS" 1654 cat $TMPDIR/pull_open.out 1655 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 1656 printf "$mergepassmsg" 1657 fi 1658 printf "\n" 1659 1660 # 1661 # Per-changeset output is neither useful nor manageable for a 1662 # newly-created repository. 1663 # 1664 if [ -f $TMPDIR/new_repository ]; then 1665 return 1666 fi 1667 1668 printf "\nadded the following changesets to open repository:\n" 1669 cat $TMPDIR/incoming_open.out 1670} 1671 1672type bringover_none > /dev/null 2>&1 || function bringover_none { 1673 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1674 touch $TMPDIR/bringover_failed 1675} 1676 1677# 1678# Decide whether to bringover to the codemgr workspace 1679# 1680if [ "$n_FLAG" = "n" ]; then 1681 PARENT_SCM_TYPE=$(parent_wstype) 1682 1683 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1684 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1685 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 1686 exit 1 1687 fi 1688 1689 run_hook PRE_BRINGOVER 1690 1691 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1692 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1693 1694 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 1695 tee -a $mail_msg_file >> $LOGFILE 1696 1697 if [ -f $TMPDIR/bringover_failed ]; then 1698 rm -f $TMPDIR/bringover_failed 1699 build_ok=n 1700 echo "trouble with bringover, quitting at `date`." | 1701 tee -a $mail_msg_file >> $LOGFILE 1702 exit 1 1703 fi 1704 1705 # 1706 # It's possible that we used the bringover above to create 1707 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 1708 # but should now be the same as $BRINGOVER_WS. 1709 # 1710 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 1711 1712 run_hook POST_BRINGOVER 1713 1714 check_closed_bins 1715 1716else 1717 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 1718fi 1719 1720# Safeguards 1721[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 1722[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 1723[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 1724 1725echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 1726 1727# System 1728whence uname | tee -a $build_environ_file >> $LOGFILE 1729uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 1730echo | tee -a $build_environ_file >> $LOGFILE 1731 1732# make 1733whence $MAKE | tee -a $build_environ_file >> $LOGFILE 1734$MAKE -v | tee -a $build_environ_file >> $LOGFILE 1735echo "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1736 tee -a $build_environ_file >> $LOGFILE 1737 1738# 1739# Report the compiler versions. 1740# 1741 1742if [[ ! -f $SRC/Makefile ]]; then 1743 build_ok=n 1744 echo "\nUnable to find \"Makefile\" in $SRC." | \ 1745 tee -a $build_environ_file >> $LOGFILE 1746 exit 1 1747fi 1748 1749( cd $SRC 1750 for target in cc-version cc64-version java-version; do 1751 echo 1752 # 1753 # Put statefile somewhere we know we can write to rather than trip 1754 # over a read-only $srcroot. 1755 # 1756 rm -f $TMPDIR/make-state 1757 export SRC 1758 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1759 continue 1760 fi 1761 touch $TMPDIR/nocompiler 1762 done 1763 echo 1764) | tee -a $build_environ_file >> $LOGFILE 1765 1766if [ -f $TMPDIR/nocompiler ]; then 1767 rm -f $TMPDIR/nocompiler 1768 build_ok=n 1769 echo "Aborting due to missing compiler." | 1770 tee -a $build_environ_file >> $LOGFILE 1771 exit 1 1772fi 1773 1774# as 1775whence as | tee -a $build_environ_file >> $LOGFILE 1776as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 1777echo | tee -a $build_environ_file >> $LOGFILE 1778 1779# Check that we're running a capable link-editor 1780whence ld | tee -a $build_environ_file >> $LOGFILE 1781LDVER=`ld -V 2>&1` 1782echo $LDVER | tee -a $build_environ_file >> $LOGFILE 1783LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 1784if [ `expr $LDVER \< 422` -eq 1 ]; then 1785 echo "The link-editor needs to be at version 422 or higher to build" | \ 1786 tee -a $build_environ_file >> $LOGFILE 1787 echo "the latest stuff. Hope your build works." | \ 1788 tee -a $build_environ_file >> $LOGFILE 1789fi 1790 1791# 1792# Build and use the workspace's tools if requested 1793# 1794if [[ "$t_FLAG" = "y" ]]; then 1795 set_non_debug_build_flags 1796 1797 build_tools ${TOOLS_PROTO} 1798 if (( $? != 0 )); then 1799 build_ok=n 1800 else 1801 use_tools $TOOLS_PROTO 1802 fi 1803fi 1804 1805# timestamp the start of the normal build; the findunref tool uses it. 1806touch $SRC/.build.tstamp 1807 1808normal_build 1809 1810ORIG_SRC=$SRC 1811BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 1812 1813 1814# 1815# There are several checks that need to look at the proto area, but 1816# they only need to look at one, and they don't care whether it's 1817# DEBUG or non-DEBUG. 1818# 1819if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 1820 checkroot=$ROOT-nd 1821else 1822 checkroot=$ROOT 1823fi 1824 1825if [ "$build_ok" = "y" ]; then 1826 echo "\n==== Creating protolist system file at `date` ====" \ 1827 >> $LOGFILE 1828 protolist $checkroot > $ATLOG/proto_list_${MACH} 1829 echo "==== protolist system file created at `date` ====\n" \ 1830 >> $LOGFILE 1831 1832 if [ "$N_FLAG" != "y" ]; then 1833 1834 E1= 1835 f1= 1836 for f in $f1; do 1837 if [ -f "$f" ]; then 1838 E1="$E1 -e $f" 1839 fi 1840 done 1841 1842 E2= 1843 f2= 1844 if [ -d "$SRC/pkg" ]; then 1845 f2="$f2 exceptions/packaging" 1846 fi 1847 1848 for f in $f2; do 1849 if [ -f "$f" ]; then 1850 E2="$E2 -e $f" 1851 fi 1852 done 1853 fi 1854 1855 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 1856 echo "\n==== Validating manifests against proto area ====\n" \ 1857 >> $mail_msg_file 1858 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1859 tee $TMPDIR/protocmp_noise >> $mail_msg_file 1860 if [[ -s $TMPDIR/protocmp_noise ]]; then 1861 build_extras_ok=n 1862 fi 1863 fi 1864 1865 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 1866 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 1867 if [ -n "$E2" ]; then 1868 ELIST=$E2 1869 else 1870 ELIST=$E1 1871 fi 1872 $PROTOCMPTERSE \ 1873 "Files in yesterday's proto area, but not today's:" \ 1874 "Files in today's proto area, but not yesterday's:" \ 1875 "Files that changed between yesterday and today:" \ 1876 ${ELIST} \ 1877 -d $REF_PROTO_LIST \ 1878 $ATLOG/proto_list_${MACH} \ 1879 >> $mail_msg_file 1880 fi 1881fi 1882 1883if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 1884 "$build_extras_ok" == "y" ]]; then 1885 staffer cp $ATLOG/proto_list_${MACH} \ 1886 $PARENT_WS/usr/src/proto_list_${MACH} 1887fi 1888 1889# Update parent proto area if necessary. This is done now 1890# so that the proto area has either DEBUG or non-DEBUG kernels. 1891# Note that this clears out the lock file, so we can dispense with 1892# the variable now. 1893if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 1894 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 1895 tee -a $LOGFILE >> $mail_msg_file 1896 rm -rf $NIGHTLY_PARENT_ROOT/* 1897 unset Ulockfile 1898 mkdir -p $NIGHTLY_PARENT_ROOT 1899 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1900 ( cd $ROOT; tar cf - . | 1901 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 1902 tee -a $mail_msg_file >> $LOGFILE 1903 fi 1904 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 1905 rm -rf $NIGHTLY_PARENT_ROOT-nd/* 1906 mkdir -p $NIGHTLY_PARENT_ROOT-nd 1907 cd $ROOT-nd 1908 ( tar cf - . | 1909 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 1910 tee -a $mail_msg_file >> $LOGFILE 1911 fi 1912 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 1913 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 1914 tee -a $LOGFILE >> $mail_msg_file 1915 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 1916 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 1917 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1918 ( cd $TOOLS_PROTO; tar cf - . | 1919 ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 1920 umask 0; tar xpf - ) ) 2>&1 | 1921 tee -a $mail_msg_file >> $LOGFILE 1922 fi 1923 fi 1924fi 1925 1926# 1927# ELF verification: ABI (-A) and runtime (-r) checks 1928# 1929if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 1930 # Directory ELF-data.$MACH holds the files produced by these tests. 1931 elf_ddir=$SRC/ELF-data.$MACH 1932 1933 # If there is a previous ELF-data backup directory, remove it. Then, 1934 # rotate current ELF-data directory into its place and create a new 1935 # empty directory 1936 rm -rf $elf_ddir.ref 1937 if [[ -d $elf_ddir ]]; then 1938 mv $elf_ddir $elf_ddir.ref 1939 fi 1940 mkdir -p $elf_ddir 1941 1942 # Call find_elf to produce a list of the ELF objects in the proto area. 1943 # This list is passed to check_rtime and interface_check, preventing 1944 # them from separately calling find_elf to do the same work twice. 1945 find_elf -fr $checkroot > $elf_ddir/object_list 1946 1947 if [[ $A_FLAG = y ]]; then 1948 echo "\n==== Check versioning and ABI information ====\n" | \ 1949 tee -a $LOGFILE >> $mail_msg_file 1950 1951 # Produce interface description for the proto. Report errors. 1952 interface_check -o -w $elf_ddir -f object_list \ 1953 -i interface -E interface.err 1954 if [[ -s $elf_ddir/interface.err ]]; then 1955 tee -a $LOGFILE < $elf_ddir/interface.err \ 1956 >> $mail_msg_file 1957 build_extras_ok=n 1958 fi 1959 1960 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 1961 # description file to that from the baseline gate. Issue a 1962 # warning if the baseline is not present, and keep going. 1963 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 1964 base_ifile="$ELF_DATA_BASELINE_DIR/interface" 1965 1966 echo "\n==== Compare versioning and ABI information" \ 1967 "to baseline ====\n" | \ 1968 tee -a $LOGFILE >> $mail_msg_file 1969 echo "Baseline: $base_ifile\n" >> $LOGFILE 1970 1971 if [[ -f $base_ifile ]]; then 1972 interface_cmp -d -o $base_ifile \ 1973 $elf_ddir/interface > $elf_ddir/interface.cmp 1974 if [[ -s $elf_ddir/interface.cmp ]]; then 1975 echo | tee -a $LOGFILE >> $mail_msg_file 1976 tee -a $LOGFILE < \ 1977 $elf_ddir/interface.cmp \ 1978 >> $mail_msg_file 1979 build_extras_ok=n 1980 fi 1981 else 1982 echo "baseline not available. comparison" \ 1983 "skipped" | \ 1984 tee -a $LOGFILE >> $mail_msg_file 1985 fi 1986 1987 fi 1988 fi 1989 1990 if [[ $r_FLAG = y ]]; then 1991 echo "\n==== Check ELF runtime attributes ====\n" | \ 1992 tee -a $LOGFILE >> $mail_msg_file 1993 1994 # If we're doing a DEBUG build the proto area will be left 1995 # with debuggable objects, thus don't assert -s. 1996 if [[ $D_FLAG = y ]]; then 1997 rtime_sflag="" 1998 else 1999 rtime_sflag="-s" 2000 fi 2001 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 2002 -D object_list -f object_list -E runtime.err \ 2003 -I runtime.attr.raw 2004 if (( $? != 0 )); then 2005 build_extras_ok=n 2006 fi 2007 2008 # check_rtime -I output needs to be sorted in order to 2009 # compare it to that from previous builds. 2010 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 2011 rm $elf_ddir/runtime.attr.raw 2012 2013 # Report errors 2014 if [[ -s $elf_ddir/runtime.err ]]; then 2015 tee -a $LOGFILE < $elf_ddir/runtime.err \ 2016 >> $mail_msg_file 2017 build_extras_ok=n 2018 fi 2019 2020 # If there is an ELF-data directory from a previous build, 2021 # then diff the attr files. These files contain information 2022 # about dependencies, versioning, and runpaths. There is some 2023 # overlap with the ABI checking done above, but this also 2024 # flushes out non-ABI interface differences along with the 2025 # other information. 2026 echo "\n==== Diff ELF runtime attributes" \ 2027 "(since last build) ====\n" | \ 2028 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 2029 2030 if [[ -f $elf_ddir.ref/runtime.attr ]]; then 2031 diff $elf_ddir.ref/runtime.attr \ 2032 $elf_ddir/runtime.attr \ 2033 >> $mail_msg_file 2034 fi 2035 fi 2036 2037 # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 2038 if [[ "$u_FLAG" = "y" ]]; then 2039 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 2040 2041 # If parent lacks the ELF-data.$MACH directory, create it 2042 if [[ ! -d $p_elf_ddir ]]; then 2043 staffer mkdir -p $p_elf_ddir 2044 fi 2045 2046 # These files are used asynchronously by other builds for ABI 2047 # verification, as above for the -A option. As such, we require 2048 # the file replacement to be atomic. Copy the data to a temp 2049 # file in the same filesystem and then rename into place. 2050 ( 2051 cd $elf_ddir 2052 for elf_dfile in *; do 2053 staffer cp $elf_dfile \ 2054 ${p_elf_ddir}/${elf_dfile}.new 2055 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 2056 ${p_elf_ddir}/${elf_dfile} 2057 done 2058 ) 2059 fi 2060fi 2061 2062# DEBUG lint of kernel begins 2063 2064if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 2065 if [ "$LINTDIRS" = "" ]; then 2066 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 2067 LINTDIRS="$SRC y" 2068 fi 2069 set $LINTDIRS 2070 while [ $# -gt 0 ]; do 2071 dolint $1 $2; shift; shift 2072 done 2073else 2074 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 2075fi 2076 2077# "make check" begins 2078 2079if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 2080 # remove old check.out 2081 rm -f $SRC/check.out 2082 2083 rm -f $SRC/check-${MACH}.out 2084 cd $SRC 2085 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 2086 >> $LOGFILE 2087 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 2088 2089 grep ":" $SRC/check-${MACH}.out | 2090 egrep -v "Ignoring unknown host" | \ 2091 sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 2092 2093 if [[ -s $TMPDIR/check_errors ]]; then 2094 build_extras_ok=n 2095 fi 2096else 2097 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 2098fi 2099 2100echo "\n==== Find core files ====\n" | \ 2101 tee -a $LOGFILE >> $mail_msg_file 2102 2103find $abssrcdirs -name core -a -type f -exec file {} \; | \ 2104 tee -a $LOGFILE >> $mail_msg_file 2105 2106if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2107 echo "\n==== Diff unreferenced files (since last build) ====\n" \ 2108 | tee -a $LOGFILE >>$mail_msg_file 2109 rm -f $SRC/unref-${MACH}.ref 2110 if [ -f $SRC/unref-${MACH}.out ]; then 2111 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2112 fi 2113 2114 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 2115 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 2116 sort > $SRC/unref-${MACH}.out 2117 2118 if [ ! -f $SRC/unref-${MACH}.ref ]; then 2119 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2120 fi 2121 2122 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 2123fi 2124 2125# Verify that the usual lists of files, such as exception lists, 2126# contain only valid references to files. If the build has failed, 2127# then don't check the proto area. 2128CHECK_PATHS=${CHECK_PATHS:-y} 2129if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 2130 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 2131 >>$mail_msg_file 2132 arg=-b 2133 [ "$build_ok" = y ] && arg= 2134 checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 2135 if [[ -s $SRC/check-paths.out ]]; then 2136 tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 2137 build_extras_ok=n 2138 fi 2139fi 2140 2141abspkg= 2142for d in $abssrcdirs; do 2143 if [ -d "$d/pkg" ]; then 2144 abspkg="$abspkg $d" 2145 fi 2146done 2147 2148if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2149 echo "\n==== Impact on file permissions ====\n" \ 2150 >> $mail_msg_file 2151 2152 if [ -n "$abspkg" ]; then 2153 for d in "$abspkg"; do 2154 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 2155 done 2156 fi 2157fi 2158 2159if [ "$L_FLAG" != "y" -a "$build_ok" = y ]; then 2160 echo "\n==== Linting packages ====\n" | \ 2161 tee -a $LOGFILE >> $mail_msg_file 2162 2163 if [ -n "$abspkg" ]; then 2164 for d in "$abspkg"; do 2165 ( cd $d/pkg ; $MAKE -e pkglint ) | \ 2166 tee -a $LOGFILE | \ 2167 egrep -v 'Lint engine setup|Starting lint run' 2168 done 2>&1 | tee $TMPDIR/pkglint_noise >> $mail_msg_file 2169 if [[ -s $TMPDIR/pkglint_noise ]]; then 2170 build_extras_ok=n 2171 fi 2172 fi 2173fi 2174 2175if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 2176 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 2177 do_wsdiff DEBUG $ROOT.prev $ROOT wsdiff.results 2178 fi 2179 2180 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 2181 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd wsdiff-nd.results 2182 fi 2183 2184 if [[ "$t_FLAG" == "y" ]]; then 2185 do_wsdiff tools $TOOLS_PROTO.prev $TOOLS_PROTO wsdiff-tools.results 2186 fi 2187fi 2188 2189END_DATE=`date` 2190echo "==== Nightly $maketype build completed: $END_DATE ====" | \ 2191 tee -a $LOGFILE >> $build_time_file 2192 2193typeset -i10 hours 2194typeset -Z2 minutes 2195typeset -Z2 seconds 2196 2197elapsed_time=$SECONDS 2198((hours = elapsed_time / 3600 )) 2199((minutes = elapsed_time / 60 % 60)) 2200((seconds = elapsed_time % 60)) 2201 2202echo "\n==== Total build time ====" | \ 2203 tee -a $LOGFILE >> $build_time_file 2204echo "\nreal ${hours}:${minutes}:${seconds}" | \ 2205 tee -a $LOGFILE >> $build_time_file 2206 2207if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2208 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 2209 2210 # 2211 # Produce a master list of unreferenced files -- ideally, we'd 2212 # generate the master just once after all of the nightlies 2213 # have finished, but there's no simple way to know when that 2214 # will be. Instead, we assume that we're the last nightly to 2215 # finish and merge all of the unref-${MACH}.out files in 2216 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 2217 # finish, then this file will be the authoritative master 2218 # list. Otherwise, another ${MACH}'s nightly will eventually 2219 # overwrite ours with its own master, but in the meantime our 2220 # temporary "master" will be no worse than any older master 2221 # which was already on the parent. 2222 # 2223 2224 set -- $PARENT_WS/usr/src/unref-*.out 2225 cp "$1" ${TMPDIR}/unref.merge 2226 shift 2227 2228 for unreffile; do 2229 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 2230 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 2231 done 2232 2233 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 2234fi 2235 2236# 2237# All done save for the sweeping up. 2238# (whichever exit we hit here will trigger the "cleanup" trap which 2239# optionally sends mail on completion). 2240# 2241if [[ "$build_ok" == "y" ]]; then 2242 if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 2243 exit 0 2244 fi 2245fi 2246 2247exit 1 2248