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