19e4fd900SJohn Levon#!/bin/ksh -p 29e4fd900SJohn Levon# 39e4fd900SJohn Levon# CDDL HEADER START 49e4fd900SJohn Levon# 59e4fd900SJohn Levon# The contents of this file are subject to the terms of the 69e4fd900SJohn Levon# Common Development and Distribution License (the "License"). 79e4fd900SJohn Levon# You may not use this file except in compliance with the License. 89e4fd900SJohn Levon# 99e4fd900SJohn Levon# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 109e4fd900SJohn Levon# or http://www.opensolaris.org/os/licensing. 119e4fd900SJohn Levon# See the License for the specific language governing permissions 129e4fd900SJohn Levon# and limitations under the License. 139e4fd900SJohn Levon# 149e4fd900SJohn Levon# When distributing Covered Code, include this CDDL HEADER in each 159e4fd900SJohn Levon# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 169e4fd900SJohn Levon# If applicable, add the following below this CDDL HEADER, with the 179e4fd900SJohn Levon# fields enclosed by brackets "[]" replaced with your own identifying 189e4fd900SJohn Levon# information: Portions Copyright [yyyy] [name of copyright owner] 199e4fd900SJohn Levon# 209e4fd900SJohn Levon# CDDL HEADER END 219e4fd900SJohn Levon# 229e4fd900SJohn Levon 239e4fd900SJohn Levon# 249e4fd900SJohn Levon# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 259e4fd900SJohn Levon# Copyright 2008, 2010, Richard Lowe 269e4fd900SJohn Levon# Copyright 2011 Nexenta Systems, Inc. All rights reserved. 279e4fd900SJohn Levon# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> 289e4fd900SJohn Levon# Copyright 2020 Joyent, Inc. 299e4fd900SJohn Levon# 309e4fd900SJohn Levon# Based on the nightly script from the integration folks, 319e4fd900SJohn Levon# Mostly modified and owned by mike_s. 329e4fd900SJohn Levon# Changes also by kjc, dmk. 339e4fd900SJohn Levon# 349e4fd900SJohn Levon# BRINGOVER_WS may be specified in the env file. 359e4fd900SJohn Levon# The default is the old behavior of CLONE_WS 369e4fd900SJohn Levon# 379e4fd900SJohn Levon# -i on the command line, means fast options, so when it's on the 389e4fd900SJohn Levon# command line (only), lint and check builds are skipped no matter what 399e4fd900SJohn Levon# the setting of their individual flags are in NIGHTLY_OPTIONS. 409e4fd900SJohn Levon# 419e4fd900SJohn Levon# LINTDIRS can be set in the env file, format is a list of: 429e4fd900SJohn Levon# 439e4fd900SJohn Levon# /dirname-to-run-lint-on flag 449e4fd900SJohn Levon# 459e4fd900SJohn Levon# Where flag is: y - enable lint noise diff output 469e4fd900SJohn Levon# n - disable lint noise diff output 479e4fd900SJohn Levon# 489e4fd900SJohn Levon# For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y" 499e4fd900SJohn Levon# 509e4fd900SJohn Levon# OPTHOME may be set in the environment to override /opt 519e4fd900SJohn Levon# 529e4fd900SJohn Levon 539e4fd900SJohn Levon# 549e4fd900SJohn Levon# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 559e4fd900SJohn Levon# under certain circumstances, which can really screw things up; unset it. 569e4fd900SJohn Levon# 579e4fd900SJohn Levonunset CDPATH 589e4fd900SJohn Levon 599e4fd900SJohn Levon# Get the absolute path of the nightly script that the user invoked. This 609e4fd900SJohn Levon# may be a relative path, and we need to do this before changing directory. 619e4fd900SJohn Levonnightly_path=`whence $0` 629e4fd900SJohn Levon 639e4fd900SJohn Levon# 649e4fd900SJohn Levon# Keep track of where we found nightly so we can invoke the matching 659e4fd900SJohn Levon# which_scm script. If that doesn't work, don't go guessing, just rely 669e4fd900SJohn Levon# on the $PATH settings, which will generally give us either /opt/onbld 679e4fd900SJohn Levon# or the user's workspace. 689e4fd900SJohn Levon# 699e4fd900SJohn LevonWHICH_SCM=$(dirname $nightly_path)/which_scm 709e4fd900SJohn Levonif [[ ! -x $WHICH_SCM ]]; then 719e4fd900SJohn Levon WHICH_SCM=which_scm 729e4fd900SJohn Levonfi 739e4fd900SJohn Levon 749e4fd900SJohn Levonfunction fatal_error 759e4fd900SJohn Levon{ 769e4fd900SJohn Levon print -u2 "nightly: $*" 779e4fd900SJohn Levon exit 1 789e4fd900SJohn Levon} 799e4fd900SJohn Levon 809e4fd900SJohn Levon# 819e4fd900SJohn Levon# Function to do a DEBUG and non-DEBUG build. Needed because we might 829e4fd900SJohn Levon# need to do another for the source build, and since we only deliver DEBUG or 839e4fd900SJohn Levon# non-DEBUG packages. 849e4fd900SJohn Levon# 859e4fd900SJohn Levon# usage: normal_build 869e4fd900SJohn Levon# 879e4fd900SJohn Levonfunction normal_build { 889e4fd900SJohn Levon 899e4fd900SJohn Levon typeset orig_p_FLAG="$p_FLAG" 909e4fd900SJohn Levon typeset crypto_signer="$CODESIGN_USER" 919e4fd900SJohn Levon 929e4fd900SJohn Levon suffix="" 939e4fd900SJohn Levon 949e4fd900SJohn Levon # non-DEBUG build begins 959e4fd900SJohn Levon 969e4fd900SJohn Levon if [ "$F_FLAG" = "n" ]; then 979e4fd900SJohn Levon set_non_debug_build_flags 989e4fd900SJohn Levon CODESIGN_USER="$crypto_signer" \ 999e4fd900SJohn Levon build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 1009e4fd900SJohn Levon else 1019e4fd900SJohn Levon echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 1029e4fd900SJohn Levon fi 1039e4fd900SJohn Levon 1049e4fd900SJohn Levon # non-DEBUG build ends 1059e4fd900SJohn Levon 1069e4fd900SJohn Levon # DEBUG build begins 1079e4fd900SJohn Levon 1089e4fd900SJohn Levon if [ "$D_FLAG" = "y" ]; then 1099e4fd900SJohn Levon set_debug_build_flags 1109e4fd900SJohn Levon CODESIGN_USER="$crypto_signer" \ 1119e4fd900SJohn Levon build "DEBUG" "$suffix" "" "$MULTI_PROTO" 1129e4fd900SJohn Levon else 1139e4fd900SJohn Levon echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 1149e4fd900SJohn Levon fi 1159e4fd900SJohn Levon 1169e4fd900SJohn Levon # DEBUG build ends 1179e4fd900SJohn Levon 1189e4fd900SJohn Levon p_FLAG="$orig_p_FLAG" 1199e4fd900SJohn Levon} 1209e4fd900SJohn Levon 1219e4fd900SJohn Levon# 1229e4fd900SJohn Levon# usage: run_hook HOOKNAME ARGS... 1239e4fd900SJohn Levon# 1249e4fd900SJohn Levon# If variable "$HOOKNAME" is defined, insert a section header into 1259e4fd900SJohn Levon# our logs and then run the command with ARGS 1269e4fd900SJohn Levon# 1279e4fd900SJohn Levonfunction run_hook { 1289e4fd900SJohn Levon HOOKNAME=$1 1299e4fd900SJohn Levon eval HOOKCMD=\$$HOOKNAME 1309e4fd900SJohn Levon shift 1319e4fd900SJohn Levon 1329e4fd900SJohn Levon if [ -n "$HOOKCMD" ]; then 1339e4fd900SJohn Levon ( 1349e4fd900SJohn Levon echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 1359e4fd900SJohn Levon ( $HOOKCMD "$@" 2>&1 ) 1369e4fd900SJohn Levon if [ "$?" -ne 0 ]; then 1379e4fd900SJohn Levon # Let exit status propagate up 1389e4fd900SJohn Levon touch $TMPDIR/abort 1399e4fd900SJohn Levon fi 1409e4fd900SJohn Levon ) | tee -a $mail_msg_file >> $LOGFILE 1419e4fd900SJohn Levon 1429e4fd900SJohn Levon if [ -f $TMPDIR/abort ]; then 1439e4fd900SJohn Levon build_ok=n 1449e4fd900SJohn Levon echo "\nAborting at request of $HOOKNAME" | 1459e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1469e4fd900SJohn Levon exit 1 1479e4fd900SJohn Levon fi 1489e4fd900SJohn Levon fi 1499e4fd900SJohn Levon} 1509e4fd900SJohn Levon 1519e4fd900SJohn Levon# Return library search directive as function of given root. 1529e4fd900SJohn Levonfunction myldlibs { 1539e4fd900SJohn Levon echo "-L$1/lib -L$1/usr/lib" 1549e4fd900SJohn Levon} 1559e4fd900SJohn Levon 1569e4fd900SJohn Levon# Return header search directive as function of given root. 1579e4fd900SJohn Levonfunction myheaders { 1589e4fd900SJohn Levon echo "-I$1/usr/include" 1599e4fd900SJohn Levon} 1609e4fd900SJohn Levon 1619e4fd900SJohn Levon# 1629e4fd900SJohn Levon# Function to do the build, including package generation. 1639e4fd900SJohn Levon# usage: build LABEL SUFFIX ND MULTIPROTO 1649e4fd900SJohn Levon# - LABEL is used to tag build output. 1659e4fd900SJohn Levon# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 1669e4fd900SJohn Levon# open-only vs full tree). 1679e4fd900SJohn Levon# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 1689e4fd900SJohn Levon# - If MULTIPROTO is "yes", it means to name the proto area according to 1699e4fd900SJohn Levon# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 1709e4fd900SJohn Levon# 1719e4fd900SJohn Levonfunction build { 1729e4fd900SJohn Levon LABEL=$1 1739e4fd900SJohn Levon SUFFIX=$2 1749e4fd900SJohn Levon ND=$3 1759e4fd900SJohn Levon MULTIPROTO=$4 1769e4fd900SJohn Levon INSTALLOG=install${SUFFIX}-${MACH} 1779e4fd900SJohn Levon NOISE=noise${SUFFIX}-${MACH} 1789e4fd900SJohn Levon PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 1799e4fd900SJohn Levon 1809e4fd900SJohn Levon ORIGROOT=$ROOT 1819e4fd900SJohn Levon [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 1829e4fd900SJohn Levon 1839e4fd900SJohn Levon export ENVLDLIBS1=`myldlibs $ROOT` 1849e4fd900SJohn Levon export ENVCPPFLAGS1=`myheaders $ROOT` 1859e4fd900SJohn Levon 1869e4fd900SJohn Levon this_build_ok=y 1879e4fd900SJohn Levon # 1889e4fd900SJohn Levon # Build OS-Networking source 1899e4fd900SJohn Levon # 1909e4fd900SJohn Levon echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 1919e4fd900SJohn Levon >> $LOGFILE 1929e4fd900SJohn Levon 1939e4fd900SJohn Levon rm -f $SRC/${INSTALLOG}.out 1949e4fd900SJohn Levon cd $SRC 1959e4fd900SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 1969e4fd900SJohn Levon tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 1979e4fd900SJohn Levon 1989e4fd900SJohn Levon echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 1999e4fd900SJohn Levon egrep ":" $SRC/${INSTALLOG}.out | 2009e4fd900SJohn Levon egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 2019e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 2029e4fd900SJohn Levon egrep -v "cc .* -o error " | \ 2039e4fd900SJohn Levon egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 2049e4fd900SJohn Levon >> $mail_msg_file 2059e4fd900SJohn Levon if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 2069e4fd900SJohn Levon build_ok=n 2079e4fd900SJohn Levon this_build_ok=n 2089e4fd900SJohn Levon fi 2099e4fd900SJohn Levon grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 2109e4fd900SJohn Levon >> $mail_msg_file 2119e4fd900SJohn Levon if [ "$?" = "0" ]; then 2129e4fd900SJohn Levon build_ok=n 2139e4fd900SJohn Levon this_build_ok=n 2149e4fd900SJohn Levon fi 2159e4fd900SJohn Levon 2169e4fd900SJohn Levon echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 2179e4fd900SJohn Levon egrep -i warning: $SRC/${INSTALLOG}.out \ 2189e4fd900SJohn Levon | egrep -v '^tic:' \ 2199e4fd900SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 2209e4fd900SJohn Levon | egrep -v "parameter <PSTAMP> set to" \ 2219e4fd900SJohn Levon | egrep -v "Ignoring unknown host" \ 2229e4fd900SJohn Levon | egrep -v "redefining segment flags attribute for" \ 2239e4fd900SJohn Levon | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 2249e4fd900SJohn Levon if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 2259e4fd900SJohn Levon build_ok=n 2269e4fd900SJohn Levon this_build_ok=n 2279e4fd900SJohn Levon fi 2289e4fd900SJohn Levon 2299e4fd900SJohn Levon echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 2309e4fd900SJohn Levon >> $LOGFILE 2319e4fd900SJohn Levon 2329e4fd900SJohn Levon echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 2339e4fd900SJohn Levon tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 2349e4fd900SJohn Levon 2359e4fd900SJohn Levon if [ "$i_FLAG" = "n" ]; then 2369e4fd900SJohn Levon rm -f $SRC/${NOISE}.ref 2379e4fd900SJohn Levon if [ -f $SRC/${NOISE}.out ]; then 2389e4fd900SJohn Levon mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 2399e4fd900SJohn Levon fi 2409e4fd900SJohn Levon grep : $SRC/${INSTALLOG}.out \ 2419e4fd900SJohn Levon | egrep -v '^/' \ 2429e4fd900SJohn Levon | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 2439e4fd900SJohn Levon | egrep -v '^tic:' \ 2449e4fd900SJohn Levon | egrep -v '^mcs' \ 2459e4fd900SJohn Levon | egrep -v '^LD_LIBRARY_PATH=' \ 2469e4fd900SJohn Levon | egrep -v 'ar: creating' \ 2479e4fd900SJohn Levon | egrep -v 'ar: writing' \ 2489e4fd900SJohn Levon | egrep -v 'conflicts:' \ 2499e4fd900SJohn Levon | egrep -v ':saved created' \ 2509e4fd900SJohn Levon | egrep -v '^stty.*c:' \ 2519e4fd900SJohn Levon | egrep -v '^mfgname.c:' \ 2529e4fd900SJohn Levon | egrep -v '^uname-i.c:' \ 2539e4fd900SJohn Levon | egrep -v '^volumes.c:' \ 2549e4fd900SJohn Levon | egrep -v '^lint library construction:' \ 2559e4fd900SJohn Levon | egrep -v 'tsort: INFORM:' \ 2569e4fd900SJohn Levon | egrep -v 'stripalign:' \ 2579e4fd900SJohn Levon | egrep -v 'chars, width' \ 2589e4fd900SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 2599e4fd900SJohn Levon | egrep -v 'PSTAMP' \ 2609e4fd900SJohn Levon | egrep -v '|%WHOANDWHERE%|' \ 2619e4fd900SJohn Levon | egrep -v '^Manifying' \ 2629e4fd900SJohn Levon | egrep -v 'Ignoring unknown host' \ 2639e4fd900SJohn Levon | egrep -v 'Processing method:' \ 2649e4fd900SJohn Levon | egrep -v '^Writing' \ 2659e4fd900SJohn Levon | egrep -v 'spellin1:' \ 2669e4fd900SJohn Levon | egrep -v '^adding:' \ 2679e4fd900SJohn Levon | egrep -v "^echo 'msgid" \ 2689e4fd900SJohn Levon | egrep -v '^echo ' \ 2699e4fd900SJohn Levon | egrep -v '\.c:$' \ 2709e4fd900SJohn Levon | egrep -v '^Adding file:' \ 2719e4fd900SJohn Levon | egrep -v 'CLASSPATH=' \ 2729e4fd900SJohn Levon | egrep -v '\/var\/mail\/:saved' \ 2739e4fd900SJohn Levon | egrep -v -- '-DUTS_VERSION=' \ 2749e4fd900SJohn Levon | egrep -v '^Running Mkbootstrap' \ 2759e4fd900SJohn Levon | egrep -v '^Applet length read:' \ 2769e4fd900SJohn Levon | egrep -v 'bytes written:' \ 2779e4fd900SJohn Levon | egrep -v '^File:SolarisAuthApplet.bin' \ 2789e4fd900SJohn Levon | egrep -v -i 'jibversion' \ 2799e4fd900SJohn Levon | egrep -v '^Output size:' \ 2809e4fd900SJohn Levon | egrep -v '^Solo size statistics:' \ 2819e4fd900SJohn Levon | egrep -v '^Using ROM API Version' \ 2829e4fd900SJohn Levon | egrep -v '^Zero Signature length:' \ 2839e4fd900SJohn Levon | egrep -v '^Note \(probably harmless\):' \ 2849e4fd900SJohn Levon | egrep -v '::' \ 2859e4fd900SJohn Levon | egrep -v -- '-xcache' \ 2869e4fd900SJohn Levon | egrep -v '^\+' \ 2879e4fd900SJohn Levon | egrep -v '^cc1: note: -fwritable-strings' \ 2889e4fd900SJohn Levon | egrep -v 'svccfg-native -s svc:/' \ 2899e4fd900SJohn Levon | sort | uniq >$SRC/${NOISE}.out 2909e4fd900SJohn Levon if [ ! -f $SRC/${NOISE}.ref ]; then 2919e4fd900SJohn Levon cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 2929e4fd900SJohn Levon fi 2939e4fd900SJohn Levon echo "\n==== Build noise differences ($LABEL) ====\n" \ 2949e4fd900SJohn Levon >>$mail_msg_file 2959e4fd900SJohn Levon diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 2969e4fd900SJohn Levon fi 2979e4fd900SJohn Levon 2989e4fd900SJohn Levon # 2999e4fd900SJohn Levon # Re-sign selected binaries using signing server 3009e4fd900SJohn Levon # (gatekeeper builds only) 3019e4fd900SJohn Levon # 3029e4fd900SJohn Levon if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 3039e4fd900SJohn Levon echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 3049e4fd900SJohn Levon signing_file="${TMPDIR}/signing" 3059e4fd900SJohn Levon rm -f ${signing_file} 3069e4fd900SJohn Levon export CODESIGN_USER 3079e4fd900SJohn Levon signproto $SRC/tools/codesign/creds 2>&1 | \ 3089e4fd900SJohn Levon tee -a ${signing_file} >> $LOGFILE 3099e4fd900SJohn Levon echo "\n==== Finished signing proto area at `date` ====\n" \ 3109e4fd900SJohn Levon >> $LOGFILE 3119e4fd900SJohn Levon echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 3129e4fd900SJohn Levon >> $mail_msg_file 3139e4fd900SJohn Levon egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 3149e4fd900SJohn Levon if (( $? == 0 )) ; then 3159e4fd900SJohn Levon build_ok=n 3169e4fd900SJohn Levon this_build_ok=n 3179e4fd900SJohn Levon fi 3189e4fd900SJohn Levon fi 3199e4fd900SJohn Levon 3209e4fd900SJohn Levon # 3219e4fd900SJohn Levon # Building Packages 3229e4fd900SJohn Levon # 3239e4fd900SJohn Levon if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 3249e4fd900SJohn Levon if [ -d $SRC/pkg ]; then 3259e4fd900SJohn Levon echo "\n==== Creating $LABEL packages at `date` ====\n" \ 3269e4fd900SJohn Levon >> $LOGFILE 3279e4fd900SJohn Levon echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 3289e4fd900SJohn Levon rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 3299e4fd900SJohn Levon mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 3309e4fd900SJohn Levon 3319e4fd900SJohn Levon rm -f $SRC/pkg/${INSTALLOG}.out 3329e4fd900SJohn Levon cd $SRC/pkg 3339e4fd900SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 3349e4fd900SJohn Levon tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 3359e4fd900SJohn Levon 3369e4fd900SJohn Levon echo "\n==== package build errors ($LABEL) ====\n" \ 3379e4fd900SJohn Levon >> $mail_msg_file 3389e4fd900SJohn Levon 3399e4fd900SJohn Levon egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 3409e4fd900SJohn Levon grep ':' | \ 3419e4fd900SJohn Levon grep -v PSTAMP | \ 3429e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 3439e4fd900SJohn Levon tee $TMPDIR/package >> $mail_msg_file 3449e4fd900SJohn Levon if [[ -s $TMPDIR/package ]]; then 3459e4fd900SJohn Levon build_extras_ok=n 3469e4fd900SJohn Levon this_build_ok=n 3479e4fd900SJohn Levon fi 3489e4fd900SJohn Levon else 3499e4fd900SJohn Levon # 3509e4fd900SJohn Levon # Handle it gracefully if -p was set but there so 3519e4fd900SJohn Levon # no pkg directory. 3529e4fd900SJohn Levon # 3539e4fd900SJohn Levon echo "\n==== No $LABEL packages to build ====\n" \ 3549e4fd900SJohn Levon >> $LOGFILE 3559e4fd900SJohn Levon fi 3569e4fd900SJohn Levon else 3579e4fd900SJohn Levon echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 3589e4fd900SJohn Levon fi 3599e4fd900SJohn Levon 3609e4fd900SJohn Levon ROOT=$ORIGROOT 3619e4fd900SJohn Levon} 3629e4fd900SJohn Levon 3639e4fd900SJohn Levon# Usage: dolint /dir y|n 3649e4fd900SJohn Levon# Arg. 2 is a flag to turn on/off the lint diff output 3659e4fd900SJohn Levonfunction dolint { 3669e4fd900SJohn Levon if [ ! -d "$1" ]; then 3679e4fd900SJohn Levon echo "dolint error: $1 is not a directory" 3689e4fd900SJohn Levon exit 1 3699e4fd900SJohn Levon fi 3709e4fd900SJohn Levon 3719e4fd900SJohn Levon if [ "$2" != "y" -a "$2" != "n" ]; then 3729e4fd900SJohn Levon echo "dolint internal error: $2 should be 'y' or 'n'" 3739e4fd900SJohn Levon exit 1 3749e4fd900SJohn Levon fi 3759e4fd900SJohn Levon 3769e4fd900SJohn Levon lintdir=$1 3779e4fd900SJohn Levon dodiff=$2 3789e4fd900SJohn Levon base=`basename $lintdir` 3799e4fd900SJohn Levon LINTOUT=$lintdir/lint-${MACH}.out 3809e4fd900SJohn Levon LINTNOISE=$lintdir/lint-noise-${MACH} 3819e4fd900SJohn Levon export ENVLDLIBS1=`myldlibs $ROOT` 3829e4fd900SJohn Levon export ENVCPPFLAGS1=`myheaders $ROOT` 3839e4fd900SJohn Levon 3849e4fd900SJohn Levon set_debug_build_flags 3859e4fd900SJohn Levon 3869e4fd900SJohn Levon # 3879e4fd900SJohn Levon # '$MAKE lint' in $lintdir 3889e4fd900SJohn Levon # 3899e4fd900SJohn Levon echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 3909e4fd900SJohn Levon 3919e4fd900SJohn Levon # remove old lint.out 3929e4fd900SJohn Levon rm -f $lintdir/lint.out $lintdir/lint-noise.out 3939e4fd900SJohn Levon if [ -f $lintdir/lint-noise.ref ]; then 3949e4fd900SJohn Levon mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 3959e4fd900SJohn Levon fi 3969e4fd900SJohn Levon 3979e4fd900SJohn Levon rm -f $LINTOUT 3989e4fd900SJohn Levon cd $lintdir 3999e4fd900SJohn Levon # 4009e4fd900SJohn Levon # Remove all .ln files to ensure a full reference file 4019e4fd900SJohn Levon # 4029e4fd900SJohn Levon rm -f Nothing_to_remove \ 4039e4fd900SJohn Levon `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \ 4049e4fd900SJohn Levon -prune -o -type f -name '*.ln' -print ` 4059e4fd900SJohn Levon 4069e4fd900SJohn Levon /bin/time $MAKE -ek lint 2>&1 | \ 4079e4fd900SJohn Levon tee -a $LINTOUT >> $LOGFILE 4089e4fd900SJohn Levon 4099e4fd900SJohn Levon echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 4109e4fd900SJohn Levon 4119e4fd900SJohn Levon grep "$MAKE:" $LINTOUT | 4129e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 4139e4fd900SJohn Levon tee $TMPDIR/lint_errs >> $mail_msg_file 4149e4fd900SJohn Levon if [[ -s $TMPDIR/lint_errs ]]; then 4159e4fd900SJohn Levon build_extras_ok=n 4169e4fd900SJohn Levon fi 4179e4fd900SJohn Levon 4189e4fd900SJohn Levon echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 4199e4fd900SJohn Levon 4209e4fd900SJohn Levon echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 4219e4fd900SJohn Levon >>$mail_msg_file 4229e4fd900SJohn Levon tail -3 $LINTOUT >>$mail_msg_file 4239e4fd900SJohn Levon 4249e4fd900SJohn Levon rm -f ${LINTNOISE}.ref 4259e4fd900SJohn Levon if [ -f ${LINTNOISE}.out ]; then 4269e4fd900SJohn Levon mv ${LINTNOISE}.out ${LINTNOISE}.ref 4279e4fd900SJohn Levon fi 4289e4fd900SJohn Levon grep : $LINTOUT | \ 4299e4fd900SJohn Levon egrep -v '^(real|user|sys)' | 4309e4fd900SJohn Levon egrep -v '(library construction)' | \ 4319e4fd900SJohn Levon egrep -v ': global crosschecks' | \ 4329e4fd900SJohn Levon egrep -v 'Ignoring unknown host' | \ 4339e4fd900SJohn Levon egrep -v '\.c:$' | \ 4349e4fd900SJohn Levon sort | uniq > ${LINTNOISE}.out 4359e4fd900SJohn Levon if [ ! -f ${LINTNOISE}.ref ]; then 4369e4fd900SJohn Levon cp ${LINTNOISE}.out ${LINTNOISE}.ref 4379e4fd900SJohn Levon fi 4389e4fd900SJohn Levon 4399e4fd900SJohn Levon if [ "$dodiff" != "n" ]; then 4409e4fd900SJohn Levon echo "\n==== lint warnings $base ====\n" \ 4419e4fd900SJohn Levon >>$mail_msg_file 4429e4fd900SJohn Levon # should be none, though there are a few that were filtered out 4439e4fd900SJohn Levon # above 4449e4fd900SJohn Levon egrep -i '(warning|lint):' ${LINTNOISE}.out \ 4459e4fd900SJohn Levon | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file 4469e4fd900SJohn Levon if [[ -s $TMPDIR/lint_warns ]]; then 4479e4fd900SJohn Levon build_extras_ok=n 4489e4fd900SJohn Levon fi 4499e4fd900SJohn Levon echo "\n==== lint noise differences $base ====\n" \ 4509e4fd900SJohn Levon >> $mail_msg_file 4519e4fd900SJohn Levon diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 4529e4fd900SJohn Levon >> $mail_msg_file 4539e4fd900SJohn Levon fi 4549e4fd900SJohn Levon} 4559e4fd900SJohn Levon 4569e4fd900SJohn Levon# 4579e4fd900SJohn Levon# Build and install the onbld tools. 4589e4fd900SJohn Levon# 4599e4fd900SJohn Levon# usage: build_tools DESTROOT 4609e4fd900SJohn Levon# 4619e4fd900SJohn Levon# returns non-zero status if the build was successful. 4629e4fd900SJohn Levon# 4639e4fd900SJohn Levonfunction build_tools { 4649e4fd900SJohn Levon DESTROOT=$1 4659e4fd900SJohn Levon 4669e4fd900SJohn Levon INSTALLOG=install-${MACH} 4679e4fd900SJohn Levon 4689e4fd900SJohn Levon echo "\n==== Building tools at `date` ====\n" \ 4699e4fd900SJohn Levon >> $LOGFILE 4709e4fd900SJohn Levon 4719e4fd900SJohn Levon rm -f ${TOOLS}/${INSTALLOG}.out 4729e4fd900SJohn Levon cd ${TOOLS} 4739e4fd900SJohn Levon /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 4749e4fd900SJohn Levon tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 4759e4fd900SJohn Levon 4769e4fd900SJohn Levon echo "\n==== Tools build errors ====\n" >> $mail_msg_file 4779e4fd900SJohn Levon 4789e4fd900SJohn Levon egrep ":" ${TOOLS}/${INSTALLOG}.out | 4799e4fd900SJohn Levon egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 4809e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 4819e4fd900SJohn Levon egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 4829e4fd900SJohn Levon 4839e4fd900SJohn Levon if [[ -s $TMPDIR/tools_errors ]]; then 4849e4fd900SJohn Levon return 1 4859e4fd900SJohn Levon fi 4869e4fd900SJohn Levon return 0 4879e4fd900SJohn Levon} 4889e4fd900SJohn Levon 4899e4fd900SJohn Levon# 4909e4fd900SJohn Levon# Set up to use locally installed tools. 4919e4fd900SJohn Levon# 4929e4fd900SJohn Levon# usage: use_tools TOOLSROOT 4939e4fd900SJohn Levon# 4949e4fd900SJohn Levonfunction use_tools { 4959e4fd900SJohn Levon TOOLSROOT=$1 4969e4fd900SJohn Levon 4979e4fd900SJohn Levon # 4989e4fd900SJohn Levon # If we're not building ON workspace, then the TOOLSROOT 4999e4fd900SJohn Levon # settings here are clearly ignored by the workspace 5009e4fd900SJohn Levon # makefiles, prepending nonexistent directories to PATH is 5019e4fd900SJohn Levon # harmless, and we clearly do not wish to override 5029e4fd900SJohn Levon # ONBLD_TOOLS. 5039e4fd900SJohn Levon # 5049e4fd900SJohn Levon # If we're building an ON workspace, then the prepended PATH 5059e4fd900SJohn Levon # elements should supercede the preexisting ONBLD_TOOLS paths, 5069e4fd900SJohn Levon # and we want to override ONBLD_TOOLS to catch the tools that 5079e4fd900SJohn Levon # don't have specific path env vars here. 5089e4fd900SJohn Levon # 5099e4fd900SJohn Levon # So the only conditional behavior is overriding ONBLD_TOOLS, 5109e4fd900SJohn Levon # and we check for "an ON workspace" by looking for 5119e4fd900SJohn Levon # ${TOOLSROOT}/opt/onbld. 5129e4fd900SJohn Levon # 5139e4fd900SJohn Levon 5149e4fd900SJohn Levon STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs 5159e4fd900SJohn Levon export STABS 5169e4fd900SJohn Levon CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs 5179e4fd900SJohn Levon export CTFSTABS 5189e4fd900SJohn Levon GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets 5199e4fd900SJohn Levon export GENOFFSETS 5209e4fd900SJohn Levon 5219e4fd900SJohn Levon CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert 5229e4fd900SJohn Levon export CTFCONVERT 5239e4fd900SJohn Levon CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge 5249e4fd900SJohn Levon export CTFMERGE 5259e4fd900SJohn Levon 5269e4fd900SJohn Levon if [ "$VERIFY_ELFSIGN" = "y" ]; then 5279e4fd900SJohn Levon ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 5289e4fd900SJohn Levon else 5299e4fd900SJohn Levon ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 5309e4fd900SJohn Levon fi 5319e4fd900SJohn Levon export ELFSIGN 5329e4fd900SJohn Levon 5339e4fd900SJohn Levon PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 5349e4fd900SJohn Levon PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 5359e4fd900SJohn Levon export PATH 5369e4fd900SJohn Levon 5379e4fd900SJohn Levon if [ -d "${TOOLSROOT}/opt/onbld" ]; then 5389e4fd900SJohn Levon ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 5399e4fd900SJohn Levon export ONBLD_TOOLS 5409e4fd900SJohn Levon fi 5419e4fd900SJohn Levon 5429e4fd900SJohn Levon echo "\n==== New environment settings. ====\n" >> $LOGFILE 5439e4fd900SJohn Levon echo "STABS=${STABS}" >> $LOGFILE 5449e4fd900SJohn Levon echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 5459e4fd900SJohn Levon echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 5469e4fd900SJohn Levon echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 5479e4fd900SJohn Levon echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 5489e4fd900SJohn Levon echo "PATH=${PATH}" >> $LOGFILE 5499e4fd900SJohn Levon echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 5509e4fd900SJohn Levon} 5519e4fd900SJohn Levon 5529e4fd900SJohn Levonfunction staffer { 5539e4fd900SJohn Levon if [ $ISUSER -ne 0 ]; then 5549e4fd900SJohn Levon "$@" 5559e4fd900SJohn Levon else 5569e4fd900SJohn Levon arg="\"$1\"" 5579e4fd900SJohn Levon shift 5589e4fd900SJohn Levon for i 5599e4fd900SJohn Levon do 5609e4fd900SJohn Levon arg="$arg \"$i\"" 5619e4fd900SJohn Levon done 5629e4fd900SJohn Levon eval su $STAFFER -c \'$arg\' 5639e4fd900SJohn Levon fi 5649e4fd900SJohn Levon} 5659e4fd900SJohn Levon 5669e4fd900SJohn Levon# 5679e4fd900SJohn Levon# Verify that the closed bins are present 5689e4fd900SJohn Levon# 5699e4fd900SJohn Levonfunction check_closed_bins { 5709e4fd900SJohn Levon if [[ ! -d "$ON_CLOSED_BINS" ]]; then 5719e4fd900SJohn Levon echo "ON_CLOSED_BINS must point to the closed binaries tree." 5729e4fd900SJohn Levon build_ok=n 5739e4fd900SJohn Levon exit 1 5749e4fd900SJohn Levon fi 5759e4fd900SJohn Levon} 5769e4fd900SJohn Levon 5779e4fd900SJohn Levon# 5789e4fd900SJohn Levon# wrapper over wsdiff. 5799e4fd900SJohn Levon# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 5809e4fd900SJohn Levon# 5819e4fd900SJohn Levonfunction do_wsdiff { 5829e4fd900SJohn Levon label=$1 5839e4fd900SJohn Levon oldproto=$2 5849e4fd900SJohn Levon newproto=$3 585*bf16a978SMarcel Telka results=$4 5869e4fd900SJohn Levon 5879e4fd900SJohn Levon wsdiff="wsdiff" 5889e4fd900SJohn Levon [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 5899e4fd900SJohn Levon 5909e4fd900SJohn Levon echo "\n==== Getting object changes since last build at `date`" \ 5919e4fd900SJohn Levon "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 592*bf16a978SMarcel Telka $wsdiff -s -r ${TMPDIR}/$results $oldproto $newproto 2>&1 | \ 5939e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 5949e4fd900SJohn Levon echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 5959e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 5969e4fd900SJohn Levon} 5979e4fd900SJohn Levon 5989e4fd900SJohn Levon# 5999e4fd900SJohn Levon# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 6009e4fd900SJohn Levon# together. 6019e4fd900SJohn Levon# 6029e4fd900SJohn Levon 6039e4fd900SJohn Levonfunction set_non_debug_build_flags { 6049e4fd900SJohn Levon export RELEASE_BUILD ; RELEASE_BUILD= 6059e4fd900SJohn Levon unset EXTRA_OPTIONS 6069e4fd900SJohn Levon unset EXTRA_CFLAGS 6079e4fd900SJohn Levon} 6089e4fd900SJohn Levon 6099e4fd900SJohn Levonfunction set_debug_build_flags { 6109e4fd900SJohn Levon unset RELEASE_BUILD 6119e4fd900SJohn Levon unset EXTRA_OPTIONS 6129e4fd900SJohn Levon unset EXTRA_CFLAGS 6139e4fd900SJohn Levon} 6149e4fd900SJohn Levon 6159e4fd900SJohn Levon 6169e4fd900SJohn LevonMACH=`uname -p` 6179e4fd900SJohn Levon 6189e4fd900SJohn Levonif [ "$OPTHOME" = "" ]; then 6199e4fd900SJohn Levon OPTHOME=/opt 6209e4fd900SJohn Levon export OPTHOME 6219e4fd900SJohn Levonfi 6229e4fd900SJohn Levon 6239e4fd900SJohn LevonUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 6249e4fd900SJohn Levon 6259e4fd900SJohn LevonWhere: 6269e4fd900SJohn Levon -i Fast incremental options (no clobber, lint, check) 6279e4fd900SJohn Levon -n Do not do a bringover 6289e4fd900SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 6299e4fd900SJohn Levon -V VERS set the build version string to VERS 6309e4fd900SJohn Levon 6319e4fd900SJohn Levon <env_file> file in Bourne shell syntax that sets and exports 6329e4fd900SJohn Levon variables that configure the operation of this script and many of 6339e4fd900SJohn Levon the scripts this one calls. If <env_file> does not exist, 6349e4fd900SJohn Levon it will be looked for in $OPTHOME/onbld/env. 6359e4fd900SJohn Levon 6369e4fd900SJohn Levonnon-DEBUG is the default build type. Build options can be set in the 6379e4fd900SJohn LevonNIGHTLY_OPTIONS variable in the <env_file> as follows: 6389e4fd900SJohn Levon 6399e4fd900SJohn Levon -A check for ABI differences in .so files 6409e4fd900SJohn Levon -C check for cstyle/hdrchk errors 6419e4fd900SJohn Levon -D do a build with DEBUG on 6429e4fd900SJohn Levon -F do _not_ do a non-DEBUG build 6439e4fd900SJohn Levon -G gate keeper default group of options (-au) 6449e4fd900SJohn Levon -I integration engineer default group of options (-ampu) 6459e4fd900SJohn Levon -M do not run pmodes (safe file permission checker) 6469e4fd900SJohn Levon -N do not run protocmp 6479e4fd900SJohn Levon -R default group of options for building a release (-mp) 6489e4fd900SJohn Levon -U update proto area in the parent 6499e4fd900SJohn Levon -V VERS set the build version string to VERS 6509e4fd900SJohn Levon -f find unreferenced files 6519e4fd900SJohn Levon -i do an incremental build (no "make clobber") 6529e4fd900SJohn Levon -l do "make lint" in $LINTDIRS (default: $SRC y) 6539e4fd900SJohn Levon -m send mail to $MAILTO at end of build 6549e4fd900SJohn Levon -n do not do a bringover 6559e4fd900SJohn Levon -p create packages 6569e4fd900SJohn Levon -r check ELF runtime attributes in the proto area 6579e4fd900SJohn Levon -t build and use the tools in $SRC/tools (default setting) 6589e4fd900SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 6599e4fd900SJohn Levon -u update proto_list_$MACH and friends in the parent workspace; 6609e4fd900SJohn Levon when used with -f, also build an unrefmaster.out in the parent 6619e4fd900SJohn Levon -w report on differences between previous and current proto areas 6629e4fd900SJohn Levon' 6639e4fd900SJohn Levon# 6649e4fd900SJohn Levon# A log file will be generated under the name $LOGFILE 6659e4fd900SJohn Levon# for partially completed build and log.`date '+%F'` 6669e4fd900SJohn Levon# in the same directory for fully completed builds. 6679e4fd900SJohn Levon# 6689e4fd900SJohn Levon 6699e4fd900SJohn Levon# default values for low-level FLAGS; G I R are group FLAGS 6709e4fd900SJohn LevonA_FLAG=n 6719e4fd900SJohn LevonC_FLAG=n 6729e4fd900SJohn LevonD_FLAG=n 6739e4fd900SJohn LevonF_FLAG=n 6749e4fd900SJohn Levonf_FLAG=n 6759e4fd900SJohn Levoni_FLAG=n; i_CMD_LINE_FLAG=n 6769e4fd900SJohn Levonl_FLAG=n 6779e4fd900SJohn LevonM_FLAG=n 6789e4fd900SJohn Levonm_FLAG=n 6799e4fd900SJohn LevonN_FLAG=n 6809e4fd900SJohn Levonn_FLAG=n 6819e4fd900SJohn Levonp_FLAG=n 6829e4fd900SJohn Levonr_FLAG=n 6839e4fd900SJohn Levont_FLAG=y 6849e4fd900SJohn LevonU_FLAG=n 6859e4fd900SJohn Levonu_FLAG=n 6869e4fd900SJohn LevonV_FLAG=n 6879e4fd900SJohn Levonw_FLAG=n 6889e4fd900SJohn LevonW_FLAG=n 6899e4fd900SJohn Levon# 6909e4fd900SJohn Levonbuild_ok=y 6919e4fd900SJohn Levonbuild_extras_ok=y 6929e4fd900SJohn Levon 6939e4fd900SJohn Levon# 6949e4fd900SJohn Levon# examine arguments 6959e4fd900SJohn Levon# 6969e4fd900SJohn Levon 6979e4fd900SJohn LevonOPTIND=1 6989e4fd900SJohn Levonwhile getopts +intV:W FLAG 6999e4fd900SJohn Levondo 7009e4fd900SJohn Levon case $FLAG in 7019e4fd900SJohn Levon i ) i_FLAG=y; i_CMD_LINE_FLAG=y 7029e4fd900SJohn Levon ;; 7039e4fd900SJohn Levon n ) n_FLAG=y 7049e4fd900SJohn Levon ;; 7059e4fd900SJohn Levon +t ) t_FLAG=n 7069e4fd900SJohn Levon ;; 7079e4fd900SJohn Levon V ) V_FLAG=y 7089e4fd900SJohn Levon V_ARG="$OPTARG" 7099e4fd900SJohn Levon ;; 7109e4fd900SJohn Levon W ) W_FLAG=y 7119e4fd900SJohn Levon ;; 7129e4fd900SJohn Levon \? ) echo "$USAGE" 7139e4fd900SJohn Levon exit 1 7149e4fd900SJohn Levon ;; 7159e4fd900SJohn Levon esac 7169e4fd900SJohn Levondone 7179e4fd900SJohn Levon 7189e4fd900SJohn Levon# correct argument count after options 7199e4fd900SJohn Levonshift `expr $OPTIND - 1` 7209e4fd900SJohn Levon 7219e4fd900SJohn Levon# test that the path to the environment-setting file was given 7229e4fd900SJohn Levonif [ $# -ne 1 ]; then 7239e4fd900SJohn Levon echo "$USAGE" 7249e4fd900SJohn Levon exit 1 7259e4fd900SJohn Levonfi 7269e4fd900SJohn Levon 7279e4fd900SJohn Levon# check if user is running nightly as root 7289e4fd900SJohn Levon# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 7299e4fd900SJohn Levon# when root invokes nightly. 7309e4fd900SJohn Levon/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 7319e4fd900SJohn LevonISUSER=$?; export ISUSER 7329e4fd900SJohn Levon 7339e4fd900SJohn Levon# 7349e4fd900SJohn Levon# force locale to C 7359e4fd900SJohn LevonLANG=C; export LANG 7369e4fd900SJohn LevonLC_ALL=C; export LC_ALL 7379e4fd900SJohn LevonLC_COLLATE=C; export LC_COLLATE 7389e4fd900SJohn LevonLC_CTYPE=C; export LC_CTYPE 7399e4fd900SJohn LevonLC_MESSAGES=C; export LC_MESSAGES 7409e4fd900SJohn LevonLC_MONETARY=C; export LC_MONETARY 7419e4fd900SJohn LevonLC_NUMERIC=C; export LC_NUMERIC 7429e4fd900SJohn LevonLC_TIME=C; export LC_TIME 7439e4fd900SJohn Levon 7449e4fd900SJohn Levon# clear environment variables we know to be bad for the build 7459e4fd900SJohn Levonunset LD_OPTIONS 7469e4fd900SJohn Levonunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 7479e4fd900SJohn Levonunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 7489e4fd900SJohn Levonunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 7499e4fd900SJohn Levonunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 7509e4fd900SJohn Levonunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 7519e4fd900SJohn Levonunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 7529e4fd900SJohn Levonunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 7539e4fd900SJohn Levonunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 7549e4fd900SJohn Levonunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 7559e4fd900SJohn Levonunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 7569e4fd900SJohn Levonunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 7579e4fd900SJohn Levonunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 7589e4fd900SJohn Levonunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 7599e4fd900SJohn Levonunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 7609e4fd900SJohn Levonunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 7619e4fd900SJohn Levonunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 7629e4fd900SJohn Levonunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 7639e4fd900SJohn Levonunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 7649e4fd900SJohn Levonunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 7659e4fd900SJohn Levonunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 7669e4fd900SJohn Levon 7679e4fd900SJohn Levonunset CONFIG 7689e4fd900SJohn Levonunset GROUP 7699e4fd900SJohn Levonunset OWNER 7709e4fd900SJohn Levonunset REMOTE 7719e4fd900SJohn Levonunset ENV 7729e4fd900SJohn Levonunset ARCH 7739e4fd900SJohn Levonunset CLASSPATH 7749e4fd900SJohn Levonunset NAME 7759e4fd900SJohn Levon 7769e4fd900SJohn Levon# 7779e4fd900SJohn Levon# To get ONBLD_TOOLS from the environment, it must come from the env file. 7789e4fd900SJohn Levon# If it comes interactively, it is generally TOOLS_PROTO, which will be 7799e4fd900SJohn Levon# clobbered before the compiler version checks, which will therefore fail. 7809e4fd900SJohn Levon# 7819e4fd900SJohn Levonunset ONBLD_TOOLS 7829e4fd900SJohn Levon 7839e4fd900SJohn Levon# 7849e4fd900SJohn Levon# Setup environmental variables 7859e4fd900SJohn Levon# 7869e4fd900SJohn Levonif [ -f /etc/nightly.conf ]; then 7879e4fd900SJohn Levon . /etc/nightly.conf 7889e4fd900SJohn Levonfi 7899e4fd900SJohn Levon 7909e4fd900SJohn Levonif [ -f $1 ]; then 7919e4fd900SJohn Levon if [[ $1 = */* ]]; then 7929e4fd900SJohn Levon . $1 7939e4fd900SJohn Levon else 7949e4fd900SJohn Levon . ./$1 7959e4fd900SJohn Levon fi 7969e4fd900SJohn Levonelse 7979e4fd900SJohn Levon if [ -f $OPTHOME/onbld/env/$1 ]; then 7989e4fd900SJohn Levon . $OPTHOME/onbld/env/$1 7999e4fd900SJohn Levon else 8009e4fd900SJohn Levon echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 8019e4fd900SJohn Levon exit 1 8029e4fd900SJohn Levon fi 8039e4fd900SJohn Levonfi 8049e4fd900SJohn Levon 8059e4fd900SJohn Levon# Check if we have sufficient data to continue... 8069e4fd900SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 8079e4fd900SJohn Levonif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 8089e4fd900SJohn Levon # Check if the gate data are valid if we don't do a "bringover" below 8099e4fd900SJohn Levon [[ -d "${CODEMGR_WS}" ]] || \ 8109e4fd900SJohn Levon fatal_error "Error: ${CODEMGR_WS} is not a directory." 8119e4fd900SJohn Levon [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 8129e4fd900SJohn Levon fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 8139e4fd900SJohn Levonfi 8149e4fd900SJohn Levon 8159e4fd900SJohn Levon# 8169e4fd900SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set. 8179e4fd900SJohn Levon# 8189e4fd900SJohn Levonif [ -z "$BUILD_PROJECT" ]; then 8199e4fd900SJohn Levon /usr/bin/newtask -c $$ 8209e4fd900SJohn Levonelse 8219e4fd900SJohn Levon /usr/bin/newtask -c $$ -p $BUILD_PROJECT 8229e4fd900SJohn Levonfi 8239e4fd900SJohn Levon 8249e4fd900SJohn Levonps -o taskid= -p $$ | read build_taskid 8259e4fd900SJohn Levonps -o project= -p $$ | read build_project 8269e4fd900SJohn Levon 8279e4fd900SJohn Levon# 8289e4fd900SJohn Levon# See if NIGHTLY_OPTIONS is set 8299e4fd900SJohn Levon# 8309e4fd900SJohn Levonif [ "$NIGHTLY_OPTIONS" = "" ]; then 8319e4fd900SJohn Levon NIGHTLY_OPTIONS="-aBm" 8329e4fd900SJohn Levonfi 8339e4fd900SJohn Levon 8349e4fd900SJohn Levon# 8359e4fd900SJohn Levon# If BRINGOVER_WS was not specified, let it default to CLONE_WS 8369e4fd900SJohn Levon# 8379e4fd900SJohn Levonif [ "$BRINGOVER_WS" = "" ]; then 8389e4fd900SJohn Levon BRINGOVER_WS=$CLONE_WS 8399e4fd900SJohn Levonfi 8409e4fd900SJohn Levon 8419e4fd900SJohn Levon# 8429e4fd900SJohn Levon# If BRINGOVER_FILES was not specified, default to usr 8439e4fd900SJohn Levon# 8449e4fd900SJohn Levonif [ "$BRINGOVER_FILES" = "" ]; then 8459e4fd900SJohn Levon BRINGOVER_FILES="usr" 8469e4fd900SJohn Levonfi 8479e4fd900SJohn Levon 8489e4fd900SJohn Levoncheck_closed_bins 8499e4fd900SJohn Levon 8509e4fd900SJohn Levon# 8519e4fd900SJohn Levon# Note: changes to the option letters here should also be applied to the 8529e4fd900SJohn Levon# bldenv script. `d' is listed for backward compatibility. 8539e4fd900SJohn Levon# 8549e4fd900SJohn LevonNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 8559e4fd900SJohn LevonOPTIND=1 8569e4fd900SJohn Levonwhile getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 8579e4fd900SJohn Levondo 8589e4fd900SJohn Levon case $FLAG in 8599e4fd900SJohn Levon A ) A_FLAG=y 8609e4fd900SJohn Levon ;; 8619e4fd900SJohn Levon B ) D_FLAG=y 8629e4fd900SJohn Levon ;; # old version of D 8639e4fd900SJohn Levon C ) C_FLAG=y 8649e4fd900SJohn Levon ;; 8659e4fd900SJohn Levon D ) D_FLAG=y 8669e4fd900SJohn Levon ;; 8679e4fd900SJohn Levon F ) F_FLAG=y 8689e4fd900SJohn Levon ;; 8699e4fd900SJohn Levon f ) f_FLAG=y 8709e4fd900SJohn Levon ;; 8719e4fd900SJohn Levon G ) u_FLAG=y 8729e4fd900SJohn Levon ;; 8739e4fd900SJohn Levon I ) m_FLAG=y 8749e4fd900SJohn Levon p_FLAG=y 8759e4fd900SJohn Levon u_FLAG=y 8769e4fd900SJohn Levon ;; 8779e4fd900SJohn Levon i ) i_FLAG=y 8789e4fd900SJohn Levon ;; 8799e4fd900SJohn Levon l ) l_FLAG=y 8809e4fd900SJohn Levon ;; 8819e4fd900SJohn Levon M ) M_FLAG=y 8829e4fd900SJohn Levon ;; 8839e4fd900SJohn Levon m ) m_FLAG=y 8849e4fd900SJohn Levon ;; 8859e4fd900SJohn Levon N ) N_FLAG=y 8869e4fd900SJohn Levon ;; 8879e4fd900SJohn Levon n ) n_FLAG=y 8889e4fd900SJohn Levon ;; 8899e4fd900SJohn Levon p ) p_FLAG=y 8909e4fd900SJohn Levon ;; 8919e4fd900SJohn Levon R ) m_FLAG=y 8929e4fd900SJohn Levon p_FLAG=y 8939e4fd900SJohn Levon ;; 8949e4fd900SJohn Levon r ) r_FLAG=y 8959e4fd900SJohn Levon ;; 8969e4fd900SJohn Levon +t ) t_FLAG=n 8979e4fd900SJohn Levon ;; 8989e4fd900SJohn Levon U ) if [ -z "${PARENT_ROOT}" ]; then 8999e4fd900SJohn Levon echo "PARENT_ROOT must be set if the U flag is" \ 9009e4fd900SJohn Levon "present in NIGHTLY_OPTIONS." 9019e4fd900SJohn Levon exit 1 9029e4fd900SJohn Levon fi 9039e4fd900SJohn Levon NIGHTLY_PARENT_ROOT=$PARENT_ROOT 9049e4fd900SJohn Levon if [ -n "${PARENT_TOOLS_ROOT}" ]; then 9059e4fd900SJohn Levon NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 9069e4fd900SJohn Levon fi 9079e4fd900SJohn Levon U_FLAG=y 9089e4fd900SJohn Levon ;; 9099e4fd900SJohn Levon u ) u_FLAG=y 9109e4fd900SJohn Levon ;; 9119e4fd900SJohn Levon w ) w_FLAG=y 9129e4fd900SJohn Levon ;; 9139e4fd900SJohn Levon W ) W_FLAG=y 9149e4fd900SJohn Levon ;; 9159e4fd900SJohn Levon \? ) echo "$USAGE" 9169e4fd900SJohn Levon exit 1 9179e4fd900SJohn Levon ;; 9189e4fd900SJohn Levon esac 9199e4fd900SJohn Levondone 9209e4fd900SJohn Levon 9219e4fd900SJohn Levonif [ $ISUSER -ne 0 ]; then 9229e4fd900SJohn Levon # Set default value for STAFFER, if needed. 9239e4fd900SJohn Levon if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 9249e4fd900SJohn Levon STAFFER=`/usr/xpg4/bin/id -un` 9259e4fd900SJohn Levon export STAFFER 9269e4fd900SJohn Levon fi 9279e4fd900SJohn Levonfi 9289e4fd900SJohn Levon 9299e4fd900SJohn Levonif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 9309e4fd900SJohn Levon MAILTO=$STAFFER 9319e4fd900SJohn Levon export MAILTO 9329e4fd900SJohn Levonfi 9339e4fd900SJohn Levon 9349e4fd900SJohn LevonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 9359e4fd900SJohn LevonPATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 9369e4fd900SJohn LevonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 9379e4fd900SJohn Levonexport PATH 9389e4fd900SJohn Levon 9399e4fd900SJohn Levon# roots of source trees, both relative to $SRC and absolute. 9409e4fd900SJohn Levonrelsrcdirs="." 9419e4fd900SJohn Levonabssrcdirs="$SRC" 9429e4fd900SJohn Levon 9439e4fd900SJohn LevonPROTOCMPTERSE="protocmp.terse -gu" 9449e4fd900SJohn LevonPOUND_SIGN="#" 9459e4fd900SJohn Levon# have we set RELEASE_DATE in our env file? 9469e4fd900SJohn Levonif [ -z "$RELEASE_DATE" ]; then 9479e4fd900SJohn Levon RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 9489e4fd900SJohn Levonfi 9499e4fd900SJohn LevonBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 9509e4fd900SJohn LevonBASEWSDIR=$(basename $CODEMGR_WS) 9519e4fd900SJohn LevonDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 9529e4fd900SJohn Levon 9539e4fd900SJohn Levon# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 9549e4fd900SJohn Levon# by avoiding repeated shell invocations to evaluate Makefile.master 9559e4fd900SJohn Levon# definitions. 9569e4fd900SJohn Levonexport POUND_SIGN RELEASE_DATE DEV_CM 9579e4fd900SJohn Levon 9589e4fd900SJohn Levonmaketype="distributed" 9599e4fd900SJohn Levonif [[ -z "$MAKE" ]]; then 9609e4fd900SJohn Levon MAKE=dmake 9619e4fd900SJohn Levonelif [[ ! -x "$MAKE" ]]; then 9629e4fd900SJohn Levon echo "\$MAKE is set to garbage in the environment" 9639e4fd900SJohn Levon exit 1 9649e4fd900SJohn Levonfi 9659e4fd900SJohn Levonexport PATH 9669e4fd900SJohn Levonexport MAKE 9679e4fd900SJohn Levon 9689e4fd900SJohn Levonif [ "${SUNWSPRO}" != "" ]; then 9699e4fd900SJohn Levon PATH="${SUNWSPRO}/bin:$PATH" 9709e4fd900SJohn Levon export PATH 9719e4fd900SJohn Levonfi 9729e4fd900SJohn Levon 9739e4fd900SJohn Levonhostname=$(uname -n) 9749e4fd900SJohn Levonif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 9759e4fd900SJohn Levonthen 9769e4fd900SJohn Levon maxjobs= 9779e4fd900SJohn Levon if [[ -f $HOME/.make.machines ]] 9789e4fd900SJohn Levon then 9799e4fd900SJohn Levon # Note: there is a hard tab and space character in the []s 9809e4fd900SJohn Levon # below. 9819e4fd900SJohn Levon egrep -i "^[ ]*$hostname[ \.]" \ 9829e4fd900SJohn Levon $HOME/.make.machines | read host jobs 9839e4fd900SJohn Levon maxjobs=${jobs##*=} 9849e4fd900SJohn Levon fi 9859e4fd900SJohn Levon 9869e4fd900SJohn Levon if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 9879e4fd900SJohn Levon then 9889e4fd900SJohn Levon # default 9899e4fd900SJohn Levon maxjobs=4 9909e4fd900SJohn Levon fi 9919e4fd900SJohn Levon 9929e4fd900SJohn Levon export DMAKE_MAX_JOBS=$maxjobs 9939e4fd900SJohn Levonfi 9949e4fd900SJohn Levon 9959e4fd900SJohn LevonDMAKE_MODE=parallel; 9969e4fd900SJohn Levonexport DMAKE_MODE 9979e4fd900SJohn Levon 9989e4fd900SJohn Levonif [ -z "${ROOT}" ]; then 9999e4fd900SJohn Levon echo "ROOT must be set." 10009e4fd900SJohn Levon exit 1 10019e4fd900SJohn Levonfi 10029e4fd900SJohn Levon 10039e4fd900SJohn Levon# 10049e4fd900SJohn Levon# if -V flag was given, reset VERSION to V_ARG 10059e4fd900SJohn Levon# 10069e4fd900SJohn Levonif [ "$V_FLAG" = "y" ]; then 10079e4fd900SJohn Levon VERSION=$V_ARG 10089e4fd900SJohn Levonfi 10099e4fd900SJohn Levon 10109e4fd900SJohn LevonTMPDIR="/tmp/nightly.tmpdir.$$" 10119e4fd900SJohn Levonexport TMPDIR 10129e4fd900SJohn Levonrm -rf ${TMPDIR} 10139e4fd900SJohn Levonmkdir -p $TMPDIR || exit 1 10149e4fd900SJohn Levonchmod 777 $TMPDIR 10159e4fd900SJohn Levon 10169e4fd900SJohn Levon# 10179e4fd900SJohn Levon# Keep elfsign's use of pkcs11_softtoken from looking in the user home 10189e4fd900SJohn Levon# directory, which doesn't always work. Needed until all build machines 10199e4fd900SJohn Levon# have the fix for 6271754 10209e4fd900SJohn Levon# 10219e4fd900SJohn LevonSOFTTOKEN_DIR=$TMPDIR 10229e4fd900SJohn Levonexport SOFTTOKEN_DIR 10239e4fd900SJohn Levon 10249e4fd900SJohn Levon# 10259e4fd900SJohn Levon# Tools should only be built non-DEBUG. Keep track of the tools proto 10269e4fd900SJohn Levon# area path relative to $TOOLS, because the latter changes in an 10279e4fd900SJohn Levon# export build. 10289e4fd900SJohn Levon# 10299e4fd900SJohn Levon# TOOLS_PROTO is included below for builds other than usr/src/tools 10309e4fd900SJohn Levon# that look for this location. For usr/src/tools, this will be 10319e4fd900SJohn Levon# overridden on the $MAKE command line in build_tools(). 10329e4fd900SJohn Levon# 10339e4fd900SJohn LevonTOOLS=${SRC}/tools 10349e4fd900SJohn LevonTOOLS_PROTO_REL=proto/root_${MACH}-nd 10359e4fd900SJohn LevonTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 10369e4fd900SJohn Levon 10379e4fd900SJohn Levonunset CFLAGS LD_LIBRARY_PATH LDFLAGS 10389e4fd900SJohn Levon 10399e4fd900SJohn Levon# create directories that are automatically removed if the nightly script 10409e4fd900SJohn Levon# fails to start correctly 10419e4fd900SJohn Levonfunction newdir { 10429e4fd900SJohn Levon dir=$1 10439e4fd900SJohn Levon toadd= 10449e4fd900SJohn Levon while [ ! -d $dir ]; do 10459e4fd900SJohn Levon toadd="$dir $toadd" 10469e4fd900SJohn Levon dir=`dirname $dir` 10479e4fd900SJohn Levon done 10489e4fd900SJohn Levon torm= 10499e4fd900SJohn Levon newlist= 10509e4fd900SJohn Levon for dir in $toadd; do 10519e4fd900SJohn Levon if staffer mkdir $dir; then 10529e4fd900SJohn Levon newlist="$ISUSER $dir $newlist" 10539e4fd900SJohn Levon torm="$dir $torm" 10549e4fd900SJohn Levon else 10559e4fd900SJohn Levon [ -z "$torm" ] || staffer rmdir $torm 10569e4fd900SJohn Levon return 1 10579e4fd900SJohn Levon fi 10589e4fd900SJohn Levon done 10599e4fd900SJohn Levon newdirlist="$newlist $newdirlist" 10609e4fd900SJohn Levon return 0 10619e4fd900SJohn Levon} 10629e4fd900SJohn Levonnewdirlist= 10639e4fd900SJohn Levon 10649e4fd900SJohn Levon[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 10659e4fd900SJohn Levon 10669e4fd900SJohn Levon# since this script assumes the build is from full source, it nullifies 10679e4fd900SJohn Levon# variables likely to have been set by a "ws" script; nullification 10689e4fd900SJohn Levon# confines the search space for headers and libraries to the proto area 10699e4fd900SJohn Levon# built from this immediate source. 10709e4fd900SJohn LevonENVLDLIBS1= 10719e4fd900SJohn LevonENVLDLIBS2= 10729e4fd900SJohn LevonENVLDLIBS3= 10739e4fd900SJohn LevonENVCPPFLAGS1= 10749e4fd900SJohn LevonENVCPPFLAGS2= 10759e4fd900SJohn LevonENVCPPFLAGS3= 10769e4fd900SJohn LevonENVCPPFLAGS4= 10779e4fd900SJohn LevonPARENT_ROOT= 10789e4fd900SJohn Levon 10799e4fd900SJohn Levonexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 10809e4fd900SJohn Levon ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 10819e4fd900SJohn Levon 10829e4fd900SJohn LevonPKGARCHIVE_ORIG=$PKGARCHIVE 10839e4fd900SJohn Levon 10849e4fd900SJohn Levon# 10859e4fd900SJohn Levon# Juggle the logs and optionally send mail on completion. 10869e4fd900SJohn Levon# 10879e4fd900SJohn Levon 10889e4fd900SJohn Levonfunction logshuffle { 10899e4fd900SJohn Levon LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 10909e4fd900SJohn Levon if [ -f $LLOG -o -d $LLOG ]; then 10919e4fd900SJohn Levon LLOG=$LLOG.$$ 10929e4fd900SJohn Levon fi 10939e4fd900SJohn Levon mkdir $LLOG 10949e4fd900SJohn Levon export LLOG 10959e4fd900SJohn Levon 10969e4fd900SJohn Levon if [ "$build_ok" = "y" ]; then 10979e4fd900SJohn Levon mv $ATLOG/proto_list_${MACH} $LLOG 10989e4fd900SJohn Levon 10999e4fd900SJohn Levon if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 11009e4fd900SJohn Levon mv $ATLOG/proto_list_tools_${MACH} $LLOG 11019e4fd900SJohn Levon fi 11029e4fd900SJohn Levon 11039e4fd900SJohn Levon if [ -f $TMPDIR/wsdiff.results ]; then 11049e4fd900SJohn Levon mv $TMPDIR/wsdiff.results $LLOG 11059e4fd900SJohn Levon fi 11069e4fd900SJohn Levon 11079e4fd900SJohn Levon if [ -f $TMPDIR/wsdiff-nd.results ]; then 11089e4fd900SJohn Levon mv $TMPDIR/wsdiff-nd.results $LLOG 11099e4fd900SJohn Levon fi 1110*bf16a978SMarcel Telka 1111*bf16a978SMarcel Telka if [ -f $TMPDIR/wsdiff-tools.results ]; then 1112*bf16a978SMarcel Telka mv $TMPDIR/wsdiff-tools.results $LLOG 1113*bf16a978SMarcel Telka fi 11149e4fd900SJohn Levon fi 11159e4fd900SJohn Levon 11169e4fd900SJohn Levon # 11179e4fd900SJohn Levon # Now that we're about to send mail, it's time to check the noise 11189e4fd900SJohn Levon # file. In the event that an error occurs beyond this point, it will 11199e4fd900SJohn Levon # be recorded in the nightly.log file, but nowhere else. This would 11209e4fd900SJohn Levon # include only errors that cause the copying of the noise log to fail 11219e4fd900SJohn Levon # or the mail itself not to be sent. 11229e4fd900SJohn Levon # 11239e4fd900SJohn Levon 11249e4fd900SJohn Levon exec >>$LOGFILE 2>&1 11259e4fd900SJohn Levon if [ -s $build_noise_file ]; then 11269e4fd900SJohn Levon echo "\n==== Nightly build noise ====\n" | 11279e4fd900SJohn Levon tee -a $LOGFILE >>$mail_msg_file 11289e4fd900SJohn Levon cat $build_noise_file >>$LOGFILE 11299e4fd900SJohn Levon cat $build_noise_file >>$mail_msg_file 11309e4fd900SJohn Levon echo | tee -a $LOGFILE >>$mail_msg_file 11319e4fd900SJohn Levon fi 11329e4fd900SJohn Levon rm -f $build_noise_file 11339e4fd900SJohn Levon 11349e4fd900SJohn Levon case "$build_ok" in 11359e4fd900SJohn Levon y) 11369e4fd900SJohn Levon state=Completed 11379e4fd900SJohn Levon ;; 11389e4fd900SJohn Levon i) 11399e4fd900SJohn Levon state=Interrupted 11409e4fd900SJohn Levon ;; 11419e4fd900SJohn Levon *) 11429e4fd900SJohn Levon state=Failed 11439e4fd900SJohn Levon ;; 11449e4fd900SJohn Levon esac 11459e4fd900SJohn Levon 11469e4fd900SJohn Levon if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 11479e4fd900SJohn Levon state=Failed 11489e4fd900SJohn Levon fi 11499e4fd900SJohn Levon 11509e4fd900SJohn Levon NIGHTLY_STATUS=$state 11519e4fd900SJohn Levon export NIGHTLY_STATUS 11529e4fd900SJohn Levon 11539e4fd900SJohn Levon run_hook POST_NIGHTLY $state 11549e4fd900SJohn Levon run_hook SYS_POST_NIGHTLY $state 11559e4fd900SJohn Levon 11569e4fd900SJohn Levon # 11579e4fd900SJohn Levon # mailx(1) sets From: based on the -r flag 11589e4fd900SJohn Levon # if it is given. 11599e4fd900SJohn Levon # 11609e4fd900SJohn Levon mailx_r= 11619e4fd900SJohn Levon if [[ -n "${MAILFROM}" ]]; then 11629e4fd900SJohn Levon mailx_r="-r ${MAILFROM}" 11639e4fd900SJohn Levon fi 11649e4fd900SJohn Levon 11659e4fd900SJohn Levon cat $build_time_file $build_environ_file $mail_msg_file \ 11669e4fd900SJohn Levon > ${LLOG}/mail_msg 11679e4fd900SJohn Levon if [ "$m_FLAG" = "y" ]; then 11689e4fd900SJohn Levon cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 11699e4fd900SJohn Levon "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 11709e4fd900SJohn Levon ${MAILTO} 11719e4fd900SJohn Levon fi 11729e4fd900SJohn Levon 11739e4fd900SJohn Levon if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 11749e4fd900SJohn Levon staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 11759e4fd900SJohn Levon staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 11769e4fd900SJohn Levon fi 11779e4fd900SJohn Levon 11789e4fd900SJohn Levon mv $LOGFILE $LLOG 11799e4fd900SJohn Levon} 11809e4fd900SJohn Levon 11819e4fd900SJohn Levon# 11829e4fd900SJohn Levon# Remove the locks and temporary files on any exit 11839e4fd900SJohn Levon# 11849e4fd900SJohn Levonfunction cleanup { 11859e4fd900SJohn Levon logshuffle 11869e4fd900SJohn Levon 11879e4fd900SJohn Levon [ -z "$lockfile" ] || staffer rm -f $lockfile 11889e4fd900SJohn Levon [ -z "$atloglockfile" ] || rm -f $atloglockfile 11899e4fd900SJohn Levon [ -z "$ulockfile" ] || staffer rm -f $ulockfile 11909e4fd900SJohn Levon [ -z "$Ulockfile" ] || rm -f $Ulockfile 11919e4fd900SJohn Levon 11929e4fd900SJohn Levon set -- $newdirlist 11939e4fd900SJohn Levon while [ $# -gt 0 ]; do 11949e4fd900SJohn Levon ISUSER=$1 staffer rmdir $2 11959e4fd900SJohn Levon shift; shift 11969e4fd900SJohn Levon done 11979e4fd900SJohn Levon rm -rf $TMPDIR 11989e4fd900SJohn Levon} 11999e4fd900SJohn Levon 12009e4fd900SJohn Levonfunction cleanup_signal { 12019e4fd900SJohn Levon build_ok=i 12029e4fd900SJohn Levon # this will trigger cleanup(), above. 12039e4fd900SJohn Levon exit 1 12049e4fd900SJohn Levon} 12059e4fd900SJohn Levon 12069e4fd900SJohn Levontrap cleanup 0 12079e4fd900SJohn Levontrap cleanup_signal 1 2 3 15 12089e4fd900SJohn Levon 12099e4fd900SJohn Levon# 12109e4fd900SJohn Levon# Generic lock file processing -- make sure that the lock file doesn't 12119e4fd900SJohn Levon# exist. If it does, it should name the build host and PID. If it 12129e4fd900SJohn Levon# doesn't, then make sure we can create it. Clean up locks that are 12139e4fd900SJohn Levon# known to be stale (assumes host name is unique among build systems 12149e4fd900SJohn Levon# for the workspace). 12159e4fd900SJohn Levon# 12169e4fd900SJohn Levonfunction create_lock { 12179e4fd900SJohn Levon lockf=$1 12189e4fd900SJohn Levon lockvar=$2 12199e4fd900SJohn Levon 12209e4fd900SJohn Levon ldir=`dirname $lockf` 12219e4fd900SJohn Levon [ -d $ldir ] || newdir $ldir || exit 1 12229e4fd900SJohn Levon eval $lockvar=$lockf 12239e4fd900SJohn Levon 12249e4fd900SJohn Levon while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 12259e4fd900SJohn Levon basews=`basename $CODEMGR_WS` 12269e4fd900SJohn Levon ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 12279e4fd900SJohn Levon if [ "$host" != "$hostname" ]; then 12289e4fd900SJohn Levon echo "$MACH build of $basews apparently" \ 12299e4fd900SJohn Levon "already started by $user on $host as $pid." 12309e4fd900SJohn Levon exit 1 12319e4fd900SJohn Levon elif kill -s 0 $pid 2>/dev/null; then 12329e4fd900SJohn Levon echo "$MACH build of $basews already started" \ 12339e4fd900SJohn Levon "by $user as $pid." 12349e4fd900SJohn Levon exit 1 12359e4fd900SJohn Levon else 12369e4fd900SJohn Levon # stale lock; clear it out and try again 12379e4fd900SJohn Levon rm -f $lockf 12389e4fd900SJohn Levon fi 12399e4fd900SJohn Levon done 12409e4fd900SJohn Levon} 12419e4fd900SJohn Levon 12429e4fd900SJohn Levon# 12439e4fd900SJohn Levon# Return the list of interesting proto areas, depending on the current 12449e4fd900SJohn Levon# options. 12459e4fd900SJohn Levon# 12469e4fd900SJohn Levonfunction allprotos { 12479e4fd900SJohn Levon typeset roots="$ROOT" 12489e4fd900SJohn Levon 12499e4fd900SJohn Levon if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 12509e4fd900SJohn Levon roots="$roots $ROOT-nd" 12519e4fd900SJohn Levon fi 12529e4fd900SJohn Levon 12539e4fd900SJohn Levon echo $roots 12549e4fd900SJohn Levon} 12559e4fd900SJohn Levon 12569e4fd900SJohn Levon# Ensure no other instance of this script is running on this host. 12579e4fd900SJohn Levon# LOCKNAME can be set in <env_file>, and is by default, but is not 12589e4fd900SJohn Levon# required due to the use of $ATLOG below. 12599e4fd900SJohn Levonif [ -n "$LOCKNAME" ]; then 12609e4fd900SJohn Levon create_lock /tmp/$LOCKNAME "lockfile" 12619e4fd900SJohn Levonfi 12629e4fd900SJohn Levon# 12639e4fd900SJohn Levon# Create from one, two, or three other locks: 12649e4fd900SJohn Levon# $ATLOG/nightly.lock 12659e4fd900SJohn Levon# - protects against multiple builds in same workspace 12669e4fd900SJohn Levon# $PARENT_WS/usr/src/nightly.$MACH.lock 12679e4fd900SJohn Levon# - protects against multiple 'u' copy-backs 12689e4fd900SJohn Levon# $NIGHTLY_PARENT_ROOT/nightly.lock 12699e4fd900SJohn Levon# - protects against multiple 'U' copy-backs 12709e4fd900SJohn Levon# 12719e4fd900SJohn Levon# Overriding ISUSER to 1 causes the lock to be created as root if the 12729e4fd900SJohn Levon# script is run as root. The default is to create it as $STAFFER. 12739e4fd900SJohn LevonISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 12749e4fd900SJohn Levonif [ "$u_FLAG" = "y" ]; then 12759e4fd900SJohn Levon create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 12769e4fd900SJohn Levonfi 12779e4fd900SJohn Levonif [ "$U_FLAG" = "y" ]; then 12789e4fd900SJohn Levon # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 12799e4fd900SJohn Levon ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 12809e4fd900SJohn Levonfi 12819e4fd900SJohn Levon 12829e4fd900SJohn Levon# Locks have been taken, so we're doing a build and we're committed to 12839e4fd900SJohn Levon# the directories we may have created so far. 12849e4fd900SJohn Levonnewdirlist= 12859e4fd900SJohn Levon 12869e4fd900SJohn Levon# 12879e4fd900SJohn Levon# Create mail_msg_file 12889e4fd900SJohn Levon# 12899e4fd900SJohn Levonmail_msg_file="${TMPDIR}/mail_msg" 12909e4fd900SJohn Levontouch $mail_msg_file 12919e4fd900SJohn Levonbuild_time_file="${TMPDIR}/build_time" 12929e4fd900SJohn Levonbuild_environ_file="${TMPDIR}/build_environ" 12939e4fd900SJohn Levontouch $build_environ_file 12949e4fd900SJohn Levon# 12959e4fd900SJohn Levon# Move old LOGFILE aside 12969e4fd900SJohn Levon# ATLOG directory already made by 'create_lock' above 12979e4fd900SJohn Levon# 12989e4fd900SJohn Levonif [ -f $LOGFILE ]; then 12999e4fd900SJohn Levon mv -f $LOGFILE ${LOGFILE}- 13009e4fd900SJohn Levonfi 13019e4fd900SJohn Levon# 13029e4fd900SJohn Levon# Build OsNet source 13039e4fd900SJohn Levon# 13049e4fd900SJohn LevonSTART_DATE=`date` 13059e4fd900SJohn LevonSECONDS=0 13069e4fd900SJohn Levonecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 13079e4fd900SJohn Levon | tee -a $LOGFILE > $build_time_file 13089e4fd900SJohn Levon 13099e4fd900SJohn Levonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 13109e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13119e4fd900SJohn Levon 13129e4fd900SJohn Levon# make sure we log only to the nightly build file 13139e4fd900SJohn Levonbuild_noise_file="${TMPDIR}/build_noise" 13149e4fd900SJohn Levonexec </dev/null >$build_noise_file 2>&1 13159e4fd900SJohn Levon 13169e4fd900SJohn Levonrun_hook SYS_PRE_NIGHTLY 13179e4fd900SJohn Levonrun_hook PRE_NIGHTLY 13189e4fd900SJohn Levon 13199e4fd900SJohn Levonecho "\n==== list of environment variables ====\n" >> $LOGFILE 13209e4fd900SJohn Levonenv >> $LOGFILE 13219e4fd900SJohn Levon 13229e4fd900SJohn Levonecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 13239e4fd900SJohn Levon 13249e4fd900SJohn Levonif [ "$N_FLAG" = "y" ]; then 13259e4fd900SJohn Levon if [ "$p_FLAG" = "y" ]; then 13269e4fd900SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13279e4fd900SJohn LevonWARNING: the p option (create packages) is set, but so is the N option (do 13289e4fd900SJohn Levon not run protocmp); this is dangerous; you should unset the N option 13299e4fd900SJohn LevonEOF 13309e4fd900SJohn Levon else 13319e4fd900SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13329e4fd900SJohn LevonWarning: the N option (do not run protocmp) is set; it probably shouldn't be 13339e4fd900SJohn LevonEOF 13349e4fd900SJohn Levon fi 13359e4fd900SJohn Levon echo "" | tee -a $mail_msg_file >> $LOGFILE 13369e4fd900SJohn Levonfi 13379e4fd900SJohn Levon 13389e4fd900SJohn Levonif [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 13399e4fd900SJohn Levon # 13409e4fd900SJohn Levon # In the past we just complained but went ahead with the lint 13419e4fd900SJohn Levon # pass, even though the proto area was built non-DEBUG. It's 13429e4fd900SJohn Levon # unlikely that non-DEBUG headers will make a difference, but 13439e4fd900SJohn Levon # rather than assuming it's a safe combination, force the user 13449e4fd900SJohn Levon # to specify a DEBUG build. 13459e4fd900SJohn Levon # 13469e4fd900SJohn Levon echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 13479e4fd900SJohn Levon | tee -a $mail_msg_file >> $LOGFILE 13489e4fd900SJohn Levon l_FLAG=n 13499e4fd900SJohn Levonfi 13509e4fd900SJohn Levon 13519e4fd900SJohn Levonif [ "$f_FLAG" = "y" ]; then 13529e4fd900SJohn Levon if [ "$i_FLAG" = "y" ]; then 13539e4fd900SJohn Levon echo "WARNING: the -f flag cannot be used during incremental" \ 13549e4fd900SJohn Levon "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13559e4fd900SJohn Levon f_FLAG=n 13569e4fd900SJohn Levon fi 13579e4fd900SJohn Levon if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 13589e4fd900SJohn Levon echo "WARNING: the -f flag requires -l, and -p;" \ 13599e4fd900SJohn Levon "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13609e4fd900SJohn Levon f_FLAG=n 13619e4fd900SJohn Levon fi 13629e4fd900SJohn Levonfi 13639e4fd900SJohn Levon 13649e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 13659e4fd900SJohn Levon echo "WARNING: -w specified, but $ROOT does not exist;" \ 13669e4fd900SJohn Levon "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 13679e4fd900SJohn Levon w_FLAG=n 13689e4fd900SJohn Levonfi 13699e4fd900SJohn Levon 13709e4fd900SJohn Levonif [ "$t_FLAG" = "n" ]; then 13719e4fd900SJohn Levon # 13729e4fd900SJohn Levon # We're not doing a tools build, so make sure elfsign(1) is 13739e4fd900SJohn Levon # new enough to safely sign non-crypto binaries. We test 13749e4fd900SJohn Levon # debugging output from elfsign to detect the old version. 13759e4fd900SJohn Levon # 13769e4fd900SJohn Levon newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 13779e4fd900SJohn Levon -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 13789e4fd900SJohn Levon | egrep algorithmOID` 13799e4fd900SJohn Levon if [ -z "$newelfsigntest" ]; then 13809e4fd900SJohn Levon echo "WARNING: /usr/bin/elfsign out of date;" \ 13819e4fd900SJohn Levon "will only sign crypto modules\n" | \ 13829e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13839e4fd900SJohn Levon export ELFSIGN_OBJECT=true 13849e4fd900SJohn Levon elif [ "$VERIFY_ELFSIGN" = "y" ]; then 13859e4fd900SJohn Levon echo "WARNING: VERIFY_ELFSIGN=y requires" \ 13869e4fd900SJohn Levon "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 13879e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13889e4fd900SJohn Levon fi 13899e4fd900SJohn Levonfi 13909e4fd900SJohn Levon 13919e4fd900SJohn Levoncase $MULTI_PROTO in 13929e4fd900SJohn Levonyes|no) ;; 13939e4fd900SJohn Levon*) 13949e4fd900SJohn Levon echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 13959e4fd900SJohn Levon "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 13969e4fd900SJohn Levon echo "Setting MULTI_PROTO to \"no\".\n" | \ 13979e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13989e4fd900SJohn Levon export MULTI_PROTO=no 13999e4fd900SJohn Levon ;; 14009e4fd900SJohn Levonesac 14019e4fd900SJohn Levon 14029e4fd900SJohn Levonecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 14039e4fd900SJohn Levonecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 14049e4fd900SJohn Levon 14059e4fd900SJohn Levon# Save the current proto area if we're comparing against the last build 14069e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 14079e4fd900SJohn Levon if [ -d "$ROOT.prev" ]; then 14089e4fd900SJohn Levon rm -rf $ROOT.prev 14099e4fd900SJohn Levon fi 14109e4fd900SJohn Levon mv $ROOT $ROOT.prev 14119e4fd900SJohn Levonfi 14129e4fd900SJohn Levon 14139e4fd900SJohn Levon# Same for non-DEBUG proto area 14149e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 14159e4fd900SJohn Levon if [ -d "$ROOT-nd.prev" ]; then 14169e4fd900SJohn Levon rm -rf $ROOT-nd.prev 14179e4fd900SJohn Levon fi 14189e4fd900SJohn Levon mv $ROOT-nd $ROOT-nd.prev 14199e4fd900SJohn Levonfi 14209e4fd900SJohn Levon 1421*bf16a978SMarcel Telka# Same for tools proto area 1422*bf16a978SMarcel Telkaif [ "$w_FLAG" = "y" -a "$t_FLAG" == "y" -a -d "$TOOLS_PROTO" ]; then 1423*bf16a978SMarcel Telka if [ -d "$TOOLS_PROTO.prev" ]; then 1424*bf16a978SMarcel Telka rm -rf $TOOLS_PROTO.prev 1425*bf16a978SMarcel Telka fi 1426*bf16a978SMarcel Telka mv $TOOLS_PROTO $TOOLS_PROTO.prev 1427*bf16a978SMarcel Telkafi 1428*bf16a978SMarcel Telka 14299e4fd900SJohn Levon# 14309e4fd900SJohn Levon# Echo the SCM type of the parent workspace, this can't just be which_scm 14319e4fd900SJohn Levon# as that does not know how to identify various network repositories. 14329e4fd900SJohn Levon# 14339e4fd900SJohn Levonfunction parent_wstype { 14349e4fd900SJohn Levon typeset scm_type junk 14359e4fd900SJohn Levon 14369e4fd900SJohn Levon CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 14379e4fd900SJohn Levon | read scm_type junk 14389e4fd900SJohn Levon if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 14399e4fd900SJohn Levon # Probe BRINGOVER_WS to determine its type 14409e4fd900SJohn Levon if [[ $BRINGOVER_WS == ssh://* ]]; then 14419e4fd900SJohn Levon scm_type="mercurial" 14429e4fd900SJohn Levon elif [[ $BRINGOVER_WS == http://* ]] && \ 14439e4fd900SJohn Levon wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 14449e4fd900SJohn Levon egrep -s "application/mercurial" 2> /dev/null; then 14459e4fd900SJohn Levon scm_type="mercurial" 14469e4fd900SJohn Levon else 14479e4fd900SJohn Levon scm_type="none" 14489e4fd900SJohn Levon fi 14499e4fd900SJohn Levon fi 14509e4fd900SJohn Levon 14519e4fd900SJohn Levon # fold both unsupported and unrecognized results into "none" 14529e4fd900SJohn Levon case "$scm_type" in 14539e4fd900SJohn Levon mercurial) 14549e4fd900SJohn Levon ;; 14559e4fd900SJohn Levon *) scm_type=none 14569e4fd900SJohn Levon ;; 14579e4fd900SJohn Levon esac 14589e4fd900SJohn Levon 14599e4fd900SJohn Levon echo $scm_type 14609e4fd900SJohn Levon} 14619e4fd900SJohn Levon 14629e4fd900SJohn Levon# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 14639e4fd900SJohn Levonfunction child_wstype { 14649e4fd900SJohn Levon typeset scm_type junk 14659e4fd900SJohn Levon 14669e4fd900SJohn Levon # Probe CODEMGR_WS to determine its type 14679e4fd900SJohn Levon if [[ -d $CODEMGR_WS ]]; then 14689e4fd900SJohn Levon $WHICH_SCM | read scm_type junk || exit 1 14699e4fd900SJohn Levon fi 14709e4fd900SJohn Levon 14719e4fd900SJohn Levon case "$scm_type" in 14729e4fd900SJohn Levon none|git|mercurial) 14739e4fd900SJohn Levon ;; 14749e4fd900SJohn Levon *) scm_type=none 14759e4fd900SJohn Levon ;; 14769e4fd900SJohn Levon esac 14779e4fd900SJohn Levon 14789e4fd900SJohn Levon echo $scm_type 14799e4fd900SJohn Levon} 14809e4fd900SJohn Levon 14819e4fd900SJohn LevonSCM_TYPE=$(child_wstype) 14829e4fd900SJohn Levon 14839e4fd900SJohn Levon# 14849e4fd900SJohn Levon# Decide whether to clobber 14859e4fd900SJohn Levon# 14869e4fd900SJohn Levonif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 14879e4fd900SJohn Levon echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 14889e4fd900SJohn Levon 14899e4fd900SJohn Levon cd $SRC 14909e4fd900SJohn Levon # remove old clobber file 14919e4fd900SJohn Levon rm -f $SRC/clobber.out 14929e4fd900SJohn Levon rm -f $SRC/clobber-${MACH}.out 14939e4fd900SJohn Levon 14949e4fd900SJohn Levon # Remove all .make.state* files, just in case we are restarting 14959e4fd900SJohn Levon # the build after having interrupted a previous 'make clobber'. 14969e4fd900SJohn Levon find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 14979e4fd900SJohn Levon -o -name 'interfaces.*' \) -prune \ 14989e4fd900SJohn Levon -o -name '.make.*' -print | xargs rm -f 14999e4fd900SJohn Levon 15009e4fd900SJohn Levon $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 15019e4fd900SJohn Levon echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 15029e4fd900SJohn Levon grep "$MAKE:" $SRC/clobber-${MACH}.out | 15039e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 15049e4fd900SJohn Levon tee $TMPDIR/clobber_errs >> $mail_msg_file 15059e4fd900SJohn Levon 15069e4fd900SJohn Levon if [[ -s $TMPDIR/clobber_errs ]]; then 15079e4fd900SJohn Levon build_extras_ok=n 15089e4fd900SJohn Levon fi 15099e4fd900SJohn Levon 15109e4fd900SJohn Levon if [[ "$t_FLAG" = "y" ]]; then 15119e4fd900SJohn Levon echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 15129e4fd900SJohn Levon cd ${TOOLS} 15139e4fd900SJohn Levon rm -f ${TOOLS}/clobber-${MACH}.out 15149e4fd900SJohn Levon $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 15159e4fd900SJohn Levon tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 15169e4fd900SJohn Levon echo "\n==== Make tools clobber ERRORS ====\n" \ 15179e4fd900SJohn Levon >> $mail_msg_file 15189e4fd900SJohn Levon grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 15199e4fd900SJohn Levon >> $mail_msg_file 15209e4fd900SJohn Levon if (( $? == 0 )); then 15219e4fd900SJohn Levon build_extras_ok=n 15229e4fd900SJohn Levon fi 15239e4fd900SJohn Levon rm -rf ${TOOLS_PROTO} 15249e4fd900SJohn Levon mkdir -p ${TOOLS_PROTO} 15259e4fd900SJohn Levon fi 15269e4fd900SJohn Levon 15279e4fd900SJohn Levon typeset roots=$(allprotos) 15289e4fd900SJohn Levon echo "\n\nClearing $roots" >> "$LOGFILE" 15299e4fd900SJohn Levon rm -rf $roots 15309e4fd900SJohn Levon 15319e4fd900SJohn Levon # Get back to a clean workspace as much as possible to catch 15329e4fd900SJohn Levon # problems that only occur on fresh workspaces. 15339e4fd900SJohn Levon # Remove all .make.state* files, libraries, and .o's that may 15349e4fd900SJohn Levon # have been omitted from clobber. A couple of libraries are 15359e4fd900SJohn Levon # under source code control, so leave them alone. 15369e4fd900SJohn Levon # We should probably blow away temporary directories too. 15379e4fd900SJohn Levon cd $SRC 15389e4fd900SJohn Levon find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 15399e4fd900SJohn Levon -o -name .git -o -name 'interfaces.*' \) -prune -o \ 15409e4fd900SJohn Levon \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 15419e4fd900SJohn Levon -name '*.o' \) -print | \ 15429e4fd900SJohn Levon grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 15439e4fd900SJohn Levonelse 15449e4fd900SJohn Levon echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 15459e4fd900SJohn Levonfi 15469e4fd900SJohn Levon 15479e4fd900SJohn Levontype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 15489e4fd900SJohn Levon typeset -x PATH=$PATH 15499e4fd900SJohn Levon 15509e4fd900SJohn Levon # If the repository doesn't exist yet, then we want to populate it. 15519e4fd900SJohn Levon if [[ ! -d $CODEMGR_WS/.hg ]]; then 15529e4fd900SJohn Levon staffer hg init $CODEMGR_WS 15539e4fd900SJohn Levon staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 15549e4fd900SJohn Levon staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 15559e4fd900SJohn Levon touch $TMPDIR/new_repository 15569e4fd900SJohn Levon fi 15579e4fd900SJohn Levon 15589e4fd900SJohn Levon typeset -x HGMERGE="/bin/false" 15599e4fd900SJohn Levon 15609e4fd900SJohn Levon # 15619e4fd900SJohn Levon # If the user has changes, regardless of whether those changes are 15629e4fd900SJohn Levon # committed, and regardless of whether those changes conflict, then 15639e4fd900SJohn Levon # we'll attempt to merge them either implicitly (uncommitted) or 15649e4fd900SJohn Levon # explicitly (committed). 15659e4fd900SJohn Levon # 15669e4fd900SJohn Levon # These are the messages we'll use to help clarify mercurial output 15679e4fd900SJohn Levon # in those cases. 15689e4fd900SJohn Levon # 15699e4fd900SJohn Levon typeset mergefailmsg="\ 15709e4fd900SJohn Levon***\n\ 15719e4fd900SJohn Levon*** nightly was unable to automatically merge your changes. You should\n\ 15729e4fd900SJohn Levon*** redo the full merge manually, following the steps outlined by mercurial\n\ 15739e4fd900SJohn Levon*** above, then restart nightly.\n\ 15749e4fd900SJohn Levon***\n" 15759e4fd900SJohn Levon typeset mergepassmsg="\ 15769e4fd900SJohn Levon***\n\ 15779e4fd900SJohn Levon*** nightly successfully merged your changes. This means that your working\n\ 15789e4fd900SJohn Levon*** directory has been updated, but those changes are not yet committed.\n\ 15799e4fd900SJohn Levon*** After nightly completes, you should validate the results of the merge,\n\ 15809e4fd900SJohn Levon*** then use hg commit manually.\n\ 15819e4fd900SJohn Levon***\n" 15829e4fd900SJohn Levon 15839e4fd900SJohn Levon # 15849e4fd900SJohn Levon # For each repository in turn: 15859e4fd900SJohn Levon # 15869e4fd900SJohn Levon # 1. Do the pull. If this fails, dump the output and bail out. 15879e4fd900SJohn Levon # 15889e4fd900SJohn Levon # 2. If the pull resulted in an extra head, do an explicit merge. 15899e4fd900SJohn Levon # If this fails, dump the output and bail out. 15909e4fd900SJohn Levon # 15919e4fd900SJohn Levon # Because we can't rely on Mercurial to exit with a failure code 15929e4fd900SJohn Levon # when a merge fails (Mercurial issue #186), we must grep the 15939e4fd900SJohn Levon # output of pull/merge to check for attempted and/or failed merges. 15949e4fd900SJohn Levon # 15959e4fd900SJohn Levon # 3. If a merge failed, set the message and fail the bringover. 15969e4fd900SJohn Levon # 15979e4fd900SJohn Levon # 4. Otherwise, if a merge succeeded, set the message 15989e4fd900SJohn Levon # 15999e4fd900SJohn Levon # 5. Dump the output, and any message from step 3 or 4. 16009e4fd900SJohn Levon # 16019e4fd900SJohn Levon 16029e4fd900SJohn Levon typeset HG_SOURCE=$BRINGOVER_WS 16039e4fd900SJohn Levon if [ ! -f $TMPDIR/new_repository ]; then 16049e4fd900SJohn Levon HG_SOURCE=$TMPDIR/open_bundle.hg 16059e4fd900SJohn Levon staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 16069e4fd900SJohn Levon -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 16079e4fd900SJohn Levon 16089e4fd900SJohn Levon # 16099e4fd900SJohn Levon # If there are no incoming changesets, then incoming will 16109e4fd900SJohn Levon # fail, and there will be no bundle file. Reset the source, 16119e4fd900SJohn Levon # to allow the remaining logic to complete with no false 16129e4fd900SJohn Levon # negatives. (Unlike incoming, pull will return success 16139e4fd900SJohn Levon # for the no-change case.) 16149e4fd900SJohn Levon # 16159e4fd900SJohn Levon if (( $? != 0 )); then 16169e4fd900SJohn Levon HG_SOURCE=$BRINGOVER_WS 16179e4fd900SJohn Levon fi 16189e4fd900SJohn Levon fi 16199e4fd900SJohn Levon 16209e4fd900SJohn Levon staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 16219e4fd900SJohn Levon > $TMPDIR/pull_open.out 2>&1 16229e4fd900SJohn Levon if (( $? != 0 )); then 16239e4fd900SJohn Levon printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 16249e4fd900SJohn Levon cat $TMPDIR/pull_open.out 16259e4fd900SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16269e4fd900SJohn Levon printf "$mergefailmsg" 16279e4fd900SJohn Levon fi 16289e4fd900SJohn Levon touch $TMPDIR/bringover_failed 16299e4fd900SJohn Levon return 16309e4fd900SJohn Levon fi 16319e4fd900SJohn Levon 16329e4fd900SJohn Levon if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16339e4fd900SJohn Levon staffer hg --cwd $CODEMGR_WS merge \ 16349e4fd900SJohn Levon >> $TMPDIR/pull_open.out 2>&1 16359e4fd900SJohn Levon if (( $? != 0 )); then 16369e4fd900SJohn Levon printf "%s: merge failed as follows:\n\n" \ 16379e4fd900SJohn Levon "$CODEMGR_WS" 16389e4fd900SJohn Levon cat $TMPDIR/pull_open.out 16399e4fd900SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out \ 16409e4fd900SJohn Levon > /dev/null 2>&1; then 16419e4fd900SJohn Levon printf "$mergefailmsg" 16429e4fd900SJohn Levon fi 16439e4fd900SJohn Levon touch $TMPDIR/bringover_failed 16449e4fd900SJohn Levon return 16459e4fd900SJohn Levon fi 16469e4fd900SJohn Levon fi 16479e4fd900SJohn Levon 16489e4fd900SJohn Levon printf "updated %s with the following results:\n" "$CODEMGR_WS" 16499e4fd900SJohn Levon cat $TMPDIR/pull_open.out 16509e4fd900SJohn Levon if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 16519e4fd900SJohn Levon printf "$mergepassmsg" 16529e4fd900SJohn Levon fi 16539e4fd900SJohn Levon printf "\n" 16549e4fd900SJohn Levon 16559e4fd900SJohn Levon # 16569e4fd900SJohn Levon # Per-changeset output is neither useful nor manageable for a 16579e4fd900SJohn Levon # newly-created repository. 16589e4fd900SJohn Levon # 16599e4fd900SJohn Levon if [ -f $TMPDIR/new_repository ]; then 16609e4fd900SJohn Levon return 16619e4fd900SJohn Levon fi 16629e4fd900SJohn Levon 16639e4fd900SJohn Levon printf "\nadded the following changesets to open repository:\n" 16649e4fd900SJohn Levon cat $TMPDIR/incoming_open.out 16659e4fd900SJohn Levon} 16669e4fd900SJohn Levon 16679e4fd900SJohn Levontype bringover_none > /dev/null 2>&1 || function bringover_none { 16689e4fd900SJohn Levon echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 16699e4fd900SJohn Levon touch $TMPDIR/bringover_failed 16709e4fd900SJohn Levon} 16719e4fd900SJohn Levon 16729e4fd900SJohn Levon# 16739e4fd900SJohn Levon# Decide whether to bringover to the codemgr workspace 16749e4fd900SJohn Levon# 16759e4fd900SJohn Levonif [ "$n_FLAG" = "n" ]; then 16769e4fd900SJohn Levon PARENT_SCM_TYPE=$(parent_wstype) 16779e4fd900SJohn Levon 16789e4fd900SJohn Levon if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 16799e4fd900SJohn Levon echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 16809e4fd900SJohn Levon "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 16819e4fd900SJohn Levon exit 1 16829e4fd900SJohn Levon fi 16839e4fd900SJohn Levon 16849e4fd900SJohn Levon run_hook PRE_BRINGOVER 16859e4fd900SJohn Levon 16869e4fd900SJohn Levon echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 16879e4fd900SJohn Levon echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 16889e4fd900SJohn Levon 16899e4fd900SJohn Levon eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 16909e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 16919e4fd900SJohn Levon 16929e4fd900SJohn Levon if [ -f $TMPDIR/bringover_failed ]; then 16939e4fd900SJohn Levon rm -f $TMPDIR/bringover_failed 16949e4fd900SJohn Levon build_ok=n 16959e4fd900SJohn Levon echo "trouble with bringover, quitting at `date`." | 16969e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 16979e4fd900SJohn Levon exit 1 16989e4fd900SJohn Levon fi 16999e4fd900SJohn Levon 17009e4fd900SJohn Levon # 17019e4fd900SJohn Levon # It's possible that we used the bringover above to create 17029e4fd900SJohn Levon # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 17039e4fd900SJohn Levon # but should now be the same as $BRINGOVER_WS. 17049e4fd900SJohn Levon # 17059e4fd900SJohn Levon [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 17069e4fd900SJohn Levon 17079e4fd900SJohn Levon run_hook POST_BRINGOVER 17089e4fd900SJohn Levon 17099e4fd900SJohn Levon check_closed_bins 17109e4fd900SJohn Levon 17119e4fd900SJohn Levonelse 17129e4fd900SJohn Levon echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 17139e4fd900SJohn Levonfi 17149e4fd900SJohn Levon 17159e4fd900SJohn Levon# Safeguards 17169e4fd900SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 17179e4fd900SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 17189e4fd900SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 17199e4fd900SJohn Levon 17209e4fd900SJohn Levonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 17219e4fd900SJohn Levon 17229e4fd900SJohn Levon# System 17239e4fd900SJohn Levonwhence uname | tee -a $build_environ_file >> $LOGFILE 17249e4fd900SJohn Levonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 17259e4fd900SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 17269e4fd900SJohn Levon 17279e4fd900SJohn Levon# make 17289e4fd900SJohn Levonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 17299e4fd900SJohn Levon$MAKE -v | tee -a $build_environ_file >> $LOGFILE 17309e4fd900SJohn Levonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 17319e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 17329e4fd900SJohn Levon 17339e4fd900SJohn Levon# 17349e4fd900SJohn Levon# Report the compiler versions. 17359e4fd900SJohn Levon# 17369e4fd900SJohn Levon 17379e4fd900SJohn Levonif [[ ! -f $SRC/Makefile ]]; then 17389e4fd900SJohn Levon build_ok=n 17399e4fd900SJohn Levon echo "\nUnable to find \"Makefile\" in $SRC." | \ 17409e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 17419e4fd900SJohn Levon exit 1 17429e4fd900SJohn Levonfi 17439e4fd900SJohn Levon 17449e4fd900SJohn Levon( cd $SRC 17459e4fd900SJohn Levon for target in cc-version cc64-version java-version; do 17469e4fd900SJohn Levon echo 17479e4fd900SJohn Levon # 17489e4fd900SJohn Levon # Put statefile somewhere we know we can write to rather than trip 17499e4fd900SJohn Levon # over a read-only $srcroot. 17509e4fd900SJohn Levon # 17519e4fd900SJohn Levon rm -f $TMPDIR/make-state 17529e4fd900SJohn Levon export SRC 17539e4fd900SJohn Levon if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 17549e4fd900SJohn Levon continue 17559e4fd900SJohn Levon fi 17569e4fd900SJohn Levon touch $TMPDIR/nocompiler 17579e4fd900SJohn Levon done 17589e4fd900SJohn Levon echo 17599e4fd900SJohn Levon) | tee -a $build_environ_file >> $LOGFILE 17609e4fd900SJohn Levon 17619e4fd900SJohn Levonif [ -f $TMPDIR/nocompiler ]; then 17629e4fd900SJohn Levon rm -f $TMPDIR/nocompiler 17639e4fd900SJohn Levon build_ok=n 17649e4fd900SJohn Levon echo "Aborting due to missing compiler." | 17659e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 17669e4fd900SJohn Levon exit 1 17679e4fd900SJohn Levonfi 17689e4fd900SJohn Levon 17699e4fd900SJohn Levon# as 17709e4fd900SJohn Levonwhence as | tee -a $build_environ_file >> $LOGFILE 17719e4fd900SJohn Levonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 17729e4fd900SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 17739e4fd900SJohn Levon 17749e4fd900SJohn Levon# Check that we're running a capable link-editor 17759e4fd900SJohn Levonwhence ld | tee -a $build_environ_file >> $LOGFILE 17769e4fd900SJohn LevonLDVER=`ld -V 2>&1` 17779e4fd900SJohn Levonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 17789e4fd900SJohn LevonLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 17799e4fd900SJohn Levonif [ `expr $LDVER \< 422` -eq 1 ]; then 17809e4fd900SJohn Levon echo "The link-editor needs to be at version 422 or higher to build" | \ 17819e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 17829e4fd900SJohn Levon echo "the latest stuff. Hope your build works." | \ 17839e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 17849e4fd900SJohn Levonfi 17859e4fd900SJohn Levon 17869e4fd900SJohn Levon# 17879e4fd900SJohn Levon# Build and use the workspace's tools if requested 17889e4fd900SJohn Levon# 17899e4fd900SJohn Levonif [[ "$t_FLAG" = "y" ]]; then 17909e4fd900SJohn Levon set_non_debug_build_flags 17919e4fd900SJohn Levon 17929e4fd900SJohn Levon build_tools ${TOOLS_PROTO} 17939e4fd900SJohn Levon if (( $? != 0 )); then 17949e4fd900SJohn Levon build_ok=n 17959e4fd900SJohn Levon else 17969e4fd900SJohn Levon use_tools $TOOLS_PROTO 17979e4fd900SJohn Levon fi 17989e4fd900SJohn Levonfi 17999e4fd900SJohn Levon 18009e4fd900SJohn Levon# timestamp the start of the normal build; the findunref tool uses it. 18019e4fd900SJohn Levontouch $SRC/.build.tstamp 18029e4fd900SJohn Levon 18039e4fd900SJohn Levonnormal_build 18049e4fd900SJohn Levon 18059e4fd900SJohn LevonORIG_SRC=$SRC 18069e4fd900SJohn LevonBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 18079e4fd900SJohn Levon 18089e4fd900SJohn Levon 18099e4fd900SJohn Levon# 18109e4fd900SJohn Levon# There are several checks that need to look at the proto area, but 18119e4fd900SJohn Levon# they only need to look at one, and they don't care whether it's 18129e4fd900SJohn Levon# DEBUG or non-DEBUG. 18139e4fd900SJohn Levon# 18149e4fd900SJohn Levonif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 18159e4fd900SJohn Levon checkroot=$ROOT-nd 18169e4fd900SJohn Levonelse 18179e4fd900SJohn Levon checkroot=$ROOT 18189e4fd900SJohn Levonfi 18199e4fd900SJohn Levon 18209e4fd900SJohn Levonif [ "$build_ok" = "y" ]; then 18219e4fd900SJohn Levon echo "\n==== Creating protolist system file at `date` ====" \ 18229e4fd900SJohn Levon >> $LOGFILE 18239e4fd900SJohn Levon protolist $checkroot > $ATLOG/proto_list_${MACH} 18249e4fd900SJohn Levon echo "==== protolist system file created at `date` ====\n" \ 18259e4fd900SJohn Levon >> $LOGFILE 18269e4fd900SJohn Levon 18279e4fd900SJohn Levon if [ "$N_FLAG" != "y" ]; then 18289e4fd900SJohn Levon 18299e4fd900SJohn Levon E1= 18309e4fd900SJohn Levon f1= 18319e4fd900SJohn Levon for f in $f1; do 18329e4fd900SJohn Levon if [ -f "$f" ]; then 18339e4fd900SJohn Levon E1="$E1 -e $f" 18349e4fd900SJohn Levon fi 18359e4fd900SJohn Levon done 18369e4fd900SJohn Levon 18379e4fd900SJohn Levon E2= 18389e4fd900SJohn Levon f2= 18399e4fd900SJohn Levon if [ -d "$SRC/pkg" ]; then 18409e4fd900SJohn Levon f2="$f2 exceptions/packaging" 18419e4fd900SJohn Levon fi 18429e4fd900SJohn Levon 18439e4fd900SJohn Levon for f in $f2; do 18449e4fd900SJohn Levon if [ -f "$f" ]; then 18459e4fd900SJohn Levon E2="$E2 -e $f" 18469e4fd900SJohn Levon fi 18479e4fd900SJohn Levon done 18489e4fd900SJohn Levon fi 18499e4fd900SJohn Levon 18509e4fd900SJohn Levon if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 18519e4fd900SJohn Levon echo "\n==== Validating manifests against proto area ====\n" \ 18529e4fd900SJohn Levon >> $mail_msg_file 18539e4fd900SJohn Levon ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 18549e4fd900SJohn Levon tee $TMPDIR/protocmp_noise >> $mail_msg_file 18559e4fd900SJohn Levon if [[ -s $TMPDIR/protocmp_noise ]]; then 18569e4fd900SJohn Levon build_extras_ok=n 18579e4fd900SJohn Levon fi 18589e4fd900SJohn Levon fi 18599e4fd900SJohn Levon 18609e4fd900SJohn Levon if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 18619e4fd900SJohn Levon echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 18629e4fd900SJohn Levon if [ -n "$E2" ]; then 18639e4fd900SJohn Levon ELIST=$E2 18649e4fd900SJohn Levon else 18659e4fd900SJohn Levon ELIST=$E1 18669e4fd900SJohn Levon fi 18679e4fd900SJohn Levon $PROTOCMPTERSE \ 18689e4fd900SJohn Levon "Files in yesterday's proto area, but not today's:" \ 18699e4fd900SJohn Levon "Files in today's proto area, but not yesterday's:" \ 18709e4fd900SJohn Levon "Files that changed between yesterday and today:" \ 18719e4fd900SJohn Levon ${ELIST} \ 18729e4fd900SJohn Levon -d $REF_PROTO_LIST \ 18739e4fd900SJohn Levon $ATLOG/proto_list_${MACH} \ 18749e4fd900SJohn Levon >> $mail_msg_file 18759e4fd900SJohn Levon fi 18769e4fd900SJohn Levonfi 18779e4fd900SJohn Levon 18789e4fd900SJohn Levonif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 18799e4fd900SJohn Levon "$build_extras_ok" == "y" ]]; then 18809e4fd900SJohn Levon staffer cp $ATLOG/proto_list_${MACH} \ 18819e4fd900SJohn Levon $PARENT_WS/usr/src/proto_list_${MACH} 18829e4fd900SJohn Levonfi 18839e4fd900SJohn Levon 18849e4fd900SJohn Levon# Update parent proto area if necessary. This is done now 18859e4fd900SJohn Levon# so that the proto area has either DEBUG or non-DEBUG kernels. 18869e4fd900SJohn Levon# Note that this clears out the lock file, so we can dispense with 18879e4fd900SJohn Levon# the variable now. 18889e4fd900SJohn Levonif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 18899e4fd900SJohn Levon echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 18909e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 18919e4fd900SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT/* 18929e4fd900SJohn Levon unset Ulockfile 18939e4fd900SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT 18949e4fd900SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 18959e4fd900SJohn Levon ( cd $ROOT; tar cf - . | 18969e4fd900SJohn Levon ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 18979e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 18989e4fd900SJohn Levon fi 18999e4fd900SJohn Levon if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 19009e4fd900SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT-nd/* 19019e4fd900SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT-nd 19029e4fd900SJohn Levon cd $ROOT-nd 19039e4fd900SJohn Levon ( tar cf - . | 19049e4fd900SJohn Levon ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 19059e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 19069e4fd900SJohn Levon fi 19079e4fd900SJohn Levon if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 19089e4fd900SJohn Levon echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 19099e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19109e4fd900SJohn Levon rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 19119e4fd900SJohn Levon mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 19129e4fd900SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 19139e4fd900SJohn Levon ( cd $TOOLS_PROTO; tar cf - . | 19149e4fd900SJohn Levon ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 19159e4fd900SJohn Levon umask 0; tar xpf - ) ) 2>&1 | 19169e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 19179e4fd900SJohn Levon fi 19189e4fd900SJohn Levon fi 19199e4fd900SJohn Levonfi 19209e4fd900SJohn Levon 19219e4fd900SJohn Levon# 19229e4fd900SJohn Levon# ELF verification: ABI (-A) and runtime (-r) checks 19239e4fd900SJohn Levon# 19249e4fd900SJohn Levonif [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 19259e4fd900SJohn Levon # Directory ELF-data.$MACH holds the files produced by these tests. 19269e4fd900SJohn Levon elf_ddir=$SRC/ELF-data.$MACH 19279e4fd900SJohn Levon 19289e4fd900SJohn Levon # If there is a previous ELF-data backup directory, remove it. Then, 19299e4fd900SJohn Levon # rotate current ELF-data directory into its place and create a new 19309e4fd900SJohn Levon # empty directory 19319e4fd900SJohn Levon rm -rf $elf_ddir.ref 19329e4fd900SJohn Levon if [[ -d $elf_ddir ]]; then 19339e4fd900SJohn Levon mv $elf_ddir $elf_ddir.ref 19349e4fd900SJohn Levon fi 19359e4fd900SJohn Levon mkdir -p $elf_ddir 19369e4fd900SJohn Levon 19379e4fd900SJohn Levon # Call find_elf to produce a list of the ELF objects in the proto area. 19389e4fd900SJohn Levon # This list is passed to check_rtime and interface_check, preventing 19399e4fd900SJohn Levon # them from separately calling find_elf to do the same work twice. 19409e4fd900SJohn Levon find_elf -fr $checkroot > $elf_ddir/object_list 19419e4fd900SJohn Levon 19429e4fd900SJohn Levon if [[ $A_FLAG = y ]]; then 19439e4fd900SJohn Levon echo "\n==== Check versioning and ABI information ====\n" | \ 19449e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19459e4fd900SJohn Levon 19469e4fd900SJohn Levon # Produce interface description for the proto. Report errors. 19479e4fd900SJohn Levon interface_check -o -w $elf_ddir -f object_list \ 19489e4fd900SJohn Levon -i interface -E interface.err 19499e4fd900SJohn Levon if [[ -s $elf_ddir/interface.err ]]; then 19509e4fd900SJohn Levon tee -a $LOGFILE < $elf_ddir/interface.err \ 19519e4fd900SJohn Levon >> $mail_msg_file 19529e4fd900SJohn Levon build_extras_ok=n 19539e4fd900SJohn Levon fi 19549e4fd900SJohn Levon 19559e4fd900SJohn Levon # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 19569e4fd900SJohn Levon # description file to that from the baseline gate. Issue a 19579e4fd900SJohn Levon # warning if the baseline is not present, and keep going. 19589e4fd900SJohn Levon if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 19599e4fd900SJohn Levon base_ifile="$ELF_DATA_BASELINE_DIR/interface" 19609e4fd900SJohn Levon 19619e4fd900SJohn Levon echo "\n==== Compare versioning and ABI information" \ 19629e4fd900SJohn Levon "to baseline ====\n" | \ 19639e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19649e4fd900SJohn Levon echo "Baseline: $base_ifile\n" >> $LOGFILE 19659e4fd900SJohn Levon 19669e4fd900SJohn Levon if [[ -f $base_ifile ]]; then 19679e4fd900SJohn Levon interface_cmp -d -o $base_ifile \ 19689e4fd900SJohn Levon $elf_ddir/interface > $elf_ddir/interface.cmp 19699e4fd900SJohn Levon if [[ -s $elf_ddir/interface.cmp ]]; then 19709e4fd900SJohn Levon echo | tee -a $LOGFILE >> $mail_msg_file 19719e4fd900SJohn Levon tee -a $LOGFILE < \ 19729e4fd900SJohn Levon $elf_ddir/interface.cmp \ 19739e4fd900SJohn Levon >> $mail_msg_file 19749e4fd900SJohn Levon build_extras_ok=n 19759e4fd900SJohn Levon fi 19769e4fd900SJohn Levon else 19779e4fd900SJohn Levon echo "baseline not available. comparison" \ 19789e4fd900SJohn Levon "skipped" | \ 19799e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19809e4fd900SJohn Levon fi 19819e4fd900SJohn Levon 19829e4fd900SJohn Levon fi 19839e4fd900SJohn Levon fi 19849e4fd900SJohn Levon 19859e4fd900SJohn Levon if [[ $r_FLAG = y ]]; then 19869e4fd900SJohn Levon echo "\n==== Check ELF runtime attributes ====\n" | \ 19879e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19889e4fd900SJohn Levon 19899e4fd900SJohn Levon # If we're doing a DEBUG build the proto area will be left 19909e4fd900SJohn Levon # with debuggable objects, thus don't assert -s. 19919e4fd900SJohn Levon if [[ $D_FLAG = y ]]; then 19929e4fd900SJohn Levon rtime_sflag="" 19939e4fd900SJohn Levon else 19949e4fd900SJohn Levon rtime_sflag="-s" 19959e4fd900SJohn Levon fi 19969e4fd900SJohn Levon check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 19979e4fd900SJohn Levon -D object_list -f object_list -E runtime.err \ 19989e4fd900SJohn Levon -I runtime.attr.raw 19999e4fd900SJohn Levon if (( $? != 0 )); then 20009e4fd900SJohn Levon build_extras_ok=n 20019e4fd900SJohn Levon fi 20029e4fd900SJohn Levon 20039e4fd900SJohn Levon # check_rtime -I output needs to be sorted in order to 20049e4fd900SJohn Levon # compare it to that from previous builds. 20059e4fd900SJohn Levon sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 20069e4fd900SJohn Levon rm $elf_ddir/runtime.attr.raw 20079e4fd900SJohn Levon 20089e4fd900SJohn Levon # Report errors 20099e4fd900SJohn Levon if [[ -s $elf_ddir/runtime.err ]]; then 20109e4fd900SJohn Levon tee -a $LOGFILE < $elf_ddir/runtime.err \ 20119e4fd900SJohn Levon >> $mail_msg_file 20129e4fd900SJohn Levon build_extras_ok=n 20139e4fd900SJohn Levon fi 20149e4fd900SJohn Levon 20159e4fd900SJohn Levon # If there is an ELF-data directory from a previous build, 20169e4fd900SJohn Levon # then diff the attr files. These files contain information 20179e4fd900SJohn Levon # about dependencies, versioning, and runpaths. There is some 20189e4fd900SJohn Levon # overlap with the ABI checking done above, but this also 20199e4fd900SJohn Levon # flushes out non-ABI interface differences along with the 20209e4fd900SJohn Levon # other information. 20219e4fd900SJohn Levon echo "\n==== Diff ELF runtime attributes" \ 20229e4fd900SJohn Levon "(since last build) ====\n" | \ 20239e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 20249e4fd900SJohn Levon 20259e4fd900SJohn Levon if [[ -f $elf_ddir.ref/runtime.attr ]]; then 20269e4fd900SJohn Levon diff $elf_ddir.ref/runtime.attr \ 20279e4fd900SJohn Levon $elf_ddir/runtime.attr \ 20289e4fd900SJohn Levon >> $mail_msg_file 20299e4fd900SJohn Levon fi 20309e4fd900SJohn Levon fi 20319e4fd900SJohn Levon 20329e4fd900SJohn Levon # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 20339e4fd900SJohn Levon if [[ "$u_FLAG" = "y" ]]; then 20349e4fd900SJohn Levon p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 20359e4fd900SJohn Levon 20369e4fd900SJohn Levon # If parent lacks the ELF-data.$MACH directory, create it 20379e4fd900SJohn Levon if [[ ! -d $p_elf_ddir ]]; then 20389e4fd900SJohn Levon staffer mkdir -p $p_elf_ddir 20399e4fd900SJohn Levon fi 20409e4fd900SJohn Levon 20419e4fd900SJohn Levon # These files are used asynchronously by other builds for ABI 20429e4fd900SJohn Levon # verification, as above for the -A option. As such, we require 20439e4fd900SJohn Levon # the file replacement to be atomic. Copy the data to a temp 20449e4fd900SJohn Levon # file in the same filesystem and then rename into place. 20459e4fd900SJohn Levon ( 20469e4fd900SJohn Levon cd $elf_ddir 20479e4fd900SJohn Levon for elf_dfile in *; do 20489e4fd900SJohn Levon staffer cp $elf_dfile \ 20499e4fd900SJohn Levon ${p_elf_ddir}/${elf_dfile}.new 20509e4fd900SJohn Levon staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 20519e4fd900SJohn Levon ${p_elf_ddir}/${elf_dfile} 20529e4fd900SJohn Levon done 20539e4fd900SJohn Levon ) 20549e4fd900SJohn Levon fi 20559e4fd900SJohn Levonfi 20569e4fd900SJohn Levon 20579e4fd900SJohn Levon# DEBUG lint of kernel begins 20589e4fd900SJohn Levon 20599e4fd900SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 20609e4fd900SJohn Levon if [ "$LINTDIRS" = "" ]; then 20619e4fd900SJohn Levon # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 20629e4fd900SJohn Levon LINTDIRS="$SRC y" 20639e4fd900SJohn Levon fi 20649e4fd900SJohn Levon set $LINTDIRS 20659e4fd900SJohn Levon while [ $# -gt 0 ]; do 20669e4fd900SJohn Levon dolint $1 $2; shift; shift 20679e4fd900SJohn Levon done 20689e4fd900SJohn Levonelse 20699e4fd900SJohn Levon echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 20709e4fd900SJohn Levonfi 20719e4fd900SJohn Levon 20729e4fd900SJohn Levon# "make check" begins 20739e4fd900SJohn Levon 20749e4fd900SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 20759e4fd900SJohn Levon # remove old check.out 20769e4fd900SJohn Levon rm -f $SRC/check.out 20779e4fd900SJohn Levon 20789e4fd900SJohn Levon rm -f $SRC/check-${MACH}.out 20799e4fd900SJohn Levon cd $SRC 20809e4fd900SJohn Levon $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 20819e4fd900SJohn Levon >> $LOGFILE 20829e4fd900SJohn Levon echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 20839e4fd900SJohn Levon 20849e4fd900SJohn Levon grep ":" $SRC/check-${MACH}.out | 20859e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 20869e4fd900SJohn Levon sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 20879e4fd900SJohn Levon 20889e4fd900SJohn Levon if [[ -s $TMPDIR/check_errors ]]; then 20899e4fd900SJohn Levon build_extras_ok=n 20909e4fd900SJohn Levon fi 20919e4fd900SJohn Levonelse 20929e4fd900SJohn Levon echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 20939e4fd900SJohn Levonfi 20949e4fd900SJohn Levon 20959e4fd900SJohn Levonecho "\n==== Find core files ====\n" | \ 20969e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 20979e4fd900SJohn Levon 20989e4fd900SJohn Levonfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 20999e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 21009e4fd900SJohn Levon 21019e4fd900SJohn Levonif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21029e4fd900SJohn Levon echo "\n==== Diff unreferenced files (since last build) ====\n" \ 21039e4fd900SJohn Levon | tee -a $LOGFILE >>$mail_msg_file 21049e4fd900SJohn Levon rm -f $SRC/unref-${MACH}.ref 21059e4fd900SJohn Levon if [ -f $SRC/unref-${MACH}.out ]; then 21069e4fd900SJohn Levon mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 21079e4fd900SJohn Levon fi 21089e4fd900SJohn Levon 21099e4fd900SJohn Levon findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 21109e4fd900SJohn Levon ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 21119e4fd900SJohn Levon sort > $SRC/unref-${MACH}.out 21129e4fd900SJohn Levon 21139e4fd900SJohn Levon if [ ! -f $SRC/unref-${MACH}.ref ]; then 21149e4fd900SJohn Levon cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 21159e4fd900SJohn Levon fi 21169e4fd900SJohn Levon 21179e4fd900SJohn Levon diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 21189e4fd900SJohn Levonfi 21199e4fd900SJohn Levon 21209e4fd900SJohn Levon# Verify that the usual lists of files, such as exception lists, 21219e4fd900SJohn Levon# contain only valid references to files. If the build has failed, 21229e4fd900SJohn Levon# then don't check the proto area. 21239e4fd900SJohn LevonCHECK_PATHS=${CHECK_PATHS:-y} 21249e4fd900SJohn Levonif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 21259e4fd900SJohn Levon echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 21269e4fd900SJohn Levon >>$mail_msg_file 21279e4fd900SJohn Levon arg=-b 21289e4fd900SJohn Levon [ "$build_ok" = y ] && arg= 21299e4fd900SJohn Levon checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 21309e4fd900SJohn Levon if [[ -s $SRC/check-paths.out ]]; then 21319e4fd900SJohn Levon tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 21329e4fd900SJohn Levon build_extras_ok=n 21339e4fd900SJohn Levon fi 21349e4fd900SJohn Levonfi 21359e4fd900SJohn Levon 21369e4fd900SJohn Levonif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 21379e4fd900SJohn Levon echo "\n==== Impact on file permissions ====\n" \ 21389e4fd900SJohn Levon >> $mail_msg_file 21399e4fd900SJohn Levon 21409e4fd900SJohn Levon abspkg= 21419e4fd900SJohn Levon for d in $abssrcdirs; do 21429e4fd900SJohn Levon if [ -d "$d/pkg" ]; then 21439e4fd900SJohn Levon abspkg="$abspkg $d" 21449e4fd900SJohn Levon fi 21459e4fd900SJohn Levon done 21469e4fd900SJohn Levon 21479e4fd900SJohn Levon if [ -n "$abspkg" ]; then 21489e4fd900SJohn Levon for d in "$abspkg"; do 21499e4fd900SJohn Levon ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 21509e4fd900SJohn Levon done 21519e4fd900SJohn Levon fi 21529e4fd900SJohn Levonfi 21539e4fd900SJohn Levon 21549e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 21559e4fd900SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 2156*bf16a978SMarcel Telka do_wsdiff DEBUG $ROOT.prev $ROOT wsdiff.results 21579e4fd900SJohn Levon fi 21589e4fd900SJohn Levon 21599e4fd900SJohn Levon if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 2160*bf16a978SMarcel Telka do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd wsdiff-nd.results 2161*bf16a978SMarcel Telka fi 2162*bf16a978SMarcel Telka 2163*bf16a978SMarcel Telka if [[ "$t_FLAG" == "y" ]]; then 2164*bf16a978SMarcel Telka do_wsdiff tools $TOOLS_PROTO.prev $TOOLS_PROTO wsdiff-tools.results 21659e4fd900SJohn Levon fi 21669e4fd900SJohn Levonfi 21679e4fd900SJohn Levon 21689e4fd900SJohn LevonEND_DATE=`date` 21699e4fd900SJohn Levonecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 21709e4fd900SJohn Levon tee -a $LOGFILE >> $build_time_file 21719e4fd900SJohn Levon 21729e4fd900SJohn Levontypeset -i10 hours 21739e4fd900SJohn Levontypeset -Z2 minutes 21749e4fd900SJohn Levontypeset -Z2 seconds 21759e4fd900SJohn Levon 21769e4fd900SJohn Levonelapsed_time=$SECONDS 21779e4fd900SJohn Levon((hours = elapsed_time / 3600 )) 21789e4fd900SJohn Levon((minutes = elapsed_time / 60 % 60)) 21799e4fd900SJohn Levon((seconds = elapsed_time % 60)) 21809e4fd900SJohn Levon 21819e4fd900SJohn Levonecho "\n==== Total build time ====" | \ 21829e4fd900SJohn Levon tee -a $LOGFILE >> $build_time_file 21839e4fd900SJohn Levonecho "\nreal ${hours}:${minutes}:${seconds}" | \ 21849e4fd900SJohn Levon tee -a $LOGFILE >> $build_time_file 21859e4fd900SJohn Levon 21869e4fd900SJohn Levonif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21879e4fd900SJohn Levon staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 21889e4fd900SJohn Levon 21899e4fd900SJohn Levon # 21909e4fd900SJohn Levon # Produce a master list of unreferenced files -- ideally, we'd 21919e4fd900SJohn Levon # generate the master just once after all of the nightlies 21929e4fd900SJohn Levon # have finished, but there's no simple way to know when that 21939e4fd900SJohn Levon # will be. Instead, we assume that we're the last nightly to 21949e4fd900SJohn Levon # finish and merge all of the unref-${MACH}.out files in 21959e4fd900SJohn Levon # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 21969e4fd900SJohn Levon # finish, then this file will be the authoritative master 21979e4fd900SJohn Levon # list. Otherwise, another ${MACH}'s nightly will eventually 21989e4fd900SJohn Levon # overwrite ours with its own master, but in the meantime our 21999e4fd900SJohn Levon # temporary "master" will be no worse than any older master 22009e4fd900SJohn Levon # which was already on the parent. 22019e4fd900SJohn Levon # 22029e4fd900SJohn Levon 22039e4fd900SJohn Levon set -- $PARENT_WS/usr/src/unref-*.out 22049e4fd900SJohn Levon cp "$1" ${TMPDIR}/unref.merge 22059e4fd900SJohn Levon shift 22069e4fd900SJohn Levon 22079e4fd900SJohn Levon for unreffile; do 22089e4fd900SJohn Levon comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 22099e4fd900SJohn Levon mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 22109e4fd900SJohn Levon done 22119e4fd900SJohn Levon 22129e4fd900SJohn Levon staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 22139e4fd900SJohn Levonfi 22149e4fd900SJohn Levon 22159e4fd900SJohn Levon# 22169e4fd900SJohn Levon# All done save for the sweeping up. 22179e4fd900SJohn Levon# (whichever exit we hit here will trigger the "cleanup" trap which 22189e4fd900SJohn Levon# optionally sends mail on completion). 22199e4fd900SJohn Levon# 22209e4fd900SJohn Levonif [[ "$build_ok" == "y" ]]; then 22219e4fd900SJohn Levon if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 22229e4fd900SJohn Levon exit 0 22239e4fd900SJohn Levon fi 22249e4fd900SJohn Levonfi 22259e4fd900SJohn Levon 22269e4fd900SJohn Levonexit 1 2227