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