15ca82e69SJohn Levon#!/bin/ksh -p 25ca82e69SJohn Levon# 35ca82e69SJohn Levon# CDDL HEADER START 45ca82e69SJohn Levon# 55ca82e69SJohn Levon# The contents of this file are subject to the terms of the 65ca82e69SJohn Levon# Common Development and Distribution License (the "License"). 75ca82e69SJohn Levon# You may not use this file except in compliance with the License. 85ca82e69SJohn Levon# 95ca82e69SJohn Levon# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 105ca82e69SJohn Levon# or http://www.opensolaris.org/os/licensing. 115ca82e69SJohn Levon# See the License for the specific language governing permissions 125ca82e69SJohn Levon# and limitations under the License. 135ca82e69SJohn Levon# 145ca82e69SJohn Levon# When distributing Covered Code, include this CDDL HEADER in each 155ca82e69SJohn Levon# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 165ca82e69SJohn Levon# If applicable, add the following below this CDDL HEADER, with the 175ca82e69SJohn Levon# fields enclosed by brackets "[]" replaced with your own identifying 185ca82e69SJohn Levon# information: Portions Copyright [yyyy] [name of copyright owner] 195ca82e69SJohn Levon# 205ca82e69SJohn Levon# CDDL HEADER END 215ca82e69SJohn Levon# 225ca82e69SJohn Levon 235ca82e69SJohn Levon# 245ca82e69SJohn Levon# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 255ca82e69SJohn Levon# Copyright 2008, 2010, Richard Lowe 263c6ef809SYuri Pankov# Copyright 2022 Tintri by DDN, Inc. All rights reserved. 275ca82e69SJohn Levon# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> 285ca82e69SJohn Levon# Copyright (c) 2017 by Delphix. All rights reserved. 295ca82e69SJohn Levon# Copyright 2020 Joyent, Inc. 305ca82e69SJohn Levon# Copyright 2019 Peter Trible. 316112cec5SJoshua M. Clulow# Copyright 2020 Oxide Computer Company 32069e6b7eSAndy Fiddaman# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 33*053feb15SBill Sommerfeld# Copyright 2025 Bill Sommerfeld <sommerfeld@hamachi.org> 345ca82e69SJohn Levon# 355ca82e69SJohn Levon# Based on the nightly script from the integration folks, 365ca82e69SJohn Levon# Mostly modified and owned by mike_s. 375ca82e69SJohn Levon# Changes also by kjc, dmk. 385ca82e69SJohn Levon# 395ca82e69SJohn Levon# BRINGOVER_WS may be specified in the env file. 405ca82e69SJohn Levon# The default is the old behavior of CLONE_WS 415ca82e69SJohn Levon# 425ca82e69SJohn Levon# -i on the command line, means fast options, so when it's on the 435ca82e69SJohn Levon# command line (only), check builds are skipped no matter what 445ca82e69SJohn Levon# the setting of their individual flags are in NIGHTLY_OPTIONS. 455ca82e69SJohn Levon# 465ca82e69SJohn Levon# OPTHOME may be set in the environment to override /opt 475ca82e69SJohn Levon# 485ca82e69SJohn Levon 495ca82e69SJohn Levon# 505ca82e69SJohn Levon# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 515ca82e69SJohn Levon# under certain circumstances, which can really screw things up; unset it. 525ca82e69SJohn Levon# 535ca82e69SJohn Levonunset CDPATH 545ca82e69SJohn Levon 555ca82e69SJohn Levon# Get the absolute path of the nightly script that the user invoked. This 565ca82e69SJohn Levon# may be a relative path, and we need to do this before changing directory. 575ca82e69SJohn Levonnightly_path=`whence $0` 585ca82e69SJohn Levon 595ca82e69SJohn Levon# 605ca82e69SJohn Levon# Keep track of where we found nightly so we can invoke the matching 615ca82e69SJohn Levon# which_scm script. If that doesn't work, don't go guessing, just rely 625ca82e69SJohn Levon# on the $PATH settings, which will generally give us either /opt/onbld 635ca82e69SJohn Levon# or the user's workspace. 645ca82e69SJohn Levon# 655ca82e69SJohn LevonWHICH_SCM=$(dirname $nightly_path)/which_scm 665ca82e69SJohn Levonif [[ ! -x $WHICH_SCM ]]; then 675ca82e69SJohn Levon WHICH_SCM=which_scm 685ca82e69SJohn Levonfi 695ca82e69SJohn Levon 705ca82e69SJohn Levonfunction fatal_error 715ca82e69SJohn Levon{ 725ca82e69SJohn Levon print -u2 "nightly: $*" 735ca82e69SJohn Levon exit 1 745ca82e69SJohn Levon} 755ca82e69SJohn Levon 765ca82e69SJohn Levon# 775ca82e69SJohn Levon# Function to do a DEBUG and non-DEBUG build. Needed because we might 785ca82e69SJohn Levon# need to do another for the source build, and since we only deliver DEBUG or 795ca82e69SJohn Levon# non-DEBUG packages. 805ca82e69SJohn Levon# 815ca82e69SJohn Levon# usage: normal_build 825ca82e69SJohn Levon# 835ca82e69SJohn Levonfunction normal_build { 845ca82e69SJohn Levon 855ca82e69SJohn Levon typeset orig_p_FLAG="$p_FLAG" 865ca82e69SJohn Levon typeset crypto_signer="$CODESIGN_USER" 875ca82e69SJohn Levon 885ca82e69SJohn Levon suffix="" 895ca82e69SJohn Levon 905ca82e69SJohn Levon # non-DEBUG build begins 915ca82e69SJohn Levon 925ca82e69SJohn Levon if [ "$F_FLAG" = "n" ]; then 935ca82e69SJohn Levon set_non_debug_build_flags 945ca82e69SJohn Levon CODESIGN_USER="$crypto_signer" \ 955ca82e69SJohn Levon build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 965ca82e69SJohn Levon else 975ca82e69SJohn Levon echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 985ca82e69SJohn Levon fi 995ca82e69SJohn Levon 1005ca82e69SJohn Levon # non-DEBUG build ends 1015ca82e69SJohn Levon 1025ca82e69SJohn Levon # DEBUG build begins 1035ca82e69SJohn Levon 1045ca82e69SJohn Levon if [ "$D_FLAG" = "y" ]; then 1055ca82e69SJohn Levon set_debug_build_flags 1065ca82e69SJohn Levon CODESIGN_USER="$crypto_signer" \ 1075ca82e69SJohn Levon build "DEBUG" "$suffix" "" "$MULTI_PROTO" 1085ca82e69SJohn Levon else 1095ca82e69SJohn Levon echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 1105ca82e69SJohn Levon fi 1115ca82e69SJohn Levon 1125ca82e69SJohn Levon # DEBUG build ends 1135ca82e69SJohn Levon 1145ca82e69SJohn Levon p_FLAG="$orig_p_FLAG" 1155ca82e69SJohn Levon} 1165ca82e69SJohn Levon 1175ca82e69SJohn Levon# 1185ca82e69SJohn Levon# usage: run_hook HOOKNAME ARGS... 1195ca82e69SJohn Levon# 1205ca82e69SJohn Levon# If variable "$HOOKNAME" is defined, insert a section header into 1215ca82e69SJohn Levon# our logs and then run the command with ARGS 1225ca82e69SJohn Levon# 1235ca82e69SJohn Levonfunction run_hook { 1245ca82e69SJohn Levon HOOKNAME=$1 1255ca82e69SJohn Levon eval HOOKCMD=\$$HOOKNAME 1265ca82e69SJohn Levon shift 1275ca82e69SJohn Levon 1285ca82e69SJohn Levon if [ -n "$HOOKCMD" ]; then 1295ca82e69SJohn Levon ( 1305ca82e69SJohn Levon echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 1315ca82e69SJohn Levon ( $HOOKCMD "$@" 2>&1 ) 1325ca82e69SJohn Levon if [ "$?" -ne 0 ]; then 1335ca82e69SJohn Levon # Let exit status propagate up 1345ca82e69SJohn Levon touch $TMPDIR/abort 1355ca82e69SJohn Levon fi 1365ca82e69SJohn Levon ) | tee -a $mail_msg_file >> $LOGFILE 1375ca82e69SJohn Levon 1385ca82e69SJohn Levon if [ -f $TMPDIR/abort ]; then 1395ca82e69SJohn Levon build_ok=n 1405ca82e69SJohn Levon echo "\nAborting at request of $HOOKNAME" | 1415ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1425ca82e69SJohn Levon exit 1 1435ca82e69SJohn Levon fi 1445ca82e69SJohn Levon fi 1455ca82e69SJohn Levon} 1465ca82e69SJohn Levon 1475ca82e69SJohn Levon# Return library search directive as function of given root. 1485ca82e69SJohn Levonfunction myldlibs { 1495ca82e69SJohn Levon echo "-L$1/lib -L$1/usr/lib" 1505ca82e69SJohn Levon} 1515ca82e69SJohn Levon 1525ca82e69SJohn Levon# Return header search directive as function of given root. 1535ca82e69SJohn Levonfunction myheaders { 1545ca82e69SJohn Levon echo "-I$1/usr/include" 1555ca82e69SJohn Levon} 1565ca82e69SJohn Levon 1575ca82e69SJohn Levon# 1585ca82e69SJohn Levon# Function to do the build, including package generation. 1595ca82e69SJohn Levon# usage: build LABEL SUFFIX ND MULTIPROTO 1605ca82e69SJohn Levon# - LABEL is used to tag build output. 1615ca82e69SJohn Levon# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 1625ca82e69SJohn Levon# open-only vs full tree). 1635ca82e69SJohn Levon# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 1645ca82e69SJohn Levon# - If MULTIPROTO is "yes", it means to name the proto area according to 1655ca82e69SJohn Levon# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 1665ca82e69SJohn Levon# 1675ca82e69SJohn Levonfunction build { 1685ca82e69SJohn Levon LABEL=$1 1695ca82e69SJohn Levon SUFFIX=$2 1705ca82e69SJohn Levon ND=$3 1715ca82e69SJohn Levon MULTIPROTO=$4 1725ca82e69SJohn Levon INSTALLOG=install${SUFFIX}-${MACH} 1735ca82e69SJohn Levon NOISE=noise${SUFFIX}-${MACH} 1745ca82e69SJohn Levon PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 1755ca82e69SJohn Levon 1765ca82e69SJohn Levon ORIGROOT=$ROOT 1775ca82e69SJohn Levon [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 1785ca82e69SJohn Levon 1795ca82e69SJohn Levon export ENVLDLIBS1=`myldlibs $ROOT` 1805ca82e69SJohn Levon export ENVCPPFLAGS1=`myheaders $ROOT` 1815ca82e69SJohn Levon 1825ca82e69SJohn Levon this_build_ok=y 1835ca82e69SJohn Levon # 1845ca82e69SJohn Levon # Build OS-Networking source 1855ca82e69SJohn Levon # 1865ca82e69SJohn Levon echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 1875ca82e69SJohn Levon >> $LOGFILE 1885ca82e69SJohn Levon 1895ca82e69SJohn Levon rm -f $SRC/${INSTALLOG}.out 1905ca82e69SJohn Levon cd $SRC 1915ca82e69SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 1925ca82e69SJohn Levon tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 1935ca82e69SJohn Levon 1945ca82e69SJohn Levon echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 1955ca82e69SJohn Levon egrep ":" $SRC/${INSTALLOG}.out | 196244a25b4SBill Sommerfeld egrep -e "(^${MAKE}"$':|[\t ]error[:\t ]|ld: guidance:)' | \ 197eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 1985ca82e69SJohn Levon egrep -v "Ignoring unknown host" | \ 1995ca82e69SJohn Levon egrep -v "cc .* -o error " | \ 2005ca82e69SJohn Levon egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 2015ca82e69SJohn Levon >> $mail_msg_file 202244a25b4SBill Sommerfeld sed -n $'/^Undefined[\t ]*first referenced$/,/^ld: fatal:/p' \ 2035ca82e69SJohn Levon < $SRC/${INSTALLOG}.out >> $mail_msg_file 2045ca82e69SJohn Levon if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 2055ca82e69SJohn Levon build_ok=n 2065ca82e69SJohn Levon this_build_ok=n 2075ca82e69SJohn Levon fi 2085ca82e69SJohn Levon grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 2095ca82e69SJohn Levon >> $mail_msg_file 2105ca82e69SJohn Levon if [ "$?" = "0" ]; then 2115ca82e69SJohn Levon build_ok=n 2125ca82e69SJohn Levon this_build_ok=n 2135ca82e69SJohn Levon fi 2145ca82e69SJohn Levon 2155ca82e69SJohn Levon echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 216a56362d6SBill Sommerfeld egrep -i 'warn(ing)?:' $SRC/${INSTALLOG}.out \ 2175ca82e69SJohn Levon | egrep -v '^tic:' \ 2185ca82e69SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 2195ca82e69SJohn Levon | egrep -v "parameter <PSTAMP> set to" \ 2205ca82e69SJohn Levon | egrep -v "Ignoring unknown host" \ 2215ca82e69SJohn Levon | egrep -v "redefining segment flags attribute for" \ 2225ca82e69SJohn Levon | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 2235ca82e69SJohn Levon if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 2245ca82e69SJohn Levon build_ok=n 2255ca82e69SJohn Levon this_build_ok=n 2265ca82e69SJohn Levon fi 2275ca82e69SJohn Levon 2285ca82e69SJohn Levon echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 2295ca82e69SJohn Levon >> $LOGFILE 2305ca82e69SJohn Levon 2315ca82e69SJohn Levon echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 2325ca82e69SJohn Levon tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 2335ca82e69SJohn Levon 2345ca82e69SJohn Levon if [ "$i_FLAG" = "n" ]; then 2355ca82e69SJohn Levon rm -f $SRC/${NOISE}.ref 2365ca82e69SJohn Levon if [ -f $SRC/${NOISE}.out ]; then 2375ca82e69SJohn Levon mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 2385ca82e69SJohn Levon fi 2395ca82e69SJohn Levon grep : $SRC/${INSTALLOG}.out \ 2405ca82e69SJohn Levon | egrep -v '^/' \ 2415ca82e69SJohn Levon | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 2425ca82e69SJohn Levon | egrep -v '^tic:' \ 2435ca82e69SJohn Levon | egrep -v '^mcs' \ 2445ca82e69SJohn Levon | egrep -v '^LD_LIBRARY_PATH=' \ 2455ca82e69SJohn Levon | egrep -v 'ar: creating' \ 2465ca82e69SJohn Levon | egrep -v 'ar: writing' \ 2475ca82e69SJohn Levon | egrep -v 'conflicts:' \ 2485ca82e69SJohn Levon | egrep -v ':saved created' \ 2495ca82e69SJohn Levon | egrep -v '^stty.*c:' \ 2505ca82e69SJohn Levon | egrep -v '^mfgname.c:' \ 2515ca82e69SJohn Levon | egrep -v '^uname-i.c:' \ 2525ca82e69SJohn Levon | egrep -v '^volumes.c:' \ 2535ca82e69SJohn Levon | egrep -v '^lint library construction:' \ 2545ca82e69SJohn Levon | egrep -v 'tsort: INFORM:' \ 2555ca82e69SJohn Levon | egrep -v 'stripalign:' \ 2565ca82e69SJohn Levon | egrep -v 'chars, width' \ 2575ca82e69SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 2585ca82e69SJohn Levon | egrep -v 'PSTAMP' \ 2595ca82e69SJohn Levon | egrep -v '^Manifying' \ 2605ca82e69SJohn Levon | egrep -v 'Ignoring unknown host' \ 2615ca82e69SJohn Levon | egrep -v 'Processing method:' \ 2625ca82e69SJohn Levon | egrep -v '^Writing' \ 2635ca82e69SJohn Levon | egrep -v 'spellin1:' \ 2645ca82e69SJohn Levon | egrep -v '^adding:' \ 2655ca82e69SJohn Levon | egrep -v "^echo 'msgid" \ 2665ca82e69SJohn Levon | egrep -v '^echo ' \ 2675ca82e69SJohn Levon | egrep -v '\.c:$' \ 2685ca82e69SJohn Levon | egrep -v '^Adding file:' \ 2695ca82e69SJohn Levon | egrep -v 'CLASSPATH=' \ 2705ca82e69SJohn Levon | egrep -v '\/var\/mail\/:saved' \ 2715ca82e69SJohn Levon | egrep -v -- '-DUTS_VERSION=' \ 2725ca82e69SJohn Levon | egrep -v '^Running Mkbootstrap' \ 2735ca82e69SJohn Levon | egrep -v '^Applet length read:' \ 2745ca82e69SJohn Levon | egrep -v 'bytes written:' \ 2755ca82e69SJohn Levon | egrep -v '^File:SolarisAuthApplet.bin' \ 2765ca82e69SJohn Levon | egrep -v -i 'jibversion' \ 2775ca82e69SJohn Levon | egrep -v '^Output size:' \ 2785ca82e69SJohn Levon | egrep -v '^Solo size statistics:' \ 2795ca82e69SJohn Levon | egrep -v '^Using ROM API Version' \ 2805ca82e69SJohn Levon | egrep -v '^Zero Signature length:' \ 2815ca82e69SJohn Levon | egrep -v '^Note \(probably harmless\):' \ 2825ca82e69SJohn Levon | egrep -v '::' \ 2835ca82e69SJohn Levon | egrep -v '^\+' \ 2845ca82e69SJohn Levon | egrep -v 'svccfg-native -s svc:/' \ 285eefeb0ceSBill Sommerfeld | egrep -v ": (Entering|Leaving) directory " \ 2865ca82e69SJohn Levon | sort | uniq >$SRC/${NOISE}.out 2875ca82e69SJohn Levon if [ ! -f $SRC/${NOISE}.ref ]; then 2885ca82e69SJohn Levon cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 2895ca82e69SJohn Levon fi 2905ca82e69SJohn Levon echo "\n==== Build noise differences ($LABEL) ====\n" \ 2915ca82e69SJohn Levon >>$mail_msg_file 2925ca82e69SJohn Levon diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 2935ca82e69SJohn Levon fi 2945ca82e69SJohn Levon 2955ca82e69SJohn Levon # 2965ca82e69SJohn Levon # Re-sign selected binaries using signing server 2975ca82e69SJohn Levon # (gatekeeper builds only) 2985ca82e69SJohn Levon # 2995ca82e69SJohn Levon if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 3005ca82e69SJohn Levon echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 3015ca82e69SJohn Levon signing_file="${TMPDIR}/signing" 3025ca82e69SJohn Levon rm -f ${signing_file} 3035ca82e69SJohn Levon export CODESIGN_USER 3045ca82e69SJohn Levon signproto $SRC/tools/codesign/creds 2>&1 | \ 3055ca82e69SJohn Levon tee -a ${signing_file} >> $LOGFILE 3065ca82e69SJohn Levon echo "\n==== Finished signing proto area at `date` ====\n" \ 3075ca82e69SJohn Levon >> $LOGFILE 3085ca82e69SJohn Levon echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 3095ca82e69SJohn Levon >> $mail_msg_file 3105ca82e69SJohn Levon egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 3115ca82e69SJohn Levon if (( $? == 0 )) ; then 3125ca82e69SJohn Levon build_ok=n 3135ca82e69SJohn Levon this_build_ok=n 3145ca82e69SJohn Levon fi 3155ca82e69SJohn Levon fi 3165ca82e69SJohn Levon 3175ca82e69SJohn Levon # 3185ca82e69SJohn Levon # Building Packages 3195ca82e69SJohn Levon # 3205ca82e69SJohn Levon if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 3215ca82e69SJohn Levon if [ -d $SRC/pkg ]; then 3225ca82e69SJohn Levon echo "\n==== Creating $LABEL packages at `date` ====\n" \ 3235ca82e69SJohn Levon >> $LOGFILE 3245ca82e69SJohn Levon echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 3255ca82e69SJohn Levon rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 3265ca82e69SJohn Levon mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 3275ca82e69SJohn Levon 3285ca82e69SJohn Levon rm -f $SRC/pkg/${INSTALLOG}.out 3295ca82e69SJohn Levon cd $SRC/pkg 3305ca82e69SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 3315ca82e69SJohn Levon tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 3325ca82e69SJohn Levon 3335ca82e69SJohn Levon echo "\n==== package build errors ($LABEL) ====\n" \ 3345ca82e69SJohn Levon >> $mail_msg_file 3355ca82e69SJohn Levon 3365ca82e69SJohn Levon egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 3375ca82e69SJohn Levon grep ':' | \ 3385ca82e69SJohn Levon grep -v PSTAMP | \ 339*053feb15SBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 3405ca82e69SJohn Levon egrep -v "Ignoring unknown host" | \ 3415ca82e69SJohn Levon tee $TMPDIR/package >> $mail_msg_file 3425ca82e69SJohn Levon if [[ -s $TMPDIR/package ]]; then 3435ca82e69SJohn Levon build_extras_ok=n 3445ca82e69SJohn Levon this_build_ok=n 3455ca82e69SJohn Levon fi 3465ca82e69SJohn Levon else 3475ca82e69SJohn Levon # 3485ca82e69SJohn Levon # Handle it gracefully if -p was set but there so 3495ca82e69SJohn Levon # no pkg directory. 3505ca82e69SJohn Levon # 3515ca82e69SJohn Levon echo "\n==== No $LABEL packages to build ====\n" \ 3525ca82e69SJohn Levon >> $LOGFILE 3535ca82e69SJohn Levon fi 3545ca82e69SJohn Levon else 3555ca82e69SJohn Levon echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 3565ca82e69SJohn Levon fi 3575ca82e69SJohn Levon 3585ca82e69SJohn Levon ROOT=$ORIGROOT 3595ca82e69SJohn Levon} 3605ca82e69SJohn Levon 3615ca82e69SJohn Levon# 3625ca82e69SJohn Levon# Bootstrap build tools which are pre-requisites for the rest of the build. 3635ca82e69SJohn Levon# 3645ca82e69SJohn Levonfunction bootstrap_tools { 3655ca82e69SJohn Levon echo "\n==== Bootstrapping tools at `date` ====\n" >> $LOGFILE 3665ca82e69SJohn Levon 3675ca82e69SJohn Levon typeset INSTALLOG=install-bootstrap-${MACH} 3685ca82e69SJohn Levon 3695ca82e69SJohn Levon rm -f $TMPDIR/make-state ${TOOLS}/$INSTALLOG.out 3705ca82e69SJohn Levon cd ${TOOLS} 3715ca82e69SJohn Levon /bin/time $MAKE -K $TMPDIR/make-state -e TARGET=install bootstrap \ 3725ca82e69SJohn Levon 2>&1 | tee -a ${TOOLS}/$INSTALLOG.out >> $LOGFILE 3735ca82e69SJohn Levon 3745ca82e69SJohn Levon echo "\n==== Bootstrap build errors ====\n" >> $mail_msg_file 3755ca82e69SJohn Levon 3765ca82e69SJohn Levon egrep ":" ${TOOLS}/$INSTALLOG.out | 377244a25b4SBill Sommerfeld egrep -e "(${MAKE}"$':|[\t ]error[:\t ])' | \ 378eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 3795ca82e69SJohn Levon egrep -v warning | tee $TMPDIR/bootstrap_errors >> $mail_msg_file 3805ca82e69SJohn Levon 3815ca82e69SJohn Levon [[ -s $TMPDIR/bootstrap_errors ]] && return 1 3825ca82e69SJohn Levon return 0 3835ca82e69SJohn Levon} 3845ca82e69SJohn Levon 3855ca82e69SJohn Levon# 3866faa6645SYuri Pankov# Build and install the tools. 3875ca82e69SJohn Levon# 3885ca82e69SJohn Levon# usage: build_tools DESTROOT 3895ca82e69SJohn Levon# 3906faa6645SYuri Pankov# returns zero status if the build was successful. 3915ca82e69SJohn Levon# 3925ca82e69SJohn Levonfunction build_tools { 3935ca82e69SJohn Levon DESTROOT=$1 3945ca82e69SJohn Levon 3955ca82e69SJohn Levon INSTALLOG=install-${MACH} 3965ca82e69SJohn Levon 3975ca82e69SJohn Levon echo "\n==== Building tools at `date` ====\n" \ 3985ca82e69SJohn Levon >> $LOGFILE 3995ca82e69SJohn Levon 4005ca82e69SJohn Levon rm -f ${TOOLS}/${INSTALLOG}.out 4015ca82e69SJohn Levon cd ${TOOLS} 4025ca82e69SJohn Levon /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 4035ca82e69SJohn Levon tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 4045ca82e69SJohn Levon 4055ca82e69SJohn Levon echo "\n==== Tools build errors ====\n" >> $mail_msg_file 4065ca82e69SJohn Levon 4075ca82e69SJohn Levon egrep ":" ${TOOLS}/${INSTALLOG}.out | 408244a25b4SBill Sommerfeld egrep -e "(${MAKE}"$':|[\t ]error[:\t ])' | \ 409eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 4105ca82e69SJohn Levon egrep -v "Ignoring unknown host" | \ 4115ca82e69SJohn Levon egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 4125ca82e69SJohn Levon 4135ca82e69SJohn Levon if [[ -s $TMPDIR/tools_errors ]]; then 4145ca82e69SJohn Levon return 1 4155ca82e69SJohn Levon fi 4165ca82e69SJohn Levon return 0 4175ca82e69SJohn Levon} 4185ca82e69SJohn Levon 4195ca82e69SJohn Levonfunction staffer { 4205ca82e69SJohn Levon if [ $ISUSER -ne 0 ]; then 4215ca82e69SJohn Levon "$@" 4225ca82e69SJohn Levon else 4235ca82e69SJohn Levon arg="\"$1\"" 4245ca82e69SJohn Levon shift 4255ca82e69SJohn Levon for i 4265ca82e69SJohn Levon do 4275ca82e69SJohn Levon arg="$arg \"$i\"" 4285ca82e69SJohn Levon done 4295ca82e69SJohn Levon eval su $STAFFER -c \'$arg\' 4305ca82e69SJohn Levon fi 4315ca82e69SJohn Levon} 4325ca82e69SJohn Levon 4335ca82e69SJohn Levon# 4345ca82e69SJohn Levon# Verify that the closed bins are present 4355ca82e69SJohn Levon# 4365ca82e69SJohn Levonfunction check_closed_bins { 4375ca82e69SJohn Levon if [[ -n "$ON_CLOSED_BINS" && ! -d "$ON_CLOSED_BINS" ]]; then 4385ca82e69SJohn Levon echo "ON_CLOSED_BINS must point to the closed binaries tree." 4395ca82e69SJohn Levon build_ok=n 4405ca82e69SJohn Levon exit 1 4415ca82e69SJohn Levon fi 4425ca82e69SJohn Levon} 4435ca82e69SJohn Levon 4445ca82e69SJohn Levon# 4455ca82e69SJohn Levon# wrapper over wsdiff. 4465ca82e69SJohn Levon# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 4475ca82e69SJohn Levon# 4485ca82e69SJohn Levonfunction do_wsdiff { 4495ca82e69SJohn Levon label=$1 4505ca82e69SJohn Levon oldproto=$2 4515ca82e69SJohn Levon newproto=$3 4525ca82e69SJohn Levon 4535ca82e69SJohn Levon wsdiff="wsdiff" 4545ca82e69SJohn Levon [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 4555ca82e69SJohn Levon 4565ca82e69SJohn Levon echo "\n==== Getting object changes since last build at `date`" \ 4575ca82e69SJohn Levon "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 4585ca82e69SJohn Levon $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 4595ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 4605ca82e69SJohn Levon echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 4615ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 4625ca82e69SJohn Levon} 4635ca82e69SJohn Levon 4645ca82e69SJohn Levon# 4655ca82e69SJohn Levon# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 4665ca82e69SJohn Levon# together. 4675ca82e69SJohn Levon# 4685ca82e69SJohn Levon 4695ca82e69SJohn Levonfunction set_non_debug_build_flags { 4705ca82e69SJohn Levon export RELEASE_BUILD ; RELEASE_BUILD= 4715ca82e69SJohn Levon unset EXTRA_OPTIONS 4725ca82e69SJohn Levon unset EXTRA_CFLAGS 4735ca82e69SJohn Levon if [ -n "$RELEASE_CONSOLE_COLOR" ]; then 4745ca82e69SJohn Levon export DEFAULT_CONSOLE_COLOR="$RELEASE_CONSOLE_COLOR" 4755ca82e69SJohn Levon fi 4765ca82e69SJohn Levon} 4775ca82e69SJohn Levon 4785ca82e69SJohn Levonfunction set_debug_build_flags { 4795ca82e69SJohn Levon unset RELEASE_BUILD 4805ca82e69SJohn Levon unset EXTRA_OPTIONS 4815ca82e69SJohn Levon unset EXTRA_CFLAGS 4825ca82e69SJohn Levon 4835ca82e69SJohn Levon if [ -n "$DEBUG_CONSOLE_COLOR" ]; then 4845ca82e69SJohn Levon export DEFAULT_CONSOLE_COLOR="$DEBUG_CONSOLE_COLOR" 4855ca82e69SJohn Levon fi 4865ca82e69SJohn Levon} 4875ca82e69SJohn Levon 4885ca82e69SJohn Levon 4895ca82e69SJohn LevonMACH=`uname -p` 4905ca82e69SJohn Levon 4915ca82e69SJohn Levonif [ "$OPTHOME" = "" ]; then 4925ca82e69SJohn Levon OPTHOME=/opt 4935ca82e69SJohn Levon export OPTHOME 4945ca82e69SJohn Levonfi 4955ca82e69SJohn Levon 496e49b90fbSBill SommerfeldUSAGE='Usage: nightly [-in] [+t] [-B WS] [-b BR] [-d WS] [-V VERS] <env_file> 4975ca82e69SJohn Levon 4985ca82e69SJohn LevonWhere: 4995ca82e69SJohn Levon -i Fast incremental options (no clobber, check) 5005ca82e69SJohn Levon -n Do not do a bringover 5015ca82e69SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 502e49b90fbSBill Sommerfeld -B WS bringover from WS (directory or URL) 503e49b90fbSBill Sommerfeld -b BR bringover branch BR 504e49b90fbSBill Sommerfeld -d WS do build in WS (directory) 5055ca82e69SJohn Levon -V VERS set the build version string to VERS 5065ca82e69SJohn Levon 5075ca82e69SJohn Levon <env_file> file in Bourne shell syntax that sets and exports 5085ca82e69SJohn Levon variables that configure the operation of this script and many of 5095ca82e69SJohn Levon the scripts this one calls. If <env_file> does not exist, 5105ca82e69SJohn Levon it will be looked for in $OPTHOME/onbld/env. 5115ca82e69SJohn Levon 512e49b90fbSBill Sommerfeldnon-DEBUG is the default build type. Build options must be set in the 5135ca82e69SJohn LevonNIGHTLY_OPTIONS variable in the <env_file> as follows: 5145ca82e69SJohn Levon 5155ca82e69SJohn Levon -A check for ABI differences in .so files 5165ca82e69SJohn Levon -C check for cstyle/hdrchk errors 5175ca82e69SJohn Levon -D do a build with DEBUG on 5185ca82e69SJohn Levon -F do _not_ do a non-DEBUG build 5195ca82e69SJohn Levon -G gate keeper default group of options (-au) 5205ca82e69SJohn Levon -I integration engineer default group of options (-ampu) 521069e6b7eSAndy Fiddaman -L do not run pkglint 5225ca82e69SJohn Levon -M do not run pmodes (safe file permission checker) 5235ca82e69SJohn Levon -N do not run protocmp 5245ca82e69SJohn Levon -R default group of options for building a release (-mp) 5255ca82e69SJohn Levon -U update proto area in the parent 5265ca82e69SJohn Levon -V VERS set the build version string to VERS 5275ca82e69SJohn Levon -f find unreferenced files 5285ca82e69SJohn Levon -i do an incremental build (no "make clobber") 5295ca82e69SJohn Levon -m send mail to $MAILTO at end of build 5305ca82e69SJohn Levon -n do not do a bringover 5315ca82e69SJohn Levon -p create packages 5325ca82e69SJohn Levon -r check ELF runtime attributes in the proto area 5335ca82e69SJohn Levon -t build and use the tools in $SRC/tools (default setting) 5345ca82e69SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 5355ca82e69SJohn Levon -u update proto_list_$MACH and friends in the parent workspace; 5365ca82e69SJohn Levon when used with -f, also build an unrefmaster.out in the parent 5375ca82e69SJohn Levon -w report on differences between previous and current proto areas 5385ca82e69SJohn Levon' 5395ca82e69SJohn Levon# 5405ca82e69SJohn Levon# A log file will be generated under the name $LOGFILE 5415ca82e69SJohn Levon# for partially completed build and log.`date '+%F'` 5425ca82e69SJohn Levon# in the same directory for fully completed builds. 5435ca82e69SJohn Levon# 5445ca82e69SJohn Levon 5455ca82e69SJohn Levon# default values for low-level FLAGS; G I R are group FLAGS 5465ca82e69SJohn LevonA_FLAG=n 5475ca82e69SJohn LevonC_FLAG=n 5485ca82e69SJohn LevonD_FLAG=n 5495ca82e69SJohn LevonF_FLAG=n 5505ca82e69SJohn Levonf_FLAG=n 5515ca82e69SJohn Levoni_FLAG=n; i_CMD_LINE_FLAG=n 552069e6b7eSAndy FiddamanL_FLAG=n 5535ca82e69SJohn LevonM_FLAG=n 5545ca82e69SJohn Levonm_FLAG=n 5555ca82e69SJohn LevonN_FLAG=n 5565ca82e69SJohn Levonn_FLAG=n 5575ca82e69SJohn Levonp_FLAG=n 5585ca82e69SJohn Levonr_FLAG=n 5595ca82e69SJohn Levont_FLAG=y 5605ca82e69SJohn LevonU_FLAG=n 5615ca82e69SJohn Levonu_FLAG=n 5625ca82e69SJohn LevonV_FLAG=n 5635ca82e69SJohn Levonw_FLAG=n 5645ca82e69SJohn LevonW_FLAG=n 5655ca82e69SJohn Levon# 5665ca82e69SJohn Levonbuild_ok=y 5675ca82e69SJohn Levonbuild_extras_ok=y 5685ca82e69SJohn Levon 5695ca82e69SJohn Levon# 5705ca82e69SJohn Levon# examine arguments 5715ca82e69SJohn Levon# 5725ca82e69SJohn Levon 5735ca82e69SJohn LevonOPTIND=1 574e49b90fbSBill Sommerfeldwhile getopts +b:B:d:intV:W FLAG 5755ca82e69SJohn Levondo 5765ca82e69SJohn Levon case $FLAG in 577e49b90fbSBill Sommerfeld b ) BRINGOVER_BRANCH="$OPTARG" 578e49b90fbSBill Sommerfeld ;; 579e49b90fbSBill Sommerfeld B ) BRINGOVER_WS="$OPTARG" 580e49b90fbSBill Sommerfeld ;; 581e49b90fbSBill Sommerfeld d ) CODEMGR_WS="$OPTARG" 582e49b90fbSBill Sommerfeld ;; 5835ca82e69SJohn Levon i ) i_FLAG=y; i_CMD_LINE_FLAG=y 5845ca82e69SJohn Levon ;; 5855ca82e69SJohn Levon n ) n_FLAG=y 5865ca82e69SJohn Levon ;; 5875ca82e69SJohn Levon +t ) t_FLAG=n 5885ca82e69SJohn Levon ;; 5895ca82e69SJohn Levon V ) V_FLAG=y 5905ca82e69SJohn Levon V_ARG="$OPTARG" 5915ca82e69SJohn Levon ;; 5925ca82e69SJohn Levon W ) W_FLAG=y 5935ca82e69SJohn Levon ;; 5945ca82e69SJohn Levon \? ) echo "$USAGE" 5955ca82e69SJohn Levon exit 1 5965ca82e69SJohn Levon ;; 5975ca82e69SJohn Levon esac 5985ca82e69SJohn Levondone 5995ca82e69SJohn Levon 6005ca82e69SJohn Levon# correct argument count after options 6015ca82e69SJohn Levonshift `expr $OPTIND - 1` 6025ca82e69SJohn Levon 6035ca82e69SJohn Levon# test that the path to the environment-setting file was given 6045ca82e69SJohn Levonif [ $# -ne 1 ]; then 6055ca82e69SJohn Levon echo "$USAGE" 6065ca82e69SJohn Levon exit 1 6075ca82e69SJohn Levonfi 6085ca82e69SJohn Levon 6095ca82e69SJohn Levon# check if user is running nightly as root 6105ca82e69SJohn Levon# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 6115ca82e69SJohn Levon# when root invokes nightly. 6125ca82e69SJohn Levon/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 6135ca82e69SJohn LevonISUSER=$?; export ISUSER 6145ca82e69SJohn Levon 6155ca82e69SJohn Levon# 6165ca82e69SJohn Levon# force locale to C 6175ca82e69SJohn LevonLANG=C; export LANG 6185ca82e69SJohn LevonLC_ALL=C; export LC_ALL 6195ca82e69SJohn LevonLC_COLLATE=C; export LC_COLLATE 6205ca82e69SJohn LevonLC_CTYPE=C; export LC_CTYPE 6215ca82e69SJohn LevonLC_MESSAGES=C; export LC_MESSAGES 6225ca82e69SJohn LevonLC_MONETARY=C; export LC_MONETARY 6235ca82e69SJohn LevonLC_NUMERIC=C; export LC_NUMERIC 6245ca82e69SJohn LevonLC_TIME=C; export LC_TIME 6255ca82e69SJohn Levon 6265ca82e69SJohn Levon# clear environment variables we know to be bad for the build 6275ca82e69SJohn Levonunset LD_OPTIONS 6285ca82e69SJohn Levonunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 6295ca82e69SJohn Levonunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 6305ca82e69SJohn Levonunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 6315ca82e69SJohn Levonunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 6325ca82e69SJohn Levonunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 6335ca82e69SJohn Levonunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 6345ca82e69SJohn Levonunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 6355ca82e69SJohn Levonunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 6365ca82e69SJohn Levonunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 6375ca82e69SJohn Levonunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 6385ca82e69SJohn Levonunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 6395ca82e69SJohn Levonunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 6405ca82e69SJohn Levonunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 6415ca82e69SJohn Levonunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 6425ca82e69SJohn Levonunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 6435ca82e69SJohn Levonunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 6445ca82e69SJohn Levonunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 6455ca82e69SJohn Levonunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 6465ca82e69SJohn Levonunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 6475ca82e69SJohn Levonunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 6485ca82e69SJohn Levon 6495ca82e69SJohn Levonunset CONFIG 6505ca82e69SJohn Levonunset GROUP 6515ca82e69SJohn Levonunset OWNER 6525ca82e69SJohn Levonunset REMOTE 6535ca82e69SJohn Levonunset ENV 6545ca82e69SJohn Levonunset ARCH 6555ca82e69SJohn Levonunset CLASSPATH 6565ca82e69SJohn Levonunset NAME 6575ca82e69SJohn Levon 6585ca82e69SJohn Levon# 6595ca82e69SJohn Levon# To get ONBLD_TOOLS from the environment, it must come from the env file. 6605ca82e69SJohn Levon# If it comes interactively, it is generally TOOLS_PROTO, which will be 6615ca82e69SJohn Levon# clobbered before the compiler version checks, which will therefore fail. 6625ca82e69SJohn Levon# 6635ca82e69SJohn Levonunset ONBLD_TOOLS 6645ca82e69SJohn Levon 6655ca82e69SJohn Levon# 6665ca82e69SJohn Levon# Setup environmental variables 6675ca82e69SJohn Levon# 6685ca82e69SJohn Levonif [ -f /etc/nightly.conf ]; then 6695ca82e69SJohn Levon . /etc/nightly.conf 6705ca82e69SJohn Levonfi 6715ca82e69SJohn Levon 6725ca82e69SJohn Levonif [ -f $1 ]; then 67326e7d9a8SRichard Lowe if [[ $1 == */* ]]; then 6745ca82e69SJohn Levon . $1 6755ca82e69SJohn Levon else 6765ca82e69SJohn Levon . ./$1 6775ca82e69SJohn Levon fi 6785ca82e69SJohn Levonelse 6795ca82e69SJohn Levon if [ -f $OPTHOME/onbld/env/$1 ]; then 6805ca82e69SJohn Levon . $OPTHOME/onbld/env/$1 6815ca82e69SJohn Levon else 6825ca82e69SJohn Levon echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 6835ca82e69SJohn Levon exit 1 6845ca82e69SJohn Levon fi 6855ca82e69SJohn Levonfi 6865ca82e69SJohn Levon 6875ca82e69SJohn Levon# Check if we have sufficient data to continue... 6885ca82e69SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 6895ca82e69SJohn Levonif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 6905ca82e69SJohn Levon # Check if the gate data are valid if we don't do a "bringover" below 6915ca82e69SJohn Levon [[ -d "${CODEMGR_WS}" ]] || \ 6925ca82e69SJohn Levon fatal_error "Error: ${CODEMGR_WS} is not a directory." 6935ca82e69SJohn Levon [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 6945ca82e69SJohn Levon fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 6955ca82e69SJohn Levonfi 6965ca82e69SJohn Levon 6975ca82e69SJohn Levon# 6985ca82e69SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set. 6995ca82e69SJohn Levon# 7005ca82e69SJohn Levonif [ -z "$BUILD_PROJECT" ]; then 7015ca82e69SJohn Levon /usr/bin/newtask -c $$ 7025ca82e69SJohn Levonelse 7035ca82e69SJohn Levon /usr/bin/newtask -c $$ -p $BUILD_PROJECT 7045ca82e69SJohn Levonfi 7055ca82e69SJohn Levon 7065ca82e69SJohn Levonps -o taskid= -p $$ | read build_taskid 7075ca82e69SJohn Levonps -o project= -p $$ | read build_project 7085ca82e69SJohn Levon 7095ca82e69SJohn Levon# 7105ca82e69SJohn Levon# See if NIGHTLY_OPTIONS is set 7115ca82e69SJohn Levon# 7125ca82e69SJohn Levonif [ "$NIGHTLY_OPTIONS" = "" ]; then 713e49b90fbSBill Sommerfeld print -u2 "NIGHTLY_OPTIONS must be set in environment file" 714e49b90fbSBill Sommerfeld echo "$USAGE" 715e49b90fbSBill Sommerfeld exit 1 7165ca82e69SJohn Levonfi 7175ca82e69SJohn Levon 7185ca82e69SJohn Levon# 7195ca82e69SJohn Levon# If BRINGOVER_WS was not specified, let it default to CLONE_WS 7205ca82e69SJohn Levon# 7215ca82e69SJohn Levonif [ "$BRINGOVER_WS" = "" ]; then 7225ca82e69SJohn Levon BRINGOVER_WS=$CLONE_WS 7235ca82e69SJohn Levonfi 7245ca82e69SJohn Levon 725fc8c3a51SBill Sommerfeldif [ "$BRINGOVER_REMOTE" = "" ]; then 726fc8c3a51SBill Sommerfeld BRINGOVER_REMOTE=nightly_bringover_ws 727fc8c3a51SBill Sommerfeldfi 728fc8c3a51SBill Sommerfeld 729fc8c3a51SBill Sommerfeldif [ "$BRINGOVER_SCM" = "" ]; then 730fc8c3a51SBill Sommerfeld BRINGOVER_SCM=git 7315ca82e69SJohn Levonfi 7325ca82e69SJohn Levon 7335ca82e69SJohn Levoncheck_closed_bins 7345ca82e69SJohn Levon 7355ca82e69SJohn Levon# 7365ca82e69SJohn Levon# Note: changes to the option letters here should also be applied to the 7375ca82e69SJohn Levon# bldenv script. `d' is listed for backward compatibility. 7385ca82e69SJohn Levon# 7395ca82e69SJohn LevonNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 7405ca82e69SJohn LevonOPTIND=1 741069e6b7eSAndy Fiddamanwhile getopts +ABCDdFfGIiLMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 7425ca82e69SJohn Levondo 7435ca82e69SJohn Levon case $FLAG in 7445ca82e69SJohn Levon A ) A_FLAG=y 7455ca82e69SJohn Levon ;; 7465ca82e69SJohn Levon B ) D_FLAG=y 7475ca82e69SJohn Levon ;; # old version of D 7485ca82e69SJohn Levon C ) C_FLAG=y 7495ca82e69SJohn Levon ;; 7505ca82e69SJohn Levon D ) D_FLAG=y 7515ca82e69SJohn Levon ;; 7525ca82e69SJohn Levon F ) F_FLAG=y 7535ca82e69SJohn Levon ;; 7545ca82e69SJohn Levon f ) f_FLAG=y 7555ca82e69SJohn Levon ;; 7565ca82e69SJohn Levon G ) u_FLAG=y 7575ca82e69SJohn Levon ;; 7585ca82e69SJohn Levon I ) m_FLAG=y 7595ca82e69SJohn Levon p_FLAG=y 7605ca82e69SJohn Levon u_FLAG=y 7615ca82e69SJohn Levon ;; 7625ca82e69SJohn Levon i ) i_FLAG=y 7635ca82e69SJohn Levon ;; 764069e6b7eSAndy Fiddaman L ) L_FLAG=y 765069e6b7eSAndy Fiddaman ;; 7665ca82e69SJohn Levon M ) M_FLAG=y 7675ca82e69SJohn Levon ;; 7685ca82e69SJohn Levon m ) m_FLAG=y 7695ca82e69SJohn Levon ;; 7705ca82e69SJohn Levon N ) N_FLAG=y 7715ca82e69SJohn Levon ;; 7725ca82e69SJohn Levon n ) n_FLAG=y 7735ca82e69SJohn Levon ;; 7745ca82e69SJohn Levon p ) p_FLAG=y 7755ca82e69SJohn Levon ;; 7765ca82e69SJohn Levon R ) m_FLAG=y 7775ca82e69SJohn Levon p_FLAG=y 7785ca82e69SJohn Levon ;; 7795ca82e69SJohn Levon r ) r_FLAG=y 7805ca82e69SJohn Levon ;; 7815ca82e69SJohn Levon +t ) t_FLAG=n 7825ca82e69SJohn Levon ;; 7835ca82e69SJohn Levon U ) if [ -z "${PARENT_ROOT}" ]; then 7845ca82e69SJohn Levon echo "PARENT_ROOT must be set if the U flag is" \ 7855ca82e69SJohn Levon "present in NIGHTLY_OPTIONS." 7865ca82e69SJohn Levon exit 1 7875ca82e69SJohn Levon fi 7885ca82e69SJohn Levon NIGHTLY_PARENT_ROOT=$PARENT_ROOT 7895ca82e69SJohn Levon if [ -n "${PARENT_TOOLS_ROOT}" ]; then 7905ca82e69SJohn Levon NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 7915ca82e69SJohn Levon fi 7925ca82e69SJohn Levon U_FLAG=y 7935ca82e69SJohn Levon ;; 7945ca82e69SJohn Levon u ) u_FLAG=y 7955ca82e69SJohn Levon ;; 7965ca82e69SJohn Levon w ) w_FLAG=y 7975ca82e69SJohn Levon ;; 7985ca82e69SJohn Levon W ) W_FLAG=y 7995ca82e69SJohn Levon ;; 8005ca82e69SJohn Levon \? ) echo "$USAGE" 8015ca82e69SJohn Levon exit 1 8025ca82e69SJohn Levon ;; 8035ca82e69SJohn Levon esac 8045ca82e69SJohn Levondone 8055ca82e69SJohn Levon 8069cc2e6acSMatt Fiddaman# Skip pkglint if packages aren't being built 8079cc2e6acSMatt Fiddaman[ $p_FLAG = n ] && L_FLAG=y 8089cc2e6acSMatt Fiddaman 8095ca82e69SJohn Levonif [ $ISUSER -ne 0 ]; then 8105ca82e69SJohn Levon # Set default value for STAFFER, if needed. 8115ca82e69SJohn Levon if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 8125ca82e69SJohn Levon STAFFER=`/usr/xpg4/bin/id -un` 8135ca82e69SJohn Levon export STAFFER 8145ca82e69SJohn Levon fi 8155ca82e69SJohn Levonfi 8165ca82e69SJohn Levon 8175ca82e69SJohn Levonif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 8185ca82e69SJohn Levon MAILTO=$STAFFER 8195ca82e69SJohn Levon export MAILTO 8205ca82e69SJohn Levonfi 8215ca82e69SJohn Levon 8225ca82e69SJohn LevonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 8235ca82e69SJohn LevonPATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 8245ca82e69SJohn LevonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 8255ca82e69SJohn Levonexport PATH 8265ca82e69SJohn Levon 8275ca82e69SJohn Levon# roots of source trees, both relative to $SRC and absolute. 8285ca82e69SJohn Levonrelsrcdirs="." 8295ca82e69SJohn Levonabssrcdirs="$SRC" 8305ca82e69SJohn Levon 8315ca82e69SJohn LevonPROTOCMPTERSE="protocmp.terse -gu" 8325ca82e69SJohn LevonPOUND_SIGN="#" 8336112cec5SJoshua M. Clulowbasews="$(basename "$CODEMGR_WS")" 8345ca82e69SJohn Levon# have we set RELEASE_DATE in our env file? 8355ca82e69SJohn Levonif [ -z "$RELEASE_DATE" ]; then 8365ca82e69SJohn Levon RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 8375ca82e69SJohn Levonfi 8386112cec5SJoshua M. Clulownow=$(LC_ALL=C date +%Y-%b-%d) 8396112cec5SJoshua M. ClulowDEV_CM_TAIL="development build: $LOGNAME $now [$basews]" 8405ca82e69SJohn Levon 8416112cec5SJoshua M. Clulow# 8426112cec5SJoshua M. Clulow# We export POUND_SIGN, RELEASE_DATE and DEV_CM_TAIL to speed up the build 8436112cec5SJoshua M. Clulow# process by avoiding repeated shell invocations to evaluate Makefile.master 8445ca82e69SJohn Levon# definitions. 8456112cec5SJoshua M. Clulow# 8466112cec5SJoshua M. Clulowexport POUND_SIGN RELEASE_DATE DEV_CM_TAIL 8475ca82e69SJohn Levon 8485ca82e69SJohn Levonmaketype="distributed" 8495ca82e69SJohn Levonif [[ -z "$MAKE" ]]; then 8505ca82e69SJohn Levon MAKE=dmake 8515ca82e69SJohn Levonelif [[ ! -x "$MAKE" ]]; then 8525ca82e69SJohn Levon echo "\$MAKE is set to garbage in the environment" 8535ca82e69SJohn Levon exit 1 8545ca82e69SJohn Levonfi 8555ca82e69SJohn Levonexport PATH 8565ca82e69SJohn Levonexport MAKE 8575ca82e69SJohn Levon 8585ca82e69SJohn Levonif [ "${SUNWSPRO}" != "" ]; then 8595ca82e69SJohn Levon PATH="${SUNWSPRO}/bin:$PATH" 8605ca82e69SJohn Levon export PATH 8615ca82e69SJohn Levonfi 8625ca82e69SJohn Levon 8635ca82e69SJohn Levonhostname=$(uname -n) 86426e7d9a8SRichard Loweif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS == 0 ]] 8655ca82e69SJohn Levonthen 8665ca82e69SJohn Levon maxjobs= 8675ca82e69SJohn Levon if [[ -f $HOME/.make.machines ]] 8685ca82e69SJohn Levon then 869244a25b4SBill Sommerfeld egrep -i $'^[\t ]*'"${hostname}"$'[\t .]' \ 8705ca82e69SJohn Levon $HOME/.make.machines | read host jobs 8715ca82e69SJohn Levon maxjobs=${jobs##*=} 8725ca82e69SJohn Levon fi 8735ca82e69SJohn Levon 87426e7d9a8SRichard Lowe if [[ $maxjobs != +([0-9]) || $maxjobs == 0 ]] 8755ca82e69SJohn Levon then 8765ca82e69SJohn Levon # default 8775ca82e69SJohn Levon maxjobs=4 8785ca82e69SJohn Levon fi 8795ca82e69SJohn Levon 8805ca82e69SJohn Levon export DMAKE_MAX_JOBS=$maxjobs 8815ca82e69SJohn Levonfi 8825ca82e69SJohn Levon 8835ca82e69SJohn LevonDMAKE_MODE=parallel; 8845ca82e69SJohn Levonexport DMAKE_MODE 8855ca82e69SJohn Levon 8865ca82e69SJohn Levonif [ -z "${ROOT}" ]; then 8875ca82e69SJohn Levon echo "ROOT must be set." 8885ca82e69SJohn Levon exit 1 8895ca82e69SJohn Levonfi 8905ca82e69SJohn Levon 8915ca82e69SJohn LevonTMPDIR="/tmp/nightly.tmpdir.$$" 8925ca82e69SJohn Levonexport TMPDIR 8935ca82e69SJohn Levonrm -rf ${TMPDIR} 8945ca82e69SJohn Levonmkdir -p $TMPDIR || exit 1 8955ca82e69SJohn Levonchmod 777 $TMPDIR 8965ca82e69SJohn Levon 8975ca82e69SJohn Levon# 8985ca82e69SJohn Levon# Work around folks who have historically used GCC_ROOT and convert it to 8995ca82e69SJohn Levon# GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could 9005ca82e69SJohn Levon# mess up the case where multiple different gcc versions are being used to 9015ca82e69SJohn Levon# shadow). 9025ca82e69SJohn Levon# 9035ca82e69SJohn Levonif [[ -n "${GCC_ROOT}" ]]; then 9045ca82e69SJohn Levon export GNUC_ROOT=${GCC_ROOT} 9055ca82e69SJohn Levonfi 9065ca82e69SJohn Levon 9075ca82e69SJohn Levon# 9085ca82e69SJohn Levon# Tools should only be built non-DEBUG. Keep track of the tools proto 9095ca82e69SJohn Levon# area path relative to $TOOLS, because the latter changes in an 9105ca82e69SJohn Levon# export build. 9115ca82e69SJohn Levon# 9125ca82e69SJohn Levon# TOOLS_PROTO is included below for builds other than usr/src/tools 9135ca82e69SJohn Levon# that look for this location. For usr/src/tools, this will be 9145ca82e69SJohn Levon# overridden on the $MAKE command line in build_tools(). 9155ca82e69SJohn Levon# 9165ca82e69SJohn LevonTOOLS=${SRC}/tools 9175ca82e69SJohn LevonTOOLS_PROTO_REL=proto/root_${MACH}-nd 9185ca82e69SJohn LevonTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 9195ca82e69SJohn Levon 9205ca82e69SJohn Levonunset CFLAGS LD_LIBRARY_PATH LDFLAGS 9215ca82e69SJohn Levon 922fc8c3a51SBill Sommerfeld# 923fc8c3a51SBill Sommerfeld# Echo the SCM type of the parent workspace, this can't just be which_scm 924fc8c3a51SBill Sommerfeld# as that does not know how to identify various network repositories. 925fc8c3a51SBill Sommerfeld# 926fc8c3a51SBill Sommerfeldfunction parent_wstype { 927fc8c3a51SBill Sommerfeld typeset scm_type junk 928fc8c3a51SBill Sommerfeld 929fc8c3a51SBill Sommerfeld CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 930fc8c3a51SBill Sommerfeld | read scm_type junk 931fc8c3a51SBill Sommerfeld if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 932fc8c3a51SBill Sommerfeld # Probe BRINGOVER_WS to determine its type 933fc8c3a51SBill Sommerfeld case "$BRINGOVER_WS" in 934fc8c3a51SBill Sommerfeld git://* | http://*.git | https://*.git) 935fc8c3a51SBill Sommerfeld scm_type="git" 936fc8c3a51SBill Sommerfeld ;; 937fc8c3a51SBill Sommerfeld ssh://* | http://* | https://* ) 938fc8c3a51SBill Sommerfeld scm_type="${BRINGOVER_SCM}" 939fc8c3a51SBill Sommerfeld ;; 940fc8c3a51SBill Sommerfeld *) scm_type="none" 941fc8c3a51SBill Sommerfeld ;; 942fc8c3a51SBill Sommerfeld esac 943fc8c3a51SBill Sommerfeld fi 944fc8c3a51SBill Sommerfeld 945fc8c3a51SBill Sommerfeld # fold both unsupported and unrecognized results into "none" 946fc8c3a51SBill Sommerfeld case "$scm_type" in 947fc8c3a51SBill Sommerfeld mercurial|git) 948fc8c3a51SBill Sommerfeld ;; 949fc8c3a51SBill Sommerfeld *) scm_type=none 950fc8c3a51SBill Sommerfeld ;; 951fc8c3a51SBill Sommerfeld esac 952fc8c3a51SBill Sommerfeld 953fc8c3a51SBill Sommerfeld echo $scm_type 954fc8c3a51SBill Sommerfeld} 955fc8c3a51SBill Sommerfeld 956fc8c3a51SBill Sommerfeld# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 957fc8c3a51SBill Sommerfeldfunction child_wstype { 958fc8c3a51SBill Sommerfeld typeset scm_type junk 959fc8c3a51SBill Sommerfeld 960fc8c3a51SBill Sommerfeld # Probe CODEMGR_WS to determine its type 961fc8c3a51SBill Sommerfeld if [[ -d $CODEMGR_WS ]]; then 962fc8c3a51SBill Sommerfeld $WHICH_SCM | read scm_type junk || exit 1 963fc8c3a51SBill Sommerfeld fi 964fc8c3a51SBill Sommerfeld 965fc8c3a51SBill Sommerfeld case "$scm_type" in 966fc8c3a51SBill Sommerfeld none|git|mercurial) 967fc8c3a51SBill Sommerfeld ;; 968fc8c3a51SBill Sommerfeld *) scm_type=none 969fc8c3a51SBill Sommerfeld ;; 970fc8c3a51SBill Sommerfeld esac 971fc8c3a51SBill Sommerfeld 972fc8c3a51SBill Sommerfeld echo $scm_type 973fc8c3a51SBill Sommerfeld} 974fc8c3a51SBill Sommerfeld 9755ca82e69SJohn Levon# create directories that are automatically removed if the nightly script 9765ca82e69SJohn Levon# fails to start correctly 9775ca82e69SJohn Levonfunction newdir { 9785ca82e69SJohn Levon dir=$1 9795ca82e69SJohn Levon toadd= 9805ca82e69SJohn Levon while [ ! -d $dir ]; do 9815ca82e69SJohn Levon toadd="$dir $toadd" 9825ca82e69SJohn Levon dir=`dirname $dir` 9835ca82e69SJohn Levon done 9845ca82e69SJohn Levon torm= 9855ca82e69SJohn Levon newlist= 9865ca82e69SJohn Levon for dir in $toadd; do 9875ca82e69SJohn Levon if staffer mkdir $dir; then 9885ca82e69SJohn Levon newlist="$ISUSER $dir $newlist" 9895ca82e69SJohn Levon torm="$dir $torm" 9905ca82e69SJohn Levon else 9915ca82e69SJohn Levon [ -z "$torm" ] || staffer rmdir $torm 9925ca82e69SJohn Levon return 1 9935ca82e69SJohn Levon fi 9945ca82e69SJohn Levon done 9955ca82e69SJohn Levon newdirlist="$newlist $newdirlist" 9965ca82e69SJohn Levon return 0 9975ca82e69SJohn Levon} 9985ca82e69SJohn Levonnewdirlist= 9995ca82e69SJohn Levon 1000fc8c3a51SBill Sommerfeld# Initialize the git repo before creating the log subdir; "git clone" insists 1001fc8c3a51SBill Sommerfeld# that a preexisting directory be empty. 1002fc8c3a51SBill Sommerfeld# Use --reference-if-able to share most of the parent's .git tree. 1003fc8c3a51SBill Sommerfeldtype init_git > /dev/null 2>&1 || function init_git { 1004fc8c3a51SBill Sommerfeld if [ -d "${BRINGOVER_WS}" ]; then 1005fc8c3a51SBill Sommerfeld REF_WS="--reference-if-able $(git -C ${BRINGOVER_WS} rev-parse --path-format=absolute --git-common-dir)" 1006fc8c3a51SBill Sommerfeld fi 1007fc8c3a51SBill Sommerfeld staffer git clone \ 1008fc8c3a51SBill Sommerfeld --no-checkout \ 1009fc8c3a51SBill Sommerfeld ${CLONE_OPTIONS} \ 1010fc8c3a51SBill Sommerfeld --origin ${BRINGOVER_REMOTE} \ 1011fc8c3a51SBill Sommerfeld ${REF_WS} \ 1012fc8c3a51SBill Sommerfeld ${BRINGOVER_WS} ${CODEMGR_WS} 1013fc8c3a51SBill Sommerfeld} 1014fc8c3a51SBill Sommerfeld 1015fc8c3a51SBill Sommerfeld# All mercurial initialization is done in bringover_mercurial 1016fc8c3a51SBill Sommerfeldtype init_mercurial > /dev/null 2>&1 || function init_mercurial { 1017fc8c3a51SBill Sommerfeld newdir $CODEMGR_WS 1018fc8c3a51SBill Sommerfeld} 1019fc8c3a51SBill Sommerfeld 1020fc8c3a51SBill Sommerfeldtype init_none > /dev/null 2>&1 || function init_none { 1021fc8c3a51SBill Sommerfeld newdir $CODEMGR_WS 1022fc8c3a51SBill Sommerfeld} 1023fc8c3a51SBill Sommerfeld 1024fc8c3a51SBill Sommerfeldfunction create_build_ws { 1025fc8c3a51SBill Sommerfeld PARENT_SCM_TYPE=$(parent_wstype) 1026fc8c3a51SBill Sommerfeld 1027fc8c3a51SBill Sommerfeld eval "init_${PARENT_SCM_TYPE}" 2>&1 1028fc8c3a51SBill Sommerfeld} 1029fc8c3a51SBill Sommerfeld 1030fc8c3a51SBill Sommerfeld[ -d $CODEMGR_WS ] || create_build_ws || exit 1 10315ca82e69SJohn Levon 10325ca82e69SJohn Levon# since this script assumes the build is from full source, it nullifies 10335ca82e69SJohn Levon# variables likely to have been set by a "ws" script; nullification 10345ca82e69SJohn Levon# confines the search space for headers and libraries to the proto area 10355ca82e69SJohn Levon# built from this immediate source. 10365ca82e69SJohn LevonENVLDLIBS1= 10375ca82e69SJohn LevonENVLDLIBS2= 10385ca82e69SJohn LevonENVLDLIBS3= 10395ca82e69SJohn LevonENVCPPFLAGS1= 10405ca82e69SJohn LevonENVCPPFLAGS2= 10415ca82e69SJohn LevonENVCPPFLAGS3= 10425ca82e69SJohn LevonENVCPPFLAGS4= 10435ca82e69SJohn LevonPARENT_ROOT= 10445ca82e69SJohn Levon 10455ca82e69SJohn Levonexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 10465ca82e69SJohn Levon ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 10475ca82e69SJohn Levon 10485ca82e69SJohn LevonPKGARCHIVE_ORIG=$PKGARCHIVE 10495ca82e69SJohn Levon 10505ca82e69SJohn Levon# 10515ca82e69SJohn Levon# Juggle the logs and optionally send mail on completion. 10525ca82e69SJohn Levon# 10535ca82e69SJohn Levon 10545ca82e69SJohn Levonfunction logshuffle { 10555ca82e69SJohn Levon LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 10565ca82e69SJohn Levon if [ -f $LLOG -o -d $LLOG ]; then 10575ca82e69SJohn Levon LLOG=$LLOG.$$ 10585ca82e69SJohn Levon fi 10595ca82e69SJohn Levon 10605ca82e69SJohn Levon rm -f "$ATLOG/latest" 2>/dev/null 10615ca82e69SJohn Levon mkdir -p $LLOG 10625ca82e69SJohn Levon export LLOG 10635ca82e69SJohn Levon 10645ca82e69SJohn Levon if [ "$build_ok" = "y" ]; then 10655ca82e69SJohn Levon mv $ATLOG/proto_list_${MACH} $LLOG 10665ca82e69SJohn Levon 10675ca82e69SJohn Levon if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 10685ca82e69SJohn Levon mv $ATLOG/proto_list_tools_${MACH} $LLOG 10695ca82e69SJohn Levon fi 10705ca82e69SJohn Levon 10715ca82e69SJohn Levon if [ -f $TMPDIR/wsdiff.results ]; then 10725ca82e69SJohn Levon mv $TMPDIR/wsdiff.results $LLOG 10735ca82e69SJohn Levon fi 10745ca82e69SJohn Levon 10755ca82e69SJohn Levon if [ -f $TMPDIR/wsdiff-nd.results ]; then 10765ca82e69SJohn Levon mv $TMPDIR/wsdiff-nd.results $LLOG 10775ca82e69SJohn Levon fi 10785ca82e69SJohn Levon fi 10795ca82e69SJohn Levon 10805ca82e69SJohn Levon # 10815ca82e69SJohn Levon # Now that we're about to send mail, it's time to check the noise 10825ca82e69SJohn Levon # file. In the event that an error occurs beyond this point, it will 10835ca82e69SJohn Levon # be recorded in the nightly.log file, but nowhere else. This would 10845ca82e69SJohn Levon # include only errors that cause the copying of the noise log to fail 10855ca82e69SJohn Levon # or the mail itself not to be sent. 10865ca82e69SJohn Levon # 10875ca82e69SJohn Levon 10885ca82e69SJohn Levon exec >>$LOGFILE 2>&1 10895ca82e69SJohn Levon if [ -s $build_noise_file ]; then 10905ca82e69SJohn Levon echo "\n==== Nightly build noise ====\n" | 10915ca82e69SJohn Levon tee -a $LOGFILE >>$mail_msg_file 10925ca82e69SJohn Levon cat $build_noise_file >>$LOGFILE 10935ca82e69SJohn Levon cat $build_noise_file >>$mail_msg_file 10945ca82e69SJohn Levon echo | tee -a $LOGFILE >>$mail_msg_file 10955ca82e69SJohn Levon fi 10965ca82e69SJohn Levon rm -f $build_noise_file 10975ca82e69SJohn Levon 10985ca82e69SJohn Levon case "$build_ok" in 10995ca82e69SJohn Levon y) 11005ca82e69SJohn Levon state=Completed 11015ca82e69SJohn Levon ;; 11025ca82e69SJohn Levon i) 11035ca82e69SJohn Levon state=Interrupted 11045ca82e69SJohn Levon ;; 11055ca82e69SJohn Levon *) 11065ca82e69SJohn Levon state=Failed 11075ca82e69SJohn Levon ;; 11085ca82e69SJohn Levon esac 11095ca82e69SJohn Levon 11105ca82e69SJohn Levon if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 11115ca82e69SJohn Levon state=Failed 11125ca82e69SJohn Levon fi 11135ca82e69SJohn Levon 11145ca82e69SJohn Levon NIGHTLY_STATUS=$state 11155ca82e69SJohn Levon export NIGHTLY_STATUS 11165ca82e69SJohn Levon 11175ca82e69SJohn Levon run_hook POST_NIGHTLY $state 11185ca82e69SJohn Levon run_hook SYS_POST_NIGHTLY $state 11195ca82e69SJohn Levon 11205ca82e69SJohn Levon # 11215ca82e69SJohn Levon # mailx(1) sets From: based on the -r flag 11225ca82e69SJohn Levon # if it is given. 11235ca82e69SJohn Levon # 11245ca82e69SJohn Levon mailx_r= 11255ca82e69SJohn Levon if [[ -n "${MAILFROM}" ]]; then 11265ca82e69SJohn Levon mailx_r="-r ${MAILFROM}" 11275ca82e69SJohn Levon fi 11285ca82e69SJohn Levon 11295ca82e69SJohn Levon cat $build_time_file $build_environ_file $mail_msg_file \ 11305ca82e69SJohn Levon > ${LLOG}/mail_msg 11315ca82e69SJohn Levon if [ "$m_FLAG" = "y" ]; then 11326112cec5SJoshua M. Clulow /usr/bin/mailx ${mailx_r} -s \ 11336112cec5SJoshua M. Clulow "Nightly ${MACH} Build of ${basews} ${state}." \ 11346112cec5SJoshua M. Clulow "${MAILTO}" < "${LLOG}/mail_msg" 11355ca82e69SJohn Levon fi 11365ca82e69SJohn Levon 11375ca82e69SJohn Levon if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 11385ca82e69SJohn Levon staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 11395ca82e69SJohn Levon staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 11405ca82e69SJohn Levon fi 11415ca82e69SJohn Levon 11425ca82e69SJohn Levon mv $LOGFILE $LLOG 11435ca82e69SJohn Levon 11445ca82e69SJohn Levon ln -s "$LLOG" "$ATLOG/latest" 11455ca82e69SJohn Levon} 11465ca82e69SJohn Levon 11475ca82e69SJohn Levon# 11485ca82e69SJohn Levon# Remove the locks and temporary files on any exit 11495ca82e69SJohn Levon# 11505ca82e69SJohn Levonfunction cleanup { 11515ca82e69SJohn Levon logshuffle 11525ca82e69SJohn Levon 11535ca82e69SJohn Levon [ -z "$lockfile" ] || staffer rm -f $lockfile 11545ca82e69SJohn Levon [ -z "$atloglockfile" ] || rm -f $atloglockfile 11555ca82e69SJohn Levon [ -z "$ulockfile" ] || staffer rm -f $ulockfile 11565ca82e69SJohn Levon [ -z "$Ulockfile" ] || rm -f $Ulockfile 11575ca82e69SJohn Levon 11585ca82e69SJohn Levon set -- $newdirlist 11595ca82e69SJohn Levon while [ $# -gt 0 ]; do 11605ca82e69SJohn Levon ISUSER=$1 staffer rmdir $2 11615ca82e69SJohn Levon shift; shift 11625ca82e69SJohn Levon done 11635ca82e69SJohn Levon rm -rf $TMPDIR 11645ca82e69SJohn Levon} 11655ca82e69SJohn Levon 11665ca82e69SJohn Levonfunction cleanup_signal { 11675ca82e69SJohn Levon build_ok=i 11685ca82e69SJohn Levon # this will trigger cleanup(), above. 11695ca82e69SJohn Levon exit 1 11705ca82e69SJohn Levon} 11715ca82e69SJohn Levon 11725ca82e69SJohn Levontrap cleanup 0 11735ca82e69SJohn Levontrap cleanup_signal 1 2 3 15 11745ca82e69SJohn Levon 11755ca82e69SJohn Levon# 11765ca82e69SJohn Levon# Generic lock file processing -- make sure that the lock file doesn't 11775ca82e69SJohn Levon# exist. If it does, it should name the build host and PID. If it 11785ca82e69SJohn Levon# doesn't, then make sure we can create it. Clean up locks that are 11795ca82e69SJohn Levon# known to be stale (assumes host name is unique among build systems 11805ca82e69SJohn Levon# for the workspace). 11815ca82e69SJohn Levon# 11825ca82e69SJohn Levonfunction create_lock { 11835ca82e69SJohn Levon lockf=$1 11845ca82e69SJohn Levon lockvar=$2 11855ca82e69SJohn Levon 11865ca82e69SJohn Levon ldir=`dirname $lockf` 11875ca82e69SJohn Levon [ -d $ldir ] || newdir $ldir || exit 1 11885ca82e69SJohn Levon eval $lockvar=$lockf 11895ca82e69SJohn Levon 11905ca82e69SJohn Levon while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 11915ca82e69SJohn Levon ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 11925ca82e69SJohn Levon if [ "$host" != "$hostname" ]; then 11935ca82e69SJohn Levon echo "$MACH build of $basews apparently" \ 11945ca82e69SJohn Levon "already started by $user on $host as $pid." 11955ca82e69SJohn Levon exit 1 11965ca82e69SJohn Levon elif kill -s 0 $pid 2>/dev/null; then 11975ca82e69SJohn Levon echo "$MACH build of $basews already started" \ 11985ca82e69SJohn Levon "by $user as $pid." 11995ca82e69SJohn Levon exit 1 12005ca82e69SJohn Levon else 12015ca82e69SJohn Levon # stale lock; clear it out and try again 12025ca82e69SJohn Levon rm -f $lockf 12035ca82e69SJohn Levon fi 12045ca82e69SJohn Levon done 12055ca82e69SJohn Levon} 12065ca82e69SJohn Levon 12075ca82e69SJohn Levon# 12085ca82e69SJohn Levon# Return the list of interesting proto areas, depending on the current 12095ca82e69SJohn Levon# options. 12105ca82e69SJohn Levon# 12115ca82e69SJohn Levonfunction allprotos { 12125ca82e69SJohn Levon typeset roots="$ROOT" 12135ca82e69SJohn Levon 121426e7d9a8SRichard Lowe if [[ "$F_FLAG" == n && "$MULTI_PROTO" == yes ]]; then 12155ca82e69SJohn Levon roots="$roots $ROOT-nd" 12165ca82e69SJohn Levon fi 12175ca82e69SJohn Levon 12185ca82e69SJohn Levon echo $roots 12195ca82e69SJohn Levon} 12205ca82e69SJohn Levon 12215ca82e69SJohn Levon# Ensure no other instance of this script is running on this host. 12225ca82e69SJohn Levon# LOCKNAME can be set in <env_file>, and is by default, but is not 12235ca82e69SJohn Levon# required due to the use of $ATLOG below. 12245ca82e69SJohn Levonif [ -n "$LOCKNAME" ]; then 12255ca82e69SJohn Levon create_lock /tmp/$LOCKNAME "lockfile" 12265ca82e69SJohn Levonfi 12275ca82e69SJohn Levon# 12285ca82e69SJohn Levon# Create from one, two, or three other locks: 12295ca82e69SJohn Levon# $ATLOG/nightly.lock 12305ca82e69SJohn Levon# - protects against multiple builds in same workspace 12315ca82e69SJohn Levon# $PARENT_WS/usr/src/nightly.$MACH.lock 12325ca82e69SJohn Levon# - protects against multiple 'u' copy-backs 12335ca82e69SJohn Levon# $NIGHTLY_PARENT_ROOT/nightly.lock 12345ca82e69SJohn Levon# - protects against multiple 'U' copy-backs 12355ca82e69SJohn Levon# 12365ca82e69SJohn Levon# Overriding ISUSER to 1 causes the lock to be created as root if the 12375ca82e69SJohn Levon# script is run as root. The default is to create it as $STAFFER. 12385ca82e69SJohn LevonISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 12395ca82e69SJohn Levonif [ "$u_FLAG" = "y" ]; then 12405ca82e69SJohn Levon create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 12415ca82e69SJohn Levonfi 12425ca82e69SJohn Levonif [ "$U_FLAG" = "y" ]; then 12435ca82e69SJohn Levon # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 12445ca82e69SJohn Levon ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 12455ca82e69SJohn Levonfi 12465ca82e69SJohn Levon 12475ca82e69SJohn Levon# Locks have been taken, so we're doing a build and we're committed to 12485ca82e69SJohn Levon# the directories we may have created so far. 12495ca82e69SJohn Levonnewdirlist= 12505ca82e69SJohn Levon 12515ca82e69SJohn Levon# 12525ca82e69SJohn Levon# Create mail_msg_file 12535ca82e69SJohn Levon# 12545ca82e69SJohn Levonmail_msg_file="${TMPDIR}/mail_msg" 12555ca82e69SJohn Levontouch $mail_msg_file 12565ca82e69SJohn Levonbuild_time_file="${TMPDIR}/build_time" 12575ca82e69SJohn Levonbuild_environ_file="${TMPDIR}/build_environ" 12585ca82e69SJohn Levontouch $build_environ_file 12595ca82e69SJohn Levon# 12605ca82e69SJohn Levon# Move old LOGFILE aside 12615ca82e69SJohn Levon# ATLOG directory already made by 'create_lock' above 12625ca82e69SJohn Levon# 12635ca82e69SJohn Levonif [ -f $LOGFILE ]; then 12645ca82e69SJohn Levon mv -f $LOGFILE ${LOGFILE}- 12655ca82e69SJohn Levonfi 12665ca82e69SJohn Levon# 12675ca82e69SJohn Levon# Build OsNet source 12685ca82e69SJohn Levon# 12695ca82e69SJohn LevonSTART_DATE=`date` 12705ca82e69SJohn LevonSECONDS=0 12715ca82e69SJohn Levonecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 12725ca82e69SJohn Levon | tee -a $LOGFILE > $build_time_file 12735ca82e69SJohn Levon 12745ca82e69SJohn Levonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 12755ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 12765ca82e69SJohn Levon 12775ca82e69SJohn Levon# make sure we log only to the nightly build file 12785ca82e69SJohn Levonbuild_noise_file="${TMPDIR}/build_noise" 12795ca82e69SJohn Levonexec </dev/null >$build_noise_file 2>&1 12805ca82e69SJohn Levon 12815ca82e69SJohn Levonrun_hook SYS_PRE_NIGHTLY 12825ca82e69SJohn Levonrun_hook PRE_NIGHTLY 12835ca82e69SJohn Levon 12845ca82e69SJohn Levonecho "\n==== list of environment variables ====\n" >> $LOGFILE 12855ca82e69SJohn Levonenv >> $LOGFILE 12865ca82e69SJohn Levon 12875ca82e69SJohn Levonecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 12885ca82e69SJohn Levon 12895ca82e69SJohn Levonif [ "$N_FLAG" = "y" ]; then 12905ca82e69SJohn Levon if [ "$p_FLAG" = "y" ]; then 12915ca82e69SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 12925ca82e69SJohn LevonWARNING: the p option (create packages) is set, but so is the N option (do 12935ca82e69SJohn Levon not run protocmp); this is dangerous; you should unset the N option 12945ca82e69SJohn LevonEOF 12955ca82e69SJohn Levon else 12965ca82e69SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 12975ca82e69SJohn LevonWarning: the N option (do not run protocmp) is set; it probably shouldn't be 12985ca82e69SJohn LevonEOF 12995ca82e69SJohn Levon fi 13005ca82e69SJohn Levon echo "" | tee -a $mail_msg_file >> $LOGFILE 13015ca82e69SJohn Levonfi 13025ca82e69SJohn Levon 13035ca82e69SJohn Levonif [ "$f_FLAG" = "y" ]; then 13045ca82e69SJohn Levon if [ "$i_FLAG" = "y" ]; then 13055ca82e69SJohn Levon echo "WARNING: the -f flag cannot be used during incremental" \ 13065ca82e69SJohn Levon "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13075ca82e69SJohn Levon f_FLAG=n 13085ca82e69SJohn Levon fi 13095ca82e69SJohn Levon if [ "${p_FLAG}" != "y" ]; then 13105ca82e69SJohn Levon echo "WARNING: the -f flag requires -p;" \ 13115ca82e69SJohn Levon "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13125ca82e69SJohn Levon f_FLAG=n 13135ca82e69SJohn Levon fi 13145ca82e69SJohn Levonfi 13155ca82e69SJohn Levon 13165ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 13175ca82e69SJohn Levon echo "WARNING: -w specified, but $ROOT does not exist;" \ 13185ca82e69SJohn Levon "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 13195ca82e69SJohn Levon w_FLAG=n 13205ca82e69SJohn Levonfi 13215ca82e69SJohn Levon 13225ca82e69SJohn Levoncase $MULTI_PROTO in 13235ca82e69SJohn Levonyes|no) ;; 13245ca82e69SJohn Levon*) 13255ca82e69SJohn Levon echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 13265ca82e69SJohn Levon "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 13275ca82e69SJohn Levon echo "Setting MULTI_PROTO to \"no\".\n" | \ 13285ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13295ca82e69SJohn Levon export MULTI_PROTO=no 13305ca82e69SJohn Levon ;; 13315ca82e69SJohn Levonesac 13325ca82e69SJohn Levon 13335ca82e69SJohn Levon# Save the current proto area if we're comparing against the last build 13345ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 13355ca82e69SJohn Levon if [ -d "$ROOT.prev" ]; then 13365ca82e69SJohn Levon rm -rf $ROOT.prev 13375ca82e69SJohn Levon fi 13385ca82e69SJohn Levon mv $ROOT $ROOT.prev 13395ca82e69SJohn Levonfi 13405ca82e69SJohn Levon 13415ca82e69SJohn Levon# Same for non-DEBUG proto area 13425ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 13435ca82e69SJohn Levon if [ -d "$ROOT-nd.prev" ]; then 13445ca82e69SJohn Levon rm -rf $ROOT-nd.prev 13455ca82e69SJohn Levon fi 13465ca82e69SJohn Levon mv $ROOT-nd $ROOT-nd.prev 13475ca82e69SJohn Levonfi 13485ca82e69SJohn Levon 13495ca82e69SJohn LevonSCM_TYPE=$(child_wstype) 13505ca82e69SJohn Levon 13515ca82e69SJohn Levon# 13525ca82e69SJohn Levon# Decide whether to clobber 13535ca82e69SJohn Levon# 13545ca82e69SJohn Levonif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 13555ca82e69SJohn Levon echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 13565ca82e69SJohn Levon 13575ca82e69SJohn Levon cd $SRC 13585ca82e69SJohn Levon # remove old clobber file 13595ca82e69SJohn Levon rm -f $SRC/clobber.out 13605ca82e69SJohn Levon rm -f $SRC/clobber-${MACH}.out 13615ca82e69SJohn Levon 13625ca82e69SJohn Levon # Remove all .make.state* files, just in case we are restarting 13635ca82e69SJohn Levon # the build after having interrupted a previous 'make clobber'. 13645ca82e69SJohn Levon find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 13655ca82e69SJohn Levon -o -name 'interfaces.*' \) -prune \ 13665ca82e69SJohn Levon -o -name '.make.*' -print | xargs rm -f 13675ca82e69SJohn Levon 13685ca82e69SJohn Levon $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 13695ca82e69SJohn Levon echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 13705ca82e69SJohn Levon grep "$MAKE:" $SRC/clobber-${MACH}.out | 1371eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 13725ca82e69SJohn Levon egrep -v "Ignoring unknown host" | \ 13735ca82e69SJohn Levon tee $TMPDIR/clobber_errs >> $mail_msg_file 13745ca82e69SJohn Levon 13755ca82e69SJohn Levon if [[ -s $TMPDIR/clobber_errs ]]; then 13765ca82e69SJohn Levon build_extras_ok=n 13775ca82e69SJohn Levon fi 13785ca82e69SJohn Levon 137926e7d9a8SRichard Lowe if [[ "$t_FLAG" == "y" ]]; then 13805ca82e69SJohn Levon echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 13815ca82e69SJohn Levon cd ${TOOLS} 13825ca82e69SJohn Levon rm -f ${TOOLS}/clobber-${MACH}.out 13835ca82e69SJohn Levon $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 13845ca82e69SJohn Levon tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 13855ca82e69SJohn Levon echo "\n==== Make tools clobber ERRORS ====\n" \ 13865ca82e69SJohn Levon >> $mail_msg_file 13875ca82e69SJohn Levon grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1388eefeb0ceSBill Sommerfeld | egrep -v ": (Entering|Leaving) directory " \ 13895ca82e69SJohn Levon >> $mail_msg_file 13905ca82e69SJohn Levon if (( $? == 0 )); then 13915ca82e69SJohn Levon build_extras_ok=n 13925ca82e69SJohn Levon fi 13935ca82e69SJohn Levon rm -rf ${TOOLS_PROTO} 13945ca82e69SJohn Levon mkdir -p ${TOOLS_PROTO} 13955ca82e69SJohn Levon fi 13965ca82e69SJohn Levon 13975ca82e69SJohn Levon typeset roots=$(allprotos) 13985ca82e69SJohn Levon echo "\n\nClearing $roots" >> "$LOGFILE" 13995ca82e69SJohn Levon rm -rf $roots 14005ca82e69SJohn Levon 14015ca82e69SJohn Levon # Get back to a clean workspace as much as possible to catch 14025ca82e69SJohn Levon # problems that only occur on fresh workspaces. 14035ca82e69SJohn Levon # Remove all .make.state* files, libraries, and .o's that may 14045ca82e69SJohn Levon # have been omitted from clobber. A couple of libraries are 14055ca82e69SJohn Levon # under source code control, so leave them alone. 14065ca82e69SJohn Levon # We should probably blow away temporary directories too. 14075ca82e69SJohn Levon cd $SRC 14085ca82e69SJohn Levon find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 14095ca82e69SJohn Levon -o -name .git -o -name 'interfaces.*' \) -prune -o \ 14105ca82e69SJohn Levon \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 14115ca82e69SJohn Levon -name '*.o' \) -print | \ 14125ca82e69SJohn Levon grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 14135ca82e69SJohn Levonelse 14145ca82e69SJohn Levon echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 14155ca82e69SJohn Levonfi 14165ca82e69SJohn Levon 1417fc8c3a51SBill Sommerfeldtype bringover_git > /dev/null 2>&1 || function bringover_git { 1418fc8c3a51SBill Sommerfeld typeset -x PATH=$PATH 1419fc8c3a51SBill Sommerfeld 1420fc8c3a51SBill Sommerfeld if [ "$BRINGOVER_BRANCH" = "" ]; then 1421fc8c3a51SBill Sommerfeld if [ -d "$BRINGOVER_WS" ]; then 1422fc8c3a51SBill Sommerfeld BRINGOVER_BRANCH=$(cd "${BRINGOVER_WS}"; git rev-parse --abbrev-ref HEAD) 1423fc8c3a51SBill Sommerfeld if [ "$BRINGOVER_BRANCH" = "HEAD" ]; then 1424fc8c3a51SBill Sommerfeld printf "%s: can't determine BRINGOVER_BRANCH from repo in 'detached HEAD' state\n" "$BRINGOVER_WS" 1425fc8c3a51SBill Sommerfeld touch $TMPDIR/bringover_failed 1426fc8c3a51SBill Sommerfeld return 1427fc8c3a51SBill Sommerfeld fi 1428fc8c3a51SBill Sommerfeld else 1429fc8c3a51SBill Sommerfeld printf "%s: can't determine BRINGOVER_BRANCH\n" "$BRINGOVER_WS" 1430fc8c3a51SBill Sommerfeld touch $TMPDIR/bringover_failed 1431fc8c3a51SBill Sommerfeld return 1432fc8c3a51SBill Sommerfeld fi 1433fc8c3a51SBill Sommerfeld fi 1434fc8c3a51SBill Sommerfeld (cd ${CODEMGR_WS} && 1435fc8c3a51SBill Sommerfeld staffer git remote set-url ${BRINGOVER_REMOTE} ${BRINGOVER_WS} && 1436fc8c3a51SBill Sommerfeld staffer git fetch ${BRINGOVER_REMOTE} ${BRINGOVER_BRANCH} && 1437fc8c3a51SBill Sommerfeld staffer git switch --force-create ${BRINGOVER_BRANCH} \ 1438fc8c3a51SBill Sommerfeld ${BRINGOVER_REMOTE}/${BRINGOVER_BRANCH}) \ 1439fc8c3a51SBill Sommerfeld >$TMPDIR/bringover.out 2>&1 1440fc8c3a51SBill Sommerfeld if (( $? != 0 )); then 1441fc8c3a51SBill Sommerfeld printf "%s: update failed as follows:\n\n" "$CODEMGR_WS" 1442fc8c3a51SBill Sommerfeld cat $TMPDIR/bringover.out 1443fc8c3a51SBill Sommerfeld touch $TMPDIR/bringover_failed 1444fc8c3a51SBill Sommerfeld return 1445fc8c3a51SBill Sommerfeld fi 1446fc8c3a51SBill Sommerfeld 1447fc8c3a51SBill Sommerfeld printf "%s: local branch '%s' updated to commit %s\n" \ 1448fc8c3a51SBill Sommerfeld "$CODEMGR_WS" "$BRINGOVER_BRANCH" \ 1449fc8c3a51SBill Sommerfeld $(cd ${CODEMGR_WS}; git rev-parse HEAD) 1450fc8c3a51SBill Sommerfeld 1451fc8c3a51SBill Sommerfeld staffer git status --no-short --branch --untracked-files=no 1452fc8c3a51SBill Sommerfeld} 1453fc8c3a51SBill Sommerfeld 14545ca82e69SJohn Levontype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 14555ca82e69SJohn Levon typeset -x PATH=$PATH 14565ca82e69SJohn Levon 14575ca82e69SJohn Levon # If the repository doesn't exist yet, then we want to populate it. 14585ca82e69SJohn Levon if [[ ! -d $CODEMGR_WS/.hg ]]; then 14595ca82e69SJohn Levon staffer hg init $CODEMGR_WS 14605ca82e69SJohn Levon staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 14615ca82e69SJohn Levon staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 14625ca82e69SJohn Levon touch $TMPDIR/new_repository 14635ca82e69SJohn Levon fi 14645ca82e69SJohn Levon 14655ca82e69SJohn Levon typeset -x HGMERGE="/bin/false" 14665ca82e69SJohn Levon 14675ca82e69SJohn Levon # 14685ca82e69SJohn Levon # If the user has changes, regardless of whether those changes are 14695ca82e69SJohn Levon # committed, and regardless of whether those changes conflict, then 14705ca82e69SJohn Levon # we'll attempt to merge them either implicitly (uncommitted) or 14715ca82e69SJohn Levon # explicitly (committed). 14725ca82e69SJohn Levon # 14735ca82e69SJohn Levon # These are the messages we'll use to help clarify mercurial output 14745ca82e69SJohn Levon # in those cases. 14755ca82e69SJohn Levon # 14765ca82e69SJohn Levon typeset mergefailmsg="\ 14775ca82e69SJohn Levon***\n\ 14785ca82e69SJohn Levon*** nightly was unable to automatically merge your changes. You should\n\ 14795ca82e69SJohn Levon*** redo the full merge manually, following the steps outlined by mercurial\n\ 14805ca82e69SJohn Levon*** above, then restart nightly.\n\ 14815ca82e69SJohn Levon***\n" 14825ca82e69SJohn Levon typeset mergepassmsg="\ 14835ca82e69SJohn Levon***\n\ 14845ca82e69SJohn Levon*** nightly successfully merged your changes. This means that your working\n\ 14855ca82e69SJohn Levon*** directory has been updated, but those changes are not yet committed.\n\ 14865ca82e69SJohn Levon*** After nightly completes, you should validate the results of the merge,\n\ 14875ca82e69SJohn Levon*** then use hg commit manually.\n\ 14885ca82e69SJohn Levon***\n" 14895ca82e69SJohn Levon 14905ca82e69SJohn Levon # 14915ca82e69SJohn Levon # For each repository in turn: 14925ca82e69SJohn Levon # 14935ca82e69SJohn Levon # 1. Do the pull. If this fails, dump the output and bail out. 14945ca82e69SJohn Levon # 14955ca82e69SJohn Levon # 2. If the pull resulted in an extra head, do an explicit merge. 14965ca82e69SJohn Levon # If this fails, dump the output and bail out. 14975ca82e69SJohn Levon # 14985ca82e69SJohn Levon # Because we can't rely on Mercurial to exit with a failure code 14995ca82e69SJohn Levon # when a merge fails (Mercurial issue #186), we must grep the 15005ca82e69SJohn Levon # output of pull/merge to check for attempted and/or failed merges. 15015ca82e69SJohn Levon # 15025ca82e69SJohn Levon # 3. If a merge failed, set the message and fail the bringover. 15035ca82e69SJohn Levon # 15045ca82e69SJohn Levon # 4. Otherwise, if a merge succeeded, set the message 15055ca82e69SJohn Levon # 15065ca82e69SJohn Levon # 5. Dump the output, and any message from step 3 or 4. 15075ca82e69SJohn Levon # 15085ca82e69SJohn Levon 15095ca82e69SJohn Levon typeset HG_SOURCE=$BRINGOVER_WS 15105ca82e69SJohn Levon if [ ! -f $TMPDIR/new_repository ]; then 15115ca82e69SJohn Levon HG_SOURCE=$TMPDIR/open_bundle.hg 15125ca82e69SJohn Levon staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 15135ca82e69SJohn Levon -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 15145ca82e69SJohn Levon 15155ca82e69SJohn Levon # 15165ca82e69SJohn Levon # If there are no incoming changesets, then incoming will 15175ca82e69SJohn Levon # fail, and there will be no bundle file. Reset the source, 15185ca82e69SJohn Levon # to allow the remaining logic to complete with no false 15195ca82e69SJohn Levon # negatives. (Unlike incoming, pull will return success 15205ca82e69SJohn Levon # for the no-change case.) 15215ca82e69SJohn Levon # 15225ca82e69SJohn Levon if (( $? != 0 )); then 15235ca82e69SJohn Levon HG_SOURCE=$BRINGOVER_WS 15245ca82e69SJohn Levon fi 15255ca82e69SJohn Levon fi 15265ca82e69SJohn Levon 15275ca82e69SJohn Levon staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 15285ca82e69SJohn Levon > $TMPDIR/pull_open.out 2>&1 15295ca82e69SJohn Levon if (( $? != 0 )); then 15305ca82e69SJohn Levon printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 15315ca82e69SJohn Levon cat $TMPDIR/pull_open.out 15325ca82e69SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 15335ca82e69SJohn Levon printf "$mergefailmsg" 15345ca82e69SJohn Levon fi 15355ca82e69SJohn Levon touch $TMPDIR/bringover_failed 15365ca82e69SJohn Levon return 15375ca82e69SJohn Levon fi 15385ca82e69SJohn Levon 15395ca82e69SJohn Levon if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 15405ca82e69SJohn Levon staffer hg --cwd $CODEMGR_WS merge \ 15415ca82e69SJohn Levon >> $TMPDIR/pull_open.out 2>&1 15425ca82e69SJohn Levon if (( $? != 0 )); then 15435ca82e69SJohn Levon printf "%s: merge failed as follows:\n\n" \ 15445ca82e69SJohn Levon "$CODEMGR_WS" 15455ca82e69SJohn Levon cat $TMPDIR/pull_open.out 15465ca82e69SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out \ 15475ca82e69SJohn Levon > /dev/null 2>&1; then 15485ca82e69SJohn Levon printf "$mergefailmsg" 15495ca82e69SJohn Levon fi 15505ca82e69SJohn Levon touch $TMPDIR/bringover_failed 15515ca82e69SJohn Levon return 15525ca82e69SJohn Levon fi 15535ca82e69SJohn Levon fi 15545ca82e69SJohn Levon 15555ca82e69SJohn Levon printf "updated %s with the following results:\n" "$CODEMGR_WS" 15565ca82e69SJohn Levon cat $TMPDIR/pull_open.out 15575ca82e69SJohn Levon if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 15585ca82e69SJohn Levon printf "$mergepassmsg" 15595ca82e69SJohn Levon fi 15605ca82e69SJohn Levon printf "\n" 15615ca82e69SJohn Levon 15625ca82e69SJohn Levon # 15635ca82e69SJohn Levon # Per-changeset output is neither useful nor manageable for a 15645ca82e69SJohn Levon # newly-created repository. 15655ca82e69SJohn Levon # 15665ca82e69SJohn Levon if [ -f $TMPDIR/new_repository ]; then 15675ca82e69SJohn Levon return 15685ca82e69SJohn Levon fi 15695ca82e69SJohn Levon 15705ca82e69SJohn Levon printf "\nadded the following changesets to open repository:\n" 15715ca82e69SJohn Levon cat $TMPDIR/incoming_open.out 15725ca82e69SJohn Levon} 15735ca82e69SJohn Levon 15745ca82e69SJohn Levontype bringover_none > /dev/null 2>&1 || function bringover_none { 15755ca82e69SJohn Levon echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 15765ca82e69SJohn Levon touch $TMPDIR/bringover_failed 15775ca82e69SJohn Levon} 15785ca82e69SJohn Levon 15795ca82e69SJohn Levon# 15805ca82e69SJohn Levon# Decide whether to bringover to the codemgr workspace 15815ca82e69SJohn Levon# 15825ca82e69SJohn Levonif [ "$n_FLAG" = "n" ]; then 15835ca82e69SJohn Levon PARENT_SCM_TYPE=$(parent_wstype) 15845ca82e69SJohn Levon 15855ca82e69SJohn Levon if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 15865ca82e69SJohn Levon echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 15875ca82e69SJohn Levon "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 15885ca82e69SJohn Levon exit 1 15895ca82e69SJohn Levon fi 15905ca82e69SJohn Levon 15915ca82e69SJohn Levon run_hook PRE_BRINGOVER 15925ca82e69SJohn Levon 15935ca82e69SJohn Levon echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 15945ca82e69SJohn Levon echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 15955ca82e69SJohn Levon 15965ca82e69SJohn Levon eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 15975ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 15985ca82e69SJohn Levon 15995ca82e69SJohn Levon if [ -f $TMPDIR/bringover_failed ]; then 16005ca82e69SJohn Levon rm -f $TMPDIR/bringover_failed 16015ca82e69SJohn Levon build_ok=n 16025ca82e69SJohn Levon echo "trouble with bringover, quitting at `date`." | 16035ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 16045ca82e69SJohn Levon exit 1 16055ca82e69SJohn Levon fi 16065ca82e69SJohn Levon 16075ca82e69SJohn Levon # 16085ca82e69SJohn Levon # It's possible that we used the bringover above to create 16095ca82e69SJohn Levon # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 16105ca82e69SJohn Levon # but should now be the same as $BRINGOVER_WS. 16115ca82e69SJohn Levon # 161226e7d9a8SRichard Lowe [[ $SCM_TYPE == none ]] && SCM_TYPE=$PARENT_SCM_TYPE 16135ca82e69SJohn Levon 16145ca82e69SJohn Levon run_hook POST_BRINGOVER 16155ca82e69SJohn Levon 16165ca82e69SJohn Levon check_closed_bins 16175ca82e69SJohn Levon 16185ca82e69SJohn Levonelse 16195ca82e69SJohn Levon echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 16205ca82e69SJohn Levonfi 16215ca82e69SJohn Levon 16225ca82e69SJohn Levon# Safeguards 16235ca82e69SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 16245ca82e69SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 16255ca82e69SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 16265ca82e69SJohn Levon 16274125432bSBill Sommerfeld# 16284125432bSBill Sommerfeld# if -V flag was given, reset VERSION to V_ARG 16294125432bSBill Sommerfeld# 16304125432bSBill Sommerfeldif [[ "$V_FLAG" == "y" ]]; then 16314125432bSBill Sommerfeld export VERSION=$V_ARG 16324125432bSBill Sommerfeldelif [[ -z "$VERSION" ]]; then 16334125432bSBill Sommerfeld export VERSION=$(git -C "${CODEMGR_WS}" describe --long --all --dirty | 16344125432bSBill Sommerfeld cut -d/ -f2-) 16354125432bSBill Sommerfeldfi 16364125432bSBill Sommerfeld 16374125432bSBill Sommerfeld[[ -n "$VERSION" ]] || fatal_error "Error: VERSION not set" 16384125432bSBill Sommerfeld 16394125432bSBill Sommerfeldecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 16404125432bSBill Sommerfeldecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 16414125432bSBill Sommerfeld 164226e7d9a8SRichard Loweif [[ "$t_FLAG" == "y" ]]; then 16435ca82e69SJohn Levon set_non_debug_build_flags 16445ca82e69SJohn Levon # Switch ONBLD_TOOLS early if -t is specified so that 16455ca82e69SJohn Levon # we could use bootstrapped cw for compiler checks. 16465ca82e69SJohn Levon ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld 16475ca82e69SJohn Levon export ONBLD_TOOLS 16483c6ef809SYuri Pankov 16493c6ef809SYuri Pankov bootstrap_tools || fatal_error "Error: could not bootstrap tools" 16505ca82e69SJohn Levonfi 16515ca82e69SJohn Levon 16525ca82e69SJohn Levonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 16535ca82e69SJohn Levon 16545ca82e69SJohn Levon# System 16555ca82e69SJohn Levonwhence uname | tee -a $build_environ_file >> $LOGFILE 16565ca82e69SJohn Levonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 16575ca82e69SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 16585ca82e69SJohn Levon 16595ca82e69SJohn Levon# make 16605ca82e69SJohn Levonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 16615ca82e69SJohn Levon$MAKE -v | tee -a $build_environ_file >> $LOGFILE 16625ca82e69SJohn Levonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 16635ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 16645ca82e69SJohn Levon 16655ca82e69SJohn Levon# 16665ca82e69SJohn Levon# Report the compiler versions. 16675ca82e69SJohn Levon# 16685ca82e69SJohn Levon 16695ca82e69SJohn Levonif [[ ! -f $SRC/Makefile ]]; then 16705ca82e69SJohn Levon build_ok=n 16715ca82e69SJohn Levon echo "\nUnable to find \"Makefile\" in $SRC." | \ 16725ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 16735ca82e69SJohn Levon exit 1 16745ca82e69SJohn Levonfi 16755ca82e69SJohn Levon 16765ca82e69SJohn Levon( cd $SRC 16775ca82e69SJohn Levon for target in cc-version java-version openssl-version; do 16785ca82e69SJohn Levon echo 16795ca82e69SJohn Levon # 16805ca82e69SJohn Levon # Put statefile somewhere we know we can write to rather than trip 16815ca82e69SJohn Levon # over a read-only $srcroot. 16825ca82e69SJohn Levon # 16835ca82e69SJohn Levon rm -f $TMPDIR/make-state 16845ca82e69SJohn Levon export SRC 16855ca82e69SJohn Levon if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 16865ca82e69SJohn Levon continue 16875ca82e69SJohn Levon fi 16885ca82e69SJohn Levon touch $TMPDIR/nocompiler 16895ca82e69SJohn Levon done 16905ca82e69SJohn Levon echo 1691*053feb15SBill Sommerfeld) | egrep -v ": (Entering|Leaving) directory " \ 1692eefeb0ceSBill Sommerfeld | tee -a $build_environ_file >> $LOGFILE 16935ca82e69SJohn Levon 16945ca82e69SJohn Levonif [ -f $TMPDIR/nocompiler ]; then 16955ca82e69SJohn Levon rm -f $TMPDIR/nocompiler 16965ca82e69SJohn Levon build_ok=n 16975ca82e69SJohn Levon echo "Aborting due to missing compiler." | 16985ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 16995ca82e69SJohn Levon exit 1 17005ca82e69SJohn Levonfi 17015ca82e69SJohn Levon 17025ca82e69SJohn Levon# Check that we're running a capable link-editor 17035ca82e69SJohn Levonwhence ld | tee -a $build_environ_file >> $LOGFILE 17045ca82e69SJohn LevonLDVER=`ld -V 2>&1` 17055ca82e69SJohn Levonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 17065ca82e69SJohn LevonLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 17075ca82e69SJohn Levonif [ `expr $LDVER \< 422` -eq 1 ]; then 17085ca82e69SJohn Levon echo "The link-editor needs to be at version 422 or higher to build" | \ 17095ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 17105ca82e69SJohn Levon echo "the latest stuff. Hope your build works." | \ 17115ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 17125ca82e69SJohn Levonfi 17135ca82e69SJohn Levon 17145ca82e69SJohn Levon# 17155ca82e69SJohn Levon# Build and use the workspace's tools if requested 17165ca82e69SJohn Levon# 171726e7d9a8SRichard Loweif [[ "$t_FLAG" == "y" ]]; then 17185ca82e69SJohn Levon set_non_debug_build_flags 17195ca82e69SJohn Levon 17205ca82e69SJohn Levon build_tools ${TOOLS_PROTO} 17215ca82e69SJohn Levon if (( $? != 0 )); then 17225ca82e69SJohn Levon build_ok=n 17236faa6645SYuri Pankov exit 1 17246faa6645SYuri Pankov fi 17256faa6645SYuri Pankov 17265ca82e69SJohn Levon STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs 17275ca82e69SJohn Levon export STABS 17285ca82e69SJohn Levon CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs 17295ca82e69SJohn Levon export CTFSTABS 17305ca82e69SJohn Levon GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets 17315ca82e69SJohn Levon export GENOFFSETS 17325ca82e69SJohn Levon 17335ca82e69SJohn Levon CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert 17345ca82e69SJohn Levon export CTFCONVERT 17355ca82e69SJohn Levon CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge 17365ca82e69SJohn Levon export CTFMERGE 17375ca82e69SJohn Levon 17385ca82e69SJohn Levon PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}" 17395ca82e69SJohn Levon PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}" 17405ca82e69SJohn Levon export PATH 17415ca82e69SJohn Levon 17425ca82e69SJohn Levon echo "\n==== New environment settings. ====\n" >> $LOGFILE 17435ca82e69SJohn Levon echo "STABS=${STABS}" >> $LOGFILE 17445ca82e69SJohn Levon echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 17455ca82e69SJohn Levon echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 17465ca82e69SJohn Levon echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 17475ca82e69SJohn Levon echo "PATH=${PATH}" >> $LOGFILE 17485ca82e69SJohn Levon echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 17495ca82e69SJohn Levonfi 17505ca82e69SJohn Levon 17515ca82e69SJohn Levon# timestamp the start of the normal build; the findunref tool uses it. 17525ca82e69SJohn Levontouch $SRC/.build.tstamp 17535ca82e69SJohn Levon 17545ca82e69SJohn Levonnormal_build 17555ca82e69SJohn Levon 17565ca82e69SJohn LevonORIG_SRC=$SRC 17575ca82e69SJohn LevonBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 17585ca82e69SJohn Levon 175926e7d9a8SRichard Loweabspkg= 176026e7d9a8SRichard Lowefor d in $abssrcdirs; do 176126e7d9a8SRichard Lowe if [ -d "$d/pkg" ]; then 176226e7d9a8SRichard Lowe abspkg="$abspkg $d" 176326e7d9a8SRichard Lowe fi 176426e7d9a8SRichard Lowedone 176526e7d9a8SRichard Lowe 176626e7d9a8SRichard Loweif [ "$L_FLAG" != "y" -a "$build_ok" = y ]; then 176726e7d9a8SRichard Lowe echo "\n==== Linting packages ====\n" | \ 176826e7d9a8SRichard Lowe tee -a $LOGFILE >> $mail_msg_file 176926e7d9a8SRichard Lowe 177026e7d9a8SRichard Lowe if [ -n "$abspkg" ]; then 177126e7d9a8SRichard Lowe for d in "$abspkg"; do 177226e7d9a8SRichard Lowe ( cd $d/pkg ; $MAKE -e pkglint ) | \ 177326e7d9a8SRichard Lowe tee -a $LOGFILE | \ 1774eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 177526e7d9a8SRichard Lowe egrep -v 'Lint engine setup|Starting lint run' 177626e7d9a8SRichard Lowe done 2>&1 | tee $TMPDIR/pkglint_noise >> $mail_msg_file 177726e7d9a8SRichard Lowe if [[ -s $TMPDIR/pkglint_noise ]]; then 177826e7d9a8SRichard Lowe build_extras_ok=n 177926e7d9a8SRichard Lowe fi 178026e7d9a8SRichard Lowe fi 178126e7d9a8SRichard Lowefi 17825ca82e69SJohn Levon 17835ca82e69SJohn Levon# 17845ca82e69SJohn Levon# There are several checks that need to look at the proto area, but 17855ca82e69SJohn Levon# they only need to look at one, and they don't care whether it's 17865ca82e69SJohn Levon# DEBUG or non-DEBUG. 17875ca82e69SJohn Levon# 178826e7d9a8SRichard Loweif [[ "$MULTI_PROTO" == yes && "$D_FLAG" == n ]]; then 17895ca82e69SJohn Levon checkroot=$ROOT-nd 17905ca82e69SJohn Levonelse 17915ca82e69SJohn Levon checkroot=$ROOT 17925ca82e69SJohn Levonfi 17935ca82e69SJohn Levon 17945ca82e69SJohn Levonif [ "$build_ok" = "y" ]; then 17955ca82e69SJohn Levon echo "\n==== Creating protolist system file at `date` ====" \ 17965ca82e69SJohn Levon >> $LOGFILE 17975ca82e69SJohn Levon protolist $checkroot > $ATLOG/proto_list_${MACH} 17985ca82e69SJohn Levon echo "==== protolist system file created at `date` ====\n" \ 17995ca82e69SJohn Levon >> $LOGFILE 18005ca82e69SJohn Levon 18015ca82e69SJohn Levon if [ "$N_FLAG" != "y" ]; then 18025ca82e69SJohn Levon 18035ca82e69SJohn Levon E1= 18045ca82e69SJohn Levon f1= 18055ca82e69SJohn Levon for f in $f1; do 18065ca82e69SJohn Levon if [ -f "$f" ]; then 18075ca82e69SJohn Levon E1="$E1 -e $f" 18085ca82e69SJohn Levon fi 18095ca82e69SJohn Levon done 18105ca82e69SJohn Levon 18115ca82e69SJohn Levon E2= 18125ca82e69SJohn Levon f2= 18135ca82e69SJohn Levon if [ -d "$SRC/pkg" ]; then 18145ca82e69SJohn Levon f2="$f2 exceptions/packaging" 18155ca82e69SJohn Levon fi 18165ca82e69SJohn Levon 18175ca82e69SJohn Levon for f in $f2; do 18185ca82e69SJohn Levon if [ -f "$f" ]; then 18195ca82e69SJohn Levon E2="$E2 -e $f" 18205ca82e69SJohn Levon fi 18215ca82e69SJohn Levon done 18225ca82e69SJohn Levon fi 18235ca82e69SJohn Levon 18245ca82e69SJohn Levon if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 18255ca82e69SJohn Levon echo "\n==== Validating manifests against proto area ====\n" \ 18265ca82e69SJohn Levon >> $mail_msg_file 18275ca82e69SJohn Levon ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1828eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 18295ca82e69SJohn Levon tee $TMPDIR/protocmp_noise >> $mail_msg_file 18305ca82e69SJohn Levon if [[ -s $TMPDIR/protocmp_noise ]]; then 18315ca82e69SJohn Levon build_extras_ok=n 18325ca82e69SJohn Levon fi 18335ca82e69SJohn Levon fi 18345ca82e69SJohn Levon 18355ca82e69SJohn Levon if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 18365ca82e69SJohn Levon echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 18375ca82e69SJohn Levon if [ -n "$E2" ]; then 18385ca82e69SJohn Levon ELIST=$E2 18395ca82e69SJohn Levon else 18405ca82e69SJohn Levon ELIST=$E1 18415ca82e69SJohn Levon fi 18425ca82e69SJohn Levon $PROTOCMPTERSE \ 18435ca82e69SJohn Levon "Files in yesterday's proto area, but not today's:" \ 18445ca82e69SJohn Levon "Files in today's proto area, but not yesterday's:" \ 18455ca82e69SJohn Levon "Files that changed between yesterday and today:" \ 18465ca82e69SJohn Levon ${ELIST} \ 18475ca82e69SJohn Levon -d $REF_PROTO_LIST \ 18485ca82e69SJohn Levon $ATLOG/proto_list_${MACH} \ 18495ca82e69SJohn Levon >> $mail_msg_file 18505ca82e69SJohn Levon fi 18515ca82e69SJohn Levonfi 18525ca82e69SJohn Levon 18535ca82e69SJohn Levonif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 18545ca82e69SJohn Levon "$build_extras_ok" == "y" ]]; then 18555ca82e69SJohn Levon staffer cp $ATLOG/proto_list_${MACH} \ 18565ca82e69SJohn Levon $PARENT_WS/usr/src/proto_list_${MACH} 18575ca82e69SJohn Levonfi 18585ca82e69SJohn Levon 18595ca82e69SJohn Levon# Update parent proto area if necessary. This is done now 18605ca82e69SJohn Levon# so that the proto area has either DEBUG or non-DEBUG kernels. 18615ca82e69SJohn Levon# Note that this clears out the lock file, so we can dispense with 18625ca82e69SJohn Levon# the variable now. 18635ca82e69SJohn Levonif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 18645ca82e69SJohn Levon echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 18655ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 18665ca82e69SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT/* 18675ca82e69SJohn Levon unset Ulockfile 18685ca82e69SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT 186926e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == no || "$D_FLAG" == y ]]; then 18705ca82e69SJohn Levon ( cd $ROOT; tar cf - . | 18715ca82e69SJohn Levon ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 18725ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 18735ca82e69SJohn Levon fi 187426e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == yes && "$F_FLAG" == n ]]; then 18755ca82e69SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT-nd/* 18765ca82e69SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT-nd 18775ca82e69SJohn Levon cd $ROOT-nd 18785ca82e69SJohn Levon ( tar cf - . | 18795ca82e69SJohn Levon ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 18805ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 18815ca82e69SJohn Levon fi 18825ca82e69SJohn Levon if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 18835ca82e69SJohn Levon echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 18845ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 18855ca82e69SJohn Levon rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 18865ca82e69SJohn Levon mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 188726e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == no || "$D_FLAG" == y ]]; then 18885ca82e69SJohn Levon ( cd $TOOLS_PROTO; tar cf - . | 18895ca82e69SJohn Levon ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 18905ca82e69SJohn Levon umask 0; tar xpf - ) ) 2>&1 | 18915ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 18925ca82e69SJohn Levon fi 18935ca82e69SJohn Levon fi 18945ca82e69SJohn Levonfi 18955ca82e69SJohn Levon 18965ca82e69SJohn Levon# 18975ca82e69SJohn Levon# ELF verification: ABI (-A) and runtime (-r) checks 18985ca82e69SJohn Levon# 189926e7d9a8SRichard Loweif [[ ($build_ok == y) && (($A_FLAG == y) || ($r_FLAG == y)) ]]; then 19005ca82e69SJohn Levon # Directory ELF-data.$MACH holds the files produced by these tests. 19015ca82e69SJohn Levon elf_ddir=$SRC/ELF-data.$MACH 19025ca82e69SJohn Levon 19035ca82e69SJohn Levon # If there is a previous ELF-data backup directory, remove it. Then, 19045ca82e69SJohn Levon # rotate current ELF-data directory into its place and create a new 19055ca82e69SJohn Levon # empty directory 19065ca82e69SJohn Levon rm -rf $elf_ddir.ref 19075ca82e69SJohn Levon if [[ -d $elf_ddir ]]; then 19085ca82e69SJohn Levon mv $elf_ddir $elf_ddir.ref 19095ca82e69SJohn Levon fi 19105ca82e69SJohn Levon mkdir -p $elf_ddir 19115ca82e69SJohn Levon 19125ca82e69SJohn Levon # Call find_elf to produce a list of the ELF objects in the proto area. 19135ca82e69SJohn Levon # This list is passed to check_rtime and interface_check, preventing 19145ca82e69SJohn Levon # them from separately calling find_elf to do the same work twice. 19155ca82e69SJohn Levon find_elf -fr $checkroot > $elf_ddir/object_list 19165ca82e69SJohn Levon 191726e7d9a8SRichard Lowe if [[ $A_FLAG == y ]]; then 19185ca82e69SJohn Levon echo "\n==== Check versioning and ABI information ====\n" | \ 19195ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19205ca82e69SJohn Levon 19215ca82e69SJohn Levon # Produce interface description for the proto. Report errors. 19225ca82e69SJohn Levon interface_check -o -w $elf_ddir -f object_list \ 19235ca82e69SJohn Levon -i interface -E interface.err 19245ca82e69SJohn Levon if [[ -s $elf_ddir/interface.err ]]; then 19255ca82e69SJohn Levon tee -a $LOGFILE < $elf_ddir/interface.err \ 19265ca82e69SJohn Levon >> $mail_msg_file 19275ca82e69SJohn Levon build_extras_ok=n 19285ca82e69SJohn Levon fi 19295ca82e69SJohn Levon 19305ca82e69SJohn Levon # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 19315ca82e69SJohn Levon # description file to that from the baseline gate. Issue a 19325ca82e69SJohn Levon # warning if the baseline is not present, and keep going. 19335ca82e69SJohn Levon if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 19345ca82e69SJohn Levon base_ifile="$ELF_DATA_BASELINE_DIR/interface" 19355ca82e69SJohn Levon 19365ca82e69SJohn Levon echo "\n==== Compare versioning and ABI information" \ 19375ca82e69SJohn Levon "to baseline ====\n" | \ 19385ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19395ca82e69SJohn Levon echo "Baseline: $base_ifile\n" >> $LOGFILE 19405ca82e69SJohn Levon 19415ca82e69SJohn Levon if [[ -f $base_ifile ]]; then 19425ca82e69SJohn Levon interface_cmp -d -o $base_ifile \ 19435ca82e69SJohn Levon $elf_ddir/interface > $elf_ddir/interface.cmp 19445ca82e69SJohn Levon if [[ -s $elf_ddir/interface.cmp ]]; then 19455ca82e69SJohn Levon echo | tee -a $LOGFILE >> $mail_msg_file 19465ca82e69SJohn Levon tee -a $LOGFILE < \ 19475ca82e69SJohn Levon $elf_ddir/interface.cmp \ 19485ca82e69SJohn Levon >> $mail_msg_file 19495ca82e69SJohn Levon build_extras_ok=n 19505ca82e69SJohn Levon fi 19515ca82e69SJohn Levon else 19525ca82e69SJohn Levon echo "baseline not available. comparison" \ 19535ca82e69SJohn Levon "skipped" | \ 19545ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19555ca82e69SJohn Levon fi 19565ca82e69SJohn Levon 19575ca82e69SJohn Levon fi 19585ca82e69SJohn Levon fi 19595ca82e69SJohn Levon 196026e7d9a8SRichard Lowe if [[ $r_FLAG == y ]]; then 19615ca82e69SJohn Levon echo "\n==== Check ELF runtime attributes ====\n" | \ 19625ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19635ca82e69SJohn Levon 19645ca82e69SJohn Levon # If we're doing a DEBUG build the proto area will be left 19655ca82e69SJohn Levon # with debuggable objects, thus don't assert -s. 196626e7d9a8SRichard Lowe if [[ $D_FLAG == y ]]; then 19675ca82e69SJohn Levon rtime_sflag="" 19685ca82e69SJohn Levon else 19695ca82e69SJohn Levon rtime_sflag="-s" 19705ca82e69SJohn Levon fi 19715ca82e69SJohn Levon check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 19725ca82e69SJohn Levon -D object_list -f object_list -E runtime.err \ 19735ca82e69SJohn Levon -I runtime.attr.raw 19745ca82e69SJohn Levon if (( $? != 0 )); then 19755ca82e69SJohn Levon build_extras_ok=n 19765ca82e69SJohn Levon fi 19775ca82e69SJohn Levon 19785ca82e69SJohn Levon # check_rtime -I output needs to be sorted in order to 19795ca82e69SJohn Levon # compare it to that from previous builds. 19805ca82e69SJohn Levon sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 19815ca82e69SJohn Levon rm $elf_ddir/runtime.attr.raw 19825ca82e69SJohn Levon 19835ca82e69SJohn Levon # Report errors 19845ca82e69SJohn Levon if [[ -s $elf_ddir/runtime.err ]]; then 19855ca82e69SJohn Levon tee -a $LOGFILE < $elf_ddir/runtime.err \ 19865ca82e69SJohn Levon >> $mail_msg_file 19875ca82e69SJohn Levon build_extras_ok=n 19885ca82e69SJohn Levon fi 19895ca82e69SJohn Levon 19905ca82e69SJohn Levon # If there is an ELF-data directory from a previous build, 19915ca82e69SJohn Levon # then diff the attr files. These files contain information 19925ca82e69SJohn Levon # about dependencies, versioning, and runpaths. There is some 19935ca82e69SJohn Levon # overlap with the ABI checking done above, but this also 19945ca82e69SJohn Levon # flushes out non-ABI interface differences along with the 19955ca82e69SJohn Levon # other information. 19965ca82e69SJohn Levon echo "\n==== Diff ELF runtime attributes" \ 19975ca82e69SJohn Levon "(since last build) ====\n" | \ 19985ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 19995ca82e69SJohn Levon 20005ca82e69SJohn Levon if [[ -f $elf_ddir.ref/runtime.attr ]]; then 20015ca82e69SJohn Levon diff $elf_ddir.ref/runtime.attr \ 20025ca82e69SJohn Levon $elf_ddir/runtime.attr \ 20035ca82e69SJohn Levon >> $mail_msg_file 20045ca82e69SJohn Levon fi 20055ca82e69SJohn Levon fi 20065ca82e69SJohn Levon 20075ca82e69SJohn Levon # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 200826e7d9a8SRichard Lowe if [[ "$u_FLAG" == "y" ]]; then 20095ca82e69SJohn Levon p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 20105ca82e69SJohn Levon 20115ca82e69SJohn Levon # If parent lacks the ELF-data.$MACH directory, create it 20125ca82e69SJohn Levon if [[ ! -d $p_elf_ddir ]]; then 20135ca82e69SJohn Levon staffer mkdir -p $p_elf_ddir 20145ca82e69SJohn Levon fi 20155ca82e69SJohn Levon 20165ca82e69SJohn Levon # These files are used asynchronously by other builds for ABI 20175ca82e69SJohn Levon # verification, as above for the -A option. As such, we require 20185ca82e69SJohn Levon # the file replacement to be atomic. Copy the data to a temp 20195ca82e69SJohn Levon # file in the same filesystem and then rename into place. 20205ca82e69SJohn Levon ( 20215ca82e69SJohn Levon cd $elf_ddir 20225ca82e69SJohn Levon for elf_dfile in *; do 20235ca82e69SJohn Levon staffer cp $elf_dfile \ 20245ca82e69SJohn Levon ${p_elf_ddir}/${elf_dfile}.new 20255ca82e69SJohn Levon staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 20265ca82e69SJohn Levon ${p_elf_ddir}/${elf_dfile} 20275ca82e69SJohn Levon done 20285ca82e69SJohn Levon ) 20295ca82e69SJohn Levon fi 20305ca82e69SJohn Levonfi 20315ca82e69SJohn Levon 20325ca82e69SJohn Levon# "make check" begins 20335ca82e69SJohn Levon 20345ca82e69SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 20355ca82e69SJohn Levon # remove old check.out 20365ca82e69SJohn Levon rm -f $SRC/check.out 20375ca82e69SJohn Levon 20385ca82e69SJohn Levon rm -f $SRC/check-${MACH}.out 20395ca82e69SJohn Levon cd $SRC 20405ca82e69SJohn Levon $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 20415ca82e69SJohn Levon >> $LOGFILE 20425ca82e69SJohn Levon echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 20435ca82e69SJohn Levon 20445ca82e69SJohn Levon grep ":" $SRC/check-${MACH}.out | 2045eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 20465ca82e69SJohn Levon egrep -v "Ignoring unknown host" | \ 20475ca82e69SJohn Levon sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 20485ca82e69SJohn Levon 20495ca82e69SJohn Levon if [[ -s $TMPDIR/check_errors ]]; then 20505ca82e69SJohn Levon build_extras_ok=n 20515ca82e69SJohn Levon fi 20525ca82e69SJohn Levonelse 20535ca82e69SJohn Levon echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 20545ca82e69SJohn Levonfi 20555ca82e69SJohn Levon 20565ca82e69SJohn Levonecho "\n==== Find core files ====\n" | \ 20575ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 20585ca82e69SJohn Levon 20595ca82e69SJohn Levonfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 20605ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 20615ca82e69SJohn Levon 20625ca82e69SJohn Levonif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 20635ca82e69SJohn Levon echo "\n==== Diff unreferenced files (since last build) ====\n" \ 20645ca82e69SJohn Levon | tee -a $LOGFILE >>$mail_msg_file 20655ca82e69SJohn Levon rm -f $SRC/unref-${MACH}.ref 20665ca82e69SJohn Levon if [ -f $SRC/unref-${MACH}.out ]; then 20675ca82e69SJohn Levon mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 20685ca82e69SJohn Levon fi 20695ca82e69SJohn Levon 20705ca82e69SJohn Levon findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 20715ca82e69SJohn Levon ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 20725ca82e69SJohn Levon sort > $SRC/unref-${MACH}.out 20735ca82e69SJohn Levon 20745ca82e69SJohn Levon if [ ! -f $SRC/unref-${MACH}.ref ]; then 20755ca82e69SJohn Levon cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 20765ca82e69SJohn Levon fi 20775ca82e69SJohn Levon 20785ca82e69SJohn Levon diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 20795ca82e69SJohn Levonfi 20805ca82e69SJohn Levon 20815ca82e69SJohn Levon# Verify that the usual lists of files, such as exception lists, 20825ca82e69SJohn Levon# contain only valid references to files. If the build has failed, 20835ca82e69SJohn Levon# then don't check the proto area. 20845ca82e69SJohn LevonCHECK_PATHS=${CHECK_PATHS:-y} 20855ca82e69SJohn Levonif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 20865ca82e69SJohn Levon echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 20875ca82e69SJohn Levon >>$mail_msg_file 20885ca82e69SJohn Levon arg=-b 20895ca82e69SJohn Levon [ "$build_ok" = y ] && arg= 20905ca82e69SJohn Levon checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 20915ca82e69SJohn Levon if [[ -s $SRC/check-paths.out ]]; then 20925ca82e69SJohn Levon tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 20935ca82e69SJohn Levon build_extras_ok=n 20945ca82e69SJohn Levon fi 20955ca82e69SJohn Levonfi 20965ca82e69SJohn Levon 2097069e6b7eSAndy Fiddamanif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2098069e6b7eSAndy Fiddaman echo "\n==== Impact on file permissions ====\n" \ 2099069e6b7eSAndy Fiddaman >> $mail_msg_file 2100069e6b7eSAndy Fiddaman 21015ca82e69SJohn Levon if [ -n "$abspkg" ]; then 21025ca82e69SJohn Levon for d in "$abspkg"; do 2103eefeb0ceSBill Sommerfeld ( cd $d/pkg ; $MAKE -e pmodes ) | \ 2104eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " \ 2105eefeb0ceSBill Sommerfeld >> $mail_msg_file 21065ca82e69SJohn Levon done 21075ca82e69SJohn Levon fi 21085ca82e69SJohn Levonfi 21095ca82e69SJohn Levon 21105ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 211126e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == no || "$D_FLAG" == y ]]; then 21125ca82e69SJohn Levon do_wsdiff DEBUG $ROOT.prev $ROOT 21135ca82e69SJohn Levon fi 21145ca82e69SJohn Levon 211526e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == yes && "$F_FLAG" == n ]]; then 21165ca82e69SJohn Levon do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 21175ca82e69SJohn Levon fi 21185ca82e69SJohn Levonfi 21195ca82e69SJohn Levon 21205ca82e69SJohn LevonEND_DATE=`date` 21215ca82e69SJohn Levonecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 21225ca82e69SJohn Levon tee -a $LOGFILE >> $build_time_file 21235ca82e69SJohn Levon 21245ca82e69SJohn Levontypeset -i10 hours 21255ca82e69SJohn Levontypeset -Z2 minutes 21265ca82e69SJohn Levontypeset -Z2 seconds 21275ca82e69SJohn Levon 21285ca82e69SJohn Levonelapsed_time=$SECONDS 21295ca82e69SJohn Levon((hours = elapsed_time / 3600 )) 21305ca82e69SJohn Levon((minutes = elapsed_time / 60 % 60)) 21315ca82e69SJohn Levon((seconds = elapsed_time % 60)) 21325ca82e69SJohn Levon 21335ca82e69SJohn Levonecho "\n==== Total build time ====" | \ 21345ca82e69SJohn Levon tee -a $LOGFILE >> $build_time_file 21355ca82e69SJohn Levonecho "\nreal ${hours}:${minutes}:${seconds}" | \ 21365ca82e69SJohn Levon tee -a $LOGFILE >> $build_time_file 21375ca82e69SJohn Levon 21385ca82e69SJohn Levonif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21395ca82e69SJohn Levon staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 21405ca82e69SJohn Levon 21415ca82e69SJohn Levon # 21425ca82e69SJohn Levon # Produce a master list of unreferenced files -- ideally, we'd 21435ca82e69SJohn Levon # generate the master just once after all of the nightlies 21445ca82e69SJohn Levon # have finished, but there's no simple way to know when that 21455ca82e69SJohn Levon # will be. Instead, we assume that we're the last nightly to 21465ca82e69SJohn Levon # finish and merge all of the unref-${MACH}.out files in 21475ca82e69SJohn Levon # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 21485ca82e69SJohn Levon # finish, then this file will be the authoritative master 21495ca82e69SJohn Levon # list. Otherwise, another ${MACH}'s nightly will eventually 21505ca82e69SJohn Levon # overwrite ours with its own master, but in the meantime our 21515ca82e69SJohn Levon # temporary "master" will be no worse than any older master 21525ca82e69SJohn Levon # which was already on the parent. 21535ca82e69SJohn Levon # 21545ca82e69SJohn Levon 21555ca82e69SJohn Levon set -- $PARENT_WS/usr/src/unref-*.out 21565ca82e69SJohn Levon cp "$1" ${TMPDIR}/unref.merge 21575ca82e69SJohn Levon shift 21585ca82e69SJohn Levon 21595ca82e69SJohn Levon for unreffile; do 21605ca82e69SJohn Levon comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 21615ca82e69SJohn Levon mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 21625ca82e69SJohn Levon done 21635ca82e69SJohn Levon 21645ca82e69SJohn Levon staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 21655ca82e69SJohn Levonfi 21665ca82e69SJohn Levon 21675ca82e69SJohn Levon# 21685ca82e69SJohn Levon# All done save for the sweeping up. 21695ca82e69SJohn Levon# (whichever exit we hit here will trigger the "cleanup" trap which 21705ca82e69SJohn Levon# optionally sends mail on completion). 21715ca82e69SJohn Levon# 21725ca82e69SJohn Levonif [[ "$build_ok" == "y" ]]; then 21735ca82e69SJohn Levon if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 21745ca82e69SJohn Levon exit 0 21755ca82e69SJohn Levon fi 21765ca82e69SJohn Levonfi 21775ca82e69SJohn Levon 21785ca82e69SJohn Levonexit 1 2179