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