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. 31*e462c128SPatrick Mooney# Copyright 2025 Oxide Computer Company 32069e6b7eSAndy Fiddaman# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 33053feb15SBill 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 | \ 339053feb15SBill 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 496*e462c128SPatrick MooneyUSAGE='Usage: nightly [-in] [-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 501e49b90fbSBill Sommerfeld -B WS bringover from WS (directory or URL) 502e49b90fbSBill Sommerfeld -b BR bringover branch BR 503e49b90fbSBill Sommerfeld -d WS do build in WS (directory) 5045ca82e69SJohn Levon -V VERS set the build version string to VERS 5055ca82e69SJohn Levon 5065ca82e69SJohn Levon <env_file> file in Bourne shell syntax that sets and exports 5075ca82e69SJohn Levon variables that configure the operation of this script and many of 5085ca82e69SJohn Levon the scripts this one calls. If <env_file> does not exist, 5095ca82e69SJohn Levon it will be looked for in $OPTHOME/onbld/env. 5105ca82e69SJohn Levon 511e49b90fbSBill Sommerfeldnon-DEBUG is the default build type. Build options must be set in the 5125ca82e69SJohn LevonNIGHTLY_OPTIONS variable in the <env_file> as follows: 5135ca82e69SJohn Levon 5145ca82e69SJohn Levon -A check for ABI differences in .so files 5155ca82e69SJohn Levon -C check for cstyle/hdrchk errors 5165ca82e69SJohn Levon -D do a build with DEBUG on 5175ca82e69SJohn Levon -F do _not_ do a non-DEBUG build 5185ca82e69SJohn Levon -G gate keeper default group of options (-au) 5195ca82e69SJohn Levon -I integration engineer default group of options (-ampu) 520069e6b7eSAndy Fiddaman -L do not run pkglint 5215ca82e69SJohn Levon -M do not run pmodes (safe file permission checker) 5225ca82e69SJohn Levon -N do not run protocmp 5235ca82e69SJohn Levon -R default group of options for building a release (-mp) 5245ca82e69SJohn Levon -U update proto area in the parent 5255ca82e69SJohn Levon -V VERS set the build version string to VERS 5265ca82e69SJohn Levon -f find unreferenced files 5275ca82e69SJohn Levon -i do an incremental build (no "make clobber") 5285ca82e69SJohn Levon -m send mail to $MAILTO at end of build 5295ca82e69SJohn Levon -n do not do a bringover 5305ca82e69SJohn Levon -p create packages 5315ca82e69SJohn Levon -r check ELF runtime attributes in the proto area 5325ca82e69SJohn Levon -t build and use the tools in $SRC/tools (default setting) 5335ca82e69SJohn Levon -u update proto_list_$MACH and friends in the parent workspace; 5345ca82e69SJohn Levon when used with -f, also build an unrefmaster.out in the parent 5355ca82e69SJohn Levon -w report on differences between previous and current proto areas 5365ca82e69SJohn Levon' 5375ca82e69SJohn Levon# 5385ca82e69SJohn Levon# A log file will be generated under the name $LOGFILE 5395ca82e69SJohn Levon# for partially completed build and log.`date '+%F'` 5405ca82e69SJohn Levon# in the same directory for fully completed builds. 5415ca82e69SJohn Levon# 5425ca82e69SJohn Levon 5435ca82e69SJohn Levon# default values for low-level FLAGS; G I R are group FLAGS 5445ca82e69SJohn LevonA_FLAG=n 5455ca82e69SJohn LevonC_FLAG=n 5465ca82e69SJohn LevonD_FLAG=n 5475ca82e69SJohn LevonF_FLAG=n 5485ca82e69SJohn Levonf_FLAG=n 5495ca82e69SJohn Levoni_FLAG=n; i_CMD_LINE_FLAG=n 550069e6b7eSAndy FiddamanL_FLAG=n 5515ca82e69SJohn LevonM_FLAG=n 5525ca82e69SJohn Levonm_FLAG=n 5535ca82e69SJohn LevonN_FLAG=n 5545ca82e69SJohn Levonn_FLAG=n 5555ca82e69SJohn Levonp_FLAG=n 5565ca82e69SJohn Levonr_FLAG=n 5575ca82e69SJohn Levont_FLAG=y 5585ca82e69SJohn LevonU_FLAG=n 5595ca82e69SJohn Levonu_FLAG=n 5605ca82e69SJohn LevonV_FLAG=n 5615ca82e69SJohn Levonw_FLAG=n 5625ca82e69SJohn LevonW_FLAG=n 5635ca82e69SJohn Levon# 5645ca82e69SJohn Levonbuild_ok=y 5655ca82e69SJohn Levonbuild_extras_ok=y 5665ca82e69SJohn Levon 5675ca82e69SJohn Levon# 5685ca82e69SJohn Levon# examine arguments 5695ca82e69SJohn Levon# 5705ca82e69SJohn Levon 5715ca82e69SJohn LevonOPTIND=1 572e49b90fbSBill Sommerfeldwhile getopts +b:B:d:intV:W FLAG 5735ca82e69SJohn Levondo 5745ca82e69SJohn Levon case $FLAG in 575e49b90fbSBill Sommerfeld b ) BRINGOVER_BRANCH="$OPTARG" 576e49b90fbSBill Sommerfeld ;; 577e49b90fbSBill Sommerfeld B ) BRINGOVER_WS="$OPTARG" 578e49b90fbSBill Sommerfeld ;; 579e49b90fbSBill Sommerfeld d ) CODEMGR_WS="$OPTARG" 580e49b90fbSBill Sommerfeld ;; 5815ca82e69SJohn Levon i ) i_FLAG=y; i_CMD_LINE_FLAG=y 5825ca82e69SJohn Levon ;; 5835ca82e69SJohn Levon n ) n_FLAG=y 5845ca82e69SJohn Levon ;; 585*e462c128SPatrick Mooney +t ) 586*e462c128SPatrick Mooney # Builds which do not use in-gate tools are not supported, but 587*e462c128SPatrick Mooney # for legacy sake the option is still accepted. 588*e462c128SPatrick Mooney t_FLAG=n 5895ca82e69SJohn Levon ;; 5905ca82e69SJohn Levon V ) V_FLAG=y 5915ca82e69SJohn Levon V_ARG="$OPTARG" 5925ca82e69SJohn Levon ;; 5935ca82e69SJohn Levon W ) W_FLAG=y 5945ca82e69SJohn Levon ;; 5955ca82e69SJohn Levon \? ) echo "$USAGE" 5965ca82e69SJohn Levon exit 1 5975ca82e69SJohn Levon ;; 5985ca82e69SJohn Levon esac 5995ca82e69SJohn Levondone 6005ca82e69SJohn Levon 6015ca82e69SJohn Levon# correct argument count after options 6025ca82e69SJohn Levonshift `expr $OPTIND - 1` 6035ca82e69SJohn Levon 6045ca82e69SJohn Levon# test that the path to the environment-setting file was given 6055ca82e69SJohn Levonif [ $# -ne 1 ]; then 6065ca82e69SJohn Levon echo "$USAGE" 6075ca82e69SJohn Levon exit 1 6085ca82e69SJohn Levonfi 6095ca82e69SJohn Levon 6105ca82e69SJohn Levon# check if user is running nightly as root 6115ca82e69SJohn Levon# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 6125ca82e69SJohn Levon# when root invokes nightly. 6135ca82e69SJohn Levon/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 6145ca82e69SJohn LevonISUSER=$?; export ISUSER 6155ca82e69SJohn Levon 6165ca82e69SJohn Levon# 6175ca82e69SJohn Levon# force locale to C 6185ca82e69SJohn LevonLANG=C; export LANG 6195ca82e69SJohn LevonLC_ALL=C; export LC_ALL 6205ca82e69SJohn LevonLC_COLLATE=C; export LC_COLLATE 6215ca82e69SJohn LevonLC_CTYPE=C; export LC_CTYPE 6225ca82e69SJohn LevonLC_MESSAGES=C; export LC_MESSAGES 6235ca82e69SJohn LevonLC_MONETARY=C; export LC_MONETARY 6245ca82e69SJohn LevonLC_NUMERIC=C; export LC_NUMERIC 6255ca82e69SJohn LevonLC_TIME=C; export LC_TIME 6265ca82e69SJohn Levon 6275ca82e69SJohn Levon# clear environment variables we know to be bad for the build 6285ca82e69SJohn Levonunset LD_OPTIONS 6295ca82e69SJohn Levonunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 6305ca82e69SJohn Levonunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 6315ca82e69SJohn Levonunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 6325ca82e69SJohn Levonunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 6335ca82e69SJohn Levonunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 6345ca82e69SJohn Levonunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 6355ca82e69SJohn Levonunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 6365ca82e69SJohn Levonunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 6375ca82e69SJohn Levonunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 6385ca82e69SJohn Levonunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 6395ca82e69SJohn Levonunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 6405ca82e69SJohn Levonunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 6415ca82e69SJohn Levonunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 6425ca82e69SJohn Levonunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 6435ca82e69SJohn Levonunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 6445ca82e69SJohn Levonunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 6455ca82e69SJohn Levonunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 6465ca82e69SJohn Levonunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 6475ca82e69SJohn Levonunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 6485ca82e69SJohn Levonunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 6495ca82e69SJohn Levon 6505ca82e69SJohn Levonunset CONFIG 6515ca82e69SJohn Levonunset GROUP 6525ca82e69SJohn Levonunset OWNER 6535ca82e69SJohn Levonunset REMOTE 6545ca82e69SJohn Levonunset ENV 6555ca82e69SJohn Levonunset ARCH 6565ca82e69SJohn Levonunset CLASSPATH 6575ca82e69SJohn Levonunset NAME 6585ca82e69SJohn Levon 6595ca82e69SJohn Levon# 6605ca82e69SJohn Levon# To get ONBLD_TOOLS from the environment, it must come from the env file. 6615ca82e69SJohn Levon# If it comes interactively, it is generally TOOLS_PROTO, which will be 6625ca82e69SJohn Levon# clobbered before the compiler version checks, which will therefore fail. 6635ca82e69SJohn Levon# 6645ca82e69SJohn Levonunset ONBLD_TOOLS 6655ca82e69SJohn Levon 6665ca82e69SJohn Levon# 6675ca82e69SJohn Levon# Setup environmental variables 6685ca82e69SJohn Levon# 6695ca82e69SJohn Levonif [ -f /etc/nightly.conf ]; then 6705ca82e69SJohn Levon . /etc/nightly.conf 6715ca82e69SJohn Levonfi 6725ca82e69SJohn Levon 6735ca82e69SJohn Levonif [ -f $1 ]; then 67426e7d9a8SRichard Lowe if [[ $1 == */* ]]; then 6755ca82e69SJohn Levon . $1 6765ca82e69SJohn Levon else 6775ca82e69SJohn Levon . ./$1 6785ca82e69SJohn Levon fi 6795ca82e69SJohn Levonelse 6805ca82e69SJohn Levon if [ -f $OPTHOME/onbld/env/$1 ]; then 6815ca82e69SJohn Levon . $OPTHOME/onbld/env/$1 6825ca82e69SJohn Levon else 6835ca82e69SJohn Levon echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 6845ca82e69SJohn Levon exit 1 6855ca82e69SJohn Levon fi 6865ca82e69SJohn Levonfi 6875ca82e69SJohn Levon 6885ca82e69SJohn Levon# Check if we have sufficient data to continue... 6895ca82e69SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 6905ca82e69SJohn Levonif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 6915ca82e69SJohn Levon # Check if the gate data are valid if we don't do a "bringover" below 6925ca82e69SJohn Levon [[ -d "${CODEMGR_WS}" ]] || \ 6935ca82e69SJohn Levon fatal_error "Error: ${CODEMGR_WS} is not a directory." 6945ca82e69SJohn Levon [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 6955ca82e69SJohn Levon fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 6965ca82e69SJohn Levonfi 6975ca82e69SJohn Levon 6985ca82e69SJohn Levon# 6995ca82e69SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set. 7005ca82e69SJohn Levon# 7015ca82e69SJohn Levonif [ -z "$BUILD_PROJECT" ]; then 7025ca82e69SJohn Levon /usr/bin/newtask -c $$ 7035ca82e69SJohn Levonelse 7045ca82e69SJohn Levon /usr/bin/newtask -c $$ -p $BUILD_PROJECT 7055ca82e69SJohn Levonfi 7065ca82e69SJohn Levon 7075ca82e69SJohn Levonps -o taskid= -p $$ | read build_taskid 7085ca82e69SJohn Levonps -o project= -p $$ | read build_project 7095ca82e69SJohn Levon 7105ca82e69SJohn Levon# 7115ca82e69SJohn Levon# See if NIGHTLY_OPTIONS is set 7125ca82e69SJohn Levon# 7135ca82e69SJohn Levonif [ "$NIGHTLY_OPTIONS" = "" ]; then 714e49b90fbSBill Sommerfeld print -u2 "NIGHTLY_OPTIONS must be set in environment file" 715e49b90fbSBill Sommerfeld echo "$USAGE" 716e49b90fbSBill Sommerfeld exit 1 7175ca82e69SJohn Levonfi 7185ca82e69SJohn Levon 7195ca82e69SJohn Levon# 7205ca82e69SJohn Levon# If BRINGOVER_WS was not specified, let it default to CLONE_WS 7215ca82e69SJohn Levon# 7225ca82e69SJohn Levonif [ "$BRINGOVER_WS" = "" ]; then 7235ca82e69SJohn Levon BRINGOVER_WS=$CLONE_WS 7245ca82e69SJohn Levonfi 7255ca82e69SJohn Levon 726fc8c3a51SBill Sommerfeldif [ "$BRINGOVER_REMOTE" = "" ]; then 727fc8c3a51SBill Sommerfeld BRINGOVER_REMOTE=nightly_bringover_ws 728fc8c3a51SBill Sommerfeldfi 729fc8c3a51SBill Sommerfeld 730fc8c3a51SBill Sommerfeldif [ "$BRINGOVER_SCM" = "" ]; then 731fc8c3a51SBill Sommerfeld BRINGOVER_SCM=git 7325ca82e69SJohn Levonfi 7335ca82e69SJohn Levon 7345ca82e69SJohn Levoncheck_closed_bins 7355ca82e69SJohn Levon 7365ca82e69SJohn Levon# 7375ca82e69SJohn Levon# Note: changes to the option letters here should also be applied to the 7385ca82e69SJohn Levon# bldenv script. `d' is listed for backward compatibility. 7395ca82e69SJohn Levon# 7405ca82e69SJohn LevonNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 7415ca82e69SJohn LevonOPTIND=1 742069e6b7eSAndy Fiddamanwhile getopts +ABCDdFfGIiLMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 7435ca82e69SJohn Levondo 7445ca82e69SJohn Levon case $FLAG in 7455ca82e69SJohn Levon A ) A_FLAG=y 7465ca82e69SJohn Levon ;; 7475ca82e69SJohn Levon B ) D_FLAG=y 7485ca82e69SJohn Levon ;; # old version of D 7495ca82e69SJohn Levon C ) C_FLAG=y 7505ca82e69SJohn Levon ;; 7515ca82e69SJohn Levon D ) D_FLAG=y 7525ca82e69SJohn Levon ;; 7535ca82e69SJohn Levon F ) F_FLAG=y 7545ca82e69SJohn Levon ;; 7555ca82e69SJohn Levon f ) f_FLAG=y 7565ca82e69SJohn Levon ;; 7575ca82e69SJohn Levon G ) u_FLAG=y 7585ca82e69SJohn Levon ;; 7595ca82e69SJohn Levon I ) m_FLAG=y 7605ca82e69SJohn Levon p_FLAG=y 7615ca82e69SJohn Levon u_FLAG=y 7625ca82e69SJohn Levon ;; 7635ca82e69SJohn Levon i ) i_FLAG=y 7645ca82e69SJohn Levon ;; 765069e6b7eSAndy Fiddaman L ) L_FLAG=y 766069e6b7eSAndy Fiddaman ;; 7675ca82e69SJohn Levon M ) M_FLAG=y 7685ca82e69SJohn Levon ;; 7695ca82e69SJohn Levon m ) m_FLAG=y 7705ca82e69SJohn Levon ;; 7715ca82e69SJohn Levon N ) N_FLAG=y 7725ca82e69SJohn Levon ;; 7735ca82e69SJohn Levon n ) n_FLAG=y 7745ca82e69SJohn Levon ;; 7755ca82e69SJohn Levon p ) p_FLAG=y 7765ca82e69SJohn Levon ;; 7775ca82e69SJohn Levon R ) m_FLAG=y 7785ca82e69SJohn Levon p_FLAG=y 7795ca82e69SJohn Levon ;; 7805ca82e69SJohn Levon r ) r_FLAG=y 7815ca82e69SJohn Levon ;; 782*e462c128SPatrick Mooney +t ) 783*e462c128SPatrick Mooney # Builds which do not use in-gate tools are not supported, but 784*e462c128SPatrick Mooney # for legacy sake the option is still accepted. 785*e462c128SPatrick Mooney t_FLAG=n 7865ca82e69SJohn Levon ;; 7875ca82e69SJohn Levon U ) if [ -z "${PARENT_ROOT}" ]; then 7885ca82e69SJohn Levon echo "PARENT_ROOT must be set if the U flag is" \ 7895ca82e69SJohn Levon "present in NIGHTLY_OPTIONS." 7905ca82e69SJohn Levon exit 1 7915ca82e69SJohn Levon fi 7925ca82e69SJohn Levon NIGHTLY_PARENT_ROOT=$PARENT_ROOT 7935ca82e69SJohn Levon if [ -n "${PARENT_TOOLS_ROOT}" ]; then 7945ca82e69SJohn Levon NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 7955ca82e69SJohn Levon fi 7965ca82e69SJohn Levon U_FLAG=y 7975ca82e69SJohn Levon ;; 7985ca82e69SJohn Levon u ) u_FLAG=y 7995ca82e69SJohn Levon ;; 8005ca82e69SJohn Levon w ) w_FLAG=y 8015ca82e69SJohn Levon ;; 8025ca82e69SJohn Levon W ) W_FLAG=y 8035ca82e69SJohn Levon ;; 8045ca82e69SJohn Levon \? ) echo "$USAGE" 8055ca82e69SJohn Levon exit 1 8065ca82e69SJohn Levon ;; 8075ca82e69SJohn Levon esac 8085ca82e69SJohn Levondone 8095ca82e69SJohn Levon 8109cc2e6acSMatt Fiddaman# Skip pkglint if packages aren't being built 8119cc2e6acSMatt Fiddaman[ $p_FLAG = n ] && L_FLAG=y 8129cc2e6acSMatt Fiddaman 8135ca82e69SJohn Levonif [ $ISUSER -ne 0 ]; then 8145ca82e69SJohn Levon # Set default value for STAFFER, if needed. 8155ca82e69SJohn Levon if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 8165ca82e69SJohn Levon STAFFER=`/usr/xpg4/bin/id -un` 8175ca82e69SJohn Levon export STAFFER 8185ca82e69SJohn Levon fi 8195ca82e69SJohn Levonfi 8205ca82e69SJohn Levon 8215ca82e69SJohn Levonif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 8225ca82e69SJohn Levon MAILTO=$STAFFER 8235ca82e69SJohn Levon export MAILTO 8245ca82e69SJohn Levonfi 8255ca82e69SJohn Levon 8265ca82e69SJohn LevonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 8275ca82e69SJohn LevonPATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 8285ca82e69SJohn LevonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 8295ca82e69SJohn Levonexport PATH 8305ca82e69SJohn Levon 8315ca82e69SJohn Levon# roots of source trees, both relative to $SRC and absolute. 8325ca82e69SJohn Levonrelsrcdirs="." 8335ca82e69SJohn Levonabssrcdirs="$SRC" 8345ca82e69SJohn Levon 8355ca82e69SJohn LevonPROTOCMPTERSE="protocmp.terse -gu" 8365ca82e69SJohn LevonPOUND_SIGN="#" 8376112cec5SJoshua M. Clulowbasews="$(basename "$CODEMGR_WS")" 8385ca82e69SJohn Levon# have we set RELEASE_DATE in our env file? 8395ca82e69SJohn Levonif [ -z "$RELEASE_DATE" ]; then 8405ca82e69SJohn Levon RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 8415ca82e69SJohn Levonfi 8426112cec5SJoshua M. Clulownow=$(LC_ALL=C date +%Y-%b-%d) 8436112cec5SJoshua M. ClulowDEV_CM_TAIL="development build: $LOGNAME $now [$basews]" 8445ca82e69SJohn Levon 8456112cec5SJoshua M. Clulow# 8466112cec5SJoshua M. Clulow# We export POUND_SIGN, RELEASE_DATE and DEV_CM_TAIL to speed up the build 8476112cec5SJoshua M. Clulow# process by avoiding repeated shell invocations to evaluate Makefile.master 8485ca82e69SJohn Levon# definitions. 8496112cec5SJoshua M. Clulow# 8506112cec5SJoshua M. Clulowexport POUND_SIGN RELEASE_DATE DEV_CM_TAIL 8515ca82e69SJohn Levon 8525ca82e69SJohn Levonmaketype="distributed" 8535ca82e69SJohn Levonif [[ -z "$MAKE" ]]; then 8545ca82e69SJohn Levon MAKE=dmake 8555ca82e69SJohn Levonelif [[ ! -x "$MAKE" ]]; then 8565ca82e69SJohn Levon echo "\$MAKE is set to garbage in the environment" 8575ca82e69SJohn Levon exit 1 8585ca82e69SJohn Levonfi 8595ca82e69SJohn Levonexport PATH 8605ca82e69SJohn Levonexport MAKE 8615ca82e69SJohn Levon 8625ca82e69SJohn Levonif [ "${SUNWSPRO}" != "" ]; then 8635ca82e69SJohn Levon PATH="${SUNWSPRO}/bin:$PATH" 8645ca82e69SJohn Levon export PATH 8655ca82e69SJohn Levonfi 8665ca82e69SJohn Levon 8675ca82e69SJohn Levonhostname=$(uname -n) 86826e7d9a8SRichard Loweif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS == 0 ]] 8695ca82e69SJohn Levonthen 8705ca82e69SJohn Levon maxjobs= 8715ca82e69SJohn Levon if [[ -f $HOME/.make.machines ]] 8725ca82e69SJohn Levon then 873244a25b4SBill Sommerfeld egrep -i $'^[\t ]*'"${hostname}"$'[\t .]' \ 8745ca82e69SJohn Levon $HOME/.make.machines | read host jobs 8755ca82e69SJohn Levon maxjobs=${jobs##*=} 8765ca82e69SJohn Levon fi 8775ca82e69SJohn Levon 87826e7d9a8SRichard Lowe if [[ $maxjobs != +([0-9]) || $maxjobs == 0 ]] 8795ca82e69SJohn Levon then 8805ca82e69SJohn Levon # default 8815ca82e69SJohn Levon maxjobs=4 8825ca82e69SJohn Levon fi 8835ca82e69SJohn Levon 8845ca82e69SJohn Levon export DMAKE_MAX_JOBS=$maxjobs 8855ca82e69SJohn Levonfi 8865ca82e69SJohn Levon 8875ca82e69SJohn LevonDMAKE_MODE=parallel; 8885ca82e69SJohn Levonexport DMAKE_MODE 8895ca82e69SJohn Levon 8905ca82e69SJohn Levonif [ -z "${ROOT}" ]; then 8915ca82e69SJohn Levon echo "ROOT must be set." 8925ca82e69SJohn Levon exit 1 8935ca82e69SJohn Levonfi 8945ca82e69SJohn Levon 8955ca82e69SJohn LevonTMPDIR="/tmp/nightly.tmpdir.$$" 8965ca82e69SJohn Levonexport TMPDIR 8975ca82e69SJohn Levonrm -rf ${TMPDIR} 8985ca82e69SJohn Levonmkdir -p $TMPDIR || exit 1 8995ca82e69SJohn Levonchmod 777 $TMPDIR 9005ca82e69SJohn Levon 9015ca82e69SJohn Levon# 9025ca82e69SJohn Levon# Work around folks who have historically used GCC_ROOT and convert it to 9035ca82e69SJohn Levon# GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could 9045ca82e69SJohn Levon# mess up the case where multiple different gcc versions are being used to 9055ca82e69SJohn Levon# shadow). 9065ca82e69SJohn Levon# 9075ca82e69SJohn Levonif [[ -n "${GCC_ROOT}" ]]; then 9085ca82e69SJohn Levon export GNUC_ROOT=${GCC_ROOT} 9095ca82e69SJohn Levonfi 9105ca82e69SJohn Levon 9115ca82e69SJohn Levon# 9125ca82e69SJohn Levon# Tools should only be built non-DEBUG. Keep track of the tools proto 9135ca82e69SJohn Levon# area path relative to $TOOLS, because the latter changes in an 9145ca82e69SJohn Levon# export build. 9155ca82e69SJohn Levon# 9165ca82e69SJohn Levon# TOOLS_PROTO is included below for builds other than usr/src/tools 9175ca82e69SJohn Levon# that look for this location. For usr/src/tools, this will be 9185ca82e69SJohn Levon# overridden on the $MAKE command line in build_tools(). 9195ca82e69SJohn Levon# 9205ca82e69SJohn LevonTOOLS=${SRC}/tools 9215ca82e69SJohn LevonTOOLS_PROTO_REL=proto/root_${MACH}-nd 9225ca82e69SJohn LevonTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 9235ca82e69SJohn Levon 9245ca82e69SJohn Levonunset CFLAGS LD_LIBRARY_PATH LDFLAGS 9255ca82e69SJohn Levon 926fc8c3a51SBill Sommerfeld# 927fc8c3a51SBill Sommerfeld# Echo the SCM type of the parent workspace, this can't just be which_scm 928fc8c3a51SBill Sommerfeld# as that does not know how to identify various network repositories. 929fc8c3a51SBill Sommerfeld# 930fc8c3a51SBill Sommerfeldfunction parent_wstype { 931fc8c3a51SBill Sommerfeld typeset scm_type junk 932fc8c3a51SBill Sommerfeld 933fc8c3a51SBill Sommerfeld CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 934fc8c3a51SBill Sommerfeld | read scm_type junk 935fc8c3a51SBill Sommerfeld if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 936fc8c3a51SBill Sommerfeld # Probe BRINGOVER_WS to determine its type 937fc8c3a51SBill Sommerfeld case "$BRINGOVER_WS" in 938fc8c3a51SBill Sommerfeld git://* | http://*.git | https://*.git) 939fc8c3a51SBill Sommerfeld scm_type="git" 940fc8c3a51SBill Sommerfeld ;; 941fc8c3a51SBill Sommerfeld ssh://* | http://* | https://* ) 942fc8c3a51SBill Sommerfeld scm_type="${BRINGOVER_SCM}" 943fc8c3a51SBill Sommerfeld ;; 944fc8c3a51SBill Sommerfeld *) scm_type="none" 945fc8c3a51SBill Sommerfeld ;; 946fc8c3a51SBill Sommerfeld esac 947fc8c3a51SBill Sommerfeld fi 948fc8c3a51SBill Sommerfeld 949fc8c3a51SBill Sommerfeld # fold both unsupported and unrecognized results into "none" 950fc8c3a51SBill Sommerfeld case "$scm_type" in 951fc8c3a51SBill Sommerfeld mercurial|git) 952fc8c3a51SBill Sommerfeld ;; 953fc8c3a51SBill Sommerfeld *) scm_type=none 954fc8c3a51SBill Sommerfeld ;; 955fc8c3a51SBill Sommerfeld esac 956fc8c3a51SBill Sommerfeld 957fc8c3a51SBill Sommerfeld echo $scm_type 958fc8c3a51SBill Sommerfeld} 959fc8c3a51SBill Sommerfeld 960fc8c3a51SBill Sommerfeld# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 961fc8c3a51SBill Sommerfeldfunction child_wstype { 962fc8c3a51SBill Sommerfeld typeset scm_type junk 963fc8c3a51SBill Sommerfeld 964fc8c3a51SBill Sommerfeld # Probe CODEMGR_WS to determine its type 965fc8c3a51SBill Sommerfeld if [[ -d $CODEMGR_WS ]]; then 966fc8c3a51SBill Sommerfeld $WHICH_SCM | read scm_type junk || exit 1 967fc8c3a51SBill Sommerfeld fi 968fc8c3a51SBill Sommerfeld 969fc8c3a51SBill Sommerfeld case "$scm_type" in 970fc8c3a51SBill Sommerfeld none|git|mercurial) 971fc8c3a51SBill Sommerfeld ;; 972fc8c3a51SBill Sommerfeld *) scm_type=none 973fc8c3a51SBill Sommerfeld ;; 974fc8c3a51SBill Sommerfeld esac 975fc8c3a51SBill Sommerfeld 976fc8c3a51SBill Sommerfeld echo $scm_type 977fc8c3a51SBill Sommerfeld} 978fc8c3a51SBill Sommerfeld 9795ca82e69SJohn Levon# create directories that are automatically removed if the nightly script 9805ca82e69SJohn Levon# fails to start correctly 9815ca82e69SJohn Levonfunction newdir { 9825ca82e69SJohn Levon dir=$1 9835ca82e69SJohn Levon toadd= 9845ca82e69SJohn Levon while [ ! -d $dir ]; do 9855ca82e69SJohn Levon toadd="$dir $toadd" 9865ca82e69SJohn Levon dir=`dirname $dir` 9875ca82e69SJohn Levon done 9885ca82e69SJohn Levon torm= 9895ca82e69SJohn Levon newlist= 9905ca82e69SJohn Levon for dir in $toadd; do 9915ca82e69SJohn Levon if staffer mkdir $dir; then 9925ca82e69SJohn Levon newlist="$ISUSER $dir $newlist" 9935ca82e69SJohn Levon torm="$dir $torm" 9945ca82e69SJohn Levon else 9955ca82e69SJohn Levon [ -z "$torm" ] || staffer rmdir $torm 9965ca82e69SJohn Levon return 1 9975ca82e69SJohn Levon fi 9985ca82e69SJohn Levon done 9995ca82e69SJohn Levon newdirlist="$newlist $newdirlist" 10005ca82e69SJohn Levon return 0 10015ca82e69SJohn Levon} 10025ca82e69SJohn Levonnewdirlist= 10035ca82e69SJohn Levon 1004fc8c3a51SBill Sommerfeld# Initialize the git repo before creating the log subdir; "git clone" insists 1005fc8c3a51SBill Sommerfeld# that a preexisting directory be empty. 1006fc8c3a51SBill Sommerfeld# Use --reference-if-able to share most of the parent's .git tree. 1007fc8c3a51SBill Sommerfeldtype init_git > /dev/null 2>&1 || function init_git { 1008fc8c3a51SBill Sommerfeld if [ -d "${BRINGOVER_WS}" ]; then 1009fc8c3a51SBill Sommerfeld REF_WS="--reference-if-able $(git -C ${BRINGOVER_WS} rev-parse --path-format=absolute --git-common-dir)" 1010fc8c3a51SBill Sommerfeld fi 1011fc8c3a51SBill Sommerfeld staffer git clone \ 1012fc8c3a51SBill Sommerfeld --no-checkout \ 1013fc8c3a51SBill Sommerfeld ${CLONE_OPTIONS} \ 1014fc8c3a51SBill Sommerfeld --origin ${BRINGOVER_REMOTE} \ 1015fc8c3a51SBill Sommerfeld ${REF_WS} \ 1016fc8c3a51SBill Sommerfeld ${BRINGOVER_WS} ${CODEMGR_WS} 1017fc8c3a51SBill Sommerfeld} 1018fc8c3a51SBill Sommerfeld 1019fc8c3a51SBill Sommerfeld# All mercurial initialization is done in bringover_mercurial 1020fc8c3a51SBill Sommerfeldtype init_mercurial > /dev/null 2>&1 || function init_mercurial { 1021fc8c3a51SBill Sommerfeld newdir $CODEMGR_WS 1022fc8c3a51SBill Sommerfeld} 1023fc8c3a51SBill Sommerfeld 1024fc8c3a51SBill Sommerfeldtype init_none > /dev/null 2>&1 || function init_none { 1025fc8c3a51SBill Sommerfeld newdir $CODEMGR_WS 1026fc8c3a51SBill Sommerfeld} 1027fc8c3a51SBill Sommerfeld 1028fc8c3a51SBill Sommerfeldfunction create_build_ws { 1029fc8c3a51SBill Sommerfeld PARENT_SCM_TYPE=$(parent_wstype) 1030fc8c3a51SBill Sommerfeld 1031fc8c3a51SBill Sommerfeld eval "init_${PARENT_SCM_TYPE}" 2>&1 1032fc8c3a51SBill Sommerfeld} 1033fc8c3a51SBill Sommerfeld 1034fc8c3a51SBill Sommerfeld[ -d $CODEMGR_WS ] || create_build_ws || exit 1 10355ca82e69SJohn Levon 10365ca82e69SJohn Levon# since this script assumes the build is from full source, it nullifies 10375ca82e69SJohn Levon# variables likely to have been set by a "ws" script; nullification 10385ca82e69SJohn Levon# confines the search space for headers and libraries to the proto area 10395ca82e69SJohn Levon# built from this immediate source. 10405ca82e69SJohn LevonENVLDLIBS1= 10415ca82e69SJohn LevonENVLDLIBS2= 10425ca82e69SJohn LevonENVLDLIBS3= 10435ca82e69SJohn LevonENVCPPFLAGS1= 10445ca82e69SJohn LevonENVCPPFLAGS2= 10455ca82e69SJohn LevonENVCPPFLAGS3= 10465ca82e69SJohn LevonENVCPPFLAGS4= 10475ca82e69SJohn LevonPARENT_ROOT= 10485ca82e69SJohn Levon 10495ca82e69SJohn Levonexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 10505ca82e69SJohn Levon ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 10515ca82e69SJohn Levon 10525ca82e69SJohn LevonPKGARCHIVE_ORIG=$PKGARCHIVE 10535ca82e69SJohn Levon 10545ca82e69SJohn Levon# 10555ca82e69SJohn Levon# Juggle the logs and optionally send mail on completion. 10565ca82e69SJohn Levon# 10575ca82e69SJohn Levon 10585ca82e69SJohn Levonfunction logshuffle { 10595ca82e69SJohn Levon LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 10605ca82e69SJohn Levon if [ -f $LLOG -o -d $LLOG ]; then 10615ca82e69SJohn Levon LLOG=$LLOG.$$ 10625ca82e69SJohn Levon fi 10635ca82e69SJohn Levon 10645ca82e69SJohn Levon rm -f "$ATLOG/latest" 2>/dev/null 10655ca82e69SJohn Levon mkdir -p $LLOG 10665ca82e69SJohn Levon export LLOG 10675ca82e69SJohn Levon 10685ca82e69SJohn Levon if [ "$build_ok" = "y" ]; then 10695ca82e69SJohn Levon mv $ATLOG/proto_list_${MACH} $LLOG 10705ca82e69SJohn Levon 10715ca82e69SJohn Levon if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 10725ca82e69SJohn Levon mv $ATLOG/proto_list_tools_${MACH} $LLOG 10735ca82e69SJohn Levon fi 10745ca82e69SJohn Levon 10755ca82e69SJohn Levon if [ -f $TMPDIR/wsdiff.results ]; then 10765ca82e69SJohn Levon mv $TMPDIR/wsdiff.results $LLOG 10775ca82e69SJohn Levon fi 10785ca82e69SJohn Levon 10795ca82e69SJohn Levon if [ -f $TMPDIR/wsdiff-nd.results ]; then 10805ca82e69SJohn Levon mv $TMPDIR/wsdiff-nd.results $LLOG 10815ca82e69SJohn Levon fi 10825ca82e69SJohn Levon fi 10835ca82e69SJohn Levon 10845ca82e69SJohn Levon # 10855ca82e69SJohn Levon # Now that we're about to send mail, it's time to check the noise 10865ca82e69SJohn Levon # file. In the event that an error occurs beyond this point, it will 10875ca82e69SJohn Levon # be recorded in the nightly.log file, but nowhere else. This would 10885ca82e69SJohn Levon # include only errors that cause the copying of the noise log to fail 10895ca82e69SJohn Levon # or the mail itself not to be sent. 10905ca82e69SJohn Levon # 10915ca82e69SJohn Levon 10925ca82e69SJohn Levon exec >>$LOGFILE 2>&1 10935ca82e69SJohn Levon if [ -s $build_noise_file ]; then 10945ca82e69SJohn Levon echo "\n==== Nightly build noise ====\n" | 10955ca82e69SJohn Levon tee -a $LOGFILE >>$mail_msg_file 10965ca82e69SJohn Levon cat $build_noise_file >>$LOGFILE 10975ca82e69SJohn Levon cat $build_noise_file >>$mail_msg_file 10985ca82e69SJohn Levon echo | tee -a $LOGFILE >>$mail_msg_file 10995ca82e69SJohn Levon fi 11005ca82e69SJohn Levon rm -f $build_noise_file 11015ca82e69SJohn Levon 11025ca82e69SJohn Levon case "$build_ok" in 11035ca82e69SJohn Levon y) 11045ca82e69SJohn Levon state=Completed 11055ca82e69SJohn Levon ;; 11065ca82e69SJohn Levon i) 11075ca82e69SJohn Levon state=Interrupted 11085ca82e69SJohn Levon ;; 11095ca82e69SJohn Levon *) 11105ca82e69SJohn Levon state=Failed 11115ca82e69SJohn Levon ;; 11125ca82e69SJohn Levon esac 11135ca82e69SJohn Levon 11145ca82e69SJohn Levon if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 11155ca82e69SJohn Levon state=Failed 11165ca82e69SJohn Levon fi 11175ca82e69SJohn Levon 11185ca82e69SJohn Levon NIGHTLY_STATUS=$state 11195ca82e69SJohn Levon export NIGHTLY_STATUS 11205ca82e69SJohn Levon 11215ca82e69SJohn Levon run_hook POST_NIGHTLY $state 11225ca82e69SJohn Levon run_hook SYS_POST_NIGHTLY $state 11235ca82e69SJohn Levon 11245ca82e69SJohn Levon # 11255ca82e69SJohn Levon # mailx(1) sets From: based on the -r flag 11265ca82e69SJohn Levon # if it is given. 11275ca82e69SJohn Levon # 11285ca82e69SJohn Levon mailx_r= 11295ca82e69SJohn Levon if [[ -n "${MAILFROM}" ]]; then 11305ca82e69SJohn Levon mailx_r="-r ${MAILFROM}" 11315ca82e69SJohn Levon fi 11325ca82e69SJohn Levon 11335ca82e69SJohn Levon cat $build_time_file $build_environ_file $mail_msg_file \ 11345ca82e69SJohn Levon > ${LLOG}/mail_msg 11355ca82e69SJohn Levon if [ "$m_FLAG" = "y" ]; then 11366112cec5SJoshua M. Clulow /usr/bin/mailx ${mailx_r} -s \ 11376112cec5SJoshua M. Clulow "Nightly ${MACH} Build of ${basews} ${state}." \ 11386112cec5SJoshua M. Clulow "${MAILTO}" < "${LLOG}/mail_msg" 11395ca82e69SJohn Levon fi 11405ca82e69SJohn Levon 11415ca82e69SJohn Levon if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 11425ca82e69SJohn Levon staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 11435ca82e69SJohn Levon staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 11445ca82e69SJohn Levon fi 11455ca82e69SJohn Levon 11465ca82e69SJohn Levon mv $LOGFILE $LLOG 11475ca82e69SJohn Levon 11485ca82e69SJohn Levon ln -s "$LLOG" "$ATLOG/latest" 11495ca82e69SJohn Levon} 11505ca82e69SJohn Levon 11515ca82e69SJohn Levon# 11525ca82e69SJohn Levon# Remove the locks and temporary files on any exit 11535ca82e69SJohn Levon# 11545ca82e69SJohn Levonfunction cleanup { 11555ca82e69SJohn Levon logshuffle 11565ca82e69SJohn Levon 11575ca82e69SJohn Levon [ -z "$lockfile" ] || staffer rm -f $lockfile 11585ca82e69SJohn Levon [ -z "$atloglockfile" ] || rm -f $atloglockfile 11595ca82e69SJohn Levon [ -z "$ulockfile" ] || staffer rm -f $ulockfile 11605ca82e69SJohn Levon [ -z "$Ulockfile" ] || rm -f $Ulockfile 11615ca82e69SJohn Levon 11625ca82e69SJohn Levon set -- $newdirlist 11635ca82e69SJohn Levon while [ $# -gt 0 ]; do 11645ca82e69SJohn Levon ISUSER=$1 staffer rmdir $2 11655ca82e69SJohn Levon shift; shift 11665ca82e69SJohn Levon done 11675ca82e69SJohn Levon rm -rf $TMPDIR 11685ca82e69SJohn Levon} 11695ca82e69SJohn Levon 11705ca82e69SJohn Levonfunction cleanup_signal { 11715ca82e69SJohn Levon build_ok=i 11725ca82e69SJohn Levon # this will trigger cleanup(), above. 11735ca82e69SJohn Levon exit 1 11745ca82e69SJohn Levon} 11755ca82e69SJohn Levon 11765ca82e69SJohn Levontrap cleanup 0 11775ca82e69SJohn Levontrap cleanup_signal 1 2 3 15 11785ca82e69SJohn Levon 11795ca82e69SJohn Levon# 11805ca82e69SJohn Levon# Generic lock file processing -- make sure that the lock file doesn't 11815ca82e69SJohn Levon# exist. If it does, it should name the build host and PID. If it 11825ca82e69SJohn Levon# doesn't, then make sure we can create it. Clean up locks that are 11835ca82e69SJohn Levon# known to be stale (assumes host name is unique among build systems 11845ca82e69SJohn Levon# for the workspace). 11855ca82e69SJohn Levon# 11865ca82e69SJohn Levonfunction create_lock { 11875ca82e69SJohn Levon lockf=$1 11885ca82e69SJohn Levon lockvar=$2 11895ca82e69SJohn Levon 11905ca82e69SJohn Levon ldir=`dirname $lockf` 11915ca82e69SJohn Levon [ -d $ldir ] || newdir $ldir || exit 1 11925ca82e69SJohn Levon eval $lockvar=$lockf 11935ca82e69SJohn Levon 11945ca82e69SJohn Levon while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 11955ca82e69SJohn Levon ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 11965ca82e69SJohn Levon if [ "$host" != "$hostname" ]; then 11975ca82e69SJohn Levon echo "$MACH build of $basews apparently" \ 11985ca82e69SJohn Levon "already started by $user on $host as $pid." 11995ca82e69SJohn Levon exit 1 12005ca82e69SJohn Levon elif kill -s 0 $pid 2>/dev/null; then 12015ca82e69SJohn Levon echo "$MACH build of $basews already started" \ 12025ca82e69SJohn Levon "by $user as $pid." 12035ca82e69SJohn Levon exit 1 12045ca82e69SJohn Levon else 12055ca82e69SJohn Levon # stale lock; clear it out and try again 12065ca82e69SJohn Levon rm -f $lockf 12075ca82e69SJohn Levon fi 12085ca82e69SJohn Levon done 12095ca82e69SJohn Levon} 12105ca82e69SJohn Levon 12115ca82e69SJohn Levon# 12125ca82e69SJohn Levon# Return the list of interesting proto areas, depending on the current 12135ca82e69SJohn Levon# options. 12145ca82e69SJohn Levon# 12155ca82e69SJohn Levonfunction allprotos { 12165ca82e69SJohn Levon typeset roots="$ROOT" 12175ca82e69SJohn Levon 121826e7d9a8SRichard Lowe if [[ "$F_FLAG" == n && "$MULTI_PROTO" == yes ]]; then 12195ca82e69SJohn Levon roots="$roots $ROOT-nd" 12205ca82e69SJohn Levon fi 12215ca82e69SJohn Levon 12225ca82e69SJohn Levon echo $roots 12235ca82e69SJohn Levon} 12245ca82e69SJohn Levon 12255ca82e69SJohn Levon# Ensure no other instance of this script is running on this host. 12265ca82e69SJohn Levon# LOCKNAME can be set in <env_file>, and is by default, but is not 12275ca82e69SJohn Levon# required due to the use of $ATLOG below. 12285ca82e69SJohn Levonif [ -n "$LOCKNAME" ]; then 12295ca82e69SJohn Levon create_lock /tmp/$LOCKNAME "lockfile" 12305ca82e69SJohn Levonfi 12315ca82e69SJohn Levon# 12325ca82e69SJohn Levon# Create from one, two, or three other locks: 12335ca82e69SJohn Levon# $ATLOG/nightly.lock 12345ca82e69SJohn Levon# - protects against multiple builds in same workspace 12355ca82e69SJohn Levon# $PARENT_WS/usr/src/nightly.$MACH.lock 12365ca82e69SJohn Levon# - protects against multiple 'u' copy-backs 12375ca82e69SJohn Levon# $NIGHTLY_PARENT_ROOT/nightly.lock 12385ca82e69SJohn Levon# - protects against multiple 'U' copy-backs 12395ca82e69SJohn Levon# 12405ca82e69SJohn Levon# Overriding ISUSER to 1 causes the lock to be created as root if the 12415ca82e69SJohn Levon# script is run as root. The default is to create it as $STAFFER. 12425ca82e69SJohn LevonISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 12435ca82e69SJohn Levonif [ "$u_FLAG" = "y" ]; then 12445ca82e69SJohn Levon create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 12455ca82e69SJohn Levonfi 12465ca82e69SJohn Levonif [ "$U_FLAG" = "y" ]; then 12475ca82e69SJohn Levon # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 12485ca82e69SJohn Levon ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 12495ca82e69SJohn Levonfi 12505ca82e69SJohn Levon 12515ca82e69SJohn Levon# Locks have been taken, so we're doing a build and we're committed to 12525ca82e69SJohn Levon# the directories we may have created so far. 12535ca82e69SJohn Levonnewdirlist= 12545ca82e69SJohn Levon 12555ca82e69SJohn Levon# 12565ca82e69SJohn Levon# Create mail_msg_file 12575ca82e69SJohn Levon# 12585ca82e69SJohn Levonmail_msg_file="${TMPDIR}/mail_msg" 12595ca82e69SJohn Levontouch $mail_msg_file 12605ca82e69SJohn Levonbuild_time_file="${TMPDIR}/build_time" 12615ca82e69SJohn Levonbuild_environ_file="${TMPDIR}/build_environ" 12625ca82e69SJohn Levontouch $build_environ_file 12635ca82e69SJohn Levon# 12645ca82e69SJohn Levon# Move old LOGFILE aside 12655ca82e69SJohn Levon# ATLOG directory already made by 'create_lock' above 12665ca82e69SJohn Levon# 12675ca82e69SJohn Levonif [ -f $LOGFILE ]; then 12685ca82e69SJohn Levon mv -f $LOGFILE ${LOGFILE}- 12695ca82e69SJohn Levonfi 12705ca82e69SJohn Levon# 12715ca82e69SJohn Levon# Build OsNet source 12725ca82e69SJohn Levon# 12735ca82e69SJohn LevonSTART_DATE=`date` 12745ca82e69SJohn LevonSECONDS=0 12755ca82e69SJohn Levonecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 12765ca82e69SJohn Levon | tee -a $LOGFILE > $build_time_file 12775ca82e69SJohn Levon 12785ca82e69SJohn Levonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 12795ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 12805ca82e69SJohn Levon 12815ca82e69SJohn Levon# make sure we log only to the nightly build file 12825ca82e69SJohn Levonbuild_noise_file="${TMPDIR}/build_noise" 12835ca82e69SJohn Levonexec </dev/null >$build_noise_file 2>&1 12845ca82e69SJohn Levon 12855ca82e69SJohn Levonrun_hook SYS_PRE_NIGHTLY 12865ca82e69SJohn Levonrun_hook PRE_NIGHTLY 12875ca82e69SJohn Levon 12885ca82e69SJohn Levonecho "\n==== list of environment variables ====\n" >> $LOGFILE 12895ca82e69SJohn Levonenv >> $LOGFILE 12905ca82e69SJohn Levon 12915ca82e69SJohn Levonecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 12925ca82e69SJohn Levon 12935ca82e69SJohn Levonif [ "$N_FLAG" = "y" ]; then 12945ca82e69SJohn Levon if [ "$p_FLAG" = "y" ]; then 12955ca82e69SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 12965ca82e69SJohn LevonWARNING: the p option (create packages) is set, but so is the N option (do 12975ca82e69SJohn Levon not run protocmp); this is dangerous; you should unset the N option 12985ca82e69SJohn LevonEOF 12995ca82e69SJohn Levon else 13005ca82e69SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13015ca82e69SJohn LevonWarning: the N option (do not run protocmp) is set; it probably shouldn't be 13025ca82e69SJohn LevonEOF 13035ca82e69SJohn Levon fi 13045ca82e69SJohn Levon echo "" | tee -a $mail_msg_file >> $LOGFILE 13055ca82e69SJohn Levonfi 13065ca82e69SJohn Levon 13075ca82e69SJohn Levonif [ "$f_FLAG" = "y" ]; then 13085ca82e69SJohn Levon if [ "$i_FLAG" = "y" ]; then 13095ca82e69SJohn Levon echo "WARNING: the -f flag cannot be used during incremental" \ 13105ca82e69SJohn Levon "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13115ca82e69SJohn Levon f_FLAG=n 13125ca82e69SJohn Levon fi 13135ca82e69SJohn Levon if [ "${p_FLAG}" != "y" ]; then 13145ca82e69SJohn Levon echo "WARNING: the -f flag requires -p;" \ 13155ca82e69SJohn Levon "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13165ca82e69SJohn Levon f_FLAG=n 13175ca82e69SJohn Levon fi 13185ca82e69SJohn Levonfi 13195ca82e69SJohn Levon 1320*e462c128SPatrick Mooneyif [[ "$t_FLAG" != "y" ]]; then 1321*e462c128SPatrick Mooney echo "WARNING: building using out-of-gate tools (via +t flag) " \ 1322*e462c128SPatrick Mooney "is not supported\n" | tee -a $mail_msg_file >> $LOGFILE 1323*e462c128SPatrick Mooneyfi 1324*e462c128SPatrick Mooney 13255ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 13265ca82e69SJohn Levon echo "WARNING: -w specified, but $ROOT does not exist;" \ 13275ca82e69SJohn Levon "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 13285ca82e69SJohn Levon w_FLAG=n 13295ca82e69SJohn Levonfi 13305ca82e69SJohn Levon 13315ca82e69SJohn Levoncase $MULTI_PROTO in 13325ca82e69SJohn Levonyes|no) ;; 13335ca82e69SJohn Levon*) 13345ca82e69SJohn Levon echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 13355ca82e69SJohn Levon "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 13365ca82e69SJohn Levon echo "Setting MULTI_PROTO to \"no\".\n" | \ 13375ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13385ca82e69SJohn Levon export MULTI_PROTO=no 13395ca82e69SJohn Levon ;; 13405ca82e69SJohn Levonesac 13415ca82e69SJohn Levon 13425ca82e69SJohn Levon# Save the current proto area if we're comparing against the last build 13435ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 13445ca82e69SJohn Levon if [ -d "$ROOT.prev" ]; then 13455ca82e69SJohn Levon rm -rf $ROOT.prev 13465ca82e69SJohn Levon fi 13475ca82e69SJohn Levon mv $ROOT $ROOT.prev 13485ca82e69SJohn Levonfi 13495ca82e69SJohn Levon 13505ca82e69SJohn Levon# Same for non-DEBUG proto area 13515ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 13525ca82e69SJohn Levon if [ -d "$ROOT-nd.prev" ]; then 13535ca82e69SJohn Levon rm -rf $ROOT-nd.prev 13545ca82e69SJohn Levon fi 13555ca82e69SJohn Levon mv $ROOT-nd $ROOT-nd.prev 13565ca82e69SJohn Levonfi 13575ca82e69SJohn Levon 13585ca82e69SJohn LevonSCM_TYPE=$(child_wstype) 13595ca82e69SJohn Levon 13605ca82e69SJohn Levon# 13615ca82e69SJohn Levon# Decide whether to clobber 13625ca82e69SJohn Levon# 13635ca82e69SJohn Levonif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 13645ca82e69SJohn Levon echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 13655ca82e69SJohn Levon 13665ca82e69SJohn Levon cd $SRC 13675ca82e69SJohn Levon # remove old clobber file 13685ca82e69SJohn Levon rm -f $SRC/clobber.out 13695ca82e69SJohn Levon rm -f $SRC/clobber-${MACH}.out 13705ca82e69SJohn Levon 13715ca82e69SJohn Levon # Remove all .make.state* files, just in case we are restarting 13725ca82e69SJohn Levon # the build after having interrupted a previous 'make clobber'. 13735ca82e69SJohn Levon find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 13745ca82e69SJohn Levon -o -name 'interfaces.*' \) -prune \ 13755ca82e69SJohn Levon -o -name '.make.*' -print | xargs rm -f 13765ca82e69SJohn Levon 13775ca82e69SJohn Levon $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 13785ca82e69SJohn Levon echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 13795ca82e69SJohn Levon grep "$MAKE:" $SRC/clobber-${MACH}.out | 1380eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 13815ca82e69SJohn Levon egrep -v "Ignoring unknown host" | \ 13825ca82e69SJohn Levon tee $TMPDIR/clobber_errs >> $mail_msg_file 13835ca82e69SJohn Levon 13845ca82e69SJohn Levon if [[ -s $TMPDIR/clobber_errs ]]; then 13855ca82e69SJohn Levon build_extras_ok=n 13865ca82e69SJohn Levon fi 13875ca82e69SJohn Levon 138826e7d9a8SRichard Lowe if [[ "$t_FLAG" == "y" ]]; then 13895ca82e69SJohn Levon echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 13905ca82e69SJohn Levon cd ${TOOLS} 13915ca82e69SJohn Levon rm -f ${TOOLS}/clobber-${MACH}.out 13925ca82e69SJohn Levon $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 13935ca82e69SJohn Levon tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 13945ca82e69SJohn Levon echo "\n==== Make tools clobber ERRORS ====\n" \ 13955ca82e69SJohn Levon >> $mail_msg_file 13965ca82e69SJohn Levon grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1397eefeb0ceSBill Sommerfeld | egrep -v ": (Entering|Leaving) directory " \ 13985ca82e69SJohn Levon >> $mail_msg_file 13995ca82e69SJohn Levon if (( $? == 0 )); then 14005ca82e69SJohn Levon build_extras_ok=n 14015ca82e69SJohn Levon fi 14025ca82e69SJohn Levon rm -rf ${TOOLS_PROTO} 14035ca82e69SJohn Levon mkdir -p ${TOOLS_PROTO} 14045ca82e69SJohn Levon fi 14055ca82e69SJohn Levon 14065ca82e69SJohn Levon typeset roots=$(allprotos) 14075ca82e69SJohn Levon echo "\n\nClearing $roots" >> "$LOGFILE" 14085ca82e69SJohn Levon rm -rf $roots 14095ca82e69SJohn Levon 14105ca82e69SJohn Levon # Get back to a clean workspace as much as possible to catch 14115ca82e69SJohn Levon # problems that only occur on fresh workspaces. 14125ca82e69SJohn Levon # Remove all .make.state* files, libraries, and .o's that may 14135ca82e69SJohn Levon # have been omitted from clobber. A couple of libraries are 14145ca82e69SJohn Levon # under source code control, so leave them alone. 14155ca82e69SJohn Levon # We should probably blow away temporary directories too. 14165ca82e69SJohn Levon cd $SRC 14175ca82e69SJohn Levon find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 14185ca82e69SJohn Levon -o -name .git -o -name 'interfaces.*' \) -prune -o \ 14195ca82e69SJohn Levon \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 14205ca82e69SJohn Levon -name '*.o' \) -print | \ 14215ca82e69SJohn Levon grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 14225ca82e69SJohn Levonelse 14235ca82e69SJohn Levon echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 14245ca82e69SJohn Levonfi 14255ca82e69SJohn Levon 1426fc8c3a51SBill Sommerfeldtype bringover_git > /dev/null 2>&1 || function bringover_git { 1427fc8c3a51SBill Sommerfeld typeset -x PATH=$PATH 1428fc8c3a51SBill Sommerfeld 1429fc8c3a51SBill Sommerfeld if [ "$BRINGOVER_BRANCH" = "" ]; then 1430fc8c3a51SBill Sommerfeld if [ -d "$BRINGOVER_WS" ]; then 1431fc8c3a51SBill Sommerfeld BRINGOVER_BRANCH=$(cd "${BRINGOVER_WS}"; git rev-parse --abbrev-ref HEAD) 1432fc8c3a51SBill Sommerfeld if [ "$BRINGOVER_BRANCH" = "HEAD" ]; then 1433fc8c3a51SBill Sommerfeld printf "%s: can't determine BRINGOVER_BRANCH from repo in 'detached HEAD' state\n" "$BRINGOVER_WS" 1434fc8c3a51SBill Sommerfeld touch $TMPDIR/bringover_failed 1435fc8c3a51SBill Sommerfeld return 1436fc8c3a51SBill Sommerfeld fi 1437fc8c3a51SBill Sommerfeld else 1438fc8c3a51SBill Sommerfeld printf "%s: can't determine BRINGOVER_BRANCH\n" "$BRINGOVER_WS" 1439fc8c3a51SBill Sommerfeld touch $TMPDIR/bringover_failed 1440fc8c3a51SBill Sommerfeld return 1441fc8c3a51SBill Sommerfeld fi 1442fc8c3a51SBill Sommerfeld fi 1443fc8c3a51SBill Sommerfeld (cd ${CODEMGR_WS} && 1444fc8c3a51SBill Sommerfeld staffer git remote set-url ${BRINGOVER_REMOTE} ${BRINGOVER_WS} && 1445fc8c3a51SBill Sommerfeld staffer git fetch ${BRINGOVER_REMOTE} ${BRINGOVER_BRANCH} && 1446fc8c3a51SBill Sommerfeld staffer git switch --force-create ${BRINGOVER_BRANCH} \ 1447fc8c3a51SBill Sommerfeld ${BRINGOVER_REMOTE}/${BRINGOVER_BRANCH}) \ 1448fc8c3a51SBill Sommerfeld >$TMPDIR/bringover.out 2>&1 1449fc8c3a51SBill Sommerfeld if (( $? != 0 )); then 1450fc8c3a51SBill Sommerfeld printf "%s: update failed as follows:\n\n" "$CODEMGR_WS" 1451fc8c3a51SBill Sommerfeld cat $TMPDIR/bringover.out 1452fc8c3a51SBill Sommerfeld touch $TMPDIR/bringover_failed 1453fc8c3a51SBill Sommerfeld return 1454fc8c3a51SBill Sommerfeld fi 1455fc8c3a51SBill Sommerfeld 1456fc8c3a51SBill Sommerfeld printf "%s: local branch '%s' updated to commit %s\n" \ 1457fc8c3a51SBill Sommerfeld "$CODEMGR_WS" "$BRINGOVER_BRANCH" \ 1458fc8c3a51SBill Sommerfeld $(cd ${CODEMGR_WS}; git rev-parse HEAD) 1459fc8c3a51SBill Sommerfeld 1460fc8c3a51SBill Sommerfeld staffer git status --no-short --branch --untracked-files=no 1461fc8c3a51SBill Sommerfeld} 1462fc8c3a51SBill Sommerfeld 14635ca82e69SJohn Levontype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 14645ca82e69SJohn Levon typeset -x PATH=$PATH 14655ca82e69SJohn Levon 14665ca82e69SJohn Levon # If the repository doesn't exist yet, then we want to populate it. 14675ca82e69SJohn Levon if [[ ! -d $CODEMGR_WS/.hg ]]; then 14685ca82e69SJohn Levon staffer hg init $CODEMGR_WS 14695ca82e69SJohn Levon staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 14705ca82e69SJohn Levon staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 14715ca82e69SJohn Levon touch $TMPDIR/new_repository 14725ca82e69SJohn Levon fi 14735ca82e69SJohn Levon 14745ca82e69SJohn Levon typeset -x HGMERGE="/bin/false" 14755ca82e69SJohn Levon 14765ca82e69SJohn Levon # 14775ca82e69SJohn Levon # If the user has changes, regardless of whether those changes are 14785ca82e69SJohn Levon # committed, and regardless of whether those changes conflict, then 14795ca82e69SJohn Levon # we'll attempt to merge them either implicitly (uncommitted) or 14805ca82e69SJohn Levon # explicitly (committed). 14815ca82e69SJohn Levon # 14825ca82e69SJohn Levon # These are the messages we'll use to help clarify mercurial output 14835ca82e69SJohn Levon # in those cases. 14845ca82e69SJohn Levon # 14855ca82e69SJohn Levon typeset mergefailmsg="\ 14865ca82e69SJohn Levon***\n\ 14875ca82e69SJohn Levon*** nightly was unable to automatically merge your changes. You should\n\ 14885ca82e69SJohn Levon*** redo the full merge manually, following the steps outlined by mercurial\n\ 14895ca82e69SJohn Levon*** above, then restart nightly.\n\ 14905ca82e69SJohn Levon***\n" 14915ca82e69SJohn Levon typeset mergepassmsg="\ 14925ca82e69SJohn Levon***\n\ 14935ca82e69SJohn Levon*** nightly successfully merged your changes. This means that your working\n\ 14945ca82e69SJohn Levon*** directory has been updated, but those changes are not yet committed.\n\ 14955ca82e69SJohn Levon*** After nightly completes, you should validate the results of the merge,\n\ 14965ca82e69SJohn Levon*** then use hg commit manually.\n\ 14975ca82e69SJohn Levon***\n" 14985ca82e69SJohn Levon 14995ca82e69SJohn Levon # 15005ca82e69SJohn Levon # For each repository in turn: 15015ca82e69SJohn Levon # 15025ca82e69SJohn Levon # 1. Do the pull. If this fails, dump the output and bail out. 15035ca82e69SJohn Levon # 15045ca82e69SJohn Levon # 2. If the pull resulted in an extra head, do an explicit merge. 15055ca82e69SJohn Levon # If this fails, dump the output and bail out. 15065ca82e69SJohn Levon # 15075ca82e69SJohn Levon # Because we can't rely on Mercurial to exit with a failure code 15085ca82e69SJohn Levon # when a merge fails (Mercurial issue #186), we must grep the 15095ca82e69SJohn Levon # output of pull/merge to check for attempted and/or failed merges. 15105ca82e69SJohn Levon # 15115ca82e69SJohn Levon # 3. If a merge failed, set the message and fail the bringover. 15125ca82e69SJohn Levon # 15135ca82e69SJohn Levon # 4. Otherwise, if a merge succeeded, set the message 15145ca82e69SJohn Levon # 15155ca82e69SJohn Levon # 5. Dump the output, and any message from step 3 or 4. 15165ca82e69SJohn Levon # 15175ca82e69SJohn Levon 15185ca82e69SJohn Levon typeset HG_SOURCE=$BRINGOVER_WS 15195ca82e69SJohn Levon if [ ! -f $TMPDIR/new_repository ]; then 15205ca82e69SJohn Levon HG_SOURCE=$TMPDIR/open_bundle.hg 15215ca82e69SJohn Levon staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 15225ca82e69SJohn Levon -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 15235ca82e69SJohn Levon 15245ca82e69SJohn Levon # 15255ca82e69SJohn Levon # If there are no incoming changesets, then incoming will 15265ca82e69SJohn Levon # fail, and there will be no bundle file. Reset the source, 15275ca82e69SJohn Levon # to allow the remaining logic to complete with no false 15285ca82e69SJohn Levon # negatives. (Unlike incoming, pull will return success 15295ca82e69SJohn Levon # for the no-change case.) 15305ca82e69SJohn Levon # 15315ca82e69SJohn Levon if (( $? != 0 )); then 15325ca82e69SJohn Levon HG_SOURCE=$BRINGOVER_WS 15335ca82e69SJohn Levon fi 15345ca82e69SJohn Levon fi 15355ca82e69SJohn Levon 15365ca82e69SJohn Levon staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 15375ca82e69SJohn Levon > $TMPDIR/pull_open.out 2>&1 15385ca82e69SJohn Levon if (( $? != 0 )); then 15395ca82e69SJohn Levon printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 15405ca82e69SJohn Levon cat $TMPDIR/pull_open.out 15415ca82e69SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 15425ca82e69SJohn Levon printf "$mergefailmsg" 15435ca82e69SJohn Levon fi 15445ca82e69SJohn Levon touch $TMPDIR/bringover_failed 15455ca82e69SJohn Levon return 15465ca82e69SJohn Levon fi 15475ca82e69SJohn Levon 15485ca82e69SJohn Levon if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 15495ca82e69SJohn Levon staffer hg --cwd $CODEMGR_WS merge \ 15505ca82e69SJohn Levon >> $TMPDIR/pull_open.out 2>&1 15515ca82e69SJohn Levon if (( $? != 0 )); then 15525ca82e69SJohn Levon printf "%s: merge failed as follows:\n\n" \ 15535ca82e69SJohn Levon "$CODEMGR_WS" 15545ca82e69SJohn Levon cat $TMPDIR/pull_open.out 15555ca82e69SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out \ 15565ca82e69SJohn Levon > /dev/null 2>&1; then 15575ca82e69SJohn Levon printf "$mergefailmsg" 15585ca82e69SJohn Levon fi 15595ca82e69SJohn Levon touch $TMPDIR/bringover_failed 15605ca82e69SJohn Levon return 15615ca82e69SJohn Levon fi 15625ca82e69SJohn Levon fi 15635ca82e69SJohn Levon 15645ca82e69SJohn Levon printf "updated %s with the following results:\n" "$CODEMGR_WS" 15655ca82e69SJohn Levon cat $TMPDIR/pull_open.out 15665ca82e69SJohn Levon if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 15675ca82e69SJohn Levon printf "$mergepassmsg" 15685ca82e69SJohn Levon fi 15695ca82e69SJohn Levon printf "\n" 15705ca82e69SJohn Levon 15715ca82e69SJohn Levon # 15725ca82e69SJohn Levon # Per-changeset output is neither useful nor manageable for a 15735ca82e69SJohn Levon # newly-created repository. 15745ca82e69SJohn Levon # 15755ca82e69SJohn Levon if [ -f $TMPDIR/new_repository ]; then 15765ca82e69SJohn Levon return 15775ca82e69SJohn Levon fi 15785ca82e69SJohn Levon 15795ca82e69SJohn Levon printf "\nadded the following changesets to open repository:\n" 15805ca82e69SJohn Levon cat $TMPDIR/incoming_open.out 15815ca82e69SJohn Levon} 15825ca82e69SJohn Levon 15835ca82e69SJohn Levontype bringover_none > /dev/null 2>&1 || function bringover_none { 15845ca82e69SJohn Levon echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 15855ca82e69SJohn Levon touch $TMPDIR/bringover_failed 15865ca82e69SJohn Levon} 15875ca82e69SJohn Levon 15885ca82e69SJohn Levon# 15895ca82e69SJohn Levon# Decide whether to bringover to the codemgr workspace 15905ca82e69SJohn Levon# 15915ca82e69SJohn Levonif [ "$n_FLAG" = "n" ]; then 15925ca82e69SJohn Levon PARENT_SCM_TYPE=$(parent_wstype) 15935ca82e69SJohn Levon 15945ca82e69SJohn Levon if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 15955ca82e69SJohn Levon echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 15965ca82e69SJohn Levon "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 15975ca82e69SJohn Levon exit 1 15985ca82e69SJohn Levon fi 15995ca82e69SJohn Levon 16005ca82e69SJohn Levon run_hook PRE_BRINGOVER 16015ca82e69SJohn Levon 16025ca82e69SJohn Levon echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 16035ca82e69SJohn Levon echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 16045ca82e69SJohn Levon 16055ca82e69SJohn Levon eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 16065ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 16075ca82e69SJohn Levon 16085ca82e69SJohn Levon if [ -f $TMPDIR/bringover_failed ]; then 16095ca82e69SJohn Levon rm -f $TMPDIR/bringover_failed 16105ca82e69SJohn Levon build_ok=n 16115ca82e69SJohn Levon echo "trouble with bringover, quitting at `date`." | 16125ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 16135ca82e69SJohn Levon exit 1 16145ca82e69SJohn Levon fi 16155ca82e69SJohn Levon 16165ca82e69SJohn Levon # 16175ca82e69SJohn Levon # It's possible that we used the bringover above to create 16185ca82e69SJohn Levon # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 16195ca82e69SJohn Levon # but should now be the same as $BRINGOVER_WS. 16205ca82e69SJohn Levon # 162126e7d9a8SRichard Lowe [[ $SCM_TYPE == none ]] && SCM_TYPE=$PARENT_SCM_TYPE 16225ca82e69SJohn Levon 16235ca82e69SJohn Levon run_hook POST_BRINGOVER 16245ca82e69SJohn Levon 16255ca82e69SJohn Levon check_closed_bins 16265ca82e69SJohn Levon 16275ca82e69SJohn Levonelse 16285ca82e69SJohn Levon echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 16295ca82e69SJohn Levonfi 16305ca82e69SJohn Levon 16315ca82e69SJohn Levon# Safeguards 16325ca82e69SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 16335ca82e69SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 16345ca82e69SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 16355ca82e69SJohn Levon 16364125432bSBill Sommerfeld# 16374125432bSBill Sommerfeld# if -V flag was given, reset VERSION to V_ARG 16384125432bSBill Sommerfeld# 16394125432bSBill Sommerfeldif [[ "$V_FLAG" == "y" ]]; then 16404125432bSBill Sommerfeld export VERSION=$V_ARG 16414125432bSBill Sommerfeldelif [[ -z "$VERSION" ]]; then 16424125432bSBill Sommerfeld export VERSION=$(git -C "${CODEMGR_WS}" describe --long --all --dirty | 16434125432bSBill Sommerfeld cut -d/ -f2-) 16444125432bSBill Sommerfeldfi 16454125432bSBill Sommerfeld 16464125432bSBill Sommerfeld[[ -n "$VERSION" ]] || fatal_error "Error: VERSION not set" 16474125432bSBill Sommerfeld 16484125432bSBill Sommerfeldecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 16494125432bSBill Sommerfeldecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 16504125432bSBill Sommerfeld 165126e7d9a8SRichard Loweif [[ "$t_FLAG" == "y" ]]; then 16525ca82e69SJohn Levon set_non_debug_build_flags 16535ca82e69SJohn Levon # Switch ONBLD_TOOLS early if -t is specified so that 16545ca82e69SJohn Levon # we could use bootstrapped cw for compiler checks. 16555ca82e69SJohn Levon ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld 16565ca82e69SJohn Levon export ONBLD_TOOLS 16573c6ef809SYuri Pankov 16583c6ef809SYuri Pankov bootstrap_tools || fatal_error "Error: could not bootstrap tools" 16595ca82e69SJohn Levonfi 16605ca82e69SJohn Levon 16615ca82e69SJohn Levonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 16625ca82e69SJohn Levon 16635ca82e69SJohn Levon# System 16645ca82e69SJohn Levonwhence uname | tee -a $build_environ_file >> $LOGFILE 16655ca82e69SJohn Levonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 16665ca82e69SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 16675ca82e69SJohn Levon 16685ca82e69SJohn Levon# make 16695ca82e69SJohn Levonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 16705ca82e69SJohn Levon$MAKE -v | tee -a $build_environ_file >> $LOGFILE 16715ca82e69SJohn Levonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 16725ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 16735ca82e69SJohn Levon 16745ca82e69SJohn Levon# 16755ca82e69SJohn Levon# Report the compiler versions. 16765ca82e69SJohn Levon# 16775ca82e69SJohn Levon 16785ca82e69SJohn Levonif [[ ! -f $SRC/Makefile ]]; then 16795ca82e69SJohn Levon build_ok=n 16805ca82e69SJohn Levon echo "\nUnable to find \"Makefile\" in $SRC." | \ 16815ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 16825ca82e69SJohn Levon exit 1 16835ca82e69SJohn Levonfi 16845ca82e69SJohn Levon 16855ca82e69SJohn Levon( cd $SRC 16865ca82e69SJohn Levon for target in cc-version java-version openssl-version; do 16875ca82e69SJohn Levon echo 16885ca82e69SJohn Levon # 16895ca82e69SJohn Levon # Put statefile somewhere we know we can write to rather than trip 16905ca82e69SJohn Levon # over a read-only $srcroot. 16915ca82e69SJohn Levon # 16925ca82e69SJohn Levon rm -f $TMPDIR/make-state 16935ca82e69SJohn Levon export SRC 16945ca82e69SJohn Levon if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 16955ca82e69SJohn Levon continue 16965ca82e69SJohn Levon fi 16975ca82e69SJohn Levon touch $TMPDIR/nocompiler 16985ca82e69SJohn Levon done 16995ca82e69SJohn Levon echo 1700053feb15SBill Sommerfeld) | egrep -v ": (Entering|Leaving) directory " \ 1701eefeb0ceSBill Sommerfeld | tee -a $build_environ_file >> $LOGFILE 17025ca82e69SJohn Levon 17035ca82e69SJohn Levonif [ -f $TMPDIR/nocompiler ]; then 17045ca82e69SJohn Levon rm -f $TMPDIR/nocompiler 17055ca82e69SJohn Levon build_ok=n 17065ca82e69SJohn Levon echo "Aborting due to missing compiler." | 17075ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 17085ca82e69SJohn Levon exit 1 17095ca82e69SJohn Levonfi 17105ca82e69SJohn Levon 17115ca82e69SJohn Levon# Check that we're running a capable link-editor 17125ca82e69SJohn Levonwhence ld | tee -a $build_environ_file >> $LOGFILE 17135ca82e69SJohn LevonLDVER=`ld -V 2>&1` 17145ca82e69SJohn Levonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 17155ca82e69SJohn LevonLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 17165ca82e69SJohn Levonif [ `expr $LDVER \< 422` -eq 1 ]; then 17175ca82e69SJohn Levon echo "The link-editor needs to be at version 422 or higher to build" | \ 17185ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 17195ca82e69SJohn Levon echo "the latest stuff. Hope your build works." | \ 17205ca82e69SJohn Levon tee -a $build_environ_file >> $LOGFILE 17215ca82e69SJohn Levonfi 17225ca82e69SJohn Levon 17235ca82e69SJohn Levon# 17245ca82e69SJohn Levon# Build and use the workspace's tools if requested 17255ca82e69SJohn Levon# 172626e7d9a8SRichard Loweif [[ "$t_FLAG" == "y" ]]; then 17275ca82e69SJohn Levon set_non_debug_build_flags 17285ca82e69SJohn Levon 17295ca82e69SJohn Levon build_tools ${TOOLS_PROTO} 17305ca82e69SJohn Levon if (( $? != 0 )); then 17315ca82e69SJohn Levon build_ok=n 17326faa6645SYuri Pankov exit 1 17336faa6645SYuri Pankov fi 17346faa6645SYuri Pankov 17355ca82e69SJohn Levon STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs 17365ca82e69SJohn Levon export STABS 17375ca82e69SJohn Levon CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs 17385ca82e69SJohn Levon export CTFSTABS 17395ca82e69SJohn Levon GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets 17405ca82e69SJohn Levon export GENOFFSETS 17415ca82e69SJohn Levon 17425ca82e69SJohn Levon CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert 17435ca82e69SJohn Levon export CTFCONVERT 17445ca82e69SJohn Levon CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge 17455ca82e69SJohn Levon export CTFMERGE 17465ca82e69SJohn Levon 17475ca82e69SJohn Levon PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}" 17485ca82e69SJohn Levon PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}" 17495ca82e69SJohn Levon export PATH 17505ca82e69SJohn Levon 17515ca82e69SJohn Levon echo "\n==== New environment settings. ====\n" >> $LOGFILE 17525ca82e69SJohn Levon echo "STABS=${STABS}" >> $LOGFILE 17535ca82e69SJohn Levon echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 17545ca82e69SJohn Levon echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 17555ca82e69SJohn Levon echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 17565ca82e69SJohn Levon echo "PATH=${PATH}" >> $LOGFILE 17575ca82e69SJohn Levon echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 17585ca82e69SJohn Levonfi 17595ca82e69SJohn Levon 17605ca82e69SJohn Levon# timestamp the start of the normal build; the findunref tool uses it. 17615ca82e69SJohn Levontouch $SRC/.build.tstamp 17625ca82e69SJohn Levon 17635ca82e69SJohn Levonnormal_build 17645ca82e69SJohn Levon 17655ca82e69SJohn LevonORIG_SRC=$SRC 17665ca82e69SJohn LevonBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 17675ca82e69SJohn Levon 176826e7d9a8SRichard Loweabspkg= 176926e7d9a8SRichard Lowefor d in $abssrcdirs; do 177026e7d9a8SRichard Lowe if [ -d "$d/pkg" ]; then 177126e7d9a8SRichard Lowe abspkg="$abspkg $d" 177226e7d9a8SRichard Lowe fi 177326e7d9a8SRichard Lowedone 177426e7d9a8SRichard Lowe 177526e7d9a8SRichard Loweif [ "$L_FLAG" != "y" -a "$build_ok" = y ]; then 177626e7d9a8SRichard Lowe echo "\n==== Linting packages ====\n" | \ 177726e7d9a8SRichard Lowe tee -a $LOGFILE >> $mail_msg_file 177826e7d9a8SRichard Lowe 177926e7d9a8SRichard Lowe if [ -n "$abspkg" ]; then 178026e7d9a8SRichard Lowe for d in "$abspkg"; do 178126e7d9a8SRichard Lowe ( cd $d/pkg ; $MAKE -e pkglint ) | \ 178226e7d9a8SRichard Lowe tee -a $LOGFILE | \ 1783eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 178426e7d9a8SRichard Lowe egrep -v 'Lint engine setup|Starting lint run' 178526e7d9a8SRichard Lowe done 2>&1 | tee $TMPDIR/pkglint_noise >> $mail_msg_file 178626e7d9a8SRichard Lowe if [[ -s $TMPDIR/pkglint_noise ]]; then 178726e7d9a8SRichard Lowe build_extras_ok=n 178826e7d9a8SRichard Lowe fi 178926e7d9a8SRichard Lowe fi 179026e7d9a8SRichard Lowefi 17915ca82e69SJohn Levon 17925ca82e69SJohn Levon# 17935ca82e69SJohn Levon# There are several checks that need to look at the proto area, but 17945ca82e69SJohn Levon# they only need to look at one, and they don't care whether it's 17955ca82e69SJohn Levon# DEBUG or non-DEBUG. 17965ca82e69SJohn Levon# 179726e7d9a8SRichard Loweif [[ "$MULTI_PROTO" == yes && "$D_FLAG" == n ]]; then 17985ca82e69SJohn Levon checkroot=$ROOT-nd 17995ca82e69SJohn Levonelse 18005ca82e69SJohn Levon checkroot=$ROOT 18015ca82e69SJohn Levonfi 18025ca82e69SJohn Levon 18035ca82e69SJohn Levonif [ "$build_ok" = "y" ]; then 18045ca82e69SJohn Levon echo "\n==== Creating protolist system file at `date` ====" \ 18055ca82e69SJohn Levon >> $LOGFILE 18065ca82e69SJohn Levon protolist $checkroot > $ATLOG/proto_list_${MACH} 18075ca82e69SJohn Levon echo "==== protolist system file created at `date` ====\n" \ 18085ca82e69SJohn Levon >> $LOGFILE 18095ca82e69SJohn Levon 18105ca82e69SJohn Levon if [ "$N_FLAG" != "y" ]; then 18115ca82e69SJohn Levon 18125ca82e69SJohn Levon E1= 18135ca82e69SJohn Levon f1= 18145ca82e69SJohn Levon for f in $f1; do 18155ca82e69SJohn Levon if [ -f "$f" ]; then 18165ca82e69SJohn Levon E1="$E1 -e $f" 18175ca82e69SJohn Levon fi 18185ca82e69SJohn Levon done 18195ca82e69SJohn Levon 18205ca82e69SJohn Levon E2= 18215ca82e69SJohn Levon f2= 18225ca82e69SJohn Levon if [ -d "$SRC/pkg" ]; then 18235ca82e69SJohn Levon f2="$f2 exceptions/packaging" 18245ca82e69SJohn Levon fi 18255ca82e69SJohn Levon 18265ca82e69SJohn Levon for f in $f2; do 18275ca82e69SJohn Levon if [ -f "$f" ]; then 18285ca82e69SJohn Levon E2="$E2 -e $f" 18295ca82e69SJohn Levon fi 18305ca82e69SJohn Levon done 18315ca82e69SJohn Levon fi 18325ca82e69SJohn Levon 18335ca82e69SJohn Levon if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 18345ca82e69SJohn Levon echo "\n==== Validating manifests against proto area ====\n" \ 18355ca82e69SJohn Levon >> $mail_msg_file 18365ca82e69SJohn Levon ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1837eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 18385ca82e69SJohn Levon tee $TMPDIR/protocmp_noise >> $mail_msg_file 18395ca82e69SJohn Levon if [[ -s $TMPDIR/protocmp_noise ]]; then 18405ca82e69SJohn Levon build_extras_ok=n 18415ca82e69SJohn Levon fi 18425ca82e69SJohn Levon fi 18435ca82e69SJohn Levon 18445ca82e69SJohn Levon if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 18455ca82e69SJohn Levon echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 18465ca82e69SJohn Levon if [ -n "$E2" ]; then 18475ca82e69SJohn Levon ELIST=$E2 18485ca82e69SJohn Levon else 18495ca82e69SJohn Levon ELIST=$E1 18505ca82e69SJohn Levon fi 18515ca82e69SJohn Levon $PROTOCMPTERSE \ 18525ca82e69SJohn Levon "Files in yesterday's proto area, but not today's:" \ 18535ca82e69SJohn Levon "Files in today's proto area, but not yesterday's:" \ 18545ca82e69SJohn Levon "Files that changed between yesterday and today:" \ 18555ca82e69SJohn Levon ${ELIST} \ 18565ca82e69SJohn Levon -d $REF_PROTO_LIST \ 18575ca82e69SJohn Levon $ATLOG/proto_list_${MACH} \ 18585ca82e69SJohn Levon >> $mail_msg_file 18595ca82e69SJohn Levon fi 18605ca82e69SJohn Levonfi 18615ca82e69SJohn Levon 18625ca82e69SJohn Levonif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 18635ca82e69SJohn Levon "$build_extras_ok" == "y" ]]; then 18645ca82e69SJohn Levon staffer cp $ATLOG/proto_list_${MACH} \ 18655ca82e69SJohn Levon $PARENT_WS/usr/src/proto_list_${MACH} 18665ca82e69SJohn Levonfi 18675ca82e69SJohn Levon 18685ca82e69SJohn Levon# Update parent proto area if necessary. This is done now 18695ca82e69SJohn Levon# so that the proto area has either DEBUG or non-DEBUG kernels. 18705ca82e69SJohn Levon# Note that this clears out the lock file, so we can dispense with 18715ca82e69SJohn Levon# the variable now. 18725ca82e69SJohn Levonif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 18735ca82e69SJohn Levon echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 18745ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 18755ca82e69SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT/* 18765ca82e69SJohn Levon unset Ulockfile 18775ca82e69SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT 187826e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == no || "$D_FLAG" == y ]]; then 18795ca82e69SJohn Levon ( cd $ROOT; tar cf - . | 18805ca82e69SJohn Levon ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 18815ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 18825ca82e69SJohn Levon fi 188326e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == yes && "$F_FLAG" == n ]]; then 18845ca82e69SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT-nd/* 18855ca82e69SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT-nd 18865ca82e69SJohn Levon cd $ROOT-nd 18875ca82e69SJohn Levon ( tar cf - . | 18885ca82e69SJohn Levon ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 18895ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 18905ca82e69SJohn Levon fi 18915ca82e69SJohn Levon if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 18925ca82e69SJohn Levon echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 18935ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 18945ca82e69SJohn Levon rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 18955ca82e69SJohn Levon mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 189626e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == no || "$D_FLAG" == y ]]; then 18975ca82e69SJohn Levon ( cd $TOOLS_PROTO; tar cf - . | 18985ca82e69SJohn Levon ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 18995ca82e69SJohn Levon umask 0; tar xpf - ) ) 2>&1 | 19005ca82e69SJohn Levon tee -a $mail_msg_file >> $LOGFILE 19015ca82e69SJohn Levon fi 19025ca82e69SJohn Levon fi 19035ca82e69SJohn Levonfi 19045ca82e69SJohn Levon 19055ca82e69SJohn Levon# 19065ca82e69SJohn Levon# ELF verification: ABI (-A) and runtime (-r) checks 19075ca82e69SJohn Levon# 190826e7d9a8SRichard Loweif [[ ($build_ok == y) && (($A_FLAG == y) || ($r_FLAG == y)) ]]; then 19095ca82e69SJohn Levon # Directory ELF-data.$MACH holds the files produced by these tests. 19105ca82e69SJohn Levon elf_ddir=$SRC/ELF-data.$MACH 19115ca82e69SJohn Levon 19125ca82e69SJohn Levon # If there is a previous ELF-data backup directory, remove it. Then, 19135ca82e69SJohn Levon # rotate current ELF-data directory into its place and create a new 19145ca82e69SJohn Levon # empty directory 19155ca82e69SJohn Levon rm -rf $elf_ddir.ref 19165ca82e69SJohn Levon if [[ -d $elf_ddir ]]; then 19175ca82e69SJohn Levon mv $elf_ddir $elf_ddir.ref 19185ca82e69SJohn Levon fi 19195ca82e69SJohn Levon mkdir -p $elf_ddir 19205ca82e69SJohn Levon 19215ca82e69SJohn Levon # Call find_elf to produce a list of the ELF objects in the proto area. 19225ca82e69SJohn Levon # This list is passed to check_rtime and interface_check, preventing 19235ca82e69SJohn Levon # them from separately calling find_elf to do the same work twice. 19245ca82e69SJohn Levon find_elf -fr $checkroot > $elf_ddir/object_list 19255ca82e69SJohn Levon 192626e7d9a8SRichard Lowe if [[ $A_FLAG == y ]]; then 19275ca82e69SJohn Levon echo "\n==== Check versioning and ABI information ====\n" | \ 19285ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19295ca82e69SJohn Levon 19305ca82e69SJohn Levon # Produce interface description for the proto. Report errors. 19315ca82e69SJohn Levon interface_check -o -w $elf_ddir -f object_list \ 19325ca82e69SJohn Levon -i interface -E interface.err 19335ca82e69SJohn Levon if [[ -s $elf_ddir/interface.err ]]; then 19345ca82e69SJohn Levon tee -a $LOGFILE < $elf_ddir/interface.err \ 19355ca82e69SJohn Levon >> $mail_msg_file 19365ca82e69SJohn Levon build_extras_ok=n 19375ca82e69SJohn Levon fi 19385ca82e69SJohn Levon 19395ca82e69SJohn Levon # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 19405ca82e69SJohn Levon # description file to that from the baseline gate. Issue a 19415ca82e69SJohn Levon # warning if the baseline is not present, and keep going. 19425ca82e69SJohn Levon if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 19435ca82e69SJohn Levon base_ifile="$ELF_DATA_BASELINE_DIR/interface" 19445ca82e69SJohn Levon 19455ca82e69SJohn Levon echo "\n==== Compare versioning and ABI information" \ 19465ca82e69SJohn Levon "to baseline ====\n" | \ 19475ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19485ca82e69SJohn Levon echo "Baseline: $base_ifile\n" >> $LOGFILE 19495ca82e69SJohn Levon 19505ca82e69SJohn Levon if [[ -f $base_ifile ]]; then 19515ca82e69SJohn Levon interface_cmp -d -o $base_ifile \ 19525ca82e69SJohn Levon $elf_ddir/interface > $elf_ddir/interface.cmp 19535ca82e69SJohn Levon if [[ -s $elf_ddir/interface.cmp ]]; then 19545ca82e69SJohn Levon echo | tee -a $LOGFILE >> $mail_msg_file 19555ca82e69SJohn Levon tee -a $LOGFILE < \ 19565ca82e69SJohn Levon $elf_ddir/interface.cmp \ 19575ca82e69SJohn Levon >> $mail_msg_file 19585ca82e69SJohn Levon build_extras_ok=n 19595ca82e69SJohn Levon fi 19605ca82e69SJohn Levon else 19615ca82e69SJohn Levon echo "baseline not available. comparison" \ 19625ca82e69SJohn Levon "skipped" | \ 19635ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19645ca82e69SJohn Levon fi 19655ca82e69SJohn Levon 19665ca82e69SJohn Levon fi 19675ca82e69SJohn Levon fi 19685ca82e69SJohn Levon 196926e7d9a8SRichard Lowe if [[ $r_FLAG == y ]]; then 19705ca82e69SJohn Levon echo "\n==== Check ELF runtime attributes ====\n" | \ 19715ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19725ca82e69SJohn Levon 19735ca82e69SJohn Levon # If we're doing a DEBUG build the proto area will be left 19745ca82e69SJohn Levon # with debuggable objects, thus don't assert -s. 197526e7d9a8SRichard Lowe if [[ $D_FLAG == y ]]; then 19765ca82e69SJohn Levon rtime_sflag="" 19775ca82e69SJohn Levon else 19785ca82e69SJohn Levon rtime_sflag="-s" 19795ca82e69SJohn Levon fi 19805ca82e69SJohn Levon check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 19815ca82e69SJohn Levon -D object_list -f object_list -E runtime.err \ 19825ca82e69SJohn Levon -I runtime.attr.raw 19835ca82e69SJohn Levon if (( $? != 0 )); then 19845ca82e69SJohn Levon build_extras_ok=n 19855ca82e69SJohn Levon fi 19865ca82e69SJohn Levon 19875ca82e69SJohn Levon # check_rtime -I output needs to be sorted in order to 19885ca82e69SJohn Levon # compare it to that from previous builds. 19895ca82e69SJohn Levon sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 19905ca82e69SJohn Levon rm $elf_ddir/runtime.attr.raw 19915ca82e69SJohn Levon 19925ca82e69SJohn Levon # Report errors 19935ca82e69SJohn Levon if [[ -s $elf_ddir/runtime.err ]]; then 19945ca82e69SJohn Levon tee -a $LOGFILE < $elf_ddir/runtime.err \ 19955ca82e69SJohn Levon >> $mail_msg_file 19965ca82e69SJohn Levon build_extras_ok=n 19975ca82e69SJohn Levon fi 19985ca82e69SJohn Levon 19995ca82e69SJohn Levon # If there is an ELF-data directory from a previous build, 20005ca82e69SJohn Levon # then diff the attr files. These files contain information 20015ca82e69SJohn Levon # about dependencies, versioning, and runpaths. There is some 20025ca82e69SJohn Levon # overlap with the ABI checking done above, but this also 20035ca82e69SJohn Levon # flushes out non-ABI interface differences along with the 20045ca82e69SJohn Levon # other information. 20055ca82e69SJohn Levon echo "\n==== Diff ELF runtime attributes" \ 20065ca82e69SJohn Levon "(since last build) ====\n" | \ 20075ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 20085ca82e69SJohn Levon 20095ca82e69SJohn Levon if [[ -f $elf_ddir.ref/runtime.attr ]]; then 20105ca82e69SJohn Levon diff $elf_ddir.ref/runtime.attr \ 20115ca82e69SJohn Levon $elf_ddir/runtime.attr \ 20125ca82e69SJohn Levon >> $mail_msg_file 20135ca82e69SJohn Levon fi 20145ca82e69SJohn Levon fi 20155ca82e69SJohn Levon 20165ca82e69SJohn Levon # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 201726e7d9a8SRichard Lowe if [[ "$u_FLAG" == "y" ]]; then 20185ca82e69SJohn Levon p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 20195ca82e69SJohn Levon 20205ca82e69SJohn Levon # If parent lacks the ELF-data.$MACH directory, create it 20215ca82e69SJohn Levon if [[ ! -d $p_elf_ddir ]]; then 20225ca82e69SJohn Levon staffer mkdir -p $p_elf_ddir 20235ca82e69SJohn Levon fi 20245ca82e69SJohn Levon 20255ca82e69SJohn Levon # These files are used asynchronously by other builds for ABI 20265ca82e69SJohn Levon # verification, as above for the -A option. As such, we require 20275ca82e69SJohn Levon # the file replacement to be atomic. Copy the data to a temp 20285ca82e69SJohn Levon # file in the same filesystem and then rename into place. 20295ca82e69SJohn Levon ( 20305ca82e69SJohn Levon cd $elf_ddir 20315ca82e69SJohn Levon for elf_dfile in *; do 20325ca82e69SJohn Levon staffer cp $elf_dfile \ 20335ca82e69SJohn Levon ${p_elf_ddir}/${elf_dfile}.new 20345ca82e69SJohn Levon staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 20355ca82e69SJohn Levon ${p_elf_ddir}/${elf_dfile} 20365ca82e69SJohn Levon done 20375ca82e69SJohn Levon ) 20385ca82e69SJohn Levon fi 20395ca82e69SJohn Levonfi 20405ca82e69SJohn Levon 20415ca82e69SJohn Levon# "make check" begins 20425ca82e69SJohn Levon 20435ca82e69SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 20445ca82e69SJohn Levon # remove old check.out 20455ca82e69SJohn Levon rm -f $SRC/check.out 20465ca82e69SJohn Levon 20475ca82e69SJohn Levon rm -f $SRC/check-${MACH}.out 20485ca82e69SJohn Levon cd $SRC 20495ca82e69SJohn Levon $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 20505ca82e69SJohn Levon >> $LOGFILE 20515ca82e69SJohn Levon echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 20525ca82e69SJohn Levon 20535ca82e69SJohn Levon grep ":" $SRC/check-${MACH}.out | 2054eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " | \ 20555ca82e69SJohn Levon egrep -v "Ignoring unknown host" | \ 20565ca82e69SJohn Levon sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 20575ca82e69SJohn Levon 20585ca82e69SJohn Levon if [[ -s $TMPDIR/check_errors ]]; then 20595ca82e69SJohn Levon build_extras_ok=n 20605ca82e69SJohn Levon fi 20615ca82e69SJohn Levonelse 20625ca82e69SJohn Levon echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 20635ca82e69SJohn Levonfi 20645ca82e69SJohn Levon 20655ca82e69SJohn Levonecho "\n==== Find core files ====\n" | \ 20665ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 20675ca82e69SJohn Levon 20685ca82e69SJohn Levonfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 20695ca82e69SJohn Levon tee -a $LOGFILE >> $mail_msg_file 20705ca82e69SJohn Levon 20715ca82e69SJohn Levonif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 20725ca82e69SJohn Levon echo "\n==== Diff unreferenced files (since last build) ====\n" \ 20735ca82e69SJohn Levon | tee -a $LOGFILE >>$mail_msg_file 20745ca82e69SJohn Levon rm -f $SRC/unref-${MACH}.ref 20755ca82e69SJohn Levon if [ -f $SRC/unref-${MACH}.out ]; then 20765ca82e69SJohn Levon mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 20775ca82e69SJohn Levon fi 20785ca82e69SJohn Levon 20795ca82e69SJohn Levon findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 20805ca82e69SJohn Levon ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 20815ca82e69SJohn Levon sort > $SRC/unref-${MACH}.out 20825ca82e69SJohn Levon 20835ca82e69SJohn Levon if [ ! -f $SRC/unref-${MACH}.ref ]; then 20845ca82e69SJohn Levon cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 20855ca82e69SJohn Levon fi 20865ca82e69SJohn Levon 20875ca82e69SJohn Levon diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 20885ca82e69SJohn Levonfi 20895ca82e69SJohn Levon 20905ca82e69SJohn Levon# Verify that the usual lists of files, such as exception lists, 20915ca82e69SJohn Levon# contain only valid references to files. If the build has failed, 20925ca82e69SJohn Levon# then don't check the proto area. 20935ca82e69SJohn LevonCHECK_PATHS=${CHECK_PATHS:-y} 20945ca82e69SJohn Levonif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 20955ca82e69SJohn Levon echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 20965ca82e69SJohn Levon >>$mail_msg_file 20975ca82e69SJohn Levon arg=-b 20985ca82e69SJohn Levon [ "$build_ok" = y ] && arg= 20995ca82e69SJohn Levon checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 21005ca82e69SJohn Levon if [[ -s $SRC/check-paths.out ]]; then 21015ca82e69SJohn Levon tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 21025ca82e69SJohn Levon build_extras_ok=n 21035ca82e69SJohn Levon fi 21045ca82e69SJohn Levonfi 21055ca82e69SJohn Levon 2106069e6b7eSAndy Fiddamanif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2107069e6b7eSAndy Fiddaman echo "\n==== Impact on file permissions ====\n" \ 2108069e6b7eSAndy Fiddaman >> $mail_msg_file 2109069e6b7eSAndy Fiddaman 21105ca82e69SJohn Levon if [ -n "$abspkg" ]; then 21115ca82e69SJohn Levon for d in "$abspkg"; do 2112eefeb0ceSBill Sommerfeld ( cd $d/pkg ; $MAKE -e pmodes ) | \ 2113eefeb0ceSBill Sommerfeld egrep -v ": (Entering|Leaving) directory " \ 2114eefeb0ceSBill Sommerfeld >> $mail_msg_file 21155ca82e69SJohn Levon done 21165ca82e69SJohn Levon fi 21175ca82e69SJohn Levonfi 21185ca82e69SJohn Levon 21195ca82e69SJohn Levonif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 212026e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == no || "$D_FLAG" == y ]]; then 21215ca82e69SJohn Levon do_wsdiff DEBUG $ROOT.prev $ROOT 21225ca82e69SJohn Levon fi 21235ca82e69SJohn Levon 212426e7d9a8SRichard Lowe if [[ "$MULTI_PROTO" == yes && "$F_FLAG" == n ]]; then 21255ca82e69SJohn Levon do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 21265ca82e69SJohn Levon fi 21275ca82e69SJohn Levonfi 21285ca82e69SJohn Levon 21295ca82e69SJohn LevonEND_DATE=`date` 21305ca82e69SJohn Levonecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 21315ca82e69SJohn Levon tee -a $LOGFILE >> $build_time_file 21325ca82e69SJohn Levon 21335ca82e69SJohn Levontypeset -i10 hours 21345ca82e69SJohn Levontypeset -Z2 minutes 21355ca82e69SJohn Levontypeset -Z2 seconds 21365ca82e69SJohn Levon 21375ca82e69SJohn Levonelapsed_time=$SECONDS 21385ca82e69SJohn Levon((hours = elapsed_time / 3600 )) 21395ca82e69SJohn Levon((minutes = elapsed_time / 60 % 60)) 21405ca82e69SJohn Levon((seconds = elapsed_time % 60)) 21415ca82e69SJohn Levon 21425ca82e69SJohn Levonecho "\n==== Total build time ====" | \ 21435ca82e69SJohn Levon tee -a $LOGFILE >> $build_time_file 21445ca82e69SJohn Levonecho "\nreal ${hours}:${minutes}:${seconds}" | \ 21455ca82e69SJohn Levon tee -a $LOGFILE >> $build_time_file 21465ca82e69SJohn Levon 21475ca82e69SJohn Levonif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21485ca82e69SJohn Levon staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 21495ca82e69SJohn Levon 21505ca82e69SJohn Levon # 21515ca82e69SJohn Levon # Produce a master list of unreferenced files -- ideally, we'd 21525ca82e69SJohn Levon # generate the master just once after all of the nightlies 21535ca82e69SJohn Levon # have finished, but there's no simple way to know when that 21545ca82e69SJohn Levon # will be. Instead, we assume that we're the last nightly to 21555ca82e69SJohn Levon # finish and merge all of the unref-${MACH}.out files in 21565ca82e69SJohn Levon # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 21575ca82e69SJohn Levon # finish, then this file will be the authoritative master 21585ca82e69SJohn Levon # list. Otherwise, another ${MACH}'s nightly will eventually 21595ca82e69SJohn Levon # overwrite ours with its own master, but in the meantime our 21605ca82e69SJohn Levon # temporary "master" will be no worse than any older master 21615ca82e69SJohn Levon # which was already on the parent. 21625ca82e69SJohn Levon # 21635ca82e69SJohn Levon 21645ca82e69SJohn Levon set -- $PARENT_WS/usr/src/unref-*.out 21655ca82e69SJohn Levon cp "$1" ${TMPDIR}/unref.merge 21665ca82e69SJohn Levon shift 21675ca82e69SJohn Levon 21685ca82e69SJohn Levon for unreffile; do 21695ca82e69SJohn Levon comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 21705ca82e69SJohn Levon mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 21715ca82e69SJohn Levon done 21725ca82e69SJohn Levon 21735ca82e69SJohn Levon staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 21745ca82e69SJohn Levonfi 21755ca82e69SJohn Levon 21765ca82e69SJohn Levon# 21775ca82e69SJohn Levon# All done save for the sweeping up. 21785ca82e69SJohn Levon# (whichever exit we hit here will trigger the "cleanup" trap which 21795ca82e69SJohn Levon# optionally sends mail on completion). 21805ca82e69SJohn Levon# 21815ca82e69SJohn Levonif [[ "$build_ok" == "y" ]]; then 21825ca82e69SJohn Levon if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 21835ca82e69SJohn Levon exit 0 21845ca82e69SJohn Levon fi 21855ca82e69SJohn Levonfi 21865ca82e69SJohn Levon 21875ca82e69SJohn Levonexit 1 2188