16b72f1c0SJohn Levon#!/bin/ksh -p 26b72f1c0SJohn Levon# 36b72f1c0SJohn Levon# CDDL HEADER START 46b72f1c0SJohn Levon# 56b72f1c0SJohn Levon# The contents of this file are subject to the terms of the 66b72f1c0SJohn Levon# Common Development and Distribution License (the "License"). 76b72f1c0SJohn Levon# You may not use this file except in compliance with the License. 86b72f1c0SJohn Levon# 96b72f1c0SJohn Levon# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 106b72f1c0SJohn Levon# or http://www.opensolaris.org/os/licensing. 116b72f1c0SJohn Levon# See the License for the specific language governing permissions 126b72f1c0SJohn Levon# and limitations under the License. 136b72f1c0SJohn Levon# 146b72f1c0SJohn Levon# When distributing Covered Code, include this CDDL HEADER in each 156b72f1c0SJohn Levon# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 166b72f1c0SJohn Levon# If applicable, add the following below this CDDL HEADER, with the 176b72f1c0SJohn Levon# fields enclosed by brackets "[]" replaced with your own identifying 186b72f1c0SJohn Levon# information: Portions Copyright [yyyy] [name of copyright owner] 196b72f1c0SJohn Levon# 206b72f1c0SJohn Levon# CDDL HEADER END 216b72f1c0SJohn Levon# 226b72f1c0SJohn Levon 236b72f1c0SJohn Levon# 246b72f1c0SJohn Levon# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 256b72f1c0SJohn Levon# Copyright 2008, 2010, Richard Lowe 266b72f1c0SJohn Levon# Copyright 2011 Nexenta Systems, Inc. All rights reserved. 276b72f1c0SJohn Levon# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> 286b72f1c0SJohn Levon# Copyright 2020 Joyent, Inc. 296b72f1c0SJohn Levon# 306b72f1c0SJohn Levon# Based on the nightly script from the integration folks, 316b72f1c0SJohn Levon# Mostly modified and owned by mike_s. 326b72f1c0SJohn Levon# Changes also by kjc, dmk. 336b72f1c0SJohn Levon# 346b72f1c0SJohn Levon# BRINGOVER_WS may be specified in the env file. 356b72f1c0SJohn Levon# The default is the old behavior of CLONE_WS 366b72f1c0SJohn Levon# 376b72f1c0SJohn Levon# -i on the command line, means fast options, so when it's on the 386b72f1c0SJohn Levon# command line (only), lint and check builds are skipped no matter what 396b72f1c0SJohn Levon# the setting of their individual flags are in NIGHTLY_OPTIONS. 406b72f1c0SJohn Levon# 416b72f1c0SJohn Levon# LINTDIRS can be set in the env file, format is a list of: 426b72f1c0SJohn Levon# 436b72f1c0SJohn Levon# /dirname-to-run-lint-on flag 446b72f1c0SJohn Levon# 456b72f1c0SJohn Levon# Where flag is: y - enable lint noise diff output 466b72f1c0SJohn Levon# n - disable lint noise diff output 476b72f1c0SJohn Levon# 486b72f1c0SJohn Levon# For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y" 496b72f1c0SJohn Levon# 506b72f1c0SJohn Levon# OPTHOME may be set in the environment to override /opt 516b72f1c0SJohn Levon# 526b72f1c0SJohn Levon 536b72f1c0SJohn Levon# 546b72f1c0SJohn Levon# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 556b72f1c0SJohn Levon# under certain circumstances, which can really screw things up; unset it. 566b72f1c0SJohn Levon# 576b72f1c0SJohn Levonunset CDPATH 586b72f1c0SJohn Levon 596b72f1c0SJohn Levon# Get the absolute path of the nightly script that the user invoked. This 606b72f1c0SJohn Levon# may be a relative path, and we need to do this before changing directory. 616b72f1c0SJohn Levonnightly_path=`whence $0` 626b72f1c0SJohn Levon 636b72f1c0SJohn Levon# 646b72f1c0SJohn Levon# Keep track of where we found nightly so we can invoke the matching 656b72f1c0SJohn Levon# which_scm script. If that doesn't work, don't go guessing, just rely 666b72f1c0SJohn Levon# on the $PATH settings, which will generally give us either /opt/onbld 676b72f1c0SJohn Levon# or the user's workspace. 686b72f1c0SJohn Levon# 696b72f1c0SJohn LevonWHICH_SCM=$(dirname $nightly_path)/which_scm 706b72f1c0SJohn Levonif [[ ! -x $WHICH_SCM ]]; then 716b72f1c0SJohn Levon WHICH_SCM=which_scm 726b72f1c0SJohn Levonfi 736b72f1c0SJohn Levon 746b72f1c0SJohn Levonfunction fatal_error 756b72f1c0SJohn Levon{ 766b72f1c0SJohn Levon print -u2 "nightly: $*" 776b72f1c0SJohn Levon exit 1 786b72f1c0SJohn Levon} 796b72f1c0SJohn Levon 806b72f1c0SJohn Levon# 816b72f1c0SJohn Levon# Function to do a DEBUG and non-DEBUG build. Needed because we might 826b72f1c0SJohn Levon# need to do another for the source build, and since we only deliver DEBUG or 836b72f1c0SJohn Levon# non-DEBUG packages. 846b72f1c0SJohn Levon# 856b72f1c0SJohn Levon# usage: normal_build 866b72f1c0SJohn Levon# 876b72f1c0SJohn Levonfunction normal_build { 886b72f1c0SJohn Levon 896b72f1c0SJohn Levon typeset orig_p_FLAG="$p_FLAG" 906b72f1c0SJohn Levon typeset crypto_signer="$CODESIGN_USER" 916b72f1c0SJohn Levon 926b72f1c0SJohn Levon suffix="" 936b72f1c0SJohn Levon 946b72f1c0SJohn Levon # non-DEBUG build begins 956b72f1c0SJohn Levon 966b72f1c0SJohn Levon if [ "$F_FLAG" = "n" ]; then 976b72f1c0SJohn Levon set_non_debug_build_flags 986b72f1c0SJohn Levon CODESIGN_USER="$crypto_signer" \ 996b72f1c0SJohn Levon build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 1006b72f1c0SJohn Levon else 1016b72f1c0SJohn Levon echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 1026b72f1c0SJohn Levon fi 1036b72f1c0SJohn Levon 1046b72f1c0SJohn Levon # non-DEBUG build ends 1056b72f1c0SJohn Levon 1066b72f1c0SJohn Levon # DEBUG build begins 1076b72f1c0SJohn Levon 1086b72f1c0SJohn Levon if [ "$D_FLAG" = "y" ]; then 1096b72f1c0SJohn Levon set_debug_build_flags 1106b72f1c0SJohn Levon CODESIGN_USER="$crypto_signer" \ 1116b72f1c0SJohn Levon build "DEBUG" "$suffix" "" "$MULTI_PROTO" 1126b72f1c0SJohn Levon else 1136b72f1c0SJohn Levon echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 1146b72f1c0SJohn Levon fi 1156b72f1c0SJohn Levon 1166b72f1c0SJohn Levon # DEBUG build ends 1176b72f1c0SJohn Levon 1186b72f1c0SJohn Levon p_FLAG="$orig_p_FLAG" 1196b72f1c0SJohn Levon} 1206b72f1c0SJohn Levon 1216b72f1c0SJohn Levon# 1226b72f1c0SJohn Levon# usage: run_hook HOOKNAME ARGS... 1236b72f1c0SJohn Levon# 1246b72f1c0SJohn Levon# If variable "$HOOKNAME" is defined, insert a section header into 1256b72f1c0SJohn Levon# our logs and then run the command with ARGS 1266b72f1c0SJohn Levon# 1276b72f1c0SJohn Levonfunction run_hook { 1286b72f1c0SJohn Levon HOOKNAME=$1 1296b72f1c0SJohn Levon eval HOOKCMD=\$$HOOKNAME 1306b72f1c0SJohn Levon shift 1316b72f1c0SJohn Levon 1326b72f1c0SJohn Levon if [ -n "$HOOKCMD" ]; then 1336b72f1c0SJohn Levon ( 1346b72f1c0SJohn Levon echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 1356b72f1c0SJohn Levon ( $HOOKCMD "$@" 2>&1 ) 1366b72f1c0SJohn Levon if [ "$?" -ne 0 ]; then 1376b72f1c0SJohn Levon # Let exit status propagate up 1386b72f1c0SJohn Levon touch $TMPDIR/abort 1396b72f1c0SJohn Levon fi 1406b72f1c0SJohn Levon ) | tee -a $mail_msg_file >> $LOGFILE 1416b72f1c0SJohn Levon 1426b72f1c0SJohn Levon if [ -f $TMPDIR/abort ]; then 1436b72f1c0SJohn Levon build_ok=n 1446b72f1c0SJohn Levon echo "\nAborting at request of $HOOKNAME" | 1456b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1466b72f1c0SJohn Levon exit 1 1476b72f1c0SJohn Levon fi 1486b72f1c0SJohn Levon fi 1496b72f1c0SJohn Levon} 1506b72f1c0SJohn Levon 1516b72f1c0SJohn Levon# Return library search directive as function of given root. 1526b72f1c0SJohn Levonfunction myldlibs { 1536b72f1c0SJohn Levon echo "-L$1/lib -L$1/usr/lib" 1546b72f1c0SJohn Levon} 1556b72f1c0SJohn Levon 1566b72f1c0SJohn Levon# Return header search directive as function of given root. 1576b72f1c0SJohn Levonfunction myheaders { 1586b72f1c0SJohn Levon echo "-I$1/usr/include" 1596b72f1c0SJohn Levon} 1606b72f1c0SJohn Levon 1616b72f1c0SJohn Levon# 1626b72f1c0SJohn Levon# Function to do the build, including package generation. 1636b72f1c0SJohn Levon# usage: build LABEL SUFFIX ND MULTIPROTO 1646b72f1c0SJohn Levon# - LABEL is used to tag build output. 1656b72f1c0SJohn Levon# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 1666b72f1c0SJohn Levon# open-only vs full tree). 1676b72f1c0SJohn Levon# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 1686b72f1c0SJohn Levon# - If MULTIPROTO is "yes", it means to name the proto area according to 1696b72f1c0SJohn Levon# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 1706b72f1c0SJohn Levon# 1716b72f1c0SJohn Levonfunction build { 1726b72f1c0SJohn Levon LABEL=$1 1736b72f1c0SJohn Levon SUFFIX=$2 1746b72f1c0SJohn Levon ND=$3 1756b72f1c0SJohn Levon MULTIPROTO=$4 1766b72f1c0SJohn Levon INSTALLOG=install${SUFFIX}-${MACH} 1776b72f1c0SJohn Levon NOISE=noise${SUFFIX}-${MACH} 1786b72f1c0SJohn Levon PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 1796b72f1c0SJohn Levon 1806b72f1c0SJohn Levon ORIGROOT=$ROOT 1816b72f1c0SJohn Levon [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 1826b72f1c0SJohn Levon 1836b72f1c0SJohn Levon export ENVLDLIBS1=`myldlibs $ROOT` 1846b72f1c0SJohn Levon export ENVCPPFLAGS1=`myheaders $ROOT` 1856b72f1c0SJohn Levon 1866b72f1c0SJohn Levon this_build_ok=y 1876b72f1c0SJohn Levon # 1886b72f1c0SJohn Levon # Build OS-Networking source 1896b72f1c0SJohn Levon # 1906b72f1c0SJohn Levon echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 1916b72f1c0SJohn Levon >> $LOGFILE 1926b72f1c0SJohn Levon 1936b72f1c0SJohn Levon rm -f $SRC/${INSTALLOG}.out 1946b72f1c0SJohn Levon cd $SRC 1956b72f1c0SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 1966b72f1c0SJohn Levon tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 1976b72f1c0SJohn Levon 1986b72f1c0SJohn Levon echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 1996b72f1c0SJohn Levon egrep ":" $SRC/${INSTALLOG}.out | 2006b72f1c0SJohn Levon egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 2016b72f1c0SJohn Levon egrep -v "Ignoring unknown host" | \ 2026b72f1c0SJohn Levon egrep -v "cc .* -o error " | \ 2036b72f1c0SJohn Levon egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 2046b72f1c0SJohn Levon >> $mail_msg_file 2056b72f1c0SJohn Levon if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 2066b72f1c0SJohn Levon build_ok=n 2076b72f1c0SJohn Levon this_build_ok=n 2086b72f1c0SJohn Levon fi 2096b72f1c0SJohn Levon grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 2106b72f1c0SJohn Levon >> $mail_msg_file 2116b72f1c0SJohn Levon if [ "$?" = "0" ]; then 2126b72f1c0SJohn Levon build_ok=n 2136b72f1c0SJohn Levon this_build_ok=n 2146b72f1c0SJohn Levon fi 2156b72f1c0SJohn Levon 2166b72f1c0SJohn Levon echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 2176b72f1c0SJohn Levon egrep -i warning: $SRC/${INSTALLOG}.out \ 2186b72f1c0SJohn Levon | egrep -v '^tic:' \ 2196b72f1c0SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 2206b72f1c0SJohn Levon | egrep -v "parameter <PSTAMP> set to" \ 2216b72f1c0SJohn Levon | egrep -v "Ignoring unknown host" \ 2226b72f1c0SJohn Levon | egrep -v "redefining segment flags attribute for" \ 2236b72f1c0SJohn Levon | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 2246b72f1c0SJohn Levon if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 2256b72f1c0SJohn Levon build_ok=n 2266b72f1c0SJohn Levon this_build_ok=n 2276b72f1c0SJohn Levon fi 2286b72f1c0SJohn Levon 2296b72f1c0SJohn Levon echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 2306b72f1c0SJohn Levon >> $LOGFILE 2316b72f1c0SJohn Levon 2326b72f1c0SJohn Levon echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 2336b72f1c0SJohn Levon tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 2346b72f1c0SJohn Levon 2356b72f1c0SJohn Levon if [ "$i_FLAG" = "n" ]; then 2366b72f1c0SJohn Levon rm -f $SRC/${NOISE}.ref 2376b72f1c0SJohn Levon if [ -f $SRC/${NOISE}.out ]; then 2386b72f1c0SJohn Levon mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 2396b72f1c0SJohn Levon fi 2406b72f1c0SJohn Levon grep : $SRC/${INSTALLOG}.out \ 2416b72f1c0SJohn Levon | egrep -v '^/' \ 2426b72f1c0SJohn Levon | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 2436b72f1c0SJohn Levon | egrep -v '^tic:' \ 2446b72f1c0SJohn Levon | egrep -v '^mcs' \ 2456b72f1c0SJohn Levon | egrep -v '^LD_LIBRARY_PATH=' \ 2466b72f1c0SJohn Levon | egrep -v 'ar: creating' \ 2476b72f1c0SJohn Levon | egrep -v 'ar: writing' \ 2486b72f1c0SJohn Levon | egrep -v 'conflicts:' \ 2496b72f1c0SJohn Levon | egrep -v ':saved created' \ 2506b72f1c0SJohn Levon | egrep -v '^stty.*c:' \ 2516b72f1c0SJohn Levon | egrep -v '^mfgname.c:' \ 2526b72f1c0SJohn Levon | egrep -v '^uname-i.c:' \ 2536b72f1c0SJohn Levon | egrep -v '^volumes.c:' \ 2546b72f1c0SJohn Levon | egrep -v '^lint library construction:' \ 2556b72f1c0SJohn Levon | egrep -v 'tsort: INFORM:' \ 2566b72f1c0SJohn Levon | egrep -v 'stripalign:' \ 2576b72f1c0SJohn Levon | egrep -v 'chars, width' \ 2586b72f1c0SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 2596b72f1c0SJohn Levon | egrep -v 'PSTAMP' \ 2606b72f1c0SJohn Levon | egrep -v '|%WHOANDWHERE%|' \ 2616b72f1c0SJohn Levon | egrep -v '^Manifying' \ 2626b72f1c0SJohn Levon | egrep -v 'Ignoring unknown host' \ 2636b72f1c0SJohn Levon | egrep -v 'Processing method:' \ 2646b72f1c0SJohn Levon | egrep -v '^Writing' \ 2656b72f1c0SJohn Levon | egrep -v 'spellin1:' \ 2666b72f1c0SJohn Levon | egrep -v '^adding:' \ 2676b72f1c0SJohn Levon | egrep -v "^echo 'msgid" \ 2686b72f1c0SJohn Levon | egrep -v '^echo ' \ 2696b72f1c0SJohn Levon | egrep -v '\.c:$' \ 2706b72f1c0SJohn Levon | egrep -v '^Adding file:' \ 2716b72f1c0SJohn Levon | egrep -v 'CLASSPATH=' \ 2726b72f1c0SJohn Levon | egrep -v '\/var\/mail\/:saved' \ 2736b72f1c0SJohn Levon | egrep -v -- '-DUTS_VERSION=' \ 2746b72f1c0SJohn Levon | egrep -v '^Running Mkbootstrap' \ 2756b72f1c0SJohn Levon | egrep -v '^Applet length read:' \ 2766b72f1c0SJohn Levon | egrep -v 'bytes written:' \ 2776b72f1c0SJohn Levon | egrep -v '^File:SolarisAuthApplet.bin' \ 2786b72f1c0SJohn Levon | egrep -v -i 'jibversion' \ 2796b72f1c0SJohn Levon | egrep -v '^Output size:' \ 2806b72f1c0SJohn Levon | egrep -v '^Solo size statistics:' \ 2816b72f1c0SJohn Levon | egrep -v '^Using ROM API Version' \ 2826b72f1c0SJohn Levon | egrep -v '^Zero Signature length:' \ 2836b72f1c0SJohn Levon | egrep -v '^Note \(probably harmless\):' \ 2846b72f1c0SJohn Levon | egrep -v '::' \ 2856b72f1c0SJohn Levon | egrep -v -- '-xcache' \ 2866b72f1c0SJohn Levon | egrep -v '^\+' \ 2876b72f1c0SJohn Levon | egrep -v '^cc1: note: -fwritable-strings' \ 2886b72f1c0SJohn Levon | egrep -v 'svccfg-native -s svc:/' \ 2896b72f1c0SJohn Levon | sort | uniq >$SRC/${NOISE}.out 2906b72f1c0SJohn Levon if [ ! -f $SRC/${NOISE}.ref ]; then 2916b72f1c0SJohn Levon cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 2926b72f1c0SJohn Levon fi 2936b72f1c0SJohn Levon echo "\n==== Build noise differences ($LABEL) ====\n" \ 2946b72f1c0SJohn Levon >>$mail_msg_file 2956b72f1c0SJohn Levon diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 2966b72f1c0SJohn Levon fi 2976b72f1c0SJohn Levon 2986b72f1c0SJohn Levon # 2996b72f1c0SJohn Levon # Re-sign selected binaries using signing server 3006b72f1c0SJohn Levon # (gatekeeper builds only) 3016b72f1c0SJohn Levon # 3026b72f1c0SJohn Levon if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 3036b72f1c0SJohn Levon echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 3046b72f1c0SJohn Levon signing_file="${TMPDIR}/signing" 3056b72f1c0SJohn Levon rm -f ${signing_file} 3066b72f1c0SJohn Levon export CODESIGN_USER 3076b72f1c0SJohn Levon signproto $SRC/tools/codesign/creds 2>&1 | \ 3086b72f1c0SJohn Levon tee -a ${signing_file} >> $LOGFILE 3096b72f1c0SJohn Levon echo "\n==== Finished signing proto area at `date` ====\n" \ 3106b72f1c0SJohn Levon >> $LOGFILE 3116b72f1c0SJohn Levon echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 3126b72f1c0SJohn Levon >> $mail_msg_file 3136b72f1c0SJohn Levon egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 3146b72f1c0SJohn Levon if (( $? == 0 )) ; then 3156b72f1c0SJohn Levon build_ok=n 3166b72f1c0SJohn Levon this_build_ok=n 3176b72f1c0SJohn Levon fi 3186b72f1c0SJohn Levon fi 3196b72f1c0SJohn Levon 3206b72f1c0SJohn Levon # 3216b72f1c0SJohn Levon # Building Packages 3226b72f1c0SJohn Levon # 3236b72f1c0SJohn Levon if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 3246b72f1c0SJohn Levon if [ -d $SRC/pkg ]; then 3256b72f1c0SJohn Levon echo "\n==== Creating $LABEL packages at `date` ====\n" \ 3266b72f1c0SJohn Levon >> $LOGFILE 3276b72f1c0SJohn Levon echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 3286b72f1c0SJohn Levon rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 3296b72f1c0SJohn Levon mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 3306b72f1c0SJohn Levon 3316b72f1c0SJohn Levon rm -f $SRC/pkg/${INSTALLOG}.out 3326b72f1c0SJohn Levon cd $SRC/pkg 3336b72f1c0SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 3346b72f1c0SJohn Levon tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 3356b72f1c0SJohn Levon 3366b72f1c0SJohn Levon echo "\n==== package build errors ($LABEL) ====\n" \ 3376b72f1c0SJohn Levon >> $mail_msg_file 3386b72f1c0SJohn Levon 3396b72f1c0SJohn Levon egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 3406b72f1c0SJohn Levon grep ':' | \ 3416b72f1c0SJohn Levon grep -v PSTAMP | \ 3426b72f1c0SJohn Levon egrep -v "Ignoring unknown host" | \ 3436b72f1c0SJohn Levon tee $TMPDIR/package >> $mail_msg_file 3446b72f1c0SJohn Levon if [[ -s $TMPDIR/package ]]; then 3456b72f1c0SJohn Levon build_extras_ok=n 3466b72f1c0SJohn Levon this_build_ok=n 3476b72f1c0SJohn Levon fi 3486b72f1c0SJohn Levon else 3496b72f1c0SJohn Levon # 3506b72f1c0SJohn Levon # Handle it gracefully if -p was set but there so 3516b72f1c0SJohn Levon # no pkg directory. 3526b72f1c0SJohn Levon # 3536b72f1c0SJohn Levon echo "\n==== No $LABEL packages to build ====\n" \ 3546b72f1c0SJohn Levon >> $LOGFILE 3556b72f1c0SJohn Levon fi 3566b72f1c0SJohn Levon else 3576b72f1c0SJohn Levon echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 3586b72f1c0SJohn Levon fi 3596b72f1c0SJohn Levon 3606b72f1c0SJohn Levon ROOT=$ORIGROOT 3616b72f1c0SJohn Levon} 3626b72f1c0SJohn Levon 3636b72f1c0SJohn Levon# Usage: dolint /dir y|n 3646b72f1c0SJohn Levon# Arg. 2 is a flag to turn on/off the lint diff output 3656b72f1c0SJohn Levonfunction dolint { 3666b72f1c0SJohn Levon if [ ! -d "$1" ]; then 3676b72f1c0SJohn Levon echo "dolint error: $1 is not a directory" 3686b72f1c0SJohn Levon exit 1 3696b72f1c0SJohn Levon fi 3706b72f1c0SJohn Levon 3716b72f1c0SJohn Levon if [ "$2" != "y" -a "$2" != "n" ]; then 3726b72f1c0SJohn Levon echo "dolint internal error: $2 should be 'y' or 'n'" 3736b72f1c0SJohn Levon exit 1 3746b72f1c0SJohn Levon fi 3756b72f1c0SJohn Levon 3766b72f1c0SJohn Levon lintdir=$1 3776b72f1c0SJohn Levon dodiff=$2 3786b72f1c0SJohn Levon base=`basename $lintdir` 3796b72f1c0SJohn Levon LINTOUT=$lintdir/lint-${MACH}.out 3806b72f1c0SJohn Levon LINTNOISE=$lintdir/lint-noise-${MACH} 3816b72f1c0SJohn Levon export ENVLDLIBS1=`myldlibs $ROOT` 3826b72f1c0SJohn Levon export ENVCPPFLAGS1=`myheaders $ROOT` 3836b72f1c0SJohn Levon 3846b72f1c0SJohn Levon set_debug_build_flags 3856b72f1c0SJohn Levon 3866b72f1c0SJohn Levon # 3876b72f1c0SJohn Levon # '$MAKE lint' in $lintdir 3886b72f1c0SJohn Levon # 3896b72f1c0SJohn Levon echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 3906b72f1c0SJohn Levon 3916b72f1c0SJohn Levon # remove old lint.out 3926b72f1c0SJohn Levon rm -f $lintdir/lint.out $lintdir/lint-noise.out 3936b72f1c0SJohn Levon if [ -f $lintdir/lint-noise.ref ]; then 3946b72f1c0SJohn Levon mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 3956b72f1c0SJohn Levon fi 3966b72f1c0SJohn Levon 3976b72f1c0SJohn Levon rm -f $LINTOUT 3986b72f1c0SJohn Levon cd $lintdir 3996b72f1c0SJohn Levon # 4006b72f1c0SJohn Levon # Remove all .ln files to ensure a full reference file 4016b72f1c0SJohn Levon # 4026b72f1c0SJohn Levon rm -f Nothing_to_remove \ 4036b72f1c0SJohn Levon `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \ 4046b72f1c0SJohn Levon -prune -o -type f -name '*.ln' -print ` 4056b72f1c0SJohn Levon 4066b72f1c0SJohn Levon /bin/time $MAKE -ek lint 2>&1 | \ 4076b72f1c0SJohn Levon tee -a $LINTOUT >> $LOGFILE 4086b72f1c0SJohn Levon 4096b72f1c0SJohn Levon echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 4106b72f1c0SJohn Levon 4116b72f1c0SJohn Levon grep "$MAKE:" $LINTOUT | 4126b72f1c0SJohn Levon egrep -v "Ignoring unknown host" | \ 4136b72f1c0SJohn Levon tee $TMPDIR/lint_errs >> $mail_msg_file 4146b72f1c0SJohn Levon if [[ -s $TMPDIR/lint_errs ]]; then 4156b72f1c0SJohn Levon build_extras_ok=n 4166b72f1c0SJohn Levon fi 4176b72f1c0SJohn Levon 4186b72f1c0SJohn Levon echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 4196b72f1c0SJohn Levon 4206b72f1c0SJohn Levon echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 4216b72f1c0SJohn Levon >>$mail_msg_file 4226b72f1c0SJohn Levon tail -3 $LINTOUT >>$mail_msg_file 4236b72f1c0SJohn Levon 4246b72f1c0SJohn Levon rm -f ${LINTNOISE}.ref 4256b72f1c0SJohn Levon if [ -f ${LINTNOISE}.out ]; then 4266b72f1c0SJohn Levon mv ${LINTNOISE}.out ${LINTNOISE}.ref 4276b72f1c0SJohn Levon fi 4286b72f1c0SJohn Levon grep : $LINTOUT | \ 4296b72f1c0SJohn Levon egrep -v '^(real|user|sys)' | 4306b72f1c0SJohn Levon egrep -v '(library construction)' | \ 4316b72f1c0SJohn Levon egrep -v ': global crosschecks' | \ 4326b72f1c0SJohn Levon egrep -v 'Ignoring unknown host' | \ 4336b72f1c0SJohn Levon egrep -v '\.c:$' | \ 4346b72f1c0SJohn Levon sort | uniq > ${LINTNOISE}.out 4356b72f1c0SJohn Levon if [ ! -f ${LINTNOISE}.ref ]; then 4366b72f1c0SJohn Levon cp ${LINTNOISE}.out ${LINTNOISE}.ref 4376b72f1c0SJohn Levon fi 4386b72f1c0SJohn Levon 4396b72f1c0SJohn Levon if [ "$dodiff" != "n" ]; then 4406b72f1c0SJohn Levon echo "\n==== lint warnings $base ====\n" \ 4416b72f1c0SJohn Levon >>$mail_msg_file 4426b72f1c0SJohn Levon # should be none, though there are a few that were filtered out 4436b72f1c0SJohn Levon # above 4446b72f1c0SJohn Levon egrep -i '(warning|lint):' ${LINTNOISE}.out \ 4456b72f1c0SJohn Levon | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file 4466b72f1c0SJohn Levon if [[ -s $TMPDIR/lint_warns ]]; then 4476b72f1c0SJohn Levon build_extras_ok=n 4486b72f1c0SJohn Levon fi 4496b72f1c0SJohn Levon echo "\n==== lint noise differences $base ====\n" \ 4506b72f1c0SJohn Levon >> $mail_msg_file 4516b72f1c0SJohn Levon diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 4526b72f1c0SJohn Levon >> $mail_msg_file 4536b72f1c0SJohn Levon fi 4546b72f1c0SJohn Levon} 4556b72f1c0SJohn Levon 4566b72f1c0SJohn Levon# 4576b72f1c0SJohn Levon# Build and install the onbld tools. 4586b72f1c0SJohn Levon# 4596b72f1c0SJohn Levon# usage: build_tools DESTROOT 4606b72f1c0SJohn Levon# 4616b72f1c0SJohn Levon# returns non-zero status if the build was successful. 4626b72f1c0SJohn Levon# 4636b72f1c0SJohn Levonfunction build_tools { 4646b72f1c0SJohn Levon DESTROOT=$1 4656b72f1c0SJohn Levon 4666b72f1c0SJohn Levon INSTALLOG=install-${MACH} 4676b72f1c0SJohn Levon 4686b72f1c0SJohn Levon echo "\n==== Building tools at `date` ====\n" \ 4696b72f1c0SJohn Levon >> $LOGFILE 4706b72f1c0SJohn Levon 4716b72f1c0SJohn Levon rm -f ${TOOLS}/${INSTALLOG}.out 4726b72f1c0SJohn Levon cd ${TOOLS} 4736b72f1c0SJohn Levon /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 4746b72f1c0SJohn Levon tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 4756b72f1c0SJohn Levon 4766b72f1c0SJohn Levon echo "\n==== Tools build errors ====\n" >> $mail_msg_file 4776b72f1c0SJohn Levon 4786b72f1c0SJohn Levon egrep ":" ${TOOLS}/${INSTALLOG}.out | 4796b72f1c0SJohn Levon egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 4806b72f1c0SJohn Levon egrep -v "Ignoring unknown host" | \ 4816b72f1c0SJohn Levon egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 4826b72f1c0SJohn Levon 4836b72f1c0SJohn Levon if [[ -s $TMPDIR/tools_errors ]]; then 4846b72f1c0SJohn Levon return 1 4856b72f1c0SJohn Levon fi 4866b72f1c0SJohn Levon return 0 4876b72f1c0SJohn Levon} 4886b72f1c0SJohn Levon 4896b72f1c0SJohn Levon# 4906b72f1c0SJohn Levon# Set up to use locally installed tools. 4916b72f1c0SJohn Levon# 4926b72f1c0SJohn Levon# usage: use_tools TOOLSROOT 4936b72f1c0SJohn Levon# 4946b72f1c0SJohn Levonfunction use_tools { 4956b72f1c0SJohn Levon TOOLSROOT=$1 4966b72f1c0SJohn Levon 4976b72f1c0SJohn Levon # 4986b72f1c0SJohn Levon # If we're not building ON workspace, then the TOOLSROOT 4996b72f1c0SJohn Levon # settings here are clearly ignored by the workspace 5006b72f1c0SJohn Levon # makefiles, prepending nonexistent directories to PATH is 5016b72f1c0SJohn Levon # harmless, and we clearly do not wish to override 5026b72f1c0SJohn Levon # ONBLD_TOOLS. 5036b72f1c0SJohn Levon # 5046b72f1c0SJohn Levon # If we're building an ON workspace, then the prepended PATH 5056b72f1c0SJohn Levon # elements should supercede the preexisting ONBLD_TOOLS paths, 5066b72f1c0SJohn Levon # and we want to override ONBLD_TOOLS to catch the tools that 5076b72f1c0SJohn Levon # don't have specific path env vars here. 5086b72f1c0SJohn Levon # 5096b72f1c0SJohn Levon # So the only conditional behavior is overriding ONBLD_TOOLS, 5106b72f1c0SJohn Levon # and we check for "an ON workspace" by looking for 5116b72f1c0SJohn Levon # ${TOOLSROOT}/opt/onbld. 5126b72f1c0SJohn Levon # 5136b72f1c0SJohn Levon 5146b72f1c0SJohn Levon STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs 5156b72f1c0SJohn Levon export STABS 5166b72f1c0SJohn Levon CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs 5176b72f1c0SJohn Levon export CTFSTABS 5186b72f1c0SJohn Levon GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets 5196b72f1c0SJohn Levon export GENOFFSETS 5206b72f1c0SJohn Levon 5216b72f1c0SJohn Levon CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert 5226b72f1c0SJohn Levon export CTFCONVERT 5236b72f1c0SJohn Levon CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge 5246b72f1c0SJohn Levon export CTFMERGE 5256b72f1c0SJohn Levon 5266b72f1c0SJohn Levon if [ "$VERIFY_ELFSIGN" = "y" ]; then 5276b72f1c0SJohn Levon ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 5286b72f1c0SJohn Levon else 5296b72f1c0SJohn Levon ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 5306b72f1c0SJohn Levon fi 5316b72f1c0SJohn Levon export ELFSIGN 5326b72f1c0SJohn Levon 5336b72f1c0SJohn Levon PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 5346b72f1c0SJohn Levon PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 5356b72f1c0SJohn Levon export PATH 5366b72f1c0SJohn Levon 5376b72f1c0SJohn Levon if [ -d "${TOOLSROOT}/opt/onbld" ]; then 5386b72f1c0SJohn Levon ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 5396b72f1c0SJohn Levon export ONBLD_TOOLS 5406b72f1c0SJohn Levon fi 5416b72f1c0SJohn Levon 5426b72f1c0SJohn Levon echo "\n==== New environment settings. ====\n" >> $LOGFILE 5436b72f1c0SJohn Levon echo "STABS=${STABS}" >> $LOGFILE 5446b72f1c0SJohn Levon echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 5456b72f1c0SJohn Levon echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 5466b72f1c0SJohn Levon echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 5476b72f1c0SJohn Levon echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 5486b72f1c0SJohn Levon echo "PATH=${PATH}" >> $LOGFILE 5496b72f1c0SJohn Levon echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 5506b72f1c0SJohn Levon} 5516b72f1c0SJohn Levon 5526b72f1c0SJohn Levonfunction staffer { 5536b72f1c0SJohn Levon if [ $ISUSER -ne 0 ]; then 5546b72f1c0SJohn Levon "$@" 5556b72f1c0SJohn Levon else 5566b72f1c0SJohn Levon arg="\"$1\"" 5576b72f1c0SJohn Levon shift 5586b72f1c0SJohn Levon for i 5596b72f1c0SJohn Levon do 5606b72f1c0SJohn Levon arg="$arg \"$i\"" 5616b72f1c0SJohn Levon done 5626b72f1c0SJohn Levon eval su $STAFFER -c \'$arg\' 5636b72f1c0SJohn Levon fi 5646b72f1c0SJohn Levon} 5656b72f1c0SJohn Levon 5666b72f1c0SJohn Levon# 5676b72f1c0SJohn Levon# Verify that the closed bins are present 5686b72f1c0SJohn Levon# 5696b72f1c0SJohn Levonfunction check_closed_bins { 5706b72f1c0SJohn Levon if [[ ! -d "$ON_CLOSED_BINS" ]]; then 5716b72f1c0SJohn Levon echo "ON_CLOSED_BINS must point to the closed binaries tree." 5726b72f1c0SJohn Levon build_ok=n 5736b72f1c0SJohn Levon exit 1 5746b72f1c0SJohn Levon fi 5756b72f1c0SJohn Levon} 5766b72f1c0SJohn Levon 5776b72f1c0SJohn Levon# 5786b72f1c0SJohn Levon# wrapper over wsdiff. 5796b72f1c0SJohn Levon# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 5806b72f1c0SJohn Levon# 5816b72f1c0SJohn Levonfunction do_wsdiff { 5826b72f1c0SJohn Levon label=$1 5836b72f1c0SJohn Levon oldproto=$2 5846b72f1c0SJohn Levon newproto=$3 585*69ce05a9SMarcel Telka results=$4 5866b72f1c0SJohn Levon 5876b72f1c0SJohn Levon wsdiff="wsdiff" 5886b72f1c0SJohn Levon [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 5896b72f1c0SJohn Levon 5906b72f1c0SJohn Levon echo "\n==== Getting object changes since last build at `date`" \ 5916b72f1c0SJohn Levon "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 592*69ce05a9SMarcel Telka $wsdiff -s -r ${TMPDIR}/$results $oldproto $newproto 2>&1 | \ 5936b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 5946b72f1c0SJohn Levon echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 5956b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 5966b72f1c0SJohn Levon} 5976b72f1c0SJohn Levon 5986b72f1c0SJohn Levon# 5996b72f1c0SJohn Levon# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 6006b72f1c0SJohn Levon# together. 6016b72f1c0SJohn Levon# 6026b72f1c0SJohn Levon 6036b72f1c0SJohn Levonfunction set_non_debug_build_flags { 6046b72f1c0SJohn Levon export RELEASE_BUILD ; RELEASE_BUILD= 6056b72f1c0SJohn Levon unset EXTRA_OPTIONS 6066b72f1c0SJohn Levon unset EXTRA_CFLAGS 6076b72f1c0SJohn Levon} 6086b72f1c0SJohn Levon 6096b72f1c0SJohn Levonfunction set_debug_build_flags { 6106b72f1c0SJohn Levon unset RELEASE_BUILD 6116b72f1c0SJohn Levon unset EXTRA_OPTIONS 6126b72f1c0SJohn Levon unset EXTRA_CFLAGS 6136b72f1c0SJohn Levon} 6146b72f1c0SJohn Levon 6156b72f1c0SJohn Levon 6166b72f1c0SJohn LevonMACH=`uname -p` 6176b72f1c0SJohn Levon 6186b72f1c0SJohn Levonif [ "$OPTHOME" = "" ]; then 6196b72f1c0SJohn Levon OPTHOME=/opt 6206b72f1c0SJohn Levon export OPTHOME 6216b72f1c0SJohn Levonfi 6226b72f1c0SJohn Levon 6236b72f1c0SJohn LevonUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 6246b72f1c0SJohn Levon 6256b72f1c0SJohn LevonWhere: 6266b72f1c0SJohn Levon -i Fast incremental options (no clobber, lint, check) 6276b72f1c0SJohn Levon -n Do not do a bringover 6286b72f1c0SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 6296b72f1c0SJohn Levon -V VERS set the build version string to VERS 6306b72f1c0SJohn Levon 6316b72f1c0SJohn Levon <env_file> file in Bourne shell syntax that sets and exports 6326b72f1c0SJohn Levon variables that configure the operation of this script and many of 6336b72f1c0SJohn Levon the scripts this one calls. If <env_file> does not exist, 6346b72f1c0SJohn Levon it will be looked for in $OPTHOME/onbld/env. 6356b72f1c0SJohn Levon 6366b72f1c0SJohn Levonnon-DEBUG is the default build type. Build options can be set in the 6376b72f1c0SJohn LevonNIGHTLY_OPTIONS variable in the <env_file> as follows: 6386b72f1c0SJohn Levon 6396b72f1c0SJohn Levon -A check for ABI differences in .so files 6406b72f1c0SJohn Levon -C check for cstyle/hdrchk errors 6416b72f1c0SJohn Levon -D do a build with DEBUG on 6426b72f1c0SJohn Levon -F do _not_ do a non-DEBUG build 6436b72f1c0SJohn Levon -G gate keeper default group of options (-au) 6446b72f1c0SJohn Levon -I integration engineer default group of options (-ampu) 6456b72f1c0SJohn Levon -M do not run pmodes (safe file permission checker) 6466b72f1c0SJohn Levon -N do not run protocmp 6476b72f1c0SJohn Levon -R default group of options for building a release (-mp) 6486b72f1c0SJohn Levon -U update proto area in the parent 6496b72f1c0SJohn Levon -V VERS set the build version string to VERS 6506b72f1c0SJohn Levon -f find unreferenced files 6516b72f1c0SJohn Levon -i do an incremental build (no "make clobber") 6526b72f1c0SJohn Levon -l do "make lint" in $LINTDIRS (default: $SRC y) 6536b72f1c0SJohn Levon -m send mail to $MAILTO at end of build 6546b72f1c0SJohn Levon -n do not do a bringover 6556b72f1c0SJohn Levon -p create packages 6566b72f1c0SJohn Levon -r check ELF runtime attributes in the proto area 6576b72f1c0SJohn Levon -t build and use the tools in $SRC/tools (default setting) 6586b72f1c0SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 6596b72f1c0SJohn Levon -u update proto_list_$MACH and friends in the parent workspace; 6606b72f1c0SJohn Levon when used with -f, also build an unrefmaster.out in the parent 6616b72f1c0SJohn Levon -w report on differences between previous and current proto areas 6626b72f1c0SJohn Levon' 6636b72f1c0SJohn Levon# 6646b72f1c0SJohn Levon# A log file will be generated under the name $LOGFILE 6656b72f1c0SJohn Levon# for partially completed build and log.`date '+%F'` 6666b72f1c0SJohn Levon# in the same directory for fully completed builds. 6676b72f1c0SJohn Levon# 6686b72f1c0SJohn Levon 6696b72f1c0SJohn Levon# default values for low-level FLAGS; G I R are group FLAGS 6706b72f1c0SJohn LevonA_FLAG=n 6716b72f1c0SJohn LevonC_FLAG=n 6726b72f1c0SJohn LevonD_FLAG=n 6736b72f1c0SJohn LevonF_FLAG=n 6746b72f1c0SJohn Levonf_FLAG=n 6756b72f1c0SJohn Levoni_FLAG=n; i_CMD_LINE_FLAG=n 6766b72f1c0SJohn Levonl_FLAG=n 6776b72f1c0SJohn LevonM_FLAG=n 6786b72f1c0SJohn Levonm_FLAG=n 6796b72f1c0SJohn LevonN_FLAG=n 6806b72f1c0SJohn Levonn_FLAG=n 6816b72f1c0SJohn Levonp_FLAG=n 6826b72f1c0SJohn Levonr_FLAG=n 6836b72f1c0SJohn Levont_FLAG=y 6846b72f1c0SJohn LevonU_FLAG=n 6856b72f1c0SJohn Levonu_FLAG=n 6866b72f1c0SJohn LevonV_FLAG=n 6876b72f1c0SJohn Levonw_FLAG=n 6886b72f1c0SJohn LevonW_FLAG=n 6896b72f1c0SJohn Levon# 6906b72f1c0SJohn Levonbuild_ok=y 6916b72f1c0SJohn Levonbuild_extras_ok=y 6926b72f1c0SJohn Levon 6936b72f1c0SJohn Levon# 6946b72f1c0SJohn Levon# examine arguments 6956b72f1c0SJohn Levon# 6966b72f1c0SJohn Levon 6976b72f1c0SJohn LevonOPTIND=1 6986b72f1c0SJohn Levonwhile getopts +intV:W FLAG 6996b72f1c0SJohn Levondo 7006b72f1c0SJohn Levon case $FLAG in 7016b72f1c0SJohn Levon i ) i_FLAG=y; i_CMD_LINE_FLAG=y 7026b72f1c0SJohn Levon ;; 7036b72f1c0SJohn Levon n ) n_FLAG=y 7046b72f1c0SJohn Levon ;; 7056b72f1c0SJohn Levon +t ) t_FLAG=n 7066b72f1c0SJohn Levon ;; 7076b72f1c0SJohn Levon V ) V_FLAG=y 7086b72f1c0SJohn Levon V_ARG="$OPTARG" 7096b72f1c0SJohn Levon ;; 7106b72f1c0SJohn Levon W ) W_FLAG=y 7116b72f1c0SJohn Levon ;; 7126b72f1c0SJohn Levon \? ) echo "$USAGE" 7136b72f1c0SJohn Levon exit 1 7146b72f1c0SJohn Levon ;; 7156b72f1c0SJohn Levon esac 7166b72f1c0SJohn Levondone 7176b72f1c0SJohn Levon 7186b72f1c0SJohn Levon# correct argument count after options 7196b72f1c0SJohn Levonshift `expr $OPTIND - 1` 7206b72f1c0SJohn Levon 7216b72f1c0SJohn Levon# test that the path to the environment-setting file was given 7226b72f1c0SJohn Levonif [ $# -ne 1 ]; then 7236b72f1c0SJohn Levon echo "$USAGE" 7246b72f1c0SJohn Levon exit 1 7256b72f1c0SJohn Levonfi 7266b72f1c0SJohn Levon 7276b72f1c0SJohn Levon# check if user is running nightly as root 7286b72f1c0SJohn Levon# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 7296b72f1c0SJohn Levon# when root invokes nightly. 7306b72f1c0SJohn Levon/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 7316b72f1c0SJohn LevonISUSER=$?; export ISUSER 7326b72f1c0SJohn Levon 7336b72f1c0SJohn Levon# 7346b72f1c0SJohn Levon# force locale to C 7356b72f1c0SJohn LevonLANG=C; export LANG 7366b72f1c0SJohn LevonLC_ALL=C; export LC_ALL 7376b72f1c0SJohn LevonLC_COLLATE=C; export LC_COLLATE 7386b72f1c0SJohn LevonLC_CTYPE=C; export LC_CTYPE 7396b72f1c0SJohn LevonLC_MESSAGES=C; export LC_MESSAGES 7406b72f1c0SJohn LevonLC_MONETARY=C; export LC_MONETARY 7416b72f1c0SJohn LevonLC_NUMERIC=C; export LC_NUMERIC 7426b72f1c0SJohn LevonLC_TIME=C; export LC_TIME 7436b72f1c0SJohn Levon 7446b72f1c0SJohn Levon# clear environment variables we know to be bad for the build 7456b72f1c0SJohn Levonunset LD_OPTIONS 7466b72f1c0SJohn Levonunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 7476b72f1c0SJohn Levonunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 7486b72f1c0SJohn Levonunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 7496b72f1c0SJohn Levonunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 7506b72f1c0SJohn Levonunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 7516b72f1c0SJohn Levonunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 7526b72f1c0SJohn Levonunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 7536b72f1c0SJohn Levonunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 7546b72f1c0SJohn Levonunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 7556b72f1c0SJohn Levonunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 7566b72f1c0SJohn Levonunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 7576b72f1c0SJohn Levonunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 7586b72f1c0SJohn Levonunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 7596b72f1c0SJohn Levonunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 7606b72f1c0SJohn Levonunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 7616b72f1c0SJohn Levonunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 7626b72f1c0SJohn Levonunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 7636b72f1c0SJohn Levonunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 7646b72f1c0SJohn Levonunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 7656b72f1c0SJohn Levonunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 7666b72f1c0SJohn Levon 7676b72f1c0SJohn Levonunset CONFIG 7686b72f1c0SJohn Levonunset GROUP 7696b72f1c0SJohn Levonunset OWNER 7706b72f1c0SJohn Levonunset REMOTE 7716b72f1c0SJohn Levonunset ENV 7726b72f1c0SJohn Levonunset ARCH 7736b72f1c0SJohn Levonunset CLASSPATH 7746b72f1c0SJohn Levonunset NAME 7756b72f1c0SJohn Levon 7766b72f1c0SJohn Levon# 7776b72f1c0SJohn Levon# To get ONBLD_TOOLS from the environment, it must come from the env file. 7786b72f1c0SJohn Levon# If it comes interactively, it is generally TOOLS_PROTO, which will be 7796b72f1c0SJohn Levon# clobbered before the compiler version checks, which will therefore fail. 7806b72f1c0SJohn Levon# 7816b72f1c0SJohn Levonunset ONBLD_TOOLS 7826b72f1c0SJohn Levon 7836b72f1c0SJohn Levon# 7846b72f1c0SJohn Levon# Setup environmental variables 7856b72f1c0SJohn Levon# 7866b72f1c0SJohn Levonif [ -f /etc/nightly.conf ]; then 7876b72f1c0SJohn Levon . /etc/nightly.conf 7886b72f1c0SJohn Levonfi 7896b72f1c0SJohn Levon 7906b72f1c0SJohn Levonif [ -f $1 ]; then 7916b72f1c0SJohn Levon if [[ $1 = */* ]]; then 7926b72f1c0SJohn Levon . $1 7936b72f1c0SJohn Levon else 7946b72f1c0SJohn Levon . ./$1 7956b72f1c0SJohn Levon fi 7966b72f1c0SJohn Levonelse 7976b72f1c0SJohn Levon if [ -f $OPTHOME/onbld/env/$1 ]; then 7986b72f1c0SJohn Levon . $OPTHOME/onbld/env/$1 7996b72f1c0SJohn Levon else 8006b72f1c0SJohn Levon echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 8016b72f1c0SJohn Levon exit 1 8026b72f1c0SJohn Levon fi 8036b72f1c0SJohn Levonfi 8046b72f1c0SJohn Levon 8056b72f1c0SJohn Levon# Check if we have sufficient data to continue... 8066b72f1c0SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 8076b72f1c0SJohn Levonif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 8086b72f1c0SJohn Levon # Check if the gate data are valid if we don't do a "bringover" below 8096b72f1c0SJohn Levon [[ -d "${CODEMGR_WS}" ]] || \ 8106b72f1c0SJohn Levon fatal_error "Error: ${CODEMGR_WS} is not a directory." 8116b72f1c0SJohn Levon [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 8126b72f1c0SJohn Levon fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 8136b72f1c0SJohn Levonfi 8146b72f1c0SJohn Levon 8156b72f1c0SJohn Levon# 8166b72f1c0SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set. 8176b72f1c0SJohn Levon# 8186b72f1c0SJohn Levonif [ -z "$BUILD_PROJECT" ]; then 8196b72f1c0SJohn Levon /usr/bin/newtask -c $$ 8206b72f1c0SJohn Levonelse 8216b72f1c0SJohn Levon /usr/bin/newtask -c $$ -p $BUILD_PROJECT 8226b72f1c0SJohn Levonfi 8236b72f1c0SJohn Levon 8246b72f1c0SJohn Levonps -o taskid= -p $$ | read build_taskid 8256b72f1c0SJohn Levonps -o project= -p $$ | read build_project 8266b72f1c0SJohn Levon 8276b72f1c0SJohn Levon# 8286b72f1c0SJohn Levon# See if NIGHTLY_OPTIONS is set 8296b72f1c0SJohn Levon# 8306b72f1c0SJohn Levonif [ "$NIGHTLY_OPTIONS" = "" ]; then 8316b72f1c0SJohn Levon NIGHTLY_OPTIONS="-aBm" 8326b72f1c0SJohn Levonfi 8336b72f1c0SJohn Levon 8346b72f1c0SJohn Levon# 8356b72f1c0SJohn Levon# If BRINGOVER_WS was not specified, let it default to CLONE_WS 8366b72f1c0SJohn Levon# 8376b72f1c0SJohn Levonif [ "$BRINGOVER_WS" = "" ]; then 8386b72f1c0SJohn Levon BRINGOVER_WS=$CLONE_WS 8396b72f1c0SJohn Levonfi 8406b72f1c0SJohn Levon 8416b72f1c0SJohn Levon# 8426b72f1c0SJohn Levon# If BRINGOVER_FILES was not specified, default to usr 8436b72f1c0SJohn Levon# 8446b72f1c0SJohn Levonif [ "$BRINGOVER_FILES" = "" ]; then 8456b72f1c0SJohn Levon BRINGOVER_FILES="usr" 8466b72f1c0SJohn Levonfi 8476b72f1c0SJohn Levon 8486b72f1c0SJohn Levoncheck_closed_bins 8496b72f1c0SJohn Levon 8506b72f1c0SJohn Levon# 8516b72f1c0SJohn Levon# Note: changes to the option letters here should also be applied to the 8526b72f1c0SJohn Levon# bldenv script. `d' is listed for backward compatibility. 8536b72f1c0SJohn Levon# 8546b72f1c0SJohn LevonNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 8556b72f1c0SJohn LevonOPTIND=1 8566b72f1c0SJohn Levonwhile getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 8576b72f1c0SJohn Levondo 8586b72f1c0SJohn Levon case $FLAG in 8596b72f1c0SJohn Levon A ) A_FLAG=y 8606b72f1c0SJohn Levon ;; 8616b72f1c0SJohn Levon B ) D_FLAG=y 8626b72f1c0SJohn Levon ;; # old version of D 8636b72f1c0SJohn Levon C ) C_FLAG=y 8646b72f1c0SJohn Levon ;; 8656b72f1c0SJohn Levon D ) D_FLAG=y 8666b72f1c0SJohn Levon ;; 8676b72f1c0SJohn Levon F ) F_FLAG=y 8686b72f1c0SJohn Levon ;; 8696b72f1c0SJohn Levon f ) f_FLAG=y 8706b72f1c0SJohn Levon ;; 8716b72f1c0SJohn Levon G ) u_FLAG=y 8726b72f1c0SJohn Levon ;; 8736b72f1c0SJohn Levon I ) m_FLAG=y 8746b72f1c0SJohn Levon p_FLAG=y 8756b72f1c0SJohn Levon u_FLAG=y 8766b72f1c0SJohn Levon ;; 8776b72f1c0SJohn Levon i ) i_FLAG=y 8786b72f1c0SJohn Levon ;; 8796b72f1c0SJohn Levon l ) l_FLAG=y 8806b72f1c0SJohn Levon ;; 8816b72f1c0SJohn Levon M ) M_FLAG=y 8826b72f1c0SJohn Levon ;; 8836b72f1c0SJohn Levon m ) m_FLAG=y 8846b72f1c0SJohn Levon ;; 8856b72f1c0SJohn Levon N ) N_FLAG=y 8866b72f1c0SJohn Levon ;; 8876b72f1c0SJohn Levon n ) n_FLAG=y 8886b72f1c0SJohn Levon ;; 8896b72f1c0SJohn Levon p ) p_FLAG=y 8906b72f1c0SJohn Levon ;; 8916b72f1c0SJohn Levon R ) m_FLAG=y 8926b72f1c0SJohn Levon p_FLAG=y 8936b72f1c0SJohn Levon ;; 8946b72f1c0SJohn Levon r ) r_FLAG=y 8956b72f1c0SJohn Levon ;; 8966b72f1c0SJohn Levon +t ) t_FLAG=n 8976b72f1c0SJohn Levon ;; 8986b72f1c0SJohn Levon U ) if [ -z "${PARENT_ROOT}" ]; then 8996b72f1c0SJohn Levon echo "PARENT_ROOT must be set if the U flag is" \ 9006b72f1c0SJohn Levon "present in NIGHTLY_OPTIONS." 9016b72f1c0SJohn Levon exit 1 9026b72f1c0SJohn Levon fi 9036b72f1c0SJohn Levon NIGHTLY_PARENT_ROOT=$PARENT_ROOT 9046b72f1c0SJohn Levon if [ -n "${PARENT_TOOLS_ROOT}" ]; then 9056b72f1c0SJohn Levon NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 9066b72f1c0SJohn Levon fi 9076b72f1c0SJohn Levon U_FLAG=y 9086b72f1c0SJohn Levon ;; 9096b72f1c0SJohn Levon u ) u_FLAG=y 9106b72f1c0SJohn Levon ;; 9116b72f1c0SJohn Levon w ) w_FLAG=y 9126b72f1c0SJohn Levon ;; 9136b72f1c0SJohn Levon W ) W_FLAG=y 9146b72f1c0SJohn Levon ;; 9156b72f1c0SJohn Levon \? ) echo "$USAGE" 9166b72f1c0SJohn Levon exit 1 9176b72f1c0SJohn Levon ;; 9186b72f1c0SJohn Levon esac 9196b72f1c0SJohn Levondone 9206b72f1c0SJohn Levon 9216b72f1c0SJohn Levonif [ $ISUSER -ne 0 ]; then 9226b72f1c0SJohn Levon # Set default value for STAFFER, if needed. 9236b72f1c0SJohn Levon if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 9246b72f1c0SJohn Levon STAFFER=`/usr/xpg4/bin/id -un` 9256b72f1c0SJohn Levon export STAFFER 9266b72f1c0SJohn Levon fi 9276b72f1c0SJohn Levonfi 9286b72f1c0SJohn Levon 9296b72f1c0SJohn Levonif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 9306b72f1c0SJohn Levon MAILTO=$STAFFER 9316b72f1c0SJohn Levon export MAILTO 9326b72f1c0SJohn Levonfi 9336b72f1c0SJohn Levon 9346b72f1c0SJohn LevonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 9356b72f1c0SJohn LevonPATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 9366b72f1c0SJohn LevonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 9376b72f1c0SJohn Levonexport PATH 9386b72f1c0SJohn Levon 9396b72f1c0SJohn Levon# roots of source trees, both relative to $SRC and absolute. 9406b72f1c0SJohn Levonrelsrcdirs="." 9416b72f1c0SJohn Levonabssrcdirs="$SRC" 9426b72f1c0SJohn Levon 9436b72f1c0SJohn LevonPROTOCMPTERSE="protocmp.terse -gu" 9446b72f1c0SJohn LevonPOUND_SIGN="#" 9456b72f1c0SJohn Levon# have we set RELEASE_DATE in our env file? 9466b72f1c0SJohn Levonif [ -z "$RELEASE_DATE" ]; then 9476b72f1c0SJohn Levon RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 9486b72f1c0SJohn Levonfi 9496b72f1c0SJohn LevonBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 9506b72f1c0SJohn LevonBASEWSDIR=$(basename $CODEMGR_WS) 9516b72f1c0SJohn LevonDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 9526b72f1c0SJohn Levon 9536b72f1c0SJohn Levon# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 9546b72f1c0SJohn Levon# by avoiding repeated shell invocations to evaluate Makefile.master 9556b72f1c0SJohn Levon# definitions. 9566b72f1c0SJohn Levonexport POUND_SIGN RELEASE_DATE DEV_CM 9576b72f1c0SJohn Levon 9586b72f1c0SJohn Levonmaketype="distributed" 9596b72f1c0SJohn Levonif [[ -z "$MAKE" ]]; then 9606b72f1c0SJohn Levon MAKE=dmake 9616b72f1c0SJohn Levonelif [[ ! -x "$MAKE" ]]; then 9626b72f1c0SJohn Levon echo "\$MAKE is set to garbage in the environment" 9636b72f1c0SJohn Levon exit 1 9646b72f1c0SJohn Levonfi 9656b72f1c0SJohn Levonexport PATH 9666b72f1c0SJohn Levonexport MAKE 9676b72f1c0SJohn Levon 9686b72f1c0SJohn Levonif [ "${SUNWSPRO}" != "" ]; then 9696b72f1c0SJohn Levon PATH="${SUNWSPRO}/bin:$PATH" 9706b72f1c0SJohn Levon export PATH 9716b72f1c0SJohn Levonfi 9726b72f1c0SJohn Levon 9736b72f1c0SJohn Levonhostname=$(uname -n) 9746b72f1c0SJohn Levonif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 9756b72f1c0SJohn Levonthen 9766b72f1c0SJohn Levon maxjobs= 9776b72f1c0SJohn Levon if [[ -f $HOME/.make.machines ]] 9786b72f1c0SJohn Levon then 9796b72f1c0SJohn Levon # Note: there is a hard tab and space character in the []s 9806b72f1c0SJohn Levon # below. 9816b72f1c0SJohn Levon egrep -i "^[ ]*$hostname[ \.]" \ 9826b72f1c0SJohn Levon $HOME/.make.machines | read host jobs 9836b72f1c0SJohn Levon maxjobs=${jobs##*=} 9846b72f1c0SJohn Levon fi 9856b72f1c0SJohn Levon 9866b72f1c0SJohn Levon if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 9876b72f1c0SJohn Levon then 9886b72f1c0SJohn Levon # default 9896b72f1c0SJohn Levon maxjobs=4 9906b72f1c0SJohn Levon fi 9916b72f1c0SJohn Levon 9926b72f1c0SJohn Levon export DMAKE_MAX_JOBS=$maxjobs 9936b72f1c0SJohn Levonfi 9946b72f1c0SJohn Levon 9956b72f1c0SJohn LevonDMAKE_MODE=parallel; 9966b72f1c0SJohn Levonexport DMAKE_MODE 9976b72f1c0SJohn Levon 9986b72f1c0SJohn Levonif [ -z "${ROOT}" ]; then 9996b72f1c0SJohn Levon echo "ROOT must be set." 10006b72f1c0SJohn Levon exit 1 10016b72f1c0SJohn Levonfi 10026b72f1c0SJohn Levon 10036b72f1c0SJohn Levon# 10046b72f1c0SJohn Levon# if -V flag was given, reset VERSION to V_ARG 10056b72f1c0SJohn Levon# 10066b72f1c0SJohn Levonif [ "$V_FLAG" = "y" ]; then 10076b72f1c0SJohn Levon VERSION=$V_ARG 10086b72f1c0SJohn Levonfi 10096b72f1c0SJohn Levon 10106b72f1c0SJohn LevonTMPDIR="/tmp/nightly.tmpdir.$$" 10116b72f1c0SJohn Levonexport TMPDIR 10126b72f1c0SJohn Levonrm -rf ${TMPDIR} 10136b72f1c0SJohn Levonmkdir -p $TMPDIR || exit 1 10146b72f1c0SJohn Levonchmod 777 $TMPDIR 10156b72f1c0SJohn Levon 10166b72f1c0SJohn Levon# 10176b72f1c0SJohn Levon# Keep elfsign's use of pkcs11_softtoken from looking in the user home 10186b72f1c0SJohn Levon# directory, which doesn't always work. Needed until all build machines 10196b72f1c0SJohn Levon# have the fix for 6271754 10206b72f1c0SJohn Levon# 10216b72f1c0SJohn LevonSOFTTOKEN_DIR=$TMPDIR 10226b72f1c0SJohn Levonexport SOFTTOKEN_DIR 10236b72f1c0SJohn Levon 10246b72f1c0SJohn Levon# 10256b72f1c0SJohn Levon# Tools should only be built non-DEBUG. Keep track of the tools proto 10266b72f1c0SJohn Levon# area path relative to $TOOLS, because the latter changes in an 10276b72f1c0SJohn Levon# export build. 10286b72f1c0SJohn Levon# 10296b72f1c0SJohn Levon# TOOLS_PROTO is included below for builds other than usr/src/tools 10306b72f1c0SJohn Levon# that look for this location. For usr/src/tools, this will be 10316b72f1c0SJohn Levon# overridden on the $MAKE command line in build_tools(). 10326b72f1c0SJohn Levon# 10336b72f1c0SJohn LevonTOOLS=${SRC}/tools 10346b72f1c0SJohn LevonTOOLS_PROTO_REL=proto/root_${MACH}-nd 10356b72f1c0SJohn LevonTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 10366b72f1c0SJohn Levon 10376b72f1c0SJohn Levonunset CFLAGS LD_LIBRARY_PATH LDFLAGS 10386b72f1c0SJohn Levon 10396b72f1c0SJohn Levon# create directories that are automatically removed if the nightly script 10406b72f1c0SJohn Levon# fails to start correctly 10416b72f1c0SJohn Levonfunction newdir { 10426b72f1c0SJohn Levon dir=$1 10436b72f1c0SJohn Levon toadd= 10446b72f1c0SJohn Levon while [ ! -d $dir ]; do 10456b72f1c0SJohn Levon toadd="$dir $toadd" 10466b72f1c0SJohn Levon dir=`dirname $dir` 10476b72f1c0SJohn Levon done 10486b72f1c0SJohn Levon torm= 10496b72f1c0SJohn Levon newlist= 10506b72f1c0SJohn Levon for dir in $toadd; do 10516b72f1c0SJohn Levon if staffer mkdir $dir; then 10526b72f1c0SJohn Levon newlist="$ISUSER $dir $newlist" 10536b72f1c0SJohn Levon torm="$dir $torm" 10546b72f1c0SJohn Levon else 10556b72f1c0SJohn Levon [ -z "$torm" ] || staffer rmdir $torm 10566b72f1c0SJohn Levon return 1 10576b72f1c0SJohn Levon fi 10586b72f1c0SJohn Levon done 10596b72f1c0SJohn Levon newdirlist="$newlist $newdirlist" 10606b72f1c0SJohn Levon return 0 10616b72f1c0SJohn Levon} 10626b72f1c0SJohn Levonnewdirlist= 10636b72f1c0SJohn Levon 10646b72f1c0SJohn Levon[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 10656b72f1c0SJohn Levon 10666b72f1c0SJohn Levon# since this script assumes the build is from full source, it nullifies 10676b72f1c0SJohn Levon# variables likely to have been set by a "ws" script; nullification 10686b72f1c0SJohn Levon# confines the search space for headers and libraries to the proto area 10696b72f1c0SJohn Levon# built from this immediate source. 10706b72f1c0SJohn LevonENVLDLIBS1= 10716b72f1c0SJohn LevonENVLDLIBS2= 10726b72f1c0SJohn LevonENVLDLIBS3= 10736b72f1c0SJohn LevonENVCPPFLAGS1= 10746b72f1c0SJohn LevonENVCPPFLAGS2= 10756b72f1c0SJohn LevonENVCPPFLAGS3= 10766b72f1c0SJohn LevonENVCPPFLAGS4= 10776b72f1c0SJohn LevonPARENT_ROOT= 10786b72f1c0SJohn Levon 10796b72f1c0SJohn Levonexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 10806b72f1c0SJohn Levon ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 10816b72f1c0SJohn Levon 10826b72f1c0SJohn LevonPKGARCHIVE_ORIG=$PKGARCHIVE 10836b72f1c0SJohn Levon 10846b72f1c0SJohn Levon# 10856b72f1c0SJohn Levon# Juggle the logs and optionally send mail on completion. 10866b72f1c0SJohn Levon# 10876b72f1c0SJohn Levon 10886b72f1c0SJohn Levonfunction logshuffle { 10896b72f1c0SJohn Levon LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 10906b72f1c0SJohn Levon if [ -f $LLOG -o -d $LLOG ]; then 10916b72f1c0SJohn Levon LLOG=$LLOG.$$ 10926b72f1c0SJohn Levon fi 10936b72f1c0SJohn Levon mkdir $LLOG 10946b72f1c0SJohn Levon export LLOG 10956b72f1c0SJohn Levon 10966b72f1c0SJohn Levon if [ "$build_ok" = "y" ]; then 10976b72f1c0SJohn Levon mv $ATLOG/proto_list_${MACH} $LLOG 10986b72f1c0SJohn Levon 10996b72f1c0SJohn Levon if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 11006b72f1c0SJohn Levon mv $ATLOG/proto_list_tools_${MACH} $LLOG 11016b72f1c0SJohn Levon fi 11026b72f1c0SJohn Levon 11036b72f1c0SJohn Levon if [ -f $TMPDIR/wsdiff.results ]; then 11046b72f1c0SJohn Levon mv $TMPDIR/wsdiff.results $LLOG 11056b72f1c0SJohn Levon fi 11066b72f1c0SJohn Levon 11076b72f1c0SJohn Levon if [ -f $TMPDIR/wsdiff-nd.results ]; then 11086b72f1c0SJohn Levon mv $TMPDIR/wsdiff-nd.results $LLOG 11096b72f1c0SJohn Levon fi 1110*69ce05a9SMarcel Telka 1111*69ce05a9SMarcel Telka if [ -f $TMPDIR/wsdiff-tools.results ]; then 1112*69ce05a9SMarcel Telka mv $TMPDIR/wsdiff-tools.results $LLOG 1113*69ce05a9SMarcel Telka fi 11146b72f1c0SJohn Levon fi 11156b72f1c0SJohn Levon 11166b72f1c0SJohn Levon # 11176b72f1c0SJohn Levon # Now that we're about to send mail, it's time to check the noise 11186b72f1c0SJohn Levon # file. In the event that an error occurs beyond this point, it will 11196b72f1c0SJohn Levon # be recorded in the nightly.log file, but nowhere else. This would 11206b72f1c0SJohn Levon # include only errors that cause the copying of the noise log to fail 11216b72f1c0SJohn Levon # or the mail itself not to be sent. 11226b72f1c0SJohn Levon # 11236b72f1c0SJohn Levon 11246b72f1c0SJohn Levon exec >>$LOGFILE 2>&1 11256b72f1c0SJohn Levon if [ -s $build_noise_file ]; then 11266b72f1c0SJohn Levon echo "\n==== Nightly build noise ====\n" | 11276b72f1c0SJohn Levon tee -a $LOGFILE >>$mail_msg_file 11286b72f1c0SJohn Levon cat $build_noise_file >>$LOGFILE 11296b72f1c0SJohn Levon cat $build_noise_file >>$mail_msg_file 11306b72f1c0SJohn Levon echo | tee -a $LOGFILE >>$mail_msg_file 11316b72f1c0SJohn Levon fi 11326b72f1c0SJohn Levon rm -f $build_noise_file 11336b72f1c0SJohn Levon 11346b72f1c0SJohn Levon case "$build_ok" in 11356b72f1c0SJohn Levon y) 11366b72f1c0SJohn Levon state=Completed 11376b72f1c0SJohn Levon ;; 11386b72f1c0SJohn Levon i) 11396b72f1c0SJohn Levon state=Interrupted 11406b72f1c0SJohn Levon ;; 11416b72f1c0SJohn Levon *) 11426b72f1c0SJohn Levon state=Failed 11436b72f1c0SJohn Levon ;; 11446b72f1c0SJohn Levon esac 11456b72f1c0SJohn Levon 11466b72f1c0SJohn Levon if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 11476b72f1c0SJohn Levon state=Failed 11486b72f1c0SJohn Levon fi 11496b72f1c0SJohn Levon 11506b72f1c0SJohn Levon NIGHTLY_STATUS=$state 11516b72f1c0SJohn Levon export NIGHTLY_STATUS 11526b72f1c0SJohn Levon 11536b72f1c0SJohn Levon run_hook POST_NIGHTLY $state 11546b72f1c0SJohn Levon run_hook SYS_POST_NIGHTLY $state 11556b72f1c0SJohn Levon 11566b72f1c0SJohn Levon # 11576b72f1c0SJohn Levon # mailx(1) sets From: based on the -r flag 11586b72f1c0SJohn Levon # if it is given. 11596b72f1c0SJohn Levon # 11606b72f1c0SJohn Levon mailx_r= 11616b72f1c0SJohn Levon if [[ -n "${MAILFROM}" ]]; then 11626b72f1c0SJohn Levon mailx_r="-r ${MAILFROM}" 11636b72f1c0SJohn Levon fi 11646b72f1c0SJohn Levon 11656b72f1c0SJohn Levon cat $build_time_file $build_environ_file $mail_msg_file \ 11666b72f1c0SJohn Levon > ${LLOG}/mail_msg 11676b72f1c0SJohn Levon if [ "$m_FLAG" = "y" ]; then 11686b72f1c0SJohn Levon cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 11696b72f1c0SJohn Levon "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 11706b72f1c0SJohn Levon ${MAILTO} 11716b72f1c0SJohn Levon fi 11726b72f1c0SJohn Levon 11736b72f1c0SJohn Levon if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 11746b72f1c0SJohn Levon staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 11756b72f1c0SJohn Levon staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 11766b72f1c0SJohn Levon fi 11776b72f1c0SJohn Levon 11786b72f1c0SJohn Levon mv $LOGFILE $LLOG 11796b72f1c0SJohn Levon} 11806b72f1c0SJohn Levon 11816b72f1c0SJohn Levon# 11826b72f1c0SJohn Levon# Remove the locks and temporary files on any exit 11836b72f1c0SJohn Levon# 11846b72f1c0SJohn Levonfunction cleanup { 11856b72f1c0SJohn Levon logshuffle 11866b72f1c0SJohn Levon 11876b72f1c0SJohn Levon [ -z "$lockfile" ] || staffer rm -f $lockfile 11886b72f1c0SJohn Levon [ -z "$atloglockfile" ] || rm -f $atloglockfile 11896b72f1c0SJohn Levon [ -z "$ulockfile" ] || staffer rm -f $ulockfile 11906b72f1c0SJohn Levon [ -z "$Ulockfile" ] || rm -f $Ulockfile 11916b72f1c0SJohn Levon 11926b72f1c0SJohn Levon set -- $newdirlist 11936b72f1c0SJohn Levon while [ $# -gt 0 ]; do 11946b72f1c0SJohn Levon ISUSER=$1 staffer rmdir $2 11956b72f1c0SJohn Levon shift; shift 11966b72f1c0SJohn Levon done 11976b72f1c0SJohn Levon rm -rf $TMPDIR 11986b72f1c0SJohn Levon} 11996b72f1c0SJohn Levon 12006b72f1c0SJohn Levonfunction cleanup_signal { 12016b72f1c0SJohn Levon build_ok=i 12026b72f1c0SJohn Levon # this will trigger cleanup(), above. 12036b72f1c0SJohn Levon exit 1 12046b72f1c0SJohn Levon} 12056b72f1c0SJohn Levon 12066b72f1c0SJohn Levontrap cleanup 0 12076b72f1c0SJohn Levontrap cleanup_signal 1 2 3 15 12086b72f1c0SJohn Levon 12096b72f1c0SJohn Levon# 12106b72f1c0SJohn Levon# Generic lock file processing -- make sure that the lock file doesn't 12116b72f1c0SJohn Levon# exist. If it does, it should name the build host and PID. If it 12126b72f1c0SJohn Levon# doesn't, then make sure we can create it. Clean up locks that are 12136b72f1c0SJohn Levon# known to be stale (assumes host name is unique among build systems 12146b72f1c0SJohn Levon# for the workspace). 12156b72f1c0SJohn Levon# 12166b72f1c0SJohn Levonfunction create_lock { 12176b72f1c0SJohn Levon lockf=$1 12186b72f1c0SJohn Levon lockvar=$2 12196b72f1c0SJohn Levon 12206b72f1c0SJohn Levon ldir=`dirname $lockf` 12216b72f1c0SJohn Levon [ -d $ldir ] || newdir $ldir || exit 1 12226b72f1c0SJohn Levon eval $lockvar=$lockf 12236b72f1c0SJohn Levon 12246b72f1c0SJohn Levon while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 12256b72f1c0SJohn Levon basews=`basename $CODEMGR_WS` 12266b72f1c0SJohn Levon ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 12276b72f1c0SJohn Levon if [ "$host" != "$hostname" ]; then 12286b72f1c0SJohn Levon echo "$MACH build of $basews apparently" \ 12296b72f1c0SJohn Levon "already started by $user on $host as $pid." 12306b72f1c0SJohn Levon exit 1 12316b72f1c0SJohn Levon elif kill -s 0 $pid 2>/dev/null; then 12326b72f1c0SJohn Levon echo "$MACH build of $basews already started" \ 12336b72f1c0SJohn Levon "by $user as $pid." 12346b72f1c0SJohn Levon exit 1 12356b72f1c0SJohn Levon else 12366b72f1c0SJohn Levon # stale lock; clear it out and try again 12376b72f1c0SJohn Levon rm -f $lockf 12386b72f1c0SJohn Levon fi 12396b72f1c0SJohn Levon done 12406b72f1c0SJohn Levon} 12416b72f1c0SJohn Levon 12426b72f1c0SJohn Levon# 12436b72f1c0SJohn Levon# Return the list of interesting proto areas, depending on the current 12446b72f1c0SJohn Levon# options. 12456b72f1c0SJohn Levon# 12466b72f1c0SJohn Levonfunction allprotos { 12476b72f1c0SJohn Levon typeset roots="$ROOT" 12486b72f1c0SJohn Levon 12496b72f1c0SJohn Levon if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 12506b72f1c0SJohn Levon roots="$roots $ROOT-nd" 12516b72f1c0SJohn Levon fi 12526b72f1c0SJohn Levon 12536b72f1c0SJohn Levon echo $roots 12546b72f1c0SJohn Levon} 12556b72f1c0SJohn Levon 12566b72f1c0SJohn Levon# Ensure no other instance of this script is running on this host. 12576b72f1c0SJohn Levon# LOCKNAME can be set in <env_file>, and is by default, but is not 12586b72f1c0SJohn Levon# required due to the use of $ATLOG below. 12596b72f1c0SJohn Levonif [ -n "$LOCKNAME" ]; then 12606b72f1c0SJohn Levon create_lock /tmp/$LOCKNAME "lockfile" 12616b72f1c0SJohn Levonfi 12626b72f1c0SJohn Levon# 12636b72f1c0SJohn Levon# Create from one, two, or three other locks: 12646b72f1c0SJohn Levon# $ATLOG/nightly.lock 12656b72f1c0SJohn Levon# - protects against multiple builds in same workspace 12666b72f1c0SJohn Levon# $PARENT_WS/usr/src/nightly.$MACH.lock 12676b72f1c0SJohn Levon# - protects against multiple 'u' copy-backs 12686b72f1c0SJohn Levon# $NIGHTLY_PARENT_ROOT/nightly.lock 12696b72f1c0SJohn Levon# - protects against multiple 'U' copy-backs 12706b72f1c0SJohn Levon# 12716b72f1c0SJohn Levon# Overriding ISUSER to 1 causes the lock to be created as root if the 12726b72f1c0SJohn Levon# script is run as root. The default is to create it as $STAFFER. 12736b72f1c0SJohn LevonISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 12746b72f1c0SJohn Levonif [ "$u_FLAG" = "y" ]; then 12756b72f1c0SJohn Levon create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 12766b72f1c0SJohn Levonfi 12776b72f1c0SJohn Levonif [ "$U_FLAG" = "y" ]; then 12786b72f1c0SJohn Levon # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 12796b72f1c0SJohn Levon ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 12806b72f1c0SJohn Levonfi 12816b72f1c0SJohn Levon 12826b72f1c0SJohn Levon# Locks have been taken, so we're doing a build and we're committed to 12836b72f1c0SJohn Levon# the directories we may have created so far. 12846b72f1c0SJohn Levonnewdirlist= 12856b72f1c0SJohn Levon 12866b72f1c0SJohn Levon# 12876b72f1c0SJohn Levon# Create mail_msg_file 12886b72f1c0SJohn Levon# 12896b72f1c0SJohn Levonmail_msg_file="${TMPDIR}/mail_msg" 12906b72f1c0SJohn Levontouch $mail_msg_file 12916b72f1c0SJohn Levonbuild_time_file="${TMPDIR}/build_time" 12926b72f1c0SJohn Levonbuild_environ_file="${TMPDIR}/build_environ" 12936b72f1c0SJohn Levontouch $build_environ_file 12946b72f1c0SJohn Levon# 12956b72f1c0SJohn Levon# Move old LOGFILE aside 12966b72f1c0SJohn Levon# ATLOG directory already made by 'create_lock' above 12976b72f1c0SJohn Levon# 12986b72f1c0SJohn Levonif [ -f $LOGFILE ]; then 12996b72f1c0SJohn Levon mv -f $LOGFILE ${LOGFILE}- 13006b72f1c0SJohn Levonfi 13016b72f1c0SJohn Levon# 13026b72f1c0SJohn Levon# Build OsNet source 13036b72f1c0SJohn Levon# 13046b72f1c0SJohn LevonSTART_DATE=`date` 13056b72f1c0SJohn LevonSECONDS=0 13066b72f1c0SJohn Levonecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 13076b72f1c0SJohn Levon | tee -a $LOGFILE > $build_time_file 13086b72f1c0SJohn Levon 13096b72f1c0SJohn Levonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 13106b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13116b72f1c0SJohn Levon 13126b72f1c0SJohn Levon# make sure we log only to the nightly build file 13136b72f1c0SJohn Levonbuild_noise_file="${TMPDIR}/build_noise" 13146b72f1c0SJohn Levonexec </dev/null >$build_noise_file 2>&1 13156b72f1c0SJohn Levon 13166b72f1c0SJohn Levonrun_hook SYS_PRE_NIGHTLY 13176b72f1c0SJohn Levonrun_hook PRE_NIGHTLY 13186b72f1c0SJohn Levon 13196b72f1c0SJohn Levonecho "\n==== list of environment variables ====\n" >> $LOGFILE 13206b72f1c0SJohn Levonenv >> $LOGFILE 13216b72f1c0SJohn Levon 13226b72f1c0SJohn Levonecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 13236b72f1c0SJohn Levon 13246b72f1c0SJohn Levonif [ "$N_FLAG" = "y" ]; then 13256b72f1c0SJohn Levon if [ "$p_FLAG" = "y" ]; then 13266b72f1c0SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13276b72f1c0SJohn LevonWARNING: the p option (create packages) is set, but so is the N option (do 13286b72f1c0SJohn Levon not run protocmp); this is dangerous; you should unset the N option 13296b72f1c0SJohn LevonEOF 13306b72f1c0SJohn Levon else 13316b72f1c0SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13326b72f1c0SJohn LevonWarning: the N option (do not run protocmp) is set; it probably shouldn't be 13336b72f1c0SJohn LevonEOF 13346b72f1c0SJohn Levon fi 13356b72f1c0SJohn Levon echo "" | tee -a $mail_msg_file >> $LOGFILE 13366b72f1c0SJohn Levonfi 13376b72f1c0SJohn Levon 13386b72f1c0SJohn Levonif [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 13396b72f1c0SJohn Levon # 13406b72f1c0SJohn Levon # In the past we just complained but went ahead with the lint 13416b72f1c0SJohn Levon # pass, even though the proto area was built non-DEBUG. It's 13426b72f1c0SJohn Levon # unlikely that non-DEBUG headers will make a difference, but 13436b72f1c0SJohn Levon # rather than assuming it's a safe combination, force the user 13446b72f1c0SJohn Levon # to specify a DEBUG build. 13456b72f1c0SJohn Levon # 13466b72f1c0SJohn Levon echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 13476b72f1c0SJohn Levon | tee -a $mail_msg_file >> $LOGFILE 13486b72f1c0SJohn Levon l_FLAG=n 13496b72f1c0SJohn Levonfi 13506b72f1c0SJohn Levon 13516b72f1c0SJohn Levonif [ "$f_FLAG" = "y" ]; then 13526b72f1c0SJohn Levon if [ "$i_FLAG" = "y" ]; then 13536b72f1c0SJohn Levon echo "WARNING: the -f flag cannot be used during incremental" \ 13546b72f1c0SJohn Levon "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13556b72f1c0SJohn Levon f_FLAG=n 13566b72f1c0SJohn Levon fi 13576b72f1c0SJohn Levon if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 13586b72f1c0SJohn Levon echo "WARNING: the -f flag requires -l, and -p;" \ 13596b72f1c0SJohn Levon "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13606b72f1c0SJohn Levon f_FLAG=n 13616b72f1c0SJohn Levon fi 13626b72f1c0SJohn Levonfi 13636b72f1c0SJohn Levon 13646b72f1c0SJohn Levonif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 13656b72f1c0SJohn Levon echo "WARNING: -w specified, but $ROOT does not exist;" \ 13666b72f1c0SJohn Levon "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 13676b72f1c0SJohn Levon w_FLAG=n 13686b72f1c0SJohn Levonfi 13696b72f1c0SJohn Levon 13706b72f1c0SJohn Levonif [ "$t_FLAG" = "n" ]; then 13716b72f1c0SJohn Levon # 13726b72f1c0SJohn Levon # We're not doing a tools build, so make sure elfsign(1) is 13736b72f1c0SJohn Levon # new enough to safely sign non-crypto binaries. We test 13746b72f1c0SJohn Levon # debugging output from elfsign to detect the old version. 13756b72f1c0SJohn Levon # 13766b72f1c0SJohn Levon newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 13776b72f1c0SJohn Levon -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 13786b72f1c0SJohn Levon | egrep algorithmOID` 13796b72f1c0SJohn Levon if [ -z "$newelfsigntest" ]; then 13806b72f1c0SJohn Levon echo "WARNING: /usr/bin/elfsign out of date;" \ 13816b72f1c0SJohn Levon "will only sign crypto modules\n" | \ 13826b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13836b72f1c0SJohn Levon export ELFSIGN_OBJECT=true 13846b72f1c0SJohn Levon elif [ "$VERIFY_ELFSIGN" = "y" ]; then 13856b72f1c0SJohn Levon echo "WARNING: VERIFY_ELFSIGN=y requires" \ 13866b72f1c0SJohn Levon "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 13876b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13886b72f1c0SJohn Levon fi 13896b72f1c0SJohn Levonfi 13906b72f1c0SJohn Levon 13916b72f1c0SJohn Levoncase $MULTI_PROTO in 13926b72f1c0SJohn Levonyes|no) ;; 13936b72f1c0SJohn Levon*) 13946b72f1c0SJohn Levon echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 13956b72f1c0SJohn Levon "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 13966b72f1c0SJohn Levon echo "Setting MULTI_PROTO to \"no\".\n" | \ 13976b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 13986b72f1c0SJohn Levon export MULTI_PROTO=no 13996b72f1c0SJohn Levon ;; 14006b72f1c0SJohn Levonesac 14016b72f1c0SJohn Levon 14026b72f1c0SJohn Levonecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 14036b72f1c0SJohn Levonecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 14046b72f1c0SJohn Levon 14056b72f1c0SJohn Levon# Save the current proto area if we're comparing against the last build 14066b72f1c0SJohn Levonif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 14076b72f1c0SJohn Levon if [ -d "$ROOT.prev" ]; then 14086b72f1c0SJohn Levon rm -rf $ROOT.prev 14096b72f1c0SJohn Levon fi 14106b72f1c0SJohn Levon mv $ROOT $ROOT.prev 14116b72f1c0SJohn Levonfi 14126b72f1c0SJohn Levon 14136b72f1c0SJohn Levon# Same for non-DEBUG proto area 14146b72f1c0SJohn Levonif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 14156b72f1c0SJohn Levon if [ -d "$ROOT-nd.prev" ]; then 14166b72f1c0SJohn Levon rm -rf $ROOT-nd.prev 14176b72f1c0SJohn Levon fi 14186b72f1c0SJohn Levon mv $ROOT-nd $ROOT-nd.prev 14196b72f1c0SJohn Levonfi 14206b72f1c0SJohn Levon 1421*69ce05a9SMarcel Telka# Same for tools proto area 1422*69ce05a9SMarcel Telkaif [ "$w_FLAG" = "y" -a "$t_FLAG" == "y" -a -d "$TOOLS_PROTO" ]; then 1423*69ce05a9SMarcel Telka if [ -d "$TOOLS_PROTO.prev" ]; then 1424*69ce05a9SMarcel Telka rm -rf $TOOLS_PROTO.prev 1425*69ce05a9SMarcel Telka fi 1426*69ce05a9SMarcel Telka mv $TOOLS_PROTO $TOOLS_PROTO.prev 1427*69ce05a9SMarcel Telkafi 1428*69ce05a9SMarcel Telka 14296b72f1c0SJohn Levon# 14306b72f1c0SJohn Levon# Echo the SCM type of the parent workspace, this can't just be which_scm 14316b72f1c0SJohn Levon# as that does not know how to identify various network repositories. 14326b72f1c0SJohn Levon# 14336b72f1c0SJohn Levonfunction parent_wstype { 14346b72f1c0SJohn Levon typeset scm_type junk 14356b72f1c0SJohn Levon 14366b72f1c0SJohn Levon CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 14376b72f1c0SJohn Levon | read scm_type junk 14386b72f1c0SJohn Levon if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 14396b72f1c0SJohn Levon # Probe BRINGOVER_WS to determine its type 14406b72f1c0SJohn Levon if [[ $BRINGOVER_WS == ssh://* ]]; then 14416b72f1c0SJohn Levon scm_type="mercurial" 14426b72f1c0SJohn Levon elif [[ $BRINGOVER_WS == http://* ]] && \ 14436b72f1c0SJohn Levon wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 14446b72f1c0SJohn Levon egrep -s "application/mercurial" 2> /dev/null; then 14456b72f1c0SJohn Levon scm_type="mercurial" 14466b72f1c0SJohn Levon else 14476b72f1c0SJohn Levon scm_type="none" 14486b72f1c0SJohn Levon fi 14496b72f1c0SJohn Levon fi 14506b72f1c0SJohn Levon 14516b72f1c0SJohn Levon # fold both unsupported and unrecognized results into "none" 14526b72f1c0SJohn Levon case "$scm_type" in 14536b72f1c0SJohn Levon mercurial) 14546b72f1c0SJohn Levon ;; 14556b72f1c0SJohn Levon *) scm_type=none 14566b72f1c0SJohn Levon ;; 14576b72f1c0SJohn Levon esac 14586b72f1c0SJohn Levon 14596b72f1c0SJohn Levon echo $scm_type 14606b72f1c0SJohn Levon} 14616b72f1c0SJohn Levon 14626b72f1c0SJohn Levon# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 14636b72f1c0SJohn Levonfunction child_wstype { 14646b72f1c0SJohn Levon typeset scm_type junk 14656b72f1c0SJohn Levon 14666b72f1c0SJohn Levon # Probe CODEMGR_WS to determine its type 14676b72f1c0SJohn Levon if [[ -d $CODEMGR_WS ]]; then 14686b72f1c0SJohn Levon $WHICH_SCM | read scm_type junk || exit 1 14696b72f1c0SJohn Levon fi 14706b72f1c0SJohn Levon 14716b72f1c0SJohn Levon case "$scm_type" in 14726b72f1c0SJohn Levon none|git|mercurial) 14736b72f1c0SJohn Levon ;; 14746b72f1c0SJohn Levon *) scm_type=none 14756b72f1c0SJohn Levon ;; 14766b72f1c0SJohn Levon esac 14776b72f1c0SJohn Levon 14786b72f1c0SJohn Levon echo $scm_type 14796b72f1c0SJohn Levon} 14806b72f1c0SJohn Levon 14816b72f1c0SJohn LevonSCM_TYPE=$(child_wstype) 14826b72f1c0SJohn Levon 14836b72f1c0SJohn Levon# 14846b72f1c0SJohn Levon# Decide whether to clobber 14856b72f1c0SJohn Levon# 14866b72f1c0SJohn Levonif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 14876b72f1c0SJohn Levon echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 14886b72f1c0SJohn Levon 14896b72f1c0SJohn Levon cd $SRC 14906b72f1c0SJohn Levon # remove old clobber file 14916b72f1c0SJohn Levon rm -f $SRC/clobber.out 14926b72f1c0SJohn Levon rm -f $SRC/clobber-${MACH}.out 14936b72f1c0SJohn Levon 14946b72f1c0SJohn Levon # Remove all .make.state* files, just in case we are restarting 14956b72f1c0SJohn Levon # the build after having interrupted a previous 'make clobber'. 14966b72f1c0SJohn Levon find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 14976b72f1c0SJohn Levon -o -name 'interfaces.*' \) -prune \ 14986b72f1c0SJohn Levon -o -name '.make.*' -print | xargs rm -f 14996b72f1c0SJohn Levon 15006b72f1c0SJohn Levon $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 15016b72f1c0SJohn Levon echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 15026b72f1c0SJohn Levon grep "$MAKE:" $SRC/clobber-${MACH}.out | 15036b72f1c0SJohn Levon egrep -v "Ignoring unknown host" | \ 15046b72f1c0SJohn Levon tee $TMPDIR/clobber_errs >> $mail_msg_file 15056b72f1c0SJohn Levon 15066b72f1c0SJohn Levon if [[ -s $TMPDIR/clobber_errs ]]; then 15076b72f1c0SJohn Levon build_extras_ok=n 15086b72f1c0SJohn Levon fi 15096b72f1c0SJohn Levon 15106b72f1c0SJohn Levon if [[ "$t_FLAG" = "y" ]]; then 15116b72f1c0SJohn Levon echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 15126b72f1c0SJohn Levon cd ${TOOLS} 15136b72f1c0SJohn Levon rm -f ${TOOLS}/clobber-${MACH}.out 15146b72f1c0SJohn Levon $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 15156b72f1c0SJohn Levon tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 15166b72f1c0SJohn Levon echo "\n==== Make tools clobber ERRORS ====\n" \ 15176b72f1c0SJohn Levon >> $mail_msg_file 15186b72f1c0SJohn Levon grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 15196b72f1c0SJohn Levon >> $mail_msg_file 15206b72f1c0SJohn Levon if (( $? == 0 )); then 15216b72f1c0SJohn Levon build_extras_ok=n 15226b72f1c0SJohn Levon fi 15236b72f1c0SJohn Levon rm -rf ${TOOLS_PROTO} 15246b72f1c0SJohn Levon mkdir -p ${TOOLS_PROTO} 15256b72f1c0SJohn Levon fi 15266b72f1c0SJohn Levon 15276b72f1c0SJohn Levon typeset roots=$(allprotos) 15286b72f1c0SJohn Levon echo "\n\nClearing $roots" >> "$LOGFILE" 15296b72f1c0SJohn Levon rm -rf $roots 15306b72f1c0SJohn Levon 15316b72f1c0SJohn Levon # Get back to a clean workspace as much as possible to catch 15326b72f1c0SJohn Levon # problems that only occur on fresh workspaces. 15336b72f1c0SJohn Levon # Remove all .make.state* files, libraries, and .o's that may 15346b72f1c0SJohn Levon # have been omitted from clobber. A couple of libraries are 15356b72f1c0SJohn Levon # under source code control, so leave them alone. 15366b72f1c0SJohn Levon # We should probably blow away temporary directories too. 15376b72f1c0SJohn Levon cd $SRC 15386b72f1c0SJohn Levon find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 15396b72f1c0SJohn Levon -o -name .git -o -name 'interfaces.*' \) -prune -o \ 15406b72f1c0SJohn Levon \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 15416b72f1c0SJohn Levon -name '*.o' \) -print | \ 15426b72f1c0SJohn Levon grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 15436b72f1c0SJohn Levonelse 15446b72f1c0SJohn Levon echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 15456b72f1c0SJohn Levonfi 15466b72f1c0SJohn Levon 15476b72f1c0SJohn Levontype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 15486b72f1c0SJohn Levon typeset -x PATH=$PATH 15496b72f1c0SJohn Levon 15506b72f1c0SJohn Levon # If the repository doesn't exist yet, then we want to populate it. 15516b72f1c0SJohn Levon if [[ ! -d $CODEMGR_WS/.hg ]]; then 15526b72f1c0SJohn Levon staffer hg init $CODEMGR_WS 15536b72f1c0SJohn Levon staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 15546b72f1c0SJohn Levon staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 15556b72f1c0SJohn Levon touch $TMPDIR/new_repository 15566b72f1c0SJohn Levon fi 15576b72f1c0SJohn Levon 15586b72f1c0SJohn Levon typeset -x HGMERGE="/bin/false" 15596b72f1c0SJohn Levon 15606b72f1c0SJohn Levon # 15616b72f1c0SJohn Levon # If the user has changes, regardless of whether those changes are 15626b72f1c0SJohn Levon # committed, and regardless of whether those changes conflict, then 15636b72f1c0SJohn Levon # we'll attempt to merge them either implicitly (uncommitted) or 15646b72f1c0SJohn Levon # explicitly (committed). 15656b72f1c0SJohn Levon # 15666b72f1c0SJohn Levon # These are the messages we'll use to help clarify mercurial output 15676b72f1c0SJohn Levon # in those cases. 15686b72f1c0SJohn Levon # 15696b72f1c0SJohn Levon typeset mergefailmsg="\ 15706b72f1c0SJohn Levon***\n\ 15716b72f1c0SJohn Levon*** nightly was unable to automatically merge your changes. You should\n\ 15726b72f1c0SJohn Levon*** redo the full merge manually, following the steps outlined by mercurial\n\ 15736b72f1c0SJohn Levon*** above, then restart nightly.\n\ 15746b72f1c0SJohn Levon***\n" 15756b72f1c0SJohn Levon typeset mergepassmsg="\ 15766b72f1c0SJohn Levon***\n\ 15776b72f1c0SJohn Levon*** nightly successfully merged your changes. This means that your working\n\ 15786b72f1c0SJohn Levon*** directory has been updated, but those changes are not yet committed.\n\ 15796b72f1c0SJohn Levon*** After nightly completes, you should validate the results of the merge,\n\ 15806b72f1c0SJohn Levon*** then use hg commit manually.\n\ 15816b72f1c0SJohn Levon***\n" 15826b72f1c0SJohn Levon 15836b72f1c0SJohn Levon # 15846b72f1c0SJohn Levon # For each repository in turn: 15856b72f1c0SJohn Levon # 15866b72f1c0SJohn Levon # 1. Do the pull. If this fails, dump the output and bail out. 15876b72f1c0SJohn Levon # 15886b72f1c0SJohn Levon # 2. If the pull resulted in an extra head, do an explicit merge. 15896b72f1c0SJohn Levon # If this fails, dump the output and bail out. 15906b72f1c0SJohn Levon # 15916b72f1c0SJohn Levon # Because we can't rely on Mercurial to exit with a failure code 15926b72f1c0SJohn Levon # when a merge fails (Mercurial issue #186), we must grep the 15936b72f1c0SJohn Levon # output of pull/merge to check for attempted and/or failed merges. 15946b72f1c0SJohn Levon # 15956b72f1c0SJohn Levon # 3. If a merge failed, set the message and fail the bringover. 15966b72f1c0SJohn Levon # 15976b72f1c0SJohn Levon # 4. Otherwise, if a merge succeeded, set the message 15986b72f1c0SJohn Levon # 15996b72f1c0SJohn Levon # 5. Dump the output, and any message from step 3 or 4. 16006b72f1c0SJohn Levon # 16016b72f1c0SJohn Levon 16026b72f1c0SJohn Levon typeset HG_SOURCE=$BRINGOVER_WS 16036b72f1c0SJohn Levon if [ ! -f $TMPDIR/new_repository ]; then 16046b72f1c0SJohn Levon HG_SOURCE=$TMPDIR/open_bundle.hg 16056b72f1c0SJohn Levon staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 16066b72f1c0SJohn Levon -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 16076b72f1c0SJohn Levon 16086b72f1c0SJohn Levon # 16096b72f1c0SJohn Levon # If there are no incoming changesets, then incoming will 16106b72f1c0SJohn Levon # fail, and there will be no bundle file. Reset the source, 16116b72f1c0SJohn Levon # to allow the remaining logic to complete with no false 16126b72f1c0SJohn Levon # negatives. (Unlike incoming, pull will return success 16136b72f1c0SJohn Levon # for the no-change case.) 16146b72f1c0SJohn Levon # 16156b72f1c0SJohn Levon if (( $? != 0 )); then 16166b72f1c0SJohn Levon HG_SOURCE=$BRINGOVER_WS 16176b72f1c0SJohn Levon fi 16186b72f1c0SJohn Levon fi 16196b72f1c0SJohn Levon 16206b72f1c0SJohn Levon staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 16216b72f1c0SJohn Levon > $TMPDIR/pull_open.out 2>&1 16226b72f1c0SJohn Levon if (( $? != 0 )); then 16236b72f1c0SJohn Levon printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 16246b72f1c0SJohn Levon cat $TMPDIR/pull_open.out 16256b72f1c0SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16266b72f1c0SJohn Levon printf "$mergefailmsg" 16276b72f1c0SJohn Levon fi 16286b72f1c0SJohn Levon touch $TMPDIR/bringover_failed 16296b72f1c0SJohn Levon return 16306b72f1c0SJohn Levon fi 16316b72f1c0SJohn Levon 16326b72f1c0SJohn Levon if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16336b72f1c0SJohn Levon staffer hg --cwd $CODEMGR_WS merge \ 16346b72f1c0SJohn Levon >> $TMPDIR/pull_open.out 2>&1 16356b72f1c0SJohn Levon if (( $? != 0 )); then 16366b72f1c0SJohn Levon printf "%s: merge failed as follows:\n\n" \ 16376b72f1c0SJohn Levon "$CODEMGR_WS" 16386b72f1c0SJohn Levon cat $TMPDIR/pull_open.out 16396b72f1c0SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out \ 16406b72f1c0SJohn Levon > /dev/null 2>&1; then 16416b72f1c0SJohn Levon printf "$mergefailmsg" 16426b72f1c0SJohn Levon fi 16436b72f1c0SJohn Levon touch $TMPDIR/bringover_failed 16446b72f1c0SJohn Levon return 16456b72f1c0SJohn Levon fi 16466b72f1c0SJohn Levon fi 16476b72f1c0SJohn Levon 16486b72f1c0SJohn Levon printf "updated %s with the following results:\n" "$CODEMGR_WS" 16496b72f1c0SJohn Levon cat $TMPDIR/pull_open.out 16506b72f1c0SJohn Levon if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 16516b72f1c0SJohn Levon printf "$mergepassmsg" 16526b72f1c0SJohn Levon fi 16536b72f1c0SJohn Levon printf "\n" 16546b72f1c0SJohn Levon 16556b72f1c0SJohn Levon # 16566b72f1c0SJohn Levon # Per-changeset output is neither useful nor manageable for a 16576b72f1c0SJohn Levon # newly-created repository. 16586b72f1c0SJohn Levon # 16596b72f1c0SJohn Levon if [ -f $TMPDIR/new_repository ]; then 16606b72f1c0SJohn Levon return 16616b72f1c0SJohn Levon fi 16626b72f1c0SJohn Levon 16636b72f1c0SJohn Levon printf "\nadded the following changesets to open repository:\n" 16646b72f1c0SJohn Levon cat $TMPDIR/incoming_open.out 16656b72f1c0SJohn Levon} 16666b72f1c0SJohn Levon 16676b72f1c0SJohn Levontype bringover_none > /dev/null 2>&1 || function bringover_none { 16686b72f1c0SJohn Levon echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 16696b72f1c0SJohn Levon touch $TMPDIR/bringover_failed 16706b72f1c0SJohn Levon} 16716b72f1c0SJohn Levon 16726b72f1c0SJohn Levon# 16736b72f1c0SJohn Levon# Decide whether to bringover to the codemgr workspace 16746b72f1c0SJohn Levon# 16756b72f1c0SJohn Levonif [ "$n_FLAG" = "n" ]; then 16766b72f1c0SJohn Levon PARENT_SCM_TYPE=$(parent_wstype) 16776b72f1c0SJohn Levon 16786b72f1c0SJohn Levon if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 16796b72f1c0SJohn Levon echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 16806b72f1c0SJohn Levon "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 16816b72f1c0SJohn Levon exit 1 16826b72f1c0SJohn Levon fi 16836b72f1c0SJohn Levon 16846b72f1c0SJohn Levon run_hook PRE_BRINGOVER 16856b72f1c0SJohn Levon 16866b72f1c0SJohn Levon echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 16876b72f1c0SJohn Levon echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 16886b72f1c0SJohn Levon 16896b72f1c0SJohn Levon eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 16906b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 16916b72f1c0SJohn Levon 16926b72f1c0SJohn Levon if [ -f $TMPDIR/bringover_failed ]; then 16936b72f1c0SJohn Levon rm -f $TMPDIR/bringover_failed 16946b72f1c0SJohn Levon build_ok=n 16956b72f1c0SJohn Levon echo "trouble with bringover, quitting at `date`." | 16966b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 16976b72f1c0SJohn Levon exit 1 16986b72f1c0SJohn Levon fi 16996b72f1c0SJohn Levon 17006b72f1c0SJohn Levon # 17016b72f1c0SJohn Levon # It's possible that we used the bringover above to create 17026b72f1c0SJohn Levon # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 17036b72f1c0SJohn Levon # but should now be the same as $BRINGOVER_WS. 17046b72f1c0SJohn Levon # 17056b72f1c0SJohn Levon [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 17066b72f1c0SJohn Levon 17076b72f1c0SJohn Levon run_hook POST_BRINGOVER 17086b72f1c0SJohn Levon 17096b72f1c0SJohn Levon check_closed_bins 17106b72f1c0SJohn Levon 17116b72f1c0SJohn Levonelse 17126b72f1c0SJohn Levon echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 17136b72f1c0SJohn Levonfi 17146b72f1c0SJohn Levon 17156b72f1c0SJohn Levon# Safeguards 17166b72f1c0SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 17176b72f1c0SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 17186b72f1c0SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 17196b72f1c0SJohn Levon 17206b72f1c0SJohn Levonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 17216b72f1c0SJohn Levon 17226b72f1c0SJohn Levon# System 17236b72f1c0SJohn Levonwhence uname | tee -a $build_environ_file >> $LOGFILE 17246b72f1c0SJohn Levonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 17256b72f1c0SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 17266b72f1c0SJohn Levon 17276b72f1c0SJohn Levon# make 17286b72f1c0SJohn Levonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 17296b72f1c0SJohn Levon$MAKE -v | tee -a $build_environ_file >> $LOGFILE 17306b72f1c0SJohn Levonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 17316b72f1c0SJohn Levon tee -a $build_environ_file >> $LOGFILE 17326b72f1c0SJohn Levon 17336b72f1c0SJohn Levon# 17346b72f1c0SJohn Levon# Report the compiler versions. 17356b72f1c0SJohn Levon# 17366b72f1c0SJohn Levon 17376b72f1c0SJohn Levonif [[ ! -f $SRC/Makefile ]]; then 17386b72f1c0SJohn Levon build_ok=n 17396b72f1c0SJohn Levon echo "\nUnable to find \"Makefile\" in $SRC." | \ 17406b72f1c0SJohn Levon tee -a $build_environ_file >> $LOGFILE 17416b72f1c0SJohn Levon exit 1 17426b72f1c0SJohn Levonfi 17436b72f1c0SJohn Levon 17446b72f1c0SJohn Levon( cd $SRC 17456b72f1c0SJohn Levon for target in cc-version cc64-version java-version; do 17466b72f1c0SJohn Levon echo 17476b72f1c0SJohn Levon # 17486b72f1c0SJohn Levon # Put statefile somewhere we know we can write to rather than trip 17496b72f1c0SJohn Levon # over a read-only $srcroot. 17506b72f1c0SJohn Levon # 17516b72f1c0SJohn Levon rm -f $TMPDIR/make-state 17526b72f1c0SJohn Levon export SRC 17536b72f1c0SJohn Levon if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 17546b72f1c0SJohn Levon continue 17556b72f1c0SJohn Levon fi 17566b72f1c0SJohn Levon touch $TMPDIR/nocompiler 17576b72f1c0SJohn Levon done 17586b72f1c0SJohn Levon echo 17596b72f1c0SJohn Levon) | tee -a $build_environ_file >> $LOGFILE 17606b72f1c0SJohn Levon 17616b72f1c0SJohn Levonif [ -f $TMPDIR/nocompiler ]; then 17626b72f1c0SJohn Levon rm -f $TMPDIR/nocompiler 17636b72f1c0SJohn Levon build_ok=n 17646b72f1c0SJohn Levon echo "Aborting due to missing compiler." | 17656b72f1c0SJohn Levon tee -a $build_environ_file >> $LOGFILE 17666b72f1c0SJohn Levon exit 1 17676b72f1c0SJohn Levonfi 17686b72f1c0SJohn Levon 17696b72f1c0SJohn Levon# as 17706b72f1c0SJohn Levonwhence as | tee -a $build_environ_file >> $LOGFILE 17716b72f1c0SJohn Levonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 17726b72f1c0SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 17736b72f1c0SJohn Levon 17746b72f1c0SJohn Levon# Check that we're running a capable link-editor 17756b72f1c0SJohn Levonwhence ld | tee -a $build_environ_file >> $LOGFILE 17766b72f1c0SJohn LevonLDVER=`ld -V 2>&1` 17776b72f1c0SJohn Levonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 17786b72f1c0SJohn LevonLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 17796b72f1c0SJohn Levonif [ `expr $LDVER \< 422` -eq 1 ]; then 17806b72f1c0SJohn Levon echo "The link-editor needs to be at version 422 or higher to build" | \ 17816b72f1c0SJohn Levon tee -a $build_environ_file >> $LOGFILE 17826b72f1c0SJohn Levon echo "the latest stuff. Hope your build works." | \ 17836b72f1c0SJohn Levon tee -a $build_environ_file >> $LOGFILE 17846b72f1c0SJohn Levonfi 17856b72f1c0SJohn Levon 17866b72f1c0SJohn Levon# 17876b72f1c0SJohn Levon# Build and use the workspace's tools if requested 17886b72f1c0SJohn Levon# 17896b72f1c0SJohn Levonif [[ "$t_FLAG" = "y" ]]; then 17906b72f1c0SJohn Levon set_non_debug_build_flags 17916b72f1c0SJohn Levon 17926b72f1c0SJohn Levon build_tools ${TOOLS_PROTO} 17936b72f1c0SJohn Levon if (( $? != 0 )); then 17946b72f1c0SJohn Levon build_ok=n 17956b72f1c0SJohn Levon else 17966b72f1c0SJohn Levon use_tools $TOOLS_PROTO 17976b72f1c0SJohn Levon fi 17986b72f1c0SJohn Levonfi 17996b72f1c0SJohn Levon 18006b72f1c0SJohn Levon# timestamp the start of the normal build; the findunref tool uses it. 18016b72f1c0SJohn Levontouch $SRC/.build.tstamp 18026b72f1c0SJohn Levon 18036b72f1c0SJohn Levonnormal_build 18046b72f1c0SJohn Levon 18056b72f1c0SJohn LevonORIG_SRC=$SRC 18066b72f1c0SJohn LevonBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 18076b72f1c0SJohn Levon 18086b72f1c0SJohn Levon 18096b72f1c0SJohn Levon# 18106b72f1c0SJohn Levon# There are several checks that need to look at the proto area, but 18116b72f1c0SJohn Levon# they only need to look at one, and they don't care whether it's 18126b72f1c0SJohn Levon# DEBUG or non-DEBUG. 18136b72f1c0SJohn Levon# 18146b72f1c0SJohn Levonif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 18156b72f1c0SJohn Levon checkroot=$ROOT-nd 18166b72f1c0SJohn Levonelse 18176b72f1c0SJohn Levon checkroot=$ROOT 18186b72f1c0SJohn Levonfi 18196b72f1c0SJohn Levon 18206b72f1c0SJohn Levonif [ "$build_ok" = "y" ]; then 18216b72f1c0SJohn Levon echo "\n==== Creating protolist system file at `date` ====" \ 18226b72f1c0SJohn Levon >> $LOGFILE 18236b72f1c0SJohn Levon protolist $checkroot > $ATLOG/proto_list_${MACH} 18246b72f1c0SJohn Levon echo "==== protolist system file created at `date` ====\n" \ 18256b72f1c0SJohn Levon >> $LOGFILE 18266b72f1c0SJohn Levon 18276b72f1c0SJohn Levon if [ "$N_FLAG" != "y" ]; then 18286b72f1c0SJohn Levon 18296b72f1c0SJohn Levon E1= 18306b72f1c0SJohn Levon f1= 18316b72f1c0SJohn Levon for f in $f1; do 18326b72f1c0SJohn Levon if [ -f "$f" ]; then 18336b72f1c0SJohn Levon E1="$E1 -e $f" 18346b72f1c0SJohn Levon fi 18356b72f1c0SJohn Levon done 18366b72f1c0SJohn Levon 18376b72f1c0SJohn Levon E2= 18386b72f1c0SJohn Levon f2= 18396b72f1c0SJohn Levon if [ -d "$SRC/pkg" ]; then 18406b72f1c0SJohn Levon f2="$f2 exceptions/packaging" 18416b72f1c0SJohn Levon fi 18426b72f1c0SJohn Levon 18436b72f1c0SJohn Levon for f in $f2; do 18446b72f1c0SJohn Levon if [ -f "$f" ]; then 18456b72f1c0SJohn Levon E2="$E2 -e $f" 18466b72f1c0SJohn Levon fi 18476b72f1c0SJohn Levon done 18486b72f1c0SJohn Levon fi 18496b72f1c0SJohn Levon 18506b72f1c0SJohn Levon if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 18516b72f1c0SJohn Levon echo "\n==== Validating manifests against proto area ====\n" \ 18526b72f1c0SJohn Levon >> $mail_msg_file 18536b72f1c0SJohn Levon ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 18546b72f1c0SJohn Levon tee $TMPDIR/protocmp_noise >> $mail_msg_file 18556b72f1c0SJohn Levon if [[ -s $TMPDIR/protocmp_noise ]]; then 18566b72f1c0SJohn Levon build_extras_ok=n 18576b72f1c0SJohn Levon fi 18586b72f1c0SJohn Levon fi 18596b72f1c0SJohn Levon 18606b72f1c0SJohn Levon if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 18616b72f1c0SJohn Levon echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 18626b72f1c0SJohn Levon if [ -n "$E2" ]; then 18636b72f1c0SJohn Levon ELIST=$E2 18646b72f1c0SJohn Levon else 18656b72f1c0SJohn Levon ELIST=$E1 18666b72f1c0SJohn Levon fi 18676b72f1c0SJohn Levon $PROTOCMPTERSE \ 18686b72f1c0SJohn Levon "Files in yesterday's proto area, but not today's:" \ 18696b72f1c0SJohn Levon "Files in today's proto area, but not yesterday's:" \ 18706b72f1c0SJohn Levon "Files that changed between yesterday and today:" \ 18716b72f1c0SJohn Levon ${ELIST} \ 18726b72f1c0SJohn Levon -d $REF_PROTO_LIST \ 18736b72f1c0SJohn Levon $ATLOG/proto_list_${MACH} \ 18746b72f1c0SJohn Levon >> $mail_msg_file 18756b72f1c0SJohn Levon fi 18766b72f1c0SJohn Levonfi 18776b72f1c0SJohn Levon 18786b72f1c0SJohn Levonif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 18796b72f1c0SJohn Levon "$build_extras_ok" == "y" ]]; then 18806b72f1c0SJohn Levon staffer cp $ATLOG/proto_list_${MACH} \ 18816b72f1c0SJohn Levon $PARENT_WS/usr/src/proto_list_${MACH} 18826b72f1c0SJohn Levonfi 18836b72f1c0SJohn Levon 18846b72f1c0SJohn Levon# Update parent proto area if necessary. This is done now 18856b72f1c0SJohn Levon# so that the proto area has either DEBUG or non-DEBUG kernels. 18866b72f1c0SJohn Levon# Note that this clears out the lock file, so we can dispense with 18876b72f1c0SJohn Levon# the variable now. 18886b72f1c0SJohn Levonif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 18896b72f1c0SJohn Levon echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 18906b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 18916b72f1c0SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT/* 18926b72f1c0SJohn Levon unset Ulockfile 18936b72f1c0SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT 18946b72f1c0SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 18956b72f1c0SJohn Levon ( cd $ROOT; tar cf - . | 18966b72f1c0SJohn Levon ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 18976b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 18986b72f1c0SJohn Levon fi 18996b72f1c0SJohn Levon if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 19006b72f1c0SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT-nd/* 19016b72f1c0SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT-nd 19026b72f1c0SJohn Levon cd $ROOT-nd 19036b72f1c0SJohn Levon ( tar cf - . | 19046b72f1c0SJohn Levon ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 19056b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 19066b72f1c0SJohn Levon fi 19076b72f1c0SJohn Levon if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 19086b72f1c0SJohn Levon echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 19096b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19106b72f1c0SJohn Levon rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 19116b72f1c0SJohn Levon mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 19126b72f1c0SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 19136b72f1c0SJohn Levon ( cd $TOOLS_PROTO; tar cf - . | 19146b72f1c0SJohn Levon ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 19156b72f1c0SJohn Levon umask 0; tar xpf - ) ) 2>&1 | 19166b72f1c0SJohn Levon tee -a $mail_msg_file >> $LOGFILE 19176b72f1c0SJohn Levon fi 19186b72f1c0SJohn Levon fi 19196b72f1c0SJohn Levonfi 19206b72f1c0SJohn Levon 19216b72f1c0SJohn Levon# 19226b72f1c0SJohn Levon# ELF verification: ABI (-A) and runtime (-r) checks 19236b72f1c0SJohn Levon# 19246b72f1c0SJohn Levonif [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 19256b72f1c0SJohn Levon # Directory ELF-data.$MACH holds the files produced by these tests. 19266b72f1c0SJohn Levon elf_ddir=$SRC/ELF-data.$MACH 19276b72f1c0SJohn Levon 19286b72f1c0SJohn Levon # If there is a previous ELF-data backup directory, remove it. Then, 19296b72f1c0SJohn Levon # rotate current ELF-data directory into its place and create a new 19306b72f1c0SJohn Levon # empty directory 19316b72f1c0SJohn Levon rm -rf $elf_ddir.ref 19326b72f1c0SJohn Levon if [[ -d $elf_ddir ]]; then 19336b72f1c0SJohn Levon mv $elf_ddir $elf_ddir.ref 19346b72f1c0SJohn Levon fi 19356b72f1c0SJohn Levon mkdir -p $elf_ddir 19366b72f1c0SJohn Levon 19376b72f1c0SJohn Levon # Call find_elf to produce a list of the ELF objects in the proto area. 19386b72f1c0SJohn Levon # This list is passed to check_rtime and interface_check, preventing 19396b72f1c0SJohn Levon # them from separately calling find_elf to do the same work twice. 19406b72f1c0SJohn Levon find_elf -fr $checkroot > $elf_ddir/object_list 19416b72f1c0SJohn Levon 19426b72f1c0SJohn Levon if [[ $A_FLAG = y ]]; then 19436b72f1c0SJohn Levon echo "\n==== Check versioning and ABI information ====\n" | \ 19446b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19456b72f1c0SJohn Levon 19466b72f1c0SJohn Levon # Produce interface description for the proto. Report errors. 19476b72f1c0SJohn Levon interface_check -o -w $elf_ddir -f object_list \ 19486b72f1c0SJohn Levon -i interface -E interface.err 19496b72f1c0SJohn Levon if [[ -s $elf_ddir/interface.err ]]; then 19506b72f1c0SJohn Levon tee -a $LOGFILE < $elf_ddir/interface.err \ 19516b72f1c0SJohn Levon >> $mail_msg_file 19526b72f1c0SJohn Levon build_extras_ok=n 19536b72f1c0SJohn Levon fi 19546b72f1c0SJohn Levon 19556b72f1c0SJohn Levon # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 19566b72f1c0SJohn Levon # description file to that from the baseline gate. Issue a 19576b72f1c0SJohn Levon # warning if the baseline is not present, and keep going. 19586b72f1c0SJohn Levon if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 19596b72f1c0SJohn Levon base_ifile="$ELF_DATA_BASELINE_DIR/interface" 19606b72f1c0SJohn Levon 19616b72f1c0SJohn Levon echo "\n==== Compare versioning and ABI information" \ 19626b72f1c0SJohn Levon "to baseline ====\n" | \ 19636b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19646b72f1c0SJohn Levon echo "Baseline: $base_ifile\n" >> $LOGFILE 19656b72f1c0SJohn Levon 19666b72f1c0SJohn Levon if [[ -f $base_ifile ]]; then 19676b72f1c0SJohn Levon interface_cmp -d -o $base_ifile \ 19686b72f1c0SJohn Levon $elf_ddir/interface > $elf_ddir/interface.cmp 19696b72f1c0SJohn Levon if [[ -s $elf_ddir/interface.cmp ]]; then 19706b72f1c0SJohn Levon echo | tee -a $LOGFILE >> $mail_msg_file 19716b72f1c0SJohn Levon tee -a $LOGFILE < \ 19726b72f1c0SJohn Levon $elf_ddir/interface.cmp \ 19736b72f1c0SJohn Levon >> $mail_msg_file 19746b72f1c0SJohn Levon build_extras_ok=n 19756b72f1c0SJohn Levon fi 19766b72f1c0SJohn Levon else 19776b72f1c0SJohn Levon echo "baseline not available. comparison" \ 19786b72f1c0SJohn Levon "skipped" | \ 19796b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19806b72f1c0SJohn Levon fi 19816b72f1c0SJohn Levon 19826b72f1c0SJohn Levon fi 19836b72f1c0SJohn Levon fi 19846b72f1c0SJohn Levon 19856b72f1c0SJohn Levon if [[ $r_FLAG = y ]]; then 19866b72f1c0SJohn Levon echo "\n==== Check ELF runtime attributes ====\n" | \ 19876b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 19886b72f1c0SJohn Levon 19896b72f1c0SJohn Levon # If we're doing a DEBUG build the proto area will be left 19906b72f1c0SJohn Levon # with debuggable objects, thus don't assert -s. 19916b72f1c0SJohn Levon if [[ $D_FLAG = y ]]; then 19926b72f1c0SJohn Levon rtime_sflag="" 19936b72f1c0SJohn Levon else 19946b72f1c0SJohn Levon rtime_sflag="-s" 19956b72f1c0SJohn Levon fi 19966b72f1c0SJohn Levon check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 19976b72f1c0SJohn Levon -D object_list -f object_list -E runtime.err \ 19986b72f1c0SJohn Levon -I runtime.attr.raw 19996b72f1c0SJohn Levon if (( $? != 0 )); then 20006b72f1c0SJohn Levon build_extras_ok=n 20016b72f1c0SJohn Levon fi 20026b72f1c0SJohn Levon 20036b72f1c0SJohn Levon # check_rtime -I output needs to be sorted in order to 20046b72f1c0SJohn Levon # compare it to that from previous builds. 20056b72f1c0SJohn Levon sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 20066b72f1c0SJohn Levon rm $elf_ddir/runtime.attr.raw 20076b72f1c0SJohn Levon 20086b72f1c0SJohn Levon # Report errors 20096b72f1c0SJohn Levon if [[ -s $elf_ddir/runtime.err ]]; then 20106b72f1c0SJohn Levon tee -a $LOGFILE < $elf_ddir/runtime.err \ 20116b72f1c0SJohn Levon >> $mail_msg_file 20126b72f1c0SJohn Levon build_extras_ok=n 20136b72f1c0SJohn Levon fi 20146b72f1c0SJohn Levon 20156b72f1c0SJohn Levon # If there is an ELF-data directory from a previous build, 20166b72f1c0SJohn Levon # then diff the attr files. These files contain information 20176b72f1c0SJohn Levon # about dependencies, versioning, and runpaths. There is some 20186b72f1c0SJohn Levon # overlap with the ABI checking done above, but this also 20196b72f1c0SJohn Levon # flushes out non-ABI interface differences along with the 20206b72f1c0SJohn Levon # other information. 20216b72f1c0SJohn Levon echo "\n==== Diff ELF runtime attributes" \ 20226b72f1c0SJohn Levon "(since last build) ====\n" | \ 20236b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 20246b72f1c0SJohn Levon 20256b72f1c0SJohn Levon if [[ -f $elf_ddir.ref/runtime.attr ]]; then 20266b72f1c0SJohn Levon diff $elf_ddir.ref/runtime.attr \ 20276b72f1c0SJohn Levon $elf_ddir/runtime.attr \ 20286b72f1c0SJohn Levon >> $mail_msg_file 20296b72f1c0SJohn Levon fi 20306b72f1c0SJohn Levon fi 20316b72f1c0SJohn Levon 20326b72f1c0SJohn Levon # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 20336b72f1c0SJohn Levon if [[ "$u_FLAG" = "y" ]]; then 20346b72f1c0SJohn Levon p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 20356b72f1c0SJohn Levon 20366b72f1c0SJohn Levon # If parent lacks the ELF-data.$MACH directory, create it 20376b72f1c0SJohn Levon if [[ ! -d $p_elf_ddir ]]; then 20386b72f1c0SJohn Levon staffer mkdir -p $p_elf_ddir 20396b72f1c0SJohn Levon fi 20406b72f1c0SJohn Levon 20416b72f1c0SJohn Levon # These files are used asynchronously by other builds for ABI 20426b72f1c0SJohn Levon # verification, as above for the -A option. As such, we require 20436b72f1c0SJohn Levon # the file replacement to be atomic. Copy the data to a temp 20446b72f1c0SJohn Levon # file in the same filesystem and then rename into place. 20456b72f1c0SJohn Levon ( 20466b72f1c0SJohn Levon cd $elf_ddir 20476b72f1c0SJohn Levon for elf_dfile in *; do 20486b72f1c0SJohn Levon staffer cp $elf_dfile \ 20496b72f1c0SJohn Levon ${p_elf_ddir}/${elf_dfile}.new 20506b72f1c0SJohn Levon staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 20516b72f1c0SJohn Levon ${p_elf_ddir}/${elf_dfile} 20526b72f1c0SJohn Levon done 20536b72f1c0SJohn Levon ) 20546b72f1c0SJohn Levon fi 20556b72f1c0SJohn Levonfi 20566b72f1c0SJohn Levon 20576b72f1c0SJohn Levon# DEBUG lint of kernel begins 20586b72f1c0SJohn Levon 20596b72f1c0SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 20606b72f1c0SJohn Levon if [ "$LINTDIRS" = "" ]; then 20616b72f1c0SJohn Levon # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 20626b72f1c0SJohn Levon LINTDIRS="$SRC y" 20636b72f1c0SJohn Levon fi 20646b72f1c0SJohn Levon set $LINTDIRS 20656b72f1c0SJohn Levon while [ $# -gt 0 ]; do 20666b72f1c0SJohn Levon dolint $1 $2; shift; shift 20676b72f1c0SJohn Levon done 20686b72f1c0SJohn Levonelse 20696b72f1c0SJohn Levon echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 20706b72f1c0SJohn Levonfi 20716b72f1c0SJohn Levon 20726b72f1c0SJohn Levon# "make check" begins 20736b72f1c0SJohn Levon 20746b72f1c0SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 20756b72f1c0SJohn Levon # remove old check.out 20766b72f1c0SJohn Levon rm -f $SRC/check.out 20776b72f1c0SJohn Levon 20786b72f1c0SJohn Levon rm -f $SRC/check-${MACH}.out 20796b72f1c0SJohn Levon cd $SRC 20806b72f1c0SJohn Levon $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 20816b72f1c0SJohn Levon >> $LOGFILE 20826b72f1c0SJohn Levon echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 20836b72f1c0SJohn Levon 20846b72f1c0SJohn Levon grep ":" $SRC/check-${MACH}.out | 20856b72f1c0SJohn Levon egrep -v "Ignoring unknown host" | \ 20866b72f1c0SJohn Levon sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 20876b72f1c0SJohn Levon 20886b72f1c0SJohn Levon if [[ -s $TMPDIR/check_errors ]]; then 20896b72f1c0SJohn Levon build_extras_ok=n 20906b72f1c0SJohn Levon fi 20916b72f1c0SJohn Levonelse 20926b72f1c0SJohn Levon echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 20936b72f1c0SJohn Levonfi 20946b72f1c0SJohn Levon 20956b72f1c0SJohn Levonecho "\n==== Find core files ====\n" | \ 20966b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 20976b72f1c0SJohn Levon 20986b72f1c0SJohn Levonfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 20996b72f1c0SJohn Levon tee -a $LOGFILE >> $mail_msg_file 21006b72f1c0SJohn Levon 21016b72f1c0SJohn Levonif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21026b72f1c0SJohn Levon echo "\n==== Diff unreferenced files (since last build) ====\n" \ 21036b72f1c0SJohn Levon | tee -a $LOGFILE >>$mail_msg_file 21046b72f1c0SJohn Levon rm -f $SRC/unref-${MACH}.ref 21056b72f1c0SJohn Levon if [ -f $SRC/unref-${MACH}.out ]; then 21066b72f1c0SJohn Levon mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 21076b72f1c0SJohn Levon fi 21086b72f1c0SJohn Levon 21096b72f1c0SJohn Levon findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 21106b72f1c0SJohn Levon ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 21116b72f1c0SJohn Levon sort > $SRC/unref-${MACH}.out 21126b72f1c0SJohn Levon 21136b72f1c0SJohn Levon if [ ! -f $SRC/unref-${MACH}.ref ]; then 21146b72f1c0SJohn Levon cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 21156b72f1c0SJohn Levon fi 21166b72f1c0SJohn Levon 21176b72f1c0SJohn Levon diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 21186b72f1c0SJohn Levonfi 21196b72f1c0SJohn Levon 21206b72f1c0SJohn Levon# Verify that the usual lists of files, such as exception lists, 21216b72f1c0SJohn Levon# contain only valid references to files. If the build has failed, 21226b72f1c0SJohn Levon# then don't check the proto area. 21236b72f1c0SJohn LevonCHECK_PATHS=${CHECK_PATHS:-y} 21246b72f1c0SJohn Levonif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 21256b72f1c0SJohn Levon echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 21266b72f1c0SJohn Levon >>$mail_msg_file 21276b72f1c0SJohn Levon arg=-b 21286b72f1c0SJohn Levon [ "$build_ok" = y ] && arg= 21296b72f1c0SJohn Levon checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 21306b72f1c0SJohn Levon if [[ -s $SRC/check-paths.out ]]; then 21316b72f1c0SJohn Levon tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 21326b72f1c0SJohn Levon build_extras_ok=n 21336b72f1c0SJohn Levon fi 21346b72f1c0SJohn Levonfi 21356b72f1c0SJohn Levon 21366b72f1c0SJohn Levonif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 21376b72f1c0SJohn Levon echo "\n==== Impact on file permissions ====\n" \ 21386b72f1c0SJohn Levon >> $mail_msg_file 21396b72f1c0SJohn Levon 21406b72f1c0SJohn Levon abspkg= 21416b72f1c0SJohn Levon for d in $abssrcdirs; do 21426b72f1c0SJohn Levon if [ -d "$d/pkg" ]; then 21436b72f1c0SJohn Levon abspkg="$abspkg $d" 21446b72f1c0SJohn Levon fi 21456b72f1c0SJohn Levon done 21466b72f1c0SJohn Levon 21476b72f1c0SJohn Levon if [ -n "$abspkg" ]; then 21486b72f1c0SJohn Levon for d in "$abspkg"; do 21496b72f1c0SJohn Levon ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 21506b72f1c0SJohn Levon done 21516b72f1c0SJohn Levon fi 21526b72f1c0SJohn Levonfi 21536b72f1c0SJohn Levon 21546b72f1c0SJohn Levonif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 21556b72f1c0SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 2156*69ce05a9SMarcel Telka do_wsdiff DEBUG $ROOT.prev $ROOT wsdiff.results 21576b72f1c0SJohn Levon fi 21586b72f1c0SJohn Levon 21596b72f1c0SJohn Levon if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 2160*69ce05a9SMarcel Telka do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd wsdiff-nd.results 2161*69ce05a9SMarcel Telka fi 2162*69ce05a9SMarcel Telka 2163*69ce05a9SMarcel Telka if [[ "$t_FLAG" == "y" ]]; then 2164*69ce05a9SMarcel Telka do_wsdiff tools $TOOLS_PROTO.prev $TOOLS_PROTO wsdiff-tools.results 21656b72f1c0SJohn Levon fi 21666b72f1c0SJohn Levonfi 21676b72f1c0SJohn Levon 21686b72f1c0SJohn LevonEND_DATE=`date` 21696b72f1c0SJohn Levonecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 21706b72f1c0SJohn Levon tee -a $LOGFILE >> $build_time_file 21716b72f1c0SJohn Levon 21726b72f1c0SJohn Levontypeset -i10 hours 21736b72f1c0SJohn Levontypeset -Z2 minutes 21746b72f1c0SJohn Levontypeset -Z2 seconds 21756b72f1c0SJohn Levon 21766b72f1c0SJohn Levonelapsed_time=$SECONDS 21776b72f1c0SJohn Levon((hours = elapsed_time / 3600 )) 21786b72f1c0SJohn Levon((minutes = elapsed_time / 60 % 60)) 21796b72f1c0SJohn Levon((seconds = elapsed_time % 60)) 21806b72f1c0SJohn Levon 21816b72f1c0SJohn Levonecho "\n==== Total build time ====" | \ 21826b72f1c0SJohn Levon tee -a $LOGFILE >> $build_time_file 21836b72f1c0SJohn Levonecho "\nreal ${hours}:${minutes}:${seconds}" | \ 21846b72f1c0SJohn Levon tee -a $LOGFILE >> $build_time_file 21856b72f1c0SJohn Levon 21866b72f1c0SJohn Levonif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21876b72f1c0SJohn Levon staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 21886b72f1c0SJohn Levon 21896b72f1c0SJohn Levon # 21906b72f1c0SJohn Levon # Produce a master list of unreferenced files -- ideally, we'd 21916b72f1c0SJohn Levon # generate the master just once after all of the nightlies 21926b72f1c0SJohn Levon # have finished, but there's no simple way to know when that 21936b72f1c0SJohn Levon # will be. Instead, we assume that we're the last nightly to 21946b72f1c0SJohn Levon # finish and merge all of the unref-${MACH}.out files in 21956b72f1c0SJohn Levon # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 21966b72f1c0SJohn Levon # finish, then this file will be the authoritative master 21976b72f1c0SJohn Levon # list. Otherwise, another ${MACH}'s nightly will eventually 21986b72f1c0SJohn Levon # overwrite ours with its own master, but in the meantime our 21996b72f1c0SJohn Levon # temporary "master" will be no worse than any older master 22006b72f1c0SJohn Levon # which was already on the parent. 22016b72f1c0SJohn Levon # 22026b72f1c0SJohn Levon 22036b72f1c0SJohn Levon set -- $PARENT_WS/usr/src/unref-*.out 22046b72f1c0SJohn Levon cp "$1" ${TMPDIR}/unref.merge 22056b72f1c0SJohn Levon shift 22066b72f1c0SJohn Levon 22076b72f1c0SJohn Levon for unreffile; do 22086b72f1c0SJohn Levon comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 22096b72f1c0SJohn Levon mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 22106b72f1c0SJohn Levon done 22116b72f1c0SJohn Levon 22126b72f1c0SJohn Levon staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 22136b72f1c0SJohn Levonfi 22146b72f1c0SJohn Levon 22156b72f1c0SJohn Levon# 22166b72f1c0SJohn Levon# All done save for the sweeping up. 22176b72f1c0SJohn Levon# (whichever exit we hit here will trigger the "cleanup" trap which 22186b72f1c0SJohn Levon# optionally sends mail on completion). 22196b72f1c0SJohn Levon# 22206b72f1c0SJohn Levonif [[ "$build_ok" == "y" ]]; then 22216b72f1c0SJohn Levon if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 22226b72f1c0SJohn Levon exit 0 22236b72f1c0SJohn Levon fi 22246b72f1c0SJohn Levonfi 22256b72f1c0SJohn Levon 22266b72f1c0SJohn Levonexit 1 2227