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