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