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