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