1*9e4fd900SJohn Levon#!/bin/ksh -p 2*9e4fd900SJohn Levon# 3*9e4fd900SJohn Levon# CDDL HEADER START 4*9e4fd900SJohn Levon# 5*9e4fd900SJohn Levon# The contents of this file are subject to the terms of the 6*9e4fd900SJohn Levon# Common Development and Distribution License (the "License"). 7*9e4fd900SJohn Levon# You may not use this file except in compliance with the License. 8*9e4fd900SJohn Levon# 9*9e4fd900SJohn Levon# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*9e4fd900SJohn Levon# or http://www.opensolaris.org/os/licensing. 11*9e4fd900SJohn Levon# See the License for the specific language governing permissions 12*9e4fd900SJohn Levon# and limitations under the License. 13*9e4fd900SJohn Levon# 14*9e4fd900SJohn Levon# When distributing Covered Code, include this CDDL HEADER in each 15*9e4fd900SJohn Levon# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*9e4fd900SJohn Levon# If applicable, add the following below this CDDL HEADER, with the 17*9e4fd900SJohn Levon# fields enclosed by brackets "[]" replaced with your own identifying 18*9e4fd900SJohn Levon# information: Portions Copyright [yyyy] [name of copyright owner] 19*9e4fd900SJohn Levon# 20*9e4fd900SJohn Levon# CDDL HEADER END 21*9e4fd900SJohn Levon# 22*9e4fd900SJohn Levon 23*9e4fd900SJohn Levon# 24*9e4fd900SJohn Levon# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 25*9e4fd900SJohn Levon# Copyright 2008, 2010, Richard Lowe 26*9e4fd900SJohn Levon# Copyright 2011 Nexenta Systems, Inc. All rights reserved. 27*9e4fd900SJohn Levon# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> 28*9e4fd900SJohn Levon# Copyright 2020 Joyent, Inc. 29*9e4fd900SJohn Levon# 30*9e4fd900SJohn Levon# Based on the nightly script from the integration folks, 31*9e4fd900SJohn Levon# Mostly modified and owned by mike_s. 32*9e4fd900SJohn Levon# Changes also by kjc, dmk. 33*9e4fd900SJohn Levon# 34*9e4fd900SJohn Levon# BRINGOVER_WS may be specified in the env file. 35*9e4fd900SJohn Levon# The default is the old behavior of CLONE_WS 36*9e4fd900SJohn Levon# 37*9e4fd900SJohn Levon# -i on the command line, means fast options, so when it's on the 38*9e4fd900SJohn Levon# command line (only), lint and check builds are skipped no matter what 39*9e4fd900SJohn Levon# the setting of their individual flags are in NIGHTLY_OPTIONS. 40*9e4fd900SJohn Levon# 41*9e4fd900SJohn Levon# LINTDIRS can be set in the env file, format is a list of: 42*9e4fd900SJohn Levon# 43*9e4fd900SJohn Levon# /dirname-to-run-lint-on flag 44*9e4fd900SJohn Levon# 45*9e4fd900SJohn Levon# Where flag is: y - enable lint noise diff output 46*9e4fd900SJohn Levon# n - disable lint noise diff output 47*9e4fd900SJohn Levon# 48*9e4fd900SJohn Levon# For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y" 49*9e4fd900SJohn Levon# 50*9e4fd900SJohn Levon# OPTHOME may be set in the environment to override /opt 51*9e4fd900SJohn Levon# 52*9e4fd900SJohn Levon 53*9e4fd900SJohn Levon# 54*9e4fd900SJohn Levon# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 55*9e4fd900SJohn Levon# under certain circumstances, which can really screw things up; unset it. 56*9e4fd900SJohn Levon# 57*9e4fd900SJohn Levonunset CDPATH 58*9e4fd900SJohn Levon 59*9e4fd900SJohn Levon# Get the absolute path of the nightly script that the user invoked. This 60*9e4fd900SJohn Levon# may be a relative path, and we need to do this before changing directory. 61*9e4fd900SJohn Levonnightly_path=`whence $0` 62*9e4fd900SJohn Levon 63*9e4fd900SJohn Levon# 64*9e4fd900SJohn Levon# Keep track of where we found nightly so we can invoke the matching 65*9e4fd900SJohn Levon# which_scm script. If that doesn't work, don't go guessing, just rely 66*9e4fd900SJohn Levon# on the $PATH settings, which will generally give us either /opt/onbld 67*9e4fd900SJohn Levon# or the user's workspace. 68*9e4fd900SJohn Levon# 69*9e4fd900SJohn LevonWHICH_SCM=$(dirname $nightly_path)/which_scm 70*9e4fd900SJohn Levonif [[ ! -x $WHICH_SCM ]]; then 71*9e4fd900SJohn Levon WHICH_SCM=which_scm 72*9e4fd900SJohn Levonfi 73*9e4fd900SJohn Levon 74*9e4fd900SJohn Levonfunction fatal_error 75*9e4fd900SJohn Levon{ 76*9e4fd900SJohn Levon print -u2 "nightly: $*" 77*9e4fd900SJohn Levon exit 1 78*9e4fd900SJohn Levon} 79*9e4fd900SJohn Levon 80*9e4fd900SJohn Levon# 81*9e4fd900SJohn Levon# Function to do a DEBUG and non-DEBUG build. Needed because we might 82*9e4fd900SJohn Levon# need to do another for the source build, and since we only deliver DEBUG or 83*9e4fd900SJohn Levon# non-DEBUG packages. 84*9e4fd900SJohn Levon# 85*9e4fd900SJohn Levon# usage: normal_build 86*9e4fd900SJohn Levon# 87*9e4fd900SJohn Levonfunction normal_build { 88*9e4fd900SJohn Levon 89*9e4fd900SJohn Levon typeset orig_p_FLAG="$p_FLAG" 90*9e4fd900SJohn Levon typeset crypto_signer="$CODESIGN_USER" 91*9e4fd900SJohn Levon 92*9e4fd900SJohn Levon suffix="" 93*9e4fd900SJohn Levon 94*9e4fd900SJohn Levon # non-DEBUG build begins 95*9e4fd900SJohn Levon 96*9e4fd900SJohn Levon if [ "$F_FLAG" = "n" ]; then 97*9e4fd900SJohn Levon set_non_debug_build_flags 98*9e4fd900SJohn Levon CODESIGN_USER="$crypto_signer" \ 99*9e4fd900SJohn Levon build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 100*9e4fd900SJohn Levon else 101*9e4fd900SJohn Levon echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 102*9e4fd900SJohn Levon fi 103*9e4fd900SJohn Levon 104*9e4fd900SJohn Levon # non-DEBUG build ends 105*9e4fd900SJohn Levon 106*9e4fd900SJohn Levon # DEBUG build begins 107*9e4fd900SJohn Levon 108*9e4fd900SJohn Levon if [ "$D_FLAG" = "y" ]; then 109*9e4fd900SJohn Levon set_debug_build_flags 110*9e4fd900SJohn Levon CODESIGN_USER="$crypto_signer" \ 111*9e4fd900SJohn Levon build "DEBUG" "$suffix" "" "$MULTI_PROTO" 112*9e4fd900SJohn Levon else 113*9e4fd900SJohn Levon echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 114*9e4fd900SJohn Levon fi 115*9e4fd900SJohn Levon 116*9e4fd900SJohn Levon # DEBUG build ends 117*9e4fd900SJohn Levon 118*9e4fd900SJohn Levon p_FLAG="$orig_p_FLAG" 119*9e4fd900SJohn Levon} 120*9e4fd900SJohn Levon 121*9e4fd900SJohn Levon# 122*9e4fd900SJohn Levon# usage: run_hook HOOKNAME ARGS... 123*9e4fd900SJohn Levon# 124*9e4fd900SJohn Levon# If variable "$HOOKNAME" is defined, insert a section header into 125*9e4fd900SJohn Levon# our logs and then run the command with ARGS 126*9e4fd900SJohn Levon# 127*9e4fd900SJohn Levonfunction run_hook { 128*9e4fd900SJohn Levon HOOKNAME=$1 129*9e4fd900SJohn Levon eval HOOKCMD=\$$HOOKNAME 130*9e4fd900SJohn Levon shift 131*9e4fd900SJohn Levon 132*9e4fd900SJohn Levon if [ -n "$HOOKCMD" ]; then 133*9e4fd900SJohn Levon ( 134*9e4fd900SJohn Levon echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 135*9e4fd900SJohn Levon ( $HOOKCMD "$@" 2>&1 ) 136*9e4fd900SJohn Levon if [ "$?" -ne 0 ]; then 137*9e4fd900SJohn Levon # Let exit status propagate up 138*9e4fd900SJohn Levon touch $TMPDIR/abort 139*9e4fd900SJohn Levon fi 140*9e4fd900SJohn Levon ) | tee -a $mail_msg_file >> $LOGFILE 141*9e4fd900SJohn Levon 142*9e4fd900SJohn Levon if [ -f $TMPDIR/abort ]; then 143*9e4fd900SJohn Levon build_ok=n 144*9e4fd900SJohn Levon echo "\nAborting at request of $HOOKNAME" | 145*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 146*9e4fd900SJohn Levon exit 1 147*9e4fd900SJohn Levon fi 148*9e4fd900SJohn Levon fi 149*9e4fd900SJohn Levon} 150*9e4fd900SJohn Levon 151*9e4fd900SJohn Levon# Return library search directive as function of given root. 152*9e4fd900SJohn Levonfunction myldlibs { 153*9e4fd900SJohn Levon echo "-L$1/lib -L$1/usr/lib" 154*9e4fd900SJohn Levon} 155*9e4fd900SJohn Levon 156*9e4fd900SJohn Levon# Return header search directive as function of given root. 157*9e4fd900SJohn Levonfunction myheaders { 158*9e4fd900SJohn Levon echo "-I$1/usr/include" 159*9e4fd900SJohn Levon} 160*9e4fd900SJohn Levon 161*9e4fd900SJohn Levon# 162*9e4fd900SJohn Levon# Function to do the build, including package generation. 163*9e4fd900SJohn Levon# usage: build LABEL SUFFIX ND MULTIPROTO 164*9e4fd900SJohn Levon# - LABEL is used to tag build output. 165*9e4fd900SJohn Levon# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 166*9e4fd900SJohn Levon# open-only vs full tree). 167*9e4fd900SJohn Levon# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 168*9e4fd900SJohn Levon# - If MULTIPROTO is "yes", it means to name the proto area according to 169*9e4fd900SJohn Levon# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 170*9e4fd900SJohn Levon# 171*9e4fd900SJohn Levonfunction build { 172*9e4fd900SJohn Levon LABEL=$1 173*9e4fd900SJohn Levon SUFFIX=$2 174*9e4fd900SJohn Levon ND=$3 175*9e4fd900SJohn Levon MULTIPROTO=$4 176*9e4fd900SJohn Levon INSTALLOG=install${SUFFIX}-${MACH} 177*9e4fd900SJohn Levon NOISE=noise${SUFFIX}-${MACH} 178*9e4fd900SJohn Levon PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 179*9e4fd900SJohn Levon 180*9e4fd900SJohn Levon ORIGROOT=$ROOT 181*9e4fd900SJohn Levon [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 182*9e4fd900SJohn Levon 183*9e4fd900SJohn Levon export ENVLDLIBS1=`myldlibs $ROOT` 184*9e4fd900SJohn Levon export ENVCPPFLAGS1=`myheaders $ROOT` 185*9e4fd900SJohn Levon 186*9e4fd900SJohn Levon this_build_ok=y 187*9e4fd900SJohn Levon # 188*9e4fd900SJohn Levon # Build OS-Networking source 189*9e4fd900SJohn Levon # 190*9e4fd900SJohn Levon echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 191*9e4fd900SJohn Levon >> $LOGFILE 192*9e4fd900SJohn Levon 193*9e4fd900SJohn Levon rm -f $SRC/${INSTALLOG}.out 194*9e4fd900SJohn Levon cd $SRC 195*9e4fd900SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 196*9e4fd900SJohn Levon tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 197*9e4fd900SJohn Levon 198*9e4fd900SJohn Levon echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 199*9e4fd900SJohn Levon egrep ":" $SRC/${INSTALLOG}.out | 200*9e4fd900SJohn Levon egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 201*9e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 202*9e4fd900SJohn Levon egrep -v "cc .* -o error " | \ 203*9e4fd900SJohn Levon egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 204*9e4fd900SJohn Levon >> $mail_msg_file 205*9e4fd900SJohn Levon if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 206*9e4fd900SJohn Levon build_ok=n 207*9e4fd900SJohn Levon this_build_ok=n 208*9e4fd900SJohn Levon fi 209*9e4fd900SJohn Levon grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 210*9e4fd900SJohn Levon >> $mail_msg_file 211*9e4fd900SJohn Levon if [ "$?" = "0" ]; then 212*9e4fd900SJohn Levon build_ok=n 213*9e4fd900SJohn Levon this_build_ok=n 214*9e4fd900SJohn Levon fi 215*9e4fd900SJohn Levon 216*9e4fd900SJohn Levon echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 217*9e4fd900SJohn Levon egrep -i warning: $SRC/${INSTALLOG}.out \ 218*9e4fd900SJohn Levon | egrep -v '^tic:' \ 219*9e4fd900SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 220*9e4fd900SJohn Levon | egrep -v "parameter <PSTAMP> set to" \ 221*9e4fd900SJohn Levon | egrep -v "Ignoring unknown host" \ 222*9e4fd900SJohn Levon | egrep -v "redefining segment flags attribute for" \ 223*9e4fd900SJohn Levon | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 224*9e4fd900SJohn Levon if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 225*9e4fd900SJohn Levon build_ok=n 226*9e4fd900SJohn Levon this_build_ok=n 227*9e4fd900SJohn Levon fi 228*9e4fd900SJohn Levon 229*9e4fd900SJohn Levon echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 230*9e4fd900SJohn Levon >> $LOGFILE 231*9e4fd900SJohn Levon 232*9e4fd900SJohn Levon echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 233*9e4fd900SJohn Levon tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 234*9e4fd900SJohn Levon 235*9e4fd900SJohn Levon if [ "$i_FLAG" = "n" ]; then 236*9e4fd900SJohn Levon rm -f $SRC/${NOISE}.ref 237*9e4fd900SJohn Levon if [ -f $SRC/${NOISE}.out ]; then 238*9e4fd900SJohn Levon mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 239*9e4fd900SJohn Levon fi 240*9e4fd900SJohn Levon grep : $SRC/${INSTALLOG}.out \ 241*9e4fd900SJohn Levon | egrep -v '^/' \ 242*9e4fd900SJohn Levon | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 243*9e4fd900SJohn Levon | egrep -v '^tic:' \ 244*9e4fd900SJohn Levon | egrep -v '^mcs' \ 245*9e4fd900SJohn Levon | egrep -v '^LD_LIBRARY_PATH=' \ 246*9e4fd900SJohn Levon | egrep -v 'ar: creating' \ 247*9e4fd900SJohn Levon | egrep -v 'ar: writing' \ 248*9e4fd900SJohn Levon | egrep -v 'conflicts:' \ 249*9e4fd900SJohn Levon | egrep -v ':saved created' \ 250*9e4fd900SJohn Levon | egrep -v '^stty.*c:' \ 251*9e4fd900SJohn Levon | egrep -v '^mfgname.c:' \ 252*9e4fd900SJohn Levon | egrep -v '^uname-i.c:' \ 253*9e4fd900SJohn Levon | egrep -v '^volumes.c:' \ 254*9e4fd900SJohn Levon | egrep -v '^lint library construction:' \ 255*9e4fd900SJohn Levon | egrep -v 'tsort: INFORM:' \ 256*9e4fd900SJohn Levon | egrep -v 'stripalign:' \ 257*9e4fd900SJohn Levon | egrep -v 'chars, width' \ 258*9e4fd900SJohn Levon | egrep -v "symbol (\`|')timezone' has differing types:" \ 259*9e4fd900SJohn Levon | egrep -v 'PSTAMP' \ 260*9e4fd900SJohn Levon | egrep -v '|%WHOANDWHERE%|' \ 261*9e4fd900SJohn Levon | egrep -v '^Manifying' \ 262*9e4fd900SJohn Levon | egrep -v 'Ignoring unknown host' \ 263*9e4fd900SJohn Levon | egrep -v 'Processing method:' \ 264*9e4fd900SJohn Levon | egrep -v '^Writing' \ 265*9e4fd900SJohn Levon | egrep -v 'spellin1:' \ 266*9e4fd900SJohn Levon | egrep -v '^adding:' \ 267*9e4fd900SJohn Levon | egrep -v "^echo 'msgid" \ 268*9e4fd900SJohn Levon | egrep -v '^echo ' \ 269*9e4fd900SJohn Levon | egrep -v '\.c:$' \ 270*9e4fd900SJohn Levon | egrep -v '^Adding file:' \ 271*9e4fd900SJohn Levon | egrep -v 'CLASSPATH=' \ 272*9e4fd900SJohn Levon | egrep -v '\/var\/mail\/:saved' \ 273*9e4fd900SJohn Levon | egrep -v -- '-DUTS_VERSION=' \ 274*9e4fd900SJohn Levon | egrep -v '^Running Mkbootstrap' \ 275*9e4fd900SJohn Levon | egrep -v '^Applet length read:' \ 276*9e4fd900SJohn Levon | egrep -v 'bytes written:' \ 277*9e4fd900SJohn Levon | egrep -v '^File:SolarisAuthApplet.bin' \ 278*9e4fd900SJohn Levon | egrep -v -i 'jibversion' \ 279*9e4fd900SJohn Levon | egrep -v '^Output size:' \ 280*9e4fd900SJohn Levon | egrep -v '^Solo size statistics:' \ 281*9e4fd900SJohn Levon | egrep -v '^Using ROM API Version' \ 282*9e4fd900SJohn Levon | egrep -v '^Zero Signature length:' \ 283*9e4fd900SJohn Levon | egrep -v '^Note \(probably harmless\):' \ 284*9e4fd900SJohn Levon | egrep -v '::' \ 285*9e4fd900SJohn Levon | egrep -v -- '-xcache' \ 286*9e4fd900SJohn Levon | egrep -v '^\+' \ 287*9e4fd900SJohn Levon | egrep -v '^cc1: note: -fwritable-strings' \ 288*9e4fd900SJohn Levon | egrep -v 'svccfg-native -s svc:/' \ 289*9e4fd900SJohn Levon | sort | uniq >$SRC/${NOISE}.out 290*9e4fd900SJohn Levon if [ ! -f $SRC/${NOISE}.ref ]; then 291*9e4fd900SJohn Levon cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 292*9e4fd900SJohn Levon fi 293*9e4fd900SJohn Levon echo "\n==== Build noise differences ($LABEL) ====\n" \ 294*9e4fd900SJohn Levon >>$mail_msg_file 295*9e4fd900SJohn Levon diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 296*9e4fd900SJohn Levon fi 297*9e4fd900SJohn Levon 298*9e4fd900SJohn Levon # 299*9e4fd900SJohn Levon # Re-sign selected binaries using signing server 300*9e4fd900SJohn Levon # (gatekeeper builds only) 301*9e4fd900SJohn Levon # 302*9e4fd900SJohn Levon if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 303*9e4fd900SJohn Levon echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 304*9e4fd900SJohn Levon signing_file="${TMPDIR}/signing" 305*9e4fd900SJohn Levon rm -f ${signing_file} 306*9e4fd900SJohn Levon export CODESIGN_USER 307*9e4fd900SJohn Levon signproto $SRC/tools/codesign/creds 2>&1 | \ 308*9e4fd900SJohn Levon tee -a ${signing_file} >> $LOGFILE 309*9e4fd900SJohn Levon echo "\n==== Finished signing proto area at `date` ====\n" \ 310*9e4fd900SJohn Levon >> $LOGFILE 311*9e4fd900SJohn Levon echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 312*9e4fd900SJohn Levon >> $mail_msg_file 313*9e4fd900SJohn Levon egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 314*9e4fd900SJohn Levon if (( $? == 0 )) ; then 315*9e4fd900SJohn Levon build_ok=n 316*9e4fd900SJohn Levon this_build_ok=n 317*9e4fd900SJohn Levon fi 318*9e4fd900SJohn Levon fi 319*9e4fd900SJohn Levon 320*9e4fd900SJohn Levon # 321*9e4fd900SJohn Levon # Building Packages 322*9e4fd900SJohn Levon # 323*9e4fd900SJohn Levon if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 324*9e4fd900SJohn Levon if [ -d $SRC/pkg ]; then 325*9e4fd900SJohn Levon echo "\n==== Creating $LABEL packages at `date` ====\n" \ 326*9e4fd900SJohn Levon >> $LOGFILE 327*9e4fd900SJohn Levon echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 328*9e4fd900SJohn Levon rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 329*9e4fd900SJohn Levon mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 330*9e4fd900SJohn Levon 331*9e4fd900SJohn Levon rm -f $SRC/pkg/${INSTALLOG}.out 332*9e4fd900SJohn Levon cd $SRC/pkg 333*9e4fd900SJohn Levon /bin/time $MAKE -e install 2>&1 | \ 334*9e4fd900SJohn Levon tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 335*9e4fd900SJohn Levon 336*9e4fd900SJohn Levon echo "\n==== package build errors ($LABEL) ====\n" \ 337*9e4fd900SJohn Levon >> $mail_msg_file 338*9e4fd900SJohn Levon 339*9e4fd900SJohn Levon egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 340*9e4fd900SJohn Levon grep ':' | \ 341*9e4fd900SJohn Levon grep -v PSTAMP | \ 342*9e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 343*9e4fd900SJohn Levon tee $TMPDIR/package >> $mail_msg_file 344*9e4fd900SJohn Levon if [[ -s $TMPDIR/package ]]; then 345*9e4fd900SJohn Levon build_extras_ok=n 346*9e4fd900SJohn Levon this_build_ok=n 347*9e4fd900SJohn Levon fi 348*9e4fd900SJohn Levon else 349*9e4fd900SJohn Levon # 350*9e4fd900SJohn Levon # Handle it gracefully if -p was set but there so 351*9e4fd900SJohn Levon # no pkg directory. 352*9e4fd900SJohn Levon # 353*9e4fd900SJohn Levon echo "\n==== No $LABEL packages to build ====\n" \ 354*9e4fd900SJohn Levon >> $LOGFILE 355*9e4fd900SJohn Levon fi 356*9e4fd900SJohn Levon else 357*9e4fd900SJohn Levon echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 358*9e4fd900SJohn Levon fi 359*9e4fd900SJohn Levon 360*9e4fd900SJohn Levon ROOT=$ORIGROOT 361*9e4fd900SJohn Levon} 362*9e4fd900SJohn Levon 363*9e4fd900SJohn Levon# Usage: dolint /dir y|n 364*9e4fd900SJohn Levon# Arg. 2 is a flag to turn on/off the lint diff output 365*9e4fd900SJohn Levonfunction dolint { 366*9e4fd900SJohn Levon if [ ! -d "$1" ]; then 367*9e4fd900SJohn Levon echo "dolint error: $1 is not a directory" 368*9e4fd900SJohn Levon exit 1 369*9e4fd900SJohn Levon fi 370*9e4fd900SJohn Levon 371*9e4fd900SJohn Levon if [ "$2" != "y" -a "$2" != "n" ]; then 372*9e4fd900SJohn Levon echo "dolint internal error: $2 should be 'y' or 'n'" 373*9e4fd900SJohn Levon exit 1 374*9e4fd900SJohn Levon fi 375*9e4fd900SJohn Levon 376*9e4fd900SJohn Levon lintdir=$1 377*9e4fd900SJohn Levon dodiff=$2 378*9e4fd900SJohn Levon base=`basename $lintdir` 379*9e4fd900SJohn Levon LINTOUT=$lintdir/lint-${MACH}.out 380*9e4fd900SJohn Levon LINTNOISE=$lintdir/lint-noise-${MACH} 381*9e4fd900SJohn Levon export ENVLDLIBS1=`myldlibs $ROOT` 382*9e4fd900SJohn Levon export ENVCPPFLAGS1=`myheaders $ROOT` 383*9e4fd900SJohn Levon 384*9e4fd900SJohn Levon set_debug_build_flags 385*9e4fd900SJohn Levon 386*9e4fd900SJohn Levon # 387*9e4fd900SJohn Levon # '$MAKE lint' in $lintdir 388*9e4fd900SJohn Levon # 389*9e4fd900SJohn Levon echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 390*9e4fd900SJohn Levon 391*9e4fd900SJohn Levon # remove old lint.out 392*9e4fd900SJohn Levon rm -f $lintdir/lint.out $lintdir/lint-noise.out 393*9e4fd900SJohn Levon if [ -f $lintdir/lint-noise.ref ]; then 394*9e4fd900SJohn Levon mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 395*9e4fd900SJohn Levon fi 396*9e4fd900SJohn Levon 397*9e4fd900SJohn Levon rm -f $LINTOUT 398*9e4fd900SJohn Levon cd $lintdir 399*9e4fd900SJohn Levon # 400*9e4fd900SJohn Levon # Remove all .ln files to ensure a full reference file 401*9e4fd900SJohn Levon # 402*9e4fd900SJohn Levon rm -f Nothing_to_remove \ 403*9e4fd900SJohn Levon `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \ 404*9e4fd900SJohn Levon -prune -o -type f -name '*.ln' -print ` 405*9e4fd900SJohn Levon 406*9e4fd900SJohn Levon /bin/time $MAKE -ek lint 2>&1 | \ 407*9e4fd900SJohn Levon tee -a $LINTOUT >> $LOGFILE 408*9e4fd900SJohn Levon 409*9e4fd900SJohn Levon echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 410*9e4fd900SJohn Levon 411*9e4fd900SJohn Levon grep "$MAKE:" $LINTOUT | 412*9e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 413*9e4fd900SJohn Levon tee $TMPDIR/lint_errs >> $mail_msg_file 414*9e4fd900SJohn Levon if [[ -s $TMPDIR/lint_errs ]]; then 415*9e4fd900SJohn Levon build_extras_ok=n 416*9e4fd900SJohn Levon fi 417*9e4fd900SJohn Levon 418*9e4fd900SJohn Levon echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 419*9e4fd900SJohn Levon 420*9e4fd900SJohn Levon echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 421*9e4fd900SJohn Levon >>$mail_msg_file 422*9e4fd900SJohn Levon tail -3 $LINTOUT >>$mail_msg_file 423*9e4fd900SJohn Levon 424*9e4fd900SJohn Levon rm -f ${LINTNOISE}.ref 425*9e4fd900SJohn Levon if [ -f ${LINTNOISE}.out ]; then 426*9e4fd900SJohn Levon mv ${LINTNOISE}.out ${LINTNOISE}.ref 427*9e4fd900SJohn Levon fi 428*9e4fd900SJohn Levon grep : $LINTOUT | \ 429*9e4fd900SJohn Levon egrep -v '^(real|user|sys)' | 430*9e4fd900SJohn Levon egrep -v '(library construction)' | \ 431*9e4fd900SJohn Levon egrep -v ': global crosschecks' | \ 432*9e4fd900SJohn Levon egrep -v 'Ignoring unknown host' | \ 433*9e4fd900SJohn Levon egrep -v '\.c:$' | \ 434*9e4fd900SJohn Levon sort | uniq > ${LINTNOISE}.out 435*9e4fd900SJohn Levon if [ ! -f ${LINTNOISE}.ref ]; then 436*9e4fd900SJohn Levon cp ${LINTNOISE}.out ${LINTNOISE}.ref 437*9e4fd900SJohn Levon fi 438*9e4fd900SJohn Levon 439*9e4fd900SJohn Levon if [ "$dodiff" != "n" ]; then 440*9e4fd900SJohn Levon echo "\n==== lint warnings $base ====\n" \ 441*9e4fd900SJohn Levon >>$mail_msg_file 442*9e4fd900SJohn Levon # should be none, though there are a few that were filtered out 443*9e4fd900SJohn Levon # above 444*9e4fd900SJohn Levon egrep -i '(warning|lint):' ${LINTNOISE}.out \ 445*9e4fd900SJohn Levon | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file 446*9e4fd900SJohn Levon if [[ -s $TMPDIR/lint_warns ]]; then 447*9e4fd900SJohn Levon build_extras_ok=n 448*9e4fd900SJohn Levon fi 449*9e4fd900SJohn Levon echo "\n==== lint noise differences $base ====\n" \ 450*9e4fd900SJohn Levon >> $mail_msg_file 451*9e4fd900SJohn Levon diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 452*9e4fd900SJohn Levon >> $mail_msg_file 453*9e4fd900SJohn Levon fi 454*9e4fd900SJohn Levon} 455*9e4fd900SJohn Levon 456*9e4fd900SJohn Levon# 457*9e4fd900SJohn Levon# Build and install the onbld tools. 458*9e4fd900SJohn Levon# 459*9e4fd900SJohn Levon# usage: build_tools DESTROOT 460*9e4fd900SJohn Levon# 461*9e4fd900SJohn Levon# returns non-zero status if the build was successful. 462*9e4fd900SJohn Levon# 463*9e4fd900SJohn Levonfunction build_tools { 464*9e4fd900SJohn Levon DESTROOT=$1 465*9e4fd900SJohn Levon 466*9e4fd900SJohn Levon INSTALLOG=install-${MACH} 467*9e4fd900SJohn Levon 468*9e4fd900SJohn Levon echo "\n==== Building tools at `date` ====\n" \ 469*9e4fd900SJohn Levon >> $LOGFILE 470*9e4fd900SJohn Levon 471*9e4fd900SJohn Levon rm -f ${TOOLS}/${INSTALLOG}.out 472*9e4fd900SJohn Levon cd ${TOOLS} 473*9e4fd900SJohn Levon /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 474*9e4fd900SJohn Levon tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 475*9e4fd900SJohn Levon 476*9e4fd900SJohn Levon echo "\n==== Tools build errors ====\n" >> $mail_msg_file 477*9e4fd900SJohn Levon 478*9e4fd900SJohn Levon egrep ":" ${TOOLS}/${INSTALLOG}.out | 479*9e4fd900SJohn Levon egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 480*9e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 481*9e4fd900SJohn Levon egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 482*9e4fd900SJohn Levon 483*9e4fd900SJohn Levon if [[ -s $TMPDIR/tools_errors ]]; then 484*9e4fd900SJohn Levon return 1 485*9e4fd900SJohn Levon fi 486*9e4fd900SJohn Levon return 0 487*9e4fd900SJohn Levon} 488*9e4fd900SJohn Levon 489*9e4fd900SJohn Levon# 490*9e4fd900SJohn Levon# Set up to use locally installed tools. 491*9e4fd900SJohn Levon# 492*9e4fd900SJohn Levon# usage: use_tools TOOLSROOT 493*9e4fd900SJohn Levon# 494*9e4fd900SJohn Levonfunction use_tools { 495*9e4fd900SJohn Levon TOOLSROOT=$1 496*9e4fd900SJohn Levon 497*9e4fd900SJohn Levon # 498*9e4fd900SJohn Levon # If we're not building ON workspace, then the TOOLSROOT 499*9e4fd900SJohn Levon # settings here are clearly ignored by the workspace 500*9e4fd900SJohn Levon # makefiles, prepending nonexistent directories to PATH is 501*9e4fd900SJohn Levon # harmless, and we clearly do not wish to override 502*9e4fd900SJohn Levon # ONBLD_TOOLS. 503*9e4fd900SJohn Levon # 504*9e4fd900SJohn Levon # If we're building an ON workspace, then the prepended PATH 505*9e4fd900SJohn Levon # elements should supercede the preexisting ONBLD_TOOLS paths, 506*9e4fd900SJohn Levon # and we want to override ONBLD_TOOLS to catch the tools that 507*9e4fd900SJohn Levon # don't have specific path env vars here. 508*9e4fd900SJohn Levon # 509*9e4fd900SJohn Levon # So the only conditional behavior is overriding ONBLD_TOOLS, 510*9e4fd900SJohn Levon # and we check for "an ON workspace" by looking for 511*9e4fd900SJohn Levon # ${TOOLSROOT}/opt/onbld. 512*9e4fd900SJohn Levon # 513*9e4fd900SJohn Levon 514*9e4fd900SJohn Levon STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs 515*9e4fd900SJohn Levon export STABS 516*9e4fd900SJohn Levon CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs 517*9e4fd900SJohn Levon export CTFSTABS 518*9e4fd900SJohn Levon GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets 519*9e4fd900SJohn Levon export GENOFFSETS 520*9e4fd900SJohn Levon 521*9e4fd900SJohn Levon CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert 522*9e4fd900SJohn Levon export CTFCONVERT 523*9e4fd900SJohn Levon CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge 524*9e4fd900SJohn Levon export CTFMERGE 525*9e4fd900SJohn Levon 526*9e4fd900SJohn Levon if [ "$VERIFY_ELFSIGN" = "y" ]; then 527*9e4fd900SJohn Levon ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 528*9e4fd900SJohn Levon else 529*9e4fd900SJohn Levon ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 530*9e4fd900SJohn Levon fi 531*9e4fd900SJohn Levon export ELFSIGN 532*9e4fd900SJohn Levon 533*9e4fd900SJohn Levon PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 534*9e4fd900SJohn Levon PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 535*9e4fd900SJohn Levon export PATH 536*9e4fd900SJohn Levon 537*9e4fd900SJohn Levon if [ -d "${TOOLSROOT}/opt/onbld" ]; then 538*9e4fd900SJohn Levon ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 539*9e4fd900SJohn Levon export ONBLD_TOOLS 540*9e4fd900SJohn Levon fi 541*9e4fd900SJohn Levon 542*9e4fd900SJohn Levon echo "\n==== New environment settings. ====\n" >> $LOGFILE 543*9e4fd900SJohn Levon echo "STABS=${STABS}" >> $LOGFILE 544*9e4fd900SJohn Levon echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 545*9e4fd900SJohn Levon echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 546*9e4fd900SJohn Levon echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 547*9e4fd900SJohn Levon echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 548*9e4fd900SJohn Levon echo "PATH=${PATH}" >> $LOGFILE 549*9e4fd900SJohn Levon echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 550*9e4fd900SJohn Levon} 551*9e4fd900SJohn Levon 552*9e4fd900SJohn Levonfunction staffer { 553*9e4fd900SJohn Levon if [ $ISUSER -ne 0 ]; then 554*9e4fd900SJohn Levon "$@" 555*9e4fd900SJohn Levon else 556*9e4fd900SJohn Levon arg="\"$1\"" 557*9e4fd900SJohn Levon shift 558*9e4fd900SJohn Levon for i 559*9e4fd900SJohn Levon do 560*9e4fd900SJohn Levon arg="$arg \"$i\"" 561*9e4fd900SJohn Levon done 562*9e4fd900SJohn Levon eval su $STAFFER -c \'$arg\' 563*9e4fd900SJohn Levon fi 564*9e4fd900SJohn Levon} 565*9e4fd900SJohn Levon 566*9e4fd900SJohn Levon# 567*9e4fd900SJohn Levon# Verify that the closed bins are present 568*9e4fd900SJohn Levon# 569*9e4fd900SJohn Levonfunction check_closed_bins { 570*9e4fd900SJohn Levon if [[ ! -d "$ON_CLOSED_BINS" ]]; then 571*9e4fd900SJohn Levon echo "ON_CLOSED_BINS must point to the closed binaries tree." 572*9e4fd900SJohn Levon build_ok=n 573*9e4fd900SJohn Levon exit 1 574*9e4fd900SJohn Levon fi 575*9e4fd900SJohn Levon} 576*9e4fd900SJohn Levon 577*9e4fd900SJohn Levon# 578*9e4fd900SJohn Levon# wrapper over wsdiff. 579*9e4fd900SJohn Levon# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 580*9e4fd900SJohn Levon# 581*9e4fd900SJohn Levonfunction do_wsdiff { 582*9e4fd900SJohn Levon label=$1 583*9e4fd900SJohn Levon oldproto=$2 584*9e4fd900SJohn Levon newproto=$3 585*9e4fd900SJohn Levon 586*9e4fd900SJohn Levon wsdiff="wsdiff" 587*9e4fd900SJohn Levon [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 588*9e4fd900SJohn Levon 589*9e4fd900SJohn Levon echo "\n==== Getting object changes since last build at `date`" \ 590*9e4fd900SJohn Levon "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 591*9e4fd900SJohn Levon $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 592*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 593*9e4fd900SJohn Levon echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 594*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 595*9e4fd900SJohn Levon} 596*9e4fd900SJohn Levon 597*9e4fd900SJohn Levon# 598*9e4fd900SJohn Levon# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 599*9e4fd900SJohn Levon# together. 600*9e4fd900SJohn Levon# 601*9e4fd900SJohn Levon 602*9e4fd900SJohn Levonfunction set_non_debug_build_flags { 603*9e4fd900SJohn Levon export RELEASE_BUILD ; RELEASE_BUILD= 604*9e4fd900SJohn Levon unset EXTRA_OPTIONS 605*9e4fd900SJohn Levon unset EXTRA_CFLAGS 606*9e4fd900SJohn Levon} 607*9e4fd900SJohn Levon 608*9e4fd900SJohn Levonfunction set_debug_build_flags { 609*9e4fd900SJohn Levon unset RELEASE_BUILD 610*9e4fd900SJohn Levon unset EXTRA_OPTIONS 611*9e4fd900SJohn Levon unset EXTRA_CFLAGS 612*9e4fd900SJohn Levon} 613*9e4fd900SJohn Levon 614*9e4fd900SJohn Levon 615*9e4fd900SJohn LevonMACH=`uname -p` 616*9e4fd900SJohn Levon 617*9e4fd900SJohn Levonif [ "$OPTHOME" = "" ]; then 618*9e4fd900SJohn Levon OPTHOME=/opt 619*9e4fd900SJohn Levon export OPTHOME 620*9e4fd900SJohn Levonfi 621*9e4fd900SJohn Levon 622*9e4fd900SJohn LevonUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 623*9e4fd900SJohn Levon 624*9e4fd900SJohn LevonWhere: 625*9e4fd900SJohn Levon -i Fast incremental options (no clobber, lint, check) 626*9e4fd900SJohn Levon -n Do not do a bringover 627*9e4fd900SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 628*9e4fd900SJohn Levon -V VERS set the build version string to VERS 629*9e4fd900SJohn Levon 630*9e4fd900SJohn Levon <env_file> file in Bourne shell syntax that sets and exports 631*9e4fd900SJohn Levon variables that configure the operation of this script and many of 632*9e4fd900SJohn Levon the scripts this one calls. If <env_file> does not exist, 633*9e4fd900SJohn Levon it will be looked for in $OPTHOME/onbld/env. 634*9e4fd900SJohn Levon 635*9e4fd900SJohn Levonnon-DEBUG is the default build type. Build options can be set in the 636*9e4fd900SJohn LevonNIGHTLY_OPTIONS variable in the <env_file> as follows: 637*9e4fd900SJohn Levon 638*9e4fd900SJohn Levon -A check for ABI differences in .so files 639*9e4fd900SJohn Levon -C check for cstyle/hdrchk errors 640*9e4fd900SJohn Levon -D do a build with DEBUG on 641*9e4fd900SJohn Levon -F do _not_ do a non-DEBUG build 642*9e4fd900SJohn Levon -G gate keeper default group of options (-au) 643*9e4fd900SJohn Levon -I integration engineer default group of options (-ampu) 644*9e4fd900SJohn Levon -M do not run pmodes (safe file permission checker) 645*9e4fd900SJohn Levon -N do not run protocmp 646*9e4fd900SJohn Levon -R default group of options for building a release (-mp) 647*9e4fd900SJohn Levon -U update proto area in the parent 648*9e4fd900SJohn Levon -V VERS set the build version string to VERS 649*9e4fd900SJohn Levon -f find unreferenced files 650*9e4fd900SJohn Levon -i do an incremental build (no "make clobber") 651*9e4fd900SJohn Levon -l do "make lint" in $LINTDIRS (default: $SRC y) 652*9e4fd900SJohn Levon -m send mail to $MAILTO at end of build 653*9e4fd900SJohn Levon -n do not do a bringover 654*9e4fd900SJohn Levon -p create packages 655*9e4fd900SJohn Levon -r check ELF runtime attributes in the proto area 656*9e4fd900SJohn Levon -t build and use the tools in $SRC/tools (default setting) 657*9e4fd900SJohn Levon +t Use the build tools in $ONBLD_TOOLS/bin 658*9e4fd900SJohn Levon -u update proto_list_$MACH and friends in the parent workspace; 659*9e4fd900SJohn Levon when used with -f, also build an unrefmaster.out in the parent 660*9e4fd900SJohn Levon -w report on differences between previous and current proto areas 661*9e4fd900SJohn Levon' 662*9e4fd900SJohn Levon# 663*9e4fd900SJohn Levon# A log file will be generated under the name $LOGFILE 664*9e4fd900SJohn Levon# for partially completed build and log.`date '+%F'` 665*9e4fd900SJohn Levon# in the same directory for fully completed builds. 666*9e4fd900SJohn Levon# 667*9e4fd900SJohn Levon 668*9e4fd900SJohn Levon# default values for low-level FLAGS; G I R are group FLAGS 669*9e4fd900SJohn LevonA_FLAG=n 670*9e4fd900SJohn LevonC_FLAG=n 671*9e4fd900SJohn LevonD_FLAG=n 672*9e4fd900SJohn LevonF_FLAG=n 673*9e4fd900SJohn Levonf_FLAG=n 674*9e4fd900SJohn Levoni_FLAG=n; i_CMD_LINE_FLAG=n 675*9e4fd900SJohn Levonl_FLAG=n 676*9e4fd900SJohn LevonM_FLAG=n 677*9e4fd900SJohn Levonm_FLAG=n 678*9e4fd900SJohn LevonN_FLAG=n 679*9e4fd900SJohn Levonn_FLAG=n 680*9e4fd900SJohn Levonp_FLAG=n 681*9e4fd900SJohn Levonr_FLAG=n 682*9e4fd900SJohn Levont_FLAG=y 683*9e4fd900SJohn LevonU_FLAG=n 684*9e4fd900SJohn Levonu_FLAG=n 685*9e4fd900SJohn LevonV_FLAG=n 686*9e4fd900SJohn Levonw_FLAG=n 687*9e4fd900SJohn LevonW_FLAG=n 688*9e4fd900SJohn Levon# 689*9e4fd900SJohn Levonbuild_ok=y 690*9e4fd900SJohn Levonbuild_extras_ok=y 691*9e4fd900SJohn Levon 692*9e4fd900SJohn Levon# 693*9e4fd900SJohn Levon# examine arguments 694*9e4fd900SJohn Levon# 695*9e4fd900SJohn Levon 696*9e4fd900SJohn LevonOPTIND=1 697*9e4fd900SJohn Levonwhile getopts +intV:W FLAG 698*9e4fd900SJohn Levondo 699*9e4fd900SJohn Levon case $FLAG in 700*9e4fd900SJohn Levon i ) i_FLAG=y; i_CMD_LINE_FLAG=y 701*9e4fd900SJohn Levon ;; 702*9e4fd900SJohn Levon n ) n_FLAG=y 703*9e4fd900SJohn Levon ;; 704*9e4fd900SJohn Levon +t ) t_FLAG=n 705*9e4fd900SJohn Levon ;; 706*9e4fd900SJohn Levon V ) V_FLAG=y 707*9e4fd900SJohn Levon V_ARG="$OPTARG" 708*9e4fd900SJohn Levon ;; 709*9e4fd900SJohn Levon W ) W_FLAG=y 710*9e4fd900SJohn Levon ;; 711*9e4fd900SJohn Levon \? ) echo "$USAGE" 712*9e4fd900SJohn Levon exit 1 713*9e4fd900SJohn Levon ;; 714*9e4fd900SJohn Levon esac 715*9e4fd900SJohn Levondone 716*9e4fd900SJohn Levon 717*9e4fd900SJohn Levon# correct argument count after options 718*9e4fd900SJohn Levonshift `expr $OPTIND - 1` 719*9e4fd900SJohn Levon 720*9e4fd900SJohn Levon# test that the path to the environment-setting file was given 721*9e4fd900SJohn Levonif [ $# -ne 1 ]; then 722*9e4fd900SJohn Levon echo "$USAGE" 723*9e4fd900SJohn Levon exit 1 724*9e4fd900SJohn Levonfi 725*9e4fd900SJohn Levon 726*9e4fd900SJohn Levon# check if user is running nightly as root 727*9e4fd900SJohn Levon# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 728*9e4fd900SJohn Levon# when root invokes nightly. 729*9e4fd900SJohn Levon/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 730*9e4fd900SJohn LevonISUSER=$?; export ISUSER 731*9e4fd900SJohn Levon 732*9e4fd900SJohn Levon# 733*9e4fd900SJohn Levon# force locale to C 734*9e4fd900SJohn LevonLANG=C; export LANG 735*9e4fd900SJohn LevonLC_ALL=C; export LC_ALL 736*9e4fd900SJohn LevonLC_COLLATE=C; export LC_COLLATE 737*9e4fd900SJohn LevonLC_CTYPE=C; export LC_CTYPE 738*9e4fd900SJohn LevonLC_MESSAGES=C; export LC_MESSAGES 739*9e4fd900SJohn LevonLC_MONETARY=C; export LC_MONETARY 740*9e4fd900SJohn LevonLC_NUMERIC=C; export LC_NUMERIC 741*9e4fd900SJohn LevonLC_TIME=C; export LC_TIME 742*9e4fd900SJohn Levon 743*9e4fd900SJohn Levon# clear environment variables we know to be bad for the build 744*9e4fd900SJohn Levonunset LD_OPTIONS 745*9e4fd900SJohn Levonunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 746*9e4fd900SJohn Levonunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 747*9e4fd900SJohn Levonunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 748*9e4fd900SJohn Levonunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 749*9e4fd900SJohn Levonunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 750*9e4fd900SJohn Levonunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 751*9e4fd900SJohn Levonunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 752*9e4fd900SJohn Levonunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 753*9e4fd900SJohn Levonunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 754*9e4fd900SJohn Levonunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 755*9e4fd900SJohn Levonunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 756*9e4fd900SJohn Levonunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 757*9e4fd900SJohn Levonunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 758*9e4fd900SJohn Levonunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 759*9e4fd900SJohn Levonunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 760*9e4fd900SJohn Levonunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 761*9e4fd900SJohn Levonunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 762*9e4fd900SJohn Levonunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 763*9e4fd900SJohn Levonunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 764*9e4fd900SJohn Levonunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 765*9e4fd900SJohn Levon 766*9e4fd900SJohn Levonunset CONFIG 767*9e4fd900SJohn Levonunset GROUP 768*9e4fd900SJohn Levonunset OWNER 769*9e4fd900SJohn Levonunset REMOTE 770*9e4fd900SJohn Levonunset ENV 771*9e4fd900SJohn Levonunset ARCH 772*9e4fd900SJohn Levonunset CLASSPATH 773*9e4fd900SJohn Levonunset NAME 774*9e4fd900SJohn Levon 775*9e4fd900SJohn Levon# 776*9e4fd900SJohn Levon# To get ONBLD_TOOLS from the environment, it must come from the env file. 777*9e4fd900SJohn Levon# If it comes interactively, it is generally TOOLS_PROTO, which will be 778*9e4fd900SJohn Levon# clobbered before the compiler version checks, which will therefore fail. 779*9e4fd900SJohn Levon# 780*9e4fd900SJohn Levonunset ONBLD_TOOLS 781*9e4fd900SJohn Levon 782*9e4fd900SJohn Levon# 783*9e4fd900SJohn Levon# Setup environmental variables 784*9e4fd900SJohn Levon# 785*9e4fd900SJohn Levonif [ -f /etc/nightly.conf ]; then 786*9e4fd900SJohn Levon . /etc/nightly.conf 787*9e4fd900SJohn Levonfi 788*9e4fd900SJohn Levon 789*9e4fd900SJohn Levonif [ -f $1 ]; then 790*9e4fd900SJohn Levon if [[ $1 = */* ]]; then 791*9e4fd900SJohn Levon . $1 792*9e4fd900SJohn Levon else 793*9e4fd900SJohn Levon . ./$1 794*9e4fd900SJohn Levon fi 795*9e4fd900SJohn Levonelse 796*9e4fd900SJohn Levon if [ -f $OPTHOME/onbld/env/$1 ]; then 797*9e4fd900SJohn Levon . $OPTHOME/onbld/env/$1 798*9e4fd900SJohn Levon else 799*9e4fd900SJohn Levon echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 800*9e4fd900SJohn Levon exit 1 801*9e4fd900SJohn Levon fi 802*9e4fd900SJohn Levonfi 803*9e4fd900SJohn Levon 804*9e4fd900SJohn Levon# Check if we have sufficient data to continue... 805*9e4fd900SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 806*9e4fd900SJohn Levonif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 807*9e4fd900SJohn Levon # Check if the gate data are valid if we don't do a "bringover" below 808*9e4fd900SJohn Levon [[ -d "${CODEMGR_WS}" ]] || \ 809*9e4fd900SJohn Levon fatal_error "Error: ${CODEMGR_WS} is not a directory." 810*9e4fd900SJohn Levon [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 811*9e4fd900SJohn Levon fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 812*9e4fd900SJohn Levonfi 813*9e4fd900SJohn Levon 814*9e4fd900SJohn Levon# 815*9e4fd900SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set. 816*9e4fd900SJohn Levon# 817*9e4fd900SJohn Levonif [ -z "$BUILD_PROJECT" ]; then 818*9e4fd900SJohn Levon /usr/bin/newtask -c $$ 819*9e4fd900SJohn Levonelse 820*9e4fd900SJohn Levon /usr/bin/newtask -c $$ -p $BUILD_PROJECT 821*9e4fd900SJohn Levonfi 822*9e4fd900SJohn Levon 823*9e4fd900SJohn Levonps -o taskid= -p $$ | read build_taskid 824*9e4fd900SJohn Levonps -o project= -p $$ | read build_project 825*9e4fd900SJohn Levon 826*9e4fd900SJohn Levon# 827*9e4fd900SJohn Levon# See if NIGHTLY_OPTIONS is set 828*9e4fd900SJohn Levon# 829*9e4fd900SJohn Levonif [ "$NIGHTLY_OPTIONS" = "" ]; then 830*9e4fd900SJohn Levon NIGHTLY_OPTIONS="-aBm" 831*9e4fd900SJohn Levonfi 832*9e4fd900SJohn Levon 833*9e4fd900SJohn Levon# 834*9e4fd900SJohn Levon# If BRINGOVER_WS was not specified, let it default to CLONE_WS 835*9e4fd900SJohn Levon# 836*9e4fd900SJohn Levonif [ "$BRINGOVER_WS" = "" ]; then 837*9e4fd900SJohn Levon BRINGOVER_WS=$CLONE_WS 838*9e4fd900SJohn Levonfi 839*9e4fd900SJohn Levon 840*9e4fd900SJohn Levon# 841*9e4fd900SJohn Levon# If BRINGOVER_FILES was not specified, default to usr 842*9e4fd900SJohn Levon# 843*9e4fd900SJohn Levonif [ "$BRINGOVER_FILES" = "" ]; then 844*9e4fd900SJohn Levon BRINGOVER_FILES="usr" 845*9e4fd900SJohn Levonfi 846*9e4fd900SJohn Levon 847*9e4fd900SJohn Levoncheck_closed_bins 848*9e4fd900SJohn Levon 849*9e4fd900SJohn Levon# 850*9e4fd900SJohn Levon# Note: changes to the option letters here should also be applied to the 851*9e4fd900SJohn Levon# bldenv script. `d' is listed for backward compatibility. 852*9e4fd900SJohn Levon# 853*9e4fd900SJohn LevonNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 854*9e4fd900SJohn LevonOPTIND=1 855*9e4fd900SJohn Levonwhile getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 856*9e4fd900SJohn Levondo 857*9e4fd900SJohn Levon case $FLAG in 858*9e4fd900SJohn Levon A ) A_FLAG=y 859*9e4fd900SJohn Levon ;; 860*9e4fd900SJohn Levon B ) D_FLAG=y 861*9e4fd900SJohn Levon ;; # old version of D 862*9e4fd900SJohn Levon C ) C_FLAG=y 863*9e4fd900SJohn Levon ;; 864*9e4fd900SJohn Levon D ) D_FLAG=y 865*9e4fd900SJohn Levon ;; 866*9e4fd900SJohn Levon F ) F_FLAG=y 867*9e4fd900SJohn Levon ;; 868*9e4fd900SJohn Levon f ) f_FLAG=y 869*9e4fd900SJohn Levon ;; 870*9e4fd900SJohn Levon G ) u_FLAG=y 871*9e4fd900SJohn Levon ;; 872*9e4fd900SJohn Levon I ) m_FLAG=y 873*9e4fd900SJohn Levon p_FLAG=y 874*9e4fd900SJohn Levon u_FLAG=y 875*9e4fd900SJohn Levon ;; 876*9e4fd900SJohn Levon i ) i_FLAG=y 877*9e4fd900SJohn Levon ;; 878*9e4fd900SJohn Levon l ) l_FLAG=y 879*9e4fd900SJohn Levon ;; 880*9e4fd900SJohn Levon M ) M_FLAG=y 881*9e4fd900SJohn Levon ;; 882*9e4fd900SJohn Levon m ) m_FLAG=y 883*9e4fd900SJohn Levon ;; 884*9e4fd900SJohn Levon N ) N_FLAG=y 885*9e4fd900SJohn Levon ;; 886*9e4fd900SJohn Levon n ) n_FLAG=y 887*9e4fd900SJohn Levon ;; 888*9e4fd900SJohn Levon p ) p_FLAG=y 889*9e4fd900SJohn Levon ;; 890*9e4fd900SJohn Levon R ) m_FLAG=y 891*9e4fd900SJohn Levon p_FLAG=y 892*9e4fd900SJohn Levon ;; 893*9e4fd900SJohn Levon r ) r_FLAG=y 894*9e4fd900SJohn Levon ;; 895*9e4fd900SJohn Levon +t ) t_FLAG=n 896*9e4fd900SJohn Levon ;; 897*9e4fd900SJohn Levon U ) if [ -z "${PARENT_ROOT}" ]; then 898*9e4fd900SJohn Levon echo "PARENT_ROOT must be set if the U flag is" \ 899*9e4fd900SJohn Levon "present in NIGHTLY_OPTIONS." 900*9e4fd900SJohn Levon exit 1 901*9e4fd900SJohn Levon fi 902*9e4fd900SJohn Levon NIGHTLY_PARENT_ROOT=$PARENT_ROOT 903*9e4fd900SJohn Levon if [ -n "${PARENT_TOOLS_ROOT}" ]; then 904*9e4fd900SJohn Levon NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 905*9e4fd900SJohn Levon fi 906*9e4fd900SJohn Levon U_FLAG=y 907*9e4fd900SJohn Levon ;; 908*9e4fd900SJohn Levon u ) u_FLAG=y 909*9e4fd900SJohn Levon ;; 910*9e4fd900SJohn Levon w ) w_FLAG=y 911*9e4fd900SJohn Levon ;; 912*9e4fd900SJohn Levon W ) W_FLAG=y 913*9e4fd900SJohn Levon ;; 914*9e4fd900SJohn Levon \? ) echo "$USAGE" 915*9e4fd900SJohn Levon exit 1 916*9e4fd900SJohn Levon ;; 917*9e4fd900SJohn Levon esac 918*9e4fd900SJohn Levondone 919*9e4fd900SJohn Levon 920*9e4fd900SJohn Levonif [ $ISUSER -ne 0 ]; then 921*9e4fd900SJohn Levon # Set default value for STAFFER, if needed. 922*9e4fd900SJohn Levon if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 923*9e4fd900SJohn Levon STAFFER=`/usr/xpg4/bin/id -un` 924*9e4fd900SJohn Levon export STAFFER 925*9e4fd900SJohn Levon fi 926*9e4fd900SJohn Levonfi 927*9e4fd900SJohn Levon 928*9e4fd900SJohn Levonif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 929*9e4fd900SJohn Levon MAILTO=$STAFFER 930*9e4fd900SJohn Levon export MAILTO 931*9e4fd900SJohn Levonfi 932*9e4fd900SJohn Levon 933*9e4fd900SJohn LevonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 934*9e4fd900SJohn LevonPATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 935*9e4fd900SJohn LevonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 936*9e4fd900SJohn Levonexport PATH 937*9e4fd900SJohn Levon 938*9e4fd900SJohn Levon# roots of source trees, both relative to $SRC and absolute. 939*9e4fd900SJohn Levonrelsrcdirs="." 940*9e4fd900SJohn Levonabssrcdirs="$SRC" 941*9e4fd900SJohn Levon 942*9e4fd900SJohn LevonPROTOCMPTERSE="protocmp.terse -gu" 943*9e4fd900SJohn LevonPOUND_SIGN="#" 944*9e4fd900SJohn Levon# have we set RELEASE_DATE in our env file? 945*9e4fd900SJohn Levonif [ -z "$RELEASE_DATE" ]; then 946*9e4fd900SJohn Levon RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 947*9e4fd900SJohn Levonfi 948*9e4fd900SJohn LevonBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 949*9e4fd900SJohn LevonBASEWSDIR=$(basename $CODEMGR_WS) 950*9e4fd900SJohn LevonDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 951*9e4fd900SJohn Levon 952*9e4fd900SJohn Levon# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 953*9e4fd900SJohn Levon# by avoiding repeated shell invocations to evaluate Makefile.master 954*9e4fd900SJohn Levon# definitions. 955*9e4fd900SJohn Levonexport POUND_SIGN RELEASE_DATE DEV_CM 956*9e4fd900SJohn Levon 957*9e4fd900SJohn Levonmaketype="distributed" 958*9e4fd900SJohn Levonif [[ -z "$MAKE" ]]; then 959*9e4fd900SJohn Levon MAKE=dmake 960*9e4fd900SJohn Levonelif [[ ! -x "$MAKE" ]]; then 961*9e4fd900SJohn Levon echo "\$MAKE is set to garbage in the environment" 962*9e4fd900SJohn Levon exit 1 963*9e4fd900SJohn Levonfi 964*9e4fd900SJohn Levonexport PATH 965*9e4fd900SJohn Levonexport MAKE 966*9e4fd900SJohn Levon 967*9e4fd900SJohn Levonif [ "${SUNWSPRO}" != "" ]; then 968*9e4fd900SJohn Levon PATH="${SUNWSPRO}/bin:$PATH" 969*9e4fd900SJohn Levon export PATH 970*9e4fd900SJohn Levonfi 971*9e4fd900SJohn Levon 972*9e4fd900SJohn Levonhostname=$(uname -n) 973*9e4fd900SJohn Levonif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 974*9e4fd900SJohn Levonthen 975*9e4fd900SJohn Levon maxjobs= 976*9e4fd900SJohn Levon if [[ -f $HOME/.make.machines ]] 977*9e4fd900SJohn Levon then 978*9e4fd900SJohn Levon # Note: there is a hard tab and space character in the []s 979*9e4fd900SJohn Levon # below. 980*9e4fd900SJohn Levon egrep -i "^[ ]*$hostname[ \.]" \ 981*9e4fd900SJohn Levon $HOME/.make.machines | read host jobs 982*9e4fd900SJohn Levon maxjobs=${jobs##*=} 983*9e4fd900SJohn Levon fi 984*9e4fd900SJohn Levon 985*9e4fd900SJohn Levon if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 986*9e4fd900SJohn Levon then 987*9e4fd900SJohn Levon # default 988*9e4fd900SJohn Levon maxjobs=4 989*9e4fd900SJohn Levon fi 990*9e4fd900SJohn Levon 991*9e4fd900SJohn Levon export DMAKE_MAX_JOBS=$maxjobs 992*9e4fd900SJohn Levonfi 993*9e4fd900SJohn Levon 994*9e4fd900SJohn LevonDMAKE_MODE=parallel; 995*9e4fd900SJohn Levonexport DMAKE_MODE 996*9e4fd900SJohn Levon 997*9e4fd900SJohn Levonif [ -z "${ROOT}" ]; then 998*9e4fd900SJohn Levon echo "ROOT must be set." 999*9e4fd900SJohn Levon exit 1 1000*9e4fd900SJohn Levonfi 1001*9e4fd900SJohn Levon 1002*9e4fd900SJohn Levon# 1003*9e4fd900SJohn Levon# if -V flag was given, reset VERSION to V_ARG 1004*9e4fd900SJohn Levon# 1005*9e4fd900SJohn Levonif [ "$V_FLAG" = "y" ]; then 1006*9e4fd900SJohn Levon VERSION=$V_ARG 1007*9e4fd900SJohn Levonfi 1008*9e4fd900SJohn Levon 1009*9e4fd900SJohn LevonTMPDIR="/tmp/nightly.tmpdir.$$" 1010*9e4fd900SJohn Levonexport TMPDIR 1011*9e4fd900SJohn Levonrm -rf ${TMPDIR} 1012*9e4fd900SJohn Levonmkdir -p $TMPDIR || exit 1 1013*9e4fd900SJohn Levonchmod 777 $TMPDIR 1014*9e4fd900SJohn Levon 1015*9e4fd900SJohn Levon# 1016*9e4fd900SJohn Levon# Keep elfsign's use of pkcs11_softtoken from looking in the user home 1017*9e4fd900SJohn Levon# directory, which doesn't always work. Needed until all build machines 1018*9e4fd900SJohn Levon# have the fix for 6271754 1019*9e4fd900SJohn Levon# 1020*9e4fd900SJohn LevonSOFTTOKEN_DIR=$TMPDIR 1021*9e4fd900SJohn Levonexport SOFTTOKEN_DIR 1022*9e4fd900SJohn Levon 1023*9e4fd900SJohn Levon# 1024*9e4fd900SJohn Levon# Tools should only be built non-DEBUG. Keep track of the tools proto 1025*9e4fd900SJohn Levon# area path relative to $TOOLS, because the latter changes in an 1026*9e4fd900SJohn Levon# export build. 1027*9e4fd900SJohn Levon# 1028*9e4fd900SJohn Levon# TOOLS_PROTO is included below for builds other than usr/src/tools 1029*9e4fd900SJohn Levon# that look for this location. For usr/src/tools, this will be 1030*9e4fd900SJohn Levon# overridden on the $MAKE command line in build_tools(). 1031*9e4fd900SJohn Levon# 1032*9e4fd900SJohn LevonTOOLS=${SRC}/tools 1033*9e4fd900SJohn LevonTOOLS_PROTO_REL=proto/root_${MACH}-nd 1034*9e4fd900SJohn LevonTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1035*9e4fd900SJohn Levon 1036*9e4fd900SJohn Levonunset CFLAGS LD_LIBRARY_PATH LDFLAGS 1037*9e4fd900SJohn Levon 1038*9e4fd900SJohn Levon# create directories that are automatically removed if the nightly script 1039*9e4fd900SJohn Levon# fails to start correctly 1040*9e4fd900SJohn Levonfunction newdir { 1041*9e4fd900SJohn Levon dir=$1 1042*9e4fd900SJohn Levon toadd= 1043*9e4fd900SJohn Levon while [ ! -d $dir ]; do 1044*9e4fd900SJohn Levon toadd="$dir $toadd" 1045*9e4fd900SJohn Levon dir=`dirname $dir` 1046*9e4fd900SJohn Levon done 1047*9e4fd900SJohn Levon torm= 1048*9e4fd900SJohn Levon newlist= 1049*9e4fd900SJohn Levon for dir in $toadd; do 1050*9e4fd900SJohn Levon if staffer mkdir $dir; then 1051*9e4fd900SJohn Levon newlist="$ISUSER $dir $newlist" 1052*9e4fd900SJohn Levon torm="$dir $torm" 1053*9e4fd900SJohn Levon else 1054*9e4fd900SJohn Levon [ -z "$torm" ] || staffer rmdir $torm 1055*9e4fd900SJohn Levon return 1 1056*9e4fd900SJohn Levon fi 1057*9e4fd900SJohn Levon done 1058*9e4fd900SJohn Levon newdirlist="$newlist $newdirlist" 1059*9e4fd900SJohn Levon return 0 1060*9e4fd900SJohn Levon} 1061*9e4fd900SJohn Levonnewdirlist= 1062*9e4fd900SJohn Levon 1063*9e4fd900SJohn Levon[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 1064*9e4fd900SJohn Levon 1065*9e4fd900SJohn Levon# since this script assumes the build is from full source, it nullifies 1066*9e4fd900SJohn Levon# variables likely to have been set by a "ws" script; nullification 1067*9e4fd900SJohn Levon# confines the search space for headers and libraries to the proto area 1068*9e4fd900SJohn Levon# built from this immediate source. 1069*9e4fd900SJohn LevonENVLDLIBS1= 1070*9e4fd900SJohn LevonENVLDLIBS2= 1071*9e4fd900SJohn LevonENVLDLIBS3= 1072*9e4fd900SJohn LevonENVCPPFLAGS1= 1073*9e4fd900SJohn LevonENVCPPFLAGS2= 1074*9e4fd900SJohn LevonENVCPPFLAGS3= 1075*9e4fd900SJohn LevonENVCPPFLAGS4= 1076*9e4fd900SJohn LevonPARENT_ROOT= 1077*9e4fd900SJohn Levon 1078*9e4fd900SJohn Levonexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1079*9e4fd900SJohn Levon ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 1080*9e4fd900SJohn Levon 1081*9e4fd900SJohn LevonPKGARCHIVE_ORIG=$PKGARCHIVE 1082*9e4fd900SJohn Levon 1083*9e4fd900SJohn Levon# 1084*9e4fd900SJohn Levon# Juggle the logs and optionally send mail on completion. 1085*9e4fd900SJohn Levon# 1086*9e4fd900SJohn Levon 1087*9e4fd900SJohn Levonfunction logshuffle { 1088*9e4fd900SJohn Levon LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 1089*9e4fd900SJohn Levon if [ -f $LLOG -o -d $LLOG ]; then 1090*9e4fd900SJohn Levon LLOG=$LLOG.$$ 1091*9e4fd900SJohn Levon fi 1092*9e4fd900SJohn Levon mkdir $LLOG 1093*9e4fd900SJohn Levon export LLOG 1094*9e4fd900SJohn Levon 1095*9e4fd900SJohn Levon if [ "$build_ok" = "y" ]; then 1096*9e4fd900SJohn Levon mv $ATLOG/proto_list_${MACH} $LLOG 1097*9e4fd900SJohn Levon 1098*9e4fd900SJohn Levon if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 1099*9e4fd900SJohn Levon mv $ATLOG/proto_list_tools_${MACH} $LLOG 1100*9e4fd900SJohn Levon fi 1101*9e4fd900SJohn Levon 1102*9e4fd900SJohn Levon if [ -f $TMPDIR/wsdiff.results ]; then 1103*9e4fd900SJohn Levon mv $TMPDIR/wsdiff.results $LLOG 1104*9e4fd900SJohn Levon fi 1105*9e4fd900SJohn Levon 1106*9e4fd900SJohn Levon if [ -f $TMPDIR/wsdiff-nd.results ]; then 1107*9e4fd900SJohn Levon mv $TMPDIR/wsdiff-nd.results $LLOG 1108*9e4fd900SJohn Levon fi 1109*9e4fd900SJohn Levon fi 1110*9e4fd900SJohn Levon 1111*9e4fd900SJohn Levon # 1112*9e4fd900SJohn Levon # Now that we're about to send mail, it's time to check the noise 1113*9e4fd900SJohn Levon # file. In the event that an error occurs beyond this point, it will 1114*9e4fd900SJohn Levon # be recorded in the nightly.log file, but nowhere else. This would 1115*9e4fd900SJohn Levon # include only errors that cause the copying of the noise log to fail 1116*9e4fd900SJohn Levon # or the mail itself not to be sent. 1117*9e4fd900SJohn Levon # 1118*9e4fd900SJohn Levon 1119*9e4fd900SJohn Levon exec >>$LOGFILE 2>&1 1120*9e4fd900SJohn Levon if [ -s $build_noise_file ]; then 1121*9e4fd900SJohn Levon echo "\n==== Nightly build noise ====\n" | 1122*9e4fd900SJohn Levon tee -a $LOGFILE >>$mail_msg_file 1123*9e4fd900SJohn Levon cat $build_noise_file >>$LOGFILE 1124*9e4fd900SJohn Levon cat $build_noise_file >>$mail_msg_file 1125*9e4fd900SJohn Levon echo | tee -a $LOGFILE >>$mail_msg_file 1126*9e4fd900SJohn Levon fi 1127*9e4fd900SJohn Levon rm -f $build_noise_file 1128*9e4fd900SJohn Levon 1129*9e4fd900SJohn Levon case "$build_ok" in 1130*9e4fd900SJohn Levon y) 1131*9e4fd900SJohn Levon state=Completed 1132*9e4fd900SJohn Levon ;; 1133*9e4fd900SJohn Levon i) 1134*9e4fd900SJohn Levon state=Interrupted 1135*9e4fd900SJohn Levon ;; 1136*9e4fd900SJohn Levon *) 1137*9e4fd900SJohn Levon state=Failed 1138*9e4fd900SJohn Levon ;; 1139*9e4fd900SJohn Levon esac 1140*9e4fd900SJohn Levon 1141*9e4fd900SJohn Levon if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 1142*9e4fd900SJohn Levon state=Failed 1143*9e4fd900SJohn Levon fi 1144*9e4fd900SJohn Levon 1145*9e4fd900SJohn Levon NIGHTLY_STATUS=$state 1146*9e4fd900SJohn Levon export NIGHTLY_STATUS 1147*9e4fd900SJohn Levon 1148*9e4fd900SJohn Levon run_hook POST_NIGHTLY $state 1149*9e4fd900SJohn Levon run_hook SYS_POST_NIGHTLY $state 1150*9e4fd900SJohn Levon 1151*9e4fd900SJohn Levon # 1152*9e4fd900SJohn Levon # mailx(1) sets From: based on the -r flag 1153*9e4fd900SJohn Levon # if it is given. 1154*9e4fd900SJohn Levon # 1155*9e4fd900SJohn Levon mailx_r= 1156*9e4fd900SJohn Levon if [[ -n "${MAILFROM}" ]]; then 1157*9e4fd900SJohn Levon mailx_r="-r ${MAILFROM}" 1158*9e4fd900SJohn Levon fi 1159*9e4fd900SJohn Levon 1160*9e4fd900SJohn Levon cat $build_time_file $build_environ_file $mail_msg_file \ 1161*9e4fd900SJohn Levon > ${LLOG}/mail_msg 1162*9e4fd900SJohn Levon if [ "$m_FLAG" = "y" ]; then 1163*9e4fd900SJohn Levon cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 1164*9e4fd900SJohn Levon "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 1165*9e4fd900SJohn Levon ${MAILTO} 1166*9e4fd900SJohn Levon fi 1167*9e4fd900SJohn Levon 1168*9e4fd900SJohn Levon if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1169*9e4fd900SJohn Levon staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 1170*9e4fd900SJohn Levon staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 1171*9e4fd900SJohn Levon fi 1172*9e4fd900SJohn Levon 1173*9e4fd900SJohn Levon mv $LOGFILE $LLOG 1174*9e4fd900SJohn Levon} 1175*9e4fd900SJohn Levon 1176*9e4fd900SJohn Levon# 1177*9e4fd900SJohn Levon# Remove the locks and temporary files on any exit 1178*9e4fd900SJohn Levon# 1179*9e4fd900SJohn Levonfunction cleanup { 1180*9e4fd900SJohn Levon logshuffle 1181*9e4fd900SJohn Levon 1182*9e4fd900SJohn Levon [ -z "$lockfile" ] || staffer rm -f $lockfile 1183*9e4fd900SJohn Levon [ -z "$atloglockfile" ] || rm -f $atloglockfile 1184*9e4fd900SJohn Levon [ -z "$ulockfile" ] || staffer rm -f $ulockfile 1185*9e4fd900SJohn Levon [ -z "$Ulockfile" ] || rm -f $Ulockfile 1186*9e4fd900SJohn Levon 1187*9e4fd900SJohn Levon set -- $newdirlist 1188*9e4fd900SJohn Levon while [ $# -gt 0 ]; do 1189*9e4fd900SJohn Levon ISUSER=$1 staffer rmdir $2 1190*9e4fd900SJohn Levon shift; shift 1191*9e4fd900SJohn Levon done 1192*9e4fd900SJohn Levon rm -rf $TMPDIR 1193*9e4fd900SJohn Levon} 1194*9e4fd900SJohn Levon 1195*9e4fd900SJohn Levonfunction cleanup_signal { 1196*9e4fd900SJohn Levon build_ok=i 1197*9e4fd900SJohn Levon # this will trigger cleanup(), above. 1198*9e4fd900SJohn Levon exit 1 1199*9e4fd900SJohn Levon} 1200*9e4fd900SJohn Levon 1201*9e4fd900SJohn Levontrap cleanup 0 1202*9e4fd900SJohn Levontrap cleanup_signal 1 2 3 15 1203*9e4fd900SJohn Levon 1204*9e4fd900SJohn Levon# 1205*9e4fd900SJohn Levon# Generic lock file processing -- make sure that the lock file doesn't 1206*9e4fd900SJohn Levon# exist. If it does, it should name the build host and PID. If it 1207*9e4fd900SJohn Levon# doesn't, then make sure we can create it. Clean up locks that are 1208*9e4fd900SJohn Levon# known to be stale (assumes host name is unique among build systems 1209*9e4fd900SJohn Levon# for the workspace). 1210*9e4fd900SJohn Levon# 1211*9e4fd900SJohn Levonfunction create_lock { 1212*9e4fd900SJohn Levon lockf=$1 1213*9e4fd900SJohn Levon lockvar=$2 1214*9e4fd900SJohn Levon 1215*9e4fd900SJohn Levon ldir=`dirname $lockf` 1216*9e4fd900SJohn Levon [ -d $ldir ] || newdir $ldir || exit 1 1217*9e4fd900SJohn Levon eval $lockvar=$lockf 1218*9e4fd900SJohn Levon 1219*9e4fd900SJohn Levon while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 1220*9e4fd900SJohn Levon basews=`basename $CODEMGR_WS` 1221*9e4fd900SJohn Levon ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 1222*9e4fd900SJohn Levon if [ "$host" != "$hostname" ]; then 1223*9e4fd900SJohn Levon echo "$MACH build of $basews apparently" \ 1224*9e4fd900SJohn Levon "already started by $user on $host as $pid." 1225*9e4fd900SJohn Levon exit 1 1226*9e4fd900SJohn Levon elif kill -s 0 $pid 2>/dev/null; then 1227*9e4fd900SJohn Levon echo "$MACH build of $basews already started" \ 1228*9e4fd900SJohn Levon "by $user as $pid." 1229*9e4fd900SJohn Levon exit 1 1230*9e4fd900SJohn Levon else 1231*9e4fd900SJohn Levon # stale lock; clear it out and try again 1232*9e4fd900SJohn Levon rm -f $lockf 1233*9e4fd900SJohn Levon fi 1234*9e4fd900SJohn Levon done 1235*9e4fd900SJohn Levon} 1236*9e4fd900SJohn Levon 1237*9e4fd900SJohn Levon# 1238*9e4fd900SJohn Levon# Return the list of interesting proto areas, depending on the current 1239*9e4fd900SJohn Levon# options. 1240*9e4fd900SJohn Levon# 1241*9e4fd900SJohn Levonfunction allprotos { 1242*9e4fd900SJohn Levon typeset roots="$ROOT" 1243*9e4fd900SJohn Levon 1244*9e4fd900SJohn Levon if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1245*9e4fd900SJohn Levon roots="$roots $ROOT-nd" 1246*9e4fd900SJohn Levon fi 1247*9e4fd900SJohn Levon 1248*9e4fd900SJohn Levon echo $roots 1249*9e4fd900SJohn Levon} 1250*9e4fd900SJohn Levon 1251*9e4fd900SJohn Levon# Ensure no other instance of this script is running on this host. 1252*9e4fd900SJohn Levon# LOCKNAME can be set in <env_file>, and is by default, but is not 1253*9e4fd900SJohn Levon# required due to the use of $ATLOG below. 1254*9e4fd900SJohn Levonif [ -n "$LOCKNAME" ]; then 1255*9e4fd900SJohn Levon create_lock /tmp/$LOCKNAME "lockfile" 1256*9e4fd900SJohn Levonfi 1257*9e4fd900SJohn Levon# 1258*9e4fd900SJohn Levon# Create from one, two, or three other locks: 1259*9e4fd900SJohn Levon# $ATLOG/nightly.lock 1260*9e4fd900SJohn Levon# - protects against multiple builds in same workspace 1261*9e4fd900SJohn Levon# $PARENT_WS/usr/src/nightly.$MACH.lock 1262*9e4fd900SJohn Levon# - protects against multiple 'u' copy-backs 1263*9e4fd900SJohn Levon# $NIGHTLY_PARENT_ROOT/nightly.lock 1264*9e4fd900SJohn Levon# - protects against multiple 'U' copy-backs 1265*9e4fd900SJohn Levon# 1266*9e4fd900SJohn Levon# Overriding ISUSER to 1 causes the lock to be created as root if the 1267*9e4fd900SJohn Levon# script is run as root. The default is to create it as $STAFFER. 1268*9e4fd900SJohn LevonISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 1269*9e4fd900SJohn Levonif [ "$u_FLAG" = "y" ]; then 1270*9e4fd900SJohn Levon create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 1271*9e4fd900SJohn Levonfi 1272*9e4fd900SJohn Levonif [ "$U_FLAG" = "y" ]; then 1273*9e4fd900SJohn Levon # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 1274*9e4fd900SJohn Levon ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 1275*9e4fd900SJohn Levonfi 1276*9e4fd900SJohn Levon 1277*9e4fd900SJohn Levon# Locks have been taken, so we're doing a build and we're committed to 1278*9e4fd900SJohn Levon# the directories we may have created so far. 1279*9e4fd900SJohn Levonnewdirlist= 1280*9e4fd900SJohn Levon 1281*9e4fd900SJohn Levon# 1282*9e4fd900SJohn Levon# Create mail_msg_file 1283*9e4fd900SJohn Levon# 1284*9e4fd900SJohn Levonmail_msg_file="${TMPDIR}/mail_msg" 1285*9e4fd900SJohn Levontouch $mail_msg_file 1286*9e4fd900SJohn Levonbuild_time_file="${TMPDIR}/build_time" 1287*9e4fd900SJohn Levonbuild_environ_file="${TMPDIR}/build_environ" 1288*9e4fd900SJohn Levontouch $build_environ_file 1289*9e4fd900SJohn Levon# 1290*9e4fd900SJohn Levon# Move old LOGFILE aside 1291*9e4fd900SJohn Levon# ATLOG directory already made by 'create_lock' above 1292*9e4fd900SJohn Levon# 1293*9e4fd900SJohn Levonif [ -f $LOGFILE ]; then 1294*9e4fd900SJohn Levon mv -f $LOGFILE ${LOGFILE}- 1295*9e4fd900SJohn Levonfi 1296*9e4fd900SJohn Levon# 1297*9e4fd900SJohn Levon# Build OsNet source 1298*9e4fd900SJohn Levon# 1299*9e4fd900SJohn LevonSTART_DATE=`date` 1300*9e4fd900SJohn LevonSECONDS=0 1301*9e4fd900SJohn Levonecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 1302*9e4fd900SJohn Levon | tee -a $LOGFILE > $build_time_file 1303*9e4fd900SJohn Levon 1304*9e4fd900SJohn Levonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1305*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1306*9e4fd900SJohn Levon 1307*9e4fd900SJohn Levon# make sure we log only to the nightly build file 1308*9e4fd900SJohn Levonbuild_noise_file="${TMPDIR}/build_noise" 1309*9e4fd900SJohn Levonexec </dev/null >$build_noise_file 2>&1 1310*9e4fd900SJohn Levon 1311*9e4fd900SJohn Levonrun_hook SYS_PRE_NIGHTLY 1312*9e4fd900SJohn Levonrun_hook PRE_NIGHTLY 1313*9e4fd900SJohn Levon 1314*9e4fd900SJohn Levonecho "\n==== list of environment variables ====\n" >> $LOGFILE 1315*9e4fd900SJohn Levonenv >> $LOGFILE 1316*9e4fd900SJohn Levon 1317*9e4fd900SJohn Levonecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 1318*9e4fd900SJohn Levon 1319*9e4fd900SJohn Levonif [ "$N_FLAG" = "y" ]; then 1320*9e4fd900SJohn Levon if [ "$p_FLAG" = "y" ]; then 1321*9e4fd900SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1322*9e4fd900SJohn LevonWARNING: the p option (create packages) is set, but so is the N option (do 1323*9e4fd900SJohn Levon not run protocmp); this is dangerous; you should unset the N option 1324*9e4fd900SJohn LevonEOF 1325*9e4fd900SJohn Levon else 1326*9e4fd900SJohn Levon cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1327*9e4fd900SJohn LevonWarning: the N option (do not run protocmp) is set; it probably shouldn't be 1328*9e4fd900SJohn LevonEOF 1329*9e4fd900SJohn Levon fi 1330*9e4fd900SJohn Levon echo "" | tee -a $mail_msg_file >> $LOGFILE 1331*9e4fd900SJohn Levonfi 1332*9e4fd900SJohn Levon 1333*9e4fd900SJohn Levonif [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 1334*9e4fd900SJohn Levon # 1335*9e4fd900SJohn Levon # In the past we just complained but went ahead with the lint 1336*9e4fd900SJohn Levon # pass, even though the proto area was built non-DEBUG. It's 1337*9e4fd900SJohn Levon # unlikely that non-DEBUG headers will make a difference, but 1338*9e4fd900SJohn Levon # rather than assuming it's a safe combination, force the user 1339*9e4fd900SJohn Levon # to specify a DEBUG build. 1340*9e4fd900SJohn Levon # 1341*9e4fd900SJohn Levon echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 1342*9e4fd900SJohn Levon | tee -a $mail_msg_file >> $LOGFILE 1343*9e4fd900SJohn Levon l_FLAG=n 1344*9e4fd900SJohn Levonfi 1345*9e4fd900SJohn Levon 1346*9e4fd900SJohn Levonif [ "$f_FLAG" = "y" ]; then 1347*9e4fd900SJohn Levon if [ "$i_FLAG" = "y" ]; then 1348*9e4fd900SJohn Levon echo "WARNING: the -f flag cannot be used during incremental" \ 1349*9e4fd900SJohn Levon "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1350*9e4fd900SJohn Levon f_FLAG=n 1351*9e4fd900SJohn Levon fi 1352*9e4fd900SJohn Levon if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 1353*9e4fd900SJohn Levon echo "WARNING: the -f flag requires -l, and -p;" \ 1354*9e4fd900SJohn Levon "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1355*9e4fd900SJohn Levon f_FLAG=n 1356*9e4fd900SJohn Levon fi 1357*9e4fd900SJohn Levonfi 1358*9e4fd900SJohn Levon 1359*9e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 1360*9e4fd900SJohn Levon echo "WARNING: -w specified, but $ROOT does not exist;" \ 1361*9e4fd900SJohn Levon "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 1362*9e4fd900SJohn Levon w_FLAG=n 1363*9e4fd900SJohn Levonfi 1364*9e4fd900SJohn Levon 1365*9e4fd900SJohn Levonif [ "$t_FLAG" = "n" ]; then 1366*9e4fd900SJohn Levon # 1367*9e4fd900SJohn Levon # We're not doing a tools build, so make sure elfsign(1) is 1368*9e4fd900SJohn Levon # new enough to safely sign non-crypto binaries. We test 1369*9e4fd900SJohn Levon # debugging output from elfsign to detect the old version. 1370*9e4fd900SJohn Levon # 1371*9e4fd900SJohn Levon newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 1372*9e4fd900SJohn Levon -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 1373*9e4fd900SJohn Levon | egrep algorithmOID` 1374*9e4fd900SJohn Levon if [ -z "$newelfsigntest" ]; then 1375*9e4fd900SJohn Levon echo "WARNING: /usr/bin/elfsign out of date;" \ 1376*9e4fd900SJohn Levon "will only sign crypto modules\n" | \ 1377*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1378*9e4fd900SJohn Levon export ELFSIGN_OBJECT=true 1379*9e4fd900SJohn Levon elif [ "$VERIFY_ELFSIGN" = "y" ]; then 1380*9e4fd900SJohn Levon echo "WARNING: VERIFY_ELFSIGN=y requires" \ 1381*9e4fd900SJohn Levon "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 1382*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1383*9e4fd900SJohn Levon fi 1384*9e4fd900SJohn Levonfi 1385*9e4fd900SJohn Levon 1386*9e4fd900SJohn Levoncase $MULTI_PROTO in 1387*9e4fd900SJohn Levonyes|no) ;; 1388*9e4fd900SJohn Levon*) 1389*9e4fd900SJohn Levon echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 1390*9e4fd900SJohn Levon "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 1391*9e4fd900SJohn Levon echo "Setting MULTI_PROTO to \"no\".\n" | \ 1392*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1393*9e4fd900SJohn Levon export MULTI_PROTO=no 1394*9e4fd900SJohn Levon ;; 1395*9e4fd900SJohn Levonesac 1396*9e4fd900SJohn Levon 1397*9e4fd900SJohn Levonecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 1398*9e4fd900SJohn Levonecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 1399*9e4fd900SJohn Levon 1400*9e4fd900SJohn Levon# Save the current proto area if we're comparing against the last build 1401*9e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 1402*9e4fd900SJohn Levon if [ -d "$ROOT.prev" ]; then 1403*9e4fd900SJohn Levon rm -rf $ROOT.prev 1404*9e4fd900SJohn Levon fi 1405*9e4fd900SJohn Levon mv $ROOT $ROOT.prev 1406*9e4fd900SJohn Levonfi 1407*9e4fd900SJohn Levon 1408*9e4fd900SJohn Levon# Same for non-DEBUG proto area 1409*9e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 1410*9e4fd900SJohn Levon if [ -d "$ROOT-nd.prev" ]; then 1411*9e4fd900SJohn Levon rm -rf $ROOT-nd.prev 1412*9e4fd900SJohn Levon fi 1413*9e4fd900SJohn Levon mv $ROOT-nd $ROOT-nd.prev 1414*9e4fd900SJohn Levonfi 1415*9e4fd900SJohn Levon 1416*9e4fd900SJohn Levon# 1417*9e4fd900SJohn Levon# Echo the SCM type of the parent workspace, this can't just be which_scm 1418*9e4fd900SJohn Levon# as that does not know how to identify various network repositories. 1419*9e4fd900SJohn Levon# 1420*9e4fd900SJohn Levonfunction parent_wstype { 1421*9e4fd900SJohn Levon typeset scm_type junk 1422*9e4fd900SJohn Levon 1423*9e4fd900SJohn Levon CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1424*9e4fd900SJohn Levon | read scm_type junk 1425*9e4fd900SJohn Levon if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 1426*9e4fd900SJohn Levon # Probe BRINGOVER_WS to determine its type 1427*9e4fd900SJohn Levon if [[ $BRINGOVER_WS == ssh://* ]]; then 1428*9e4fd900SJohn Levon scm_type="mercurial" 1429*9e4fd900SJohn Levon elif [[ $BRINGOVER_WS == http://* ]] && \ 1430*9e4fd900SJohn Levon wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 1431*9e4fd900SJohn Levon egrep -s "application/mercurial" 2> /dev/null; then 1432*9e4fd900SJohn Levon scm_type="mercurial" 1433*9e4fd900SJohn Levon else 1434*9e4fd900SJohn Levon scm_type="none" 1435*9e4fd900SJohn Levon fi 1436*9e4fd900SJohn Levon fi 1437*9e4fd900SJohn Levon 1438*9e4fd900SJohn Levon # fold both unsupported and unrecognized results into "none" 1439*9e4fd900SJohn Levon case "$scm_type" in 1440*9e4fd900SJohn Levon mercurial) 1441*9e4fd900SJohn Levon ;; 1442*9e4fd900SJohn Levon *) scm_type=none 1443*9e4fd900SJohn Levon ;; 1444*9e4fd900SJohn Levon esac 1445*9e4fd900SJohn Levon 1446*9e4fd900SJohn Levon echo $scm_type 1447*9e4fd900SJohn Levon} 1448*9e4fd900SJohn Levon 1449*9e4fd900SJohn Levon# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1450*9e4fd900SJohn Levonfunction child_wstype { 1451*9e4fd900SJohn Levon typeset scm_type junk 1452*9e4fd900SJohn Levon 1453*9e4fd900SJohn Levon # Probe CODEMGR_WS to determine its type 1454*9e4fd900SJohn Levon if [[ -d $CODEMGR_WS ]]; then 1455*9e4fd900SJohn Levon $WHICH_SCM | read scm_type junk || exit 1 1456*9e4fd900SJohn Levon fi 1457*9e4fd900SJohn Levon 1458*9e4fd900SJohn Levon case "$scm_type" in 1459*9e4fd900SJohn Levon none|git|mercurial) 1460*9e4fd900SJohn Levon ;; 1461*9e4fd900SJohn Levon *) scm_type=none 1462*9e4fd900SJohn Levon ;; 1463*9e4fd900SJohn Levon esac 1464*9e4fd900SJohn Levon 1465*9e4fd900SJohn Levon echo $scm_type 1466*9e4fd900SJohn Levon} 1467*9e4fd900SJohn Levon 1468*9e4fd900SJohn LevonSCM_TYPE=$(child_wstype) 1469*9e4fd900SJohn Levon 1470*9e4fd900SJohn Levon# 1471*9e4fd900SJohn Levon# Decide whether to clobber 1472*9e4fd900SJohn Levon# 1473*9e4fd900SJohn Levonif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 1474*9e4fd900SJohn Levon echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 1475*9e4fd900SJohn Levon 1476*9e4fd900SJohn Levon cd $SRC 1477*9e4fd900SJohn Levon # remove old clobber file 1478*9e4fd900SJohn Levon rm -f $SRC/clobber.out 1479*9e4fd900SJohn Levon rm -f $SRC/clobber-${MACH}.out 1480*9e4fd900SJohn Levon 1481*9e4fd900SJohn Levon # Remove all .make.state* files, just in case we are restarting 1482*9e4fd900SJohn Levon # the build after having interrupted a previous 'make clobber'. 1483*9e4fd900SJohn Levon find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1484*9e4fd900SJohn Levon -o -name 'interfaces.*' \) -prune \ 1485*9e4fd900SJohn Levon -o -name '.make.*' -print | xargs rm -f 1486*9e4fd900SJohn Levon 1487*9e4fd900SJohn Levon $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 1488*9e4fd900SJohn Levon echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 1489*9e4fd900SJohn Levon grep "$MAKE:" $SRC/clobber-${MACH}.out | 1490*9e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 1491*9e4fd900SJohn Levon tee $TMPDIR/clobber_errs >> $mail_msg_file 1492*9e4fd900SJohn Levon 1493*9e4fd900SJohn Levon if [[ -s $TMPDIR/clobber_errs ]]; then 1494*9e4fd900SJohn Levon build_extras_ok=n 1495*9e4fd900SJohn Levon fi 1496*9e4fd900SJohn Levon 1497*9e4fd900SJohn Levon if [[ "$t_FLAG" = "y" ]]; then 1498*9e4fd900SJohn Levon echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 1499*9e4fd900SJohn Levon cd ${TOOLS} 1500*9e4fd900SJohn Levon rm -f ${TOOLS}/clobber-${MACH}.out 1501*9e4fd900SJohn Levon $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 1502*9e4fd900SJohn Levon tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 1503*9e4fd900SJohn Levon echo "\n==== Make tools clobber ERRORS ====\n" \ 1504*9e4fd900SJohn Levon >> $mail_msg_file 1505*9e4fd900SJohn Levon grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1506*9e4fd900SJohn Levon >> $mail_msg_file 1507*9e4fd900SJohn Levon if (( $? == 0 )); then 1508*9e4fd900SJohn Levon build_extras_ok=n 1509*9e4fd900SJohn Levon fi 1510*9e4fd900SJohn Levon rm -rf ${TOOLS_PROTO} 1511*9e4fd900SJohn Levon mkdir -p ${TOOLS_PROTO} 1512*9e4fd900SJohn Levon fi 1513*9e4fd900SJohn Levon 1514*9e4fd900SJohn Levon typeset roots=$(allprotos) 1515*9e4fd900SJohn Levon echo "\n\nClearing $roots" >> "$LOGFILE" 1516*9e4fd900SJohn Levon rm -rf $roots 1517*9e4fd900SJohn Levon 1518*9e4fd900SJohn Levon # Get back to a clean workspace as much as possible to catch 1519*9e4fd900SJohn Levon # problems that only occur on fresh workspaces. 1520*9e4fd900SJohn Levon # Remove all .make.state* files, libraries, and .o's that may 1521*9e4fd900SJohn Levon # have been omitted from clobber. A couple of libraries are 1522*9e4fd900SJohn Levon # under source code control, so leave them alone. 1523*9e4fd900SJohn Levon # We should probably blow away temporary directories too. 1524*9e4fd900SJohn Levon cd $SRC 1525*9e4fd900SJohn Levon find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 1526*9e4fd900SJohn Levon -o -name .git -o -name 'interfaces.*' \) -prune -o \ 1527*9e4fd900SJohn Levon \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1528*9e4fd900SJohn Levon -name '*.o' \) -print | \ 1529*9e4fd900SJohn Levon grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 1530*9e4fd900SJohn Levonelse 1531*9e4fd900SJohn Levon echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 1532*9e4fd900SJohn Levonfi 1533*9e4fd900SJohn Levon 1534*9e4fd900SJohn Levontype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1535*9e4fd900SJohn Levon typeset -x PATH=$PATH 1536*9e4fd900SJohn Levon 1537*9e4fd900SJohn Levon # If the repository doesn't exist yet, then we want to populate it. 1538*9e4fd900SJohn Levon if [[ ! -d $CODEMGR_WS/.hg ]]; then 1539*9e4fd900SJohn Levon staffer hg init $CODEMGR_WS 1540*9e4fd900SJohn Levon staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 1541*9e4fd900SJohn Levon staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1542*9e4fd900SJohn Levon touch $TMPDIR/new_repository 1543*9e4fd900SJohn Levon fi 1544*9e4fd900SJohn Levon 1545*9e4fd900SJohn Levon typeset -x HGMERGE="/bin/false" 1546*9e4fd900SJohn Levon 1547*9e4fd900SJohn Levon # 1548*9e4fd900SJohn Levon # If the user has changes, regardless of whether those changes are 1549*9e4fd900SJohn Levon # committed, and regardless of whether those changes conflict, then 1550*9e4fd900SJohn Levon # we'll attempt to merge them either implicitly (uncommitted) or 1551*9e4fd900SJohn Levon # explicitly (committed). 1552*9e4fd900SJohn Levon # 1553*9e4fd900SJohn Levon # These are the messages we'll use to help clarify mercurial output 1554*9e4fd900SJohn Levon # in those cases. 1555*9e4fd900SJohn Levon # 1556*9e4fd900SJohn Levon typeset mergefailmsg="\ 1557*9e4fd900SJohn Levon***\n\ 1558*9e4fd900SJohn Levon*** nightly was unable to automatically merge your changes. You should\n\ 1559*9e4fd900SJohn Levon*** redo the full merge manually, following the steps outlined by mercurial\n\ 1560*9e4fd900SJohn Levon*** above, then restart nightly.\n\ 1561*9e4fd900SJohn Levon***\n" 1562*9e4fd900SJohn Levon typeset mergepassmsg="\ 1563*9e4fd900SJohn Levon***\n\ 1564*9e4fd900SJohn Levon*** nightly successfully merged your changes. This means that your working\n\ 1565*9e4fd900SJohn Levon*** directory has been updated, but those changes are not yet committed.\n\ 1566*9e4fd900SJohn Levon*** After nightly completes, you should validate the results of the merge,\n\ 1567*9e4fd900SJohn Levon*** then use hg commit manually.\n\ 1568*9e4fd900SJohn Levon***\n" 1569*9e4fd900SJohn Levon 1570*9e4fd900SJohn Levon # 1571*9e4fd900SJohn Levon # For each repository in turn: 1572*9e4fd900SJohn Levon # 1573*9e4fd900SJohn Levon # 1. Do the pull. If this fails, dump the output and bail out. 1574*9e4fd900SJohn Levon # 1575*9e4fd900SJohn Levon # 2. If the pull resulted in an extra head, do an explicit merge. 1576*9e4fd900SJohn Levon # If this fails, dump the output and bail out. 1577*9e4fd900SJohn Levon # 1578*9e4fd900SJohn Levon # Because we can't rely on Mercurial to exit with a failure code 1579*9e4fd900SJohn Levon # when a merge fails (Mercurial issue #186), we must grep the 1580*9e4fd900SJohn Levon # output of pull/merge to check for attempted and/or failed merges. 1581*9e4fd900SJohn Levon # 1582*9e4fd900SJohn Levon # 3. If a merge failed, set the message and fail the bringover. 1583*9e4fd900SJohn Levon # 1584*9e4fd900SJohn Levon # 4. Otherwise, if a merge succeeded, set the message 1585*9e4fd900SJohn Levon # 1586*9e4fd900SJohn Levon # 5. Dump the output, and any message from step 3 or 4. 1587*9e4fd900SJohn Levon # 1588*9e4fd900SJohn Levon 1589*9e4fd900SJohn Levon typeset HG_SOURCE=$BRINGOVER_WS 1590*9e4fd900SJohn Levon if [ ! -f $TMPDIR/new_repository ]; then 1591*9e4fd900SJohn Levon HG_SOURCE=$TMPDIR/open_bundle.hg 1592*9e4fd900SJohn Levon staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1593*9e4fd900SJohn Levon -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1594*9e4fd900SJohn Levon 1595*9e4fd900SJohn Levon # 1596*9e4fd900SJohn Levon # If there are no incoming changesets, then incoming will 1597*9e4fd900SJohn Levon # fail, and there will be no bundle file. Reset the source, 1598*9e4fd900SJohn Levon # to allow the remaining logic to complete with no false 1599*9e4fd900SJohn Levon # negatives. (Unlike incoming, pull will return success 1600*9e4fd900SJohn Levon # for the no-change case.) 1601*9e4fd900SJohn Levon # 1602*9e4fd900SJohn Levon if (( $? != 0 )); then 1603*9e4fd900SJohn Levon HG_SOURCE=$BRINGOVER_WS 1604*9e4fd900SJohn Levon fi 1605*9e4fd900SJohn Levon fi 1606*9e4fd900SJohn Levon 1607*9e4fd900SJohn Levon staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 1608*9e4fd900SJohn Levon > $TMPDIR/pull_open.out 2>&1 1609*9e4fd900SJohn Levon if (( $? != 0 )); then 1610*9e4fd900SJohn Levon printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 1611*9e4fd900SJohn Levon cat $TMPDIR/pull_open.out 1612*9e4fd900SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 1613*9e4fd900SJohn Levon printf "$mergefailmsg" 1614*9e4fd900SJohn Levon fi 1615*9e4fd900SJohn Levon touch $TMPDIR/bringover_failed 1616*9e4fd900SJohn Levon return 1617*9e4fd900SJohn Levon fi 1618*9e4fd900SJohn Levon 1619*9e4fd900SJohn Levon if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 1620*9e4fd900SJohn Levon staffer hg --cwd $CODEMGR_WS merge \ 1621*9e4fd900SJohn Levon >> $TMPDIR/pull_open.out 2>&1 1622*9e4fd900SJohn Levon if (( $? != 0 )); then 1623*9e4fd900SJohn Levon printf "%s: merge failed as follows:\n\n" \ 1624*9e4fd900SJohn Levon "$CODEMGR_WS" 1625*9e4fd900SJohn Levon cat $TMPDIR/pull_open.out 1626*9e4fd900SJohn Levon if grep "^merging.*failed" $TMPDIR/pull_open.out \ 1627*9e4fd900SJohn Levon > /dev/null 2>&1; then 1628*9e4fd900SJohn Levon printf "$mergefailmsg" 1629*9e4fd900SJohn Levon fi 1630*9e4fd900SJohn Levon touch $TMPDIR/bringover_failed 1631*9e4fd900SJohn Levon return 1632*9e4fd900SJohn Levon fi 1633*9e4fd900SJohn Levon fi 1634*9e4fd900SJohn Levon 1635*9e4fd900SJohn Levon printf "updated %s with the following results:\n" "$CODEMGR_WS" 1636*9e4fd900SJohn Levon cat $TMPDIR/pull_open.out 1637*9e4fd900SJohn Levon if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 1638*9e4fd900SJohn Levon printf "$mergepassmsg" 1639*9e4fd900SJohn Levon fi 1640*9e4fd900SJohn Levon printf "\n" 1641*9e4fd900SJohn Levon 1642*9e4fd900SJohn Levon # 1643*9e4fd900SJohn Levon # Per-changeset output is neither useful nor manageable for a 1644*9e4fd900SJohn Levon # newly-created repository. 1645*9e4fd900SJohn Levon # 1646*9e4fd900SJohn Levon if [ -f $TMPDIR/new_repository ]; then 1647*9e4fd900SJohn Levon return 1648*9e4fd900SJohn Levon fi 1649*9e4fd900SJohn Levon 1650*9e4fd900SJohn Levon printf "\nadded the following changesets to open repository:\n" 1651*9e4fd900SJohn Levon cat $TMPDIR/incoming_open.out 1652*9e4fd900SJohn Levon} 1653*9e4fd900SJohn Levon 1654*9e4fd900SJohn Levontype bringover_none > /dev/null 2>&1 || function bringover_none { 1655*9e4fd900SJohn Levon echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1656*9e4fd900SJohn Levon touch $TMPDIR/bringover_failed 1657*9e4fd900SJohn Levon} 1658*9e4fd900SJohn Levon 1659*9e4fd900SJohn Levon# 1660*9e4fd900SJohn Levon# Decide whether to bringover to the codemgr workspace 1661*9e4fd900SJohn Levon# 1662*9e4fd900SJohn Levonif [ "$n_FLAG" = "n" ]; then 1663*9e4fd900SJohn Levon PARENT_SCM_TYPE=$(parent_wstype) 1664*9e4fd900SJohn Levon 1665*9e4fd900SJohn Levon if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1666*9e4fd900SJohn Levon echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1667*9e4fd900SJohn Levon "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 1668*9e4fd900SJohn Levon exit 1 1669*9e4fd900SJohn Levon fi 1670*9e4fd900SJohn Levon 1671*9e4fd900SJohn Levon run_hook PRE_BRINGOVER 1672*9e4fd900SJohn Levon 1673*9e4fd900SJohn Levon echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1674*9e4fd900SJohn Levon echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1675*9e4fd900SJohn Levon 1676*9e4fd900SJohn Levon eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 1677*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1678*9e4fd900SJohn Levon 1679*9e4fd900SJohn Levon if [ -f $TMPDIR/bringover_failed ]; then 1680*9e4fd900SJohn Levon rm -f $TMPDIR/bringover_failed 1681*9e4fd900SJohn Levon build_ok=n 1682*9e4fd900SJohn Levon echo "trouble with bringover, quitting at `date`." | 1683*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1684*9e4fd900SJohn Levon exit 1 1685*9e4fd900SJohn Levon fi 1686*9e4fd900SJohn Levon 1687*9e4fd900SJohn Levon # 1688*9e4fd900SJohn Levon # It's possible that we used the bringover above to create 1689*9e4fd900SJohn Levon # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 1690*9e4fd900SJohn Levon # but should now be the same as $BRINGOVER_WS. 1691*9e4fd900SJohn Levon # 1692*9e4fd900SJohn Levon [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 1693*9e4fd900SJohn Levon 1694*9e4fd900SJohn Levon run_hook POST_BRINGOVER 1695*9e4fd900SJohn Levon 1696*9e4fd900SJohn Levon check_closed_bins 1697*9e4fd900SJohn Levon 1698*9e4fd900SJohn Levonelse 1699*9e4fd900SJohn Levon echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 1700*9e4fd900SJohn Levonfi 1701*9e4fd900SJohn Levon 1702*9e4fd900SJohn Levon# Safeguards 1703*9e4fd900SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 1704*9e4fd900SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 1705*9e4fd900SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 1706*9e4fd900SJohn Levon 1707*9e4fd900SJohn Levonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 1708*9e4fd900SJohn Levon 1709*9e4fd900SJohn Levon# System 1710*9e4fd900SJohn Levonwhence uname | tee -a $build_environ_file >> $LOGFILE 1711*9e4fd900SJohn Levonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 1712*9e4fd900SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 1713*9e4fd900SJohn Levon 1714*9e4fd900SJohn Levon# make 1715*9e4fd900SJohn Levonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 1716*9e4fd900SJohn Levon$MAKE -v | tee -a $build_environ_file >> $LOGFILE 1717*9e4fd900SJohn Levonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1718*9e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 1719*9e4fd900SJohn Levon 1720*9e4fd900SJohn Levon# 1721*9e4fd900SJohn Levon# Report the compiler versions. 1722*9e4fd900SJohn Levon# 1723*9e4fd900SJohn Levon 1724*9e4fd900SJohn Levonif [[ ! -f $SRC/Makefile ]]; then 1725*9e4fd900SJohn Levon build_ok=n 1726*9e4fd900SJohn Levon echo "\nUnable to find \"Makefile\" in $SRC." | \ 1727*9e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 1728*9e4fd900SJohn Levon exit 1 1729*9e4fd900SJohn Levonfi 1730*9e4fd900SJohn Levon 1731*9e4fd900SJohn Levon( cd $SRC 1732*9e4fd900SJohn Levon for target in cc-version cc64-version java-version; do 1733*9e4fd900SJohn Levon echo 1734*9e4fd900SJohn Levon # 1735*9e4fd900SJohn Levon # Put statefile somewhere we know we can write to rather than trip 1736*9e4fd900SJohn Levon # over a read-only $srcroot. 1737*9e4fd900SJohn Levon # 1738*9e4fd900SJohn Levon rm -f $TMPDIR/make-state 1739*9e4fd900SJohn Levon export SRC 1740*9e4fd900SJohn Levon if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1741*9e4fd900SJohn Levon continue 1742*9e4fd900SJohn Levon fi 1743*9e4fd900SJohn Levon touch $TMPDIR/nocompiler 1744*9e4fd900SJohn Levon done 1745*9e4fd900SJohn Levon echo 1746*9e4fd900SJohn Levon) | tee -a $build_environ_file >> $LOGFILE 1747*9e4fd900SJohn Levon 1748*9e4fd900SJohn Levonif [ -f $TMPDIR/nocompiler ]; then 1749*9e4fd900SJohn Levon rm -f $TMPDIR/nocompiler 1750*9e4fd900SJohn Levon build_ok=n 1751*9e4fd900SJohn Levon echo "Aborting due to missing compiler." | 1752*9e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 1753*9e4fd900SJohn Levon exit 1 1754*9e4fd900SJohn Levonfi 1755*9e4fd900SJohn Levon 1756*9e4fd900SJohn Levon# as 1757*9e4fd900SJohn Levonwhence as | tee -a $build_environ_file >> $LOGFILE 1758*9e4fd900SJohn Levonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 1759*9e4fd900SJohn Levonecho | tee -a $build_environ_file >> $LOGFILE 1760*9e4fd900SJohn Levon 1761*9e4fd900SJohn Levon# Check that we're running a capable link-editor 1762*9e4fd900SJohn Levonwhence ld | tee -a $build_environ_file >> $LOGFILE 1763*9e4fd900SJohn LevonLDVER=`ld -V 2>&1` 1764*9e4fd900SJohn Levonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 1765*9e4fd900SJohn LevonLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 1766*9e4fd900SJohn Levonif [ `expr $LDVER \< 422` -eq 1 ]; then 1767*9e4fd900SJohn Levon echo "The link-editor needs to be at version 422 or higher to build" | \ 1768*9e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 1769*9e4fd900SJohn Levon echo "the latest stuff. Hope your build works." | \ 1770*9e4fd900SJohn Levon tee -a $build_environ_file >> $LOGFILE 1771*9e4fd900SJohn Levonfi 1772*9e4fd900SJohn Levon 1773*9e4fd900SJohn Levon# 1774*9e4fd900SJohn Levon# Build and use the workspace's tools if requested 1775*9e4fd900SJohn Levon# 1776*9e4fd900SJohn Levonif [[ "$t_FLAG" = "y" ]]; then 1777*9e4fd900SJohn Levon set_non_debug_build_flags 1778*9e4fd900SJohn Levon 1779*9e4fd900SJohn Levon build_tools ${TOOLS_PROTO} 1780*9e4fd900SJohn Levon if (( $? != 0 )); then 1781*9e4fd900SJohn Levon build_ok=n 1782*9e4fd900SJohn Levon else 1783*9e4fd900SJohn Levon use_tools $TOOLS_PROTO 1784*9e4fd900SJohn Levon fi 1785*9e4fd900SJohn Levonfi 1786*9e4fd900SJohn Levon 1787*9e4fd900SJohn Levon# timestamp the start of the normal build; the findunref tool uses it. 1788*9e4fd900SJohn Levontouch $SRC/.build.tstamp 1789*9e4fd900SJohn Levon 1790*9e4fd900SJohn Levonnormal_build 1791*9e4fd900SJohn Levon 1792*9e4fd900SJohn LevonORIG_SRC=$SRC 1793*9e4fd900SJohn LevonBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 1794*9e4fd900SJohn Levon 1795*9e4fd900SJohn Levon 1796*9e4fd900SJohn Levon# 1797*9e4fd900SJohn Levon# There are several checks that need to look at the proto area, but 1798*9e4fd900SJohn Levon# they only need to look at one, and they don't care whether it's 1799*9e4fd900SJohn Levon# DEBUG or non-DEBUG. 1800*9e4fd900SJohn Levon# 1801*9e4fd900SJohn Levonif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 1802*9e4fd900SJohn Levon checkroot=$ROOT-nd 1803*9e4fd900SJohn Levonelse 1804*9e4fd900SJohn Levon checkroot=$ROOT 1805*9e4fd900SJohn Levonfi 1806*9e4fd900SJohn Levon 1807*9e4fd900SJohn Levonif [ "$build_ok" = "y" ]; then 1808*9e4fd900SJohn Levon echo "\n==== Creating protolist system file at `date` ====" \ 1809*9e4fd900SJohn Levon >> $LOGFILE 1810*9e4fd900SJohn Levon protolist $checkroot > $ATLOG/proto_list_${MACH} 1811*9e4fd900SJohn Levon echo "==== protolist system file created at `date` ====\n" \ 1812*9e4fd900SJohn Levon >> $LOGFILE 1813*9e4fd900SJohn Levon 1814*9e4fd900SJohn Levon if [ "$N_FLAG" != "y" ]; then 1815*9e4fd900SJohn Levon 1816*9e4fd900SJohn Levon E1= 1817*9e4fd900SJohn Levon f1= 1818*9e4fd900SJohn Levon for f in $f1; do 1819*9e4fd900SJohn Levon if [ -f "$f" ]; then 1820*9e4fd900SJohn Levon E1="$E1 -e $f" 1821*9e4fd900SJohn Levon fi 1822*9e4fd900SJohn Levon done 1823*9e4fd900SJohn Levon 1824*9e4fd900SJohn Levon E2= 1825*9e4fd900SJohn Levon f2= 1826*9e4fd900SJohn Levon if [ -d "$SRC/pkg" ]; then 1827*9e4fd900SJohn Levon f2="$f2 exceptions/packaging" 1828*9e4fd900SJohn Levon fi 1829*9e4fd900SJohn Levon 1830*9e4fd900SJohn Levon for f in $f2; do 1831*9e4fd900SJohn Levon if [ -f "$f" ]; then 1832*9e4fd900SJohn Levon E2="$E2 -e $f" 1833*9e4fd900SJohn Levon fi 1834*9e4fd900SJohn Levon done 1835*9e4fd900SJohn Levon fi 1836*9e4fd900SJohn Levon 1837*9e4fd900SJohn Levon if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 1838*9e4fd900SJohn Levon echo "\n==== Validating manifests against proto area ====\n" \ 1839*9e4fd900SJohn Levon >> $mail_msg_file 1840*9e4fd900SJohn Levon ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1841*9e4fd900SJohn Levon tee $TMPDIR/protocmp_noise >> $mail_msg_file 1842*9e4fd900SJohn Levon if [[ -s $TMPDIR/protocmp_noise ]]; then 1843*9e4fd900SJohn Levon build_extras_ok=n 1844*9e4fd900SJohn Levon fi 1845*9e4fd900SJohn Levon fi 1846*9e4fd900SJohn Levon 1847*9e4fd900SJohn Levon if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 1848*9e4fd900SJohn Levon echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 1849*9e4fd900SJohn Levon if [ -n "$E2" ]; then 1850*9e4fd900SJohn Levon ELIST=$E2 1851*9e4fd900SJohn Levon else 1852*9e4fd900SJohn Levon ELIST=$E1 1853*9e4fd900SJohn Levon fi 1854*9e4fd900SJohn Levon $PROTOCMPTERSE \ 1855*9e4fd900SJohn Levon "Files in yesterday's proto area, but not today's:" \ 1856*9e4fd900SJohn Levon "Files in today's proto area, but not yesterday's:" \ 1857*9e4fd900SJohn Levon "Files that changed between yesterday and today:" \ 1858*9e4fd900SJohn Levon ${ELIST} \ 1859*9e4fd900SJohn Levon -d $REF_PROTO_LIST \ 1860*9e4fd900SJohn Levon $ATLOG/proto_list_${MACH} \ 1861*9e4fd900SJohn Levon >> $mail_msg_file 1862*9e4fd900SJohn Levon fi 1863*9e4fd900SJohn Levonfi 1864*9e4fd900SJohn Levon 1865*9e4fd900SJohn Levonif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 1866*9e4fd900SJohn Levon "$build_extras_ok" == "y" ]]; then 1867*9e4fd900SJohn Levon staffer cp $ATLOG/proto_list_${MACH} \ 1868*9e4fd900SJohn Levon $PARENT_WS/usr/src/proto_list_${MACH} 1869*9e4fd900SJohn Levonfi 1870*9e4fd900SJohn Levon 1871*9e4fd900SJohn Levon# Update parent proto area if necessary. This is done now 1872*9e4fd900SJohn Levon# so that the proto area has either DEBUG or non-DEBUG kernels. 1873*9e4fd900SJohn Levon# Note that this clears out the lock file, so we can dispense with 1874*9e4fd900SJohn Levon# the variable now. 1875*9e4fd900SJohn Levonif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 1876*9e4fd900SJohn Levon echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 1877*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 1878*9e4fd900SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT/* 1879*9e4fd900SJohn Levon unset Ulockfile 1880*9e4fd900SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT 1881*9e4fd900SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1882*9e4fd900SJohn Levon ( cd $ROOT; tar cf - . | 1883*9e4fd900SJohn Levon ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 1884*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1885*9e4fd900SJohn Levon fi 1886*9e4fd900SJohn Levon if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 1887*9e4fd900SJohn Levon rm -rf $NIGHTLY_PARENT_ROOT-nd/* 1888*9e4fd900SJohn Levon mkdir -p $NIGHTLY_PARENT_ROOT-nd 1889*9e4fd900SJohn Levon cd $ROOT-nd 1890*9e4fd900SJohn Levon ( tar cf - . | 1891*9e4fd900SJohn Levon ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 1892*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1893*9e4fd900SJohn Levon fi 1894*9e4fd900SJohn Levon if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 1895*9e4fd900SJohn Levon echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 1896*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 1897*9e4fd900SJohn Levon rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 1898*9e4fd900SJohn Levon mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 1899*9e4fd900SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1900*9e4fd900SJohn Levon ( cd $TOOLS_PROTO; tar cf - . | 1901*9e4fd900SJohn Levon ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 1902*9e4fd900SJohn Levon umask 0; tar xpf - ) ) 2>&1 | 1903*9e4fd900SJohn Levon tee -a $mail_msg_file >> $LOGFILE 1904*9e4fd900SJohn Levon fi 1905*9e4fd900SJohn Levon fi 1906*9e4fd900SJohn Levonfi 1907*9e4fd900SJohn Levon 1908*9e4fd900SJohn Levon# 1909*9e4fd900SJohn Levon# ELF verification: ABI (-A) and runtime (-r) checks 1910*9e4fd900SJohn Levon# 1911*9e4fd900SJohn Levonif [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 1912*9e4fd900SJohn Levon # Directory ELF-data.$MACH holds the files produced by these tests. 1913*9e4fd900SJohn Levon elf_ddir=$SRC/ELF-data.$MACH 1914*9e4fd900SJohn Levon 1915*9e4fd900SJohn Levon # If there is a previous ELF-data backup directory, remove it. Then, 1916*9e4fd900SJohn Levon # rotate current ELF-data directory into its place and create a new 1917*9e4fd900SJohn Levon # empty directory 1918*9e4fd900SJohn Levon rm -rf $elf_ddir.ref 1919*9e4fd900SJohn Levon if [[ -d $elf_ddir ]]; then 1920*9e4fd900SJohn Levon mv $elf_ddir $elf_ddir.ref 1921*9e4fd900SJohn Levon fi 1922*9e4fd900SJohn Levon mkdir -p $elf_ddir 1923*9e4fd900SJohn Levon 1924*9e4fd900SJohn Levon # Call find_elf to produce a list of the ELF objects in the proto area. 1925*9e4fd900SJohn Levon # This list is passed to check_rtime and interface_check, preventing 1926*9e4fd900SJohn Levon # them from separately calling find_elf to do the same work twice. 1927*9e4fd900SJohn Levon find_elf -fr $checkroot > $elf_ddir/object_list 1928*9e4fd900SJohn Levon 1929*9e4fd900SJohn Levon if [[ $A_FLAG = y ]]; then 1930*9e4fd900SJohn Levon echo "\n==== Check versioning and ABI information ====\n" | \ 1931*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 1932*9e4fd900SJohn Levon 1933*9e4fd900SJohn Levon # Produce interface description for the proto. Report errors. 1934*9e4fd900SJohn Levon interface_check -o -w $elf_ddir -f object_list \ 1935*9e4fd900SJohn Levon -i interface -E interface.err 1936*9e4fd900SJohn Levon if [[ -s $elf_ddir/interface.err ]]; then 1937*9e4fd900SJohn Levon tee -a $LOGFILE < $elf_ddir/interface.err \ 1938*9e4fd900SJohn Levon >> $mail_msg_file 1939*9e4fd900SJohn Levon build_extras_ok=n 1940*9e4fd900SJohn Levon fi 1941*9e4fd900SJohn Levon 1942*9e4fd900SJohn Levon # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 1943*9e4fd900SJohn Levon # description file to that from the baseline gate. Issue a 1944*9e4fd900SJohn Levon # warning if the baseline is not present, and keep going. 1945*9e4fd900SJohn Levon if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 1946*9e4fd900SJohn Levon base_ifile="$ELF_DATA_BASELINE_DIR/interface" 1947*9e4fd900SJohn Levon 1948*9e4fd900SJohn Levon echo "\n==== Compare versioning and ABI information" \ 1949*9e4fd900SJohn Levon "to baseline ====\n" | \ 1950*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 1951*9e4fd900SJohn Levon echo "Baseline: $base_ifile\n" >> $LOGFILE 1952*9e4fd900SJohn Levon 1953*9e4fd900SJohn Levon if [[ -f $base_ifile ]]; then 1954*9e4fd900SJohn Levon interface_cmp -d -o $base_ifile \ 1955*9e4fd900SJohn Levon $elf_ddir/interface > $elf_ddir/interface.cmp 1956*9e4fd900SJohn Levon if [[ -s $elf_ddir/interface.cmp ]]; then 1957*9e4fd900SJohn Levon echo | tee -a $LOGFILE >> $mail_msg_file 1958*9e4fd900SJohn Levon tee -a $LOGFILE < \ 1959*9e4fd900SJohn Levon $elf_ddir/interface.cmp \ 1960*9e4fd900SJohn Levon >> $mail_msg_file 1961*9e4fd900SJohn Levon build_extras_ok=n 1962*9e4fd900SJohn Levon fi 1963*9e4fd900SJohn Levon else 1964*9e4fd900SJohn Levon echo "baseline not available. comparison" \ 1965*9e4fd900SJohn Levon "skipped" | \ 1966*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 1967*9e4fd900SJohn Levon fi 1968*9e4fd900SJohn Levon 1969*9e4fd900SJohn Levon fi 1970*9e4fd900SJohn Levon fi 1971*9e4fd900SJohn Levon 1972*9e4fd900SJohn Levon if [[ $r_FLAG = y ]]; then 1973*9e4fd900SJohn Levon echo "\n==== Check ELF runtime attributes ====\n" | \ 1974*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 1975*9e4fd900SJohn Levon 1976*9e4fd900SJohn Levon # If we're doing a DEBUG build the proto area will be left 1977*9e4fd900SJohn Levon # with debuggable objects, thus don't assert -s. 1978*9e4fd900SJohn Levon if [[ $D_FLAG = y ]]; then 1979*9e4fd900SJohn Levon rtime_sflag="" 1980*9e4fd900SJohn Levon else 1981*9e4fd900SJohn Levon rtime_sflag="-s" 1982*9e4fd900SJohn Levon fi 1983*9e4fd900SJohn Levon check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 1984*9e4fd900SJohn Levon -D object_list -f object_list -E runtime.err \ 1985*9e4fd900SJohn Levon -I runtime.attr.raw 1986*9e4fd900SJohn Levon if (( $? != 0 )); then 1987*9e4fd900SJohn Levon build_extras_ok=n 1988*9e4fd900SJohn Levon fi 1989*9e4fd900SJohn Levon 1990*9e4fd900SJohn Levon # check_rtime -I output needs to be sorted in order to 1991*9e4fd900SJohn Levon # compare it to that from previous builds. 1992*9e4fd900SJohn Levon sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 1993*9e4fd900SJohn Levon rm $elf_ddir/runtime.attr.raw 1994*9e4fd900SJohn Levon 1995*9e4fd900SJohn Levon # Report errors 1996*9e4fd900SJohn Levon if [[ -s $elf_ddir/runtime.err ]]; then 1997*9e4fd900SJohn Levon tee -a $LOGFILE < $elf_ddir/runtime.err \ 1998*9e4fd900SJohn Levon >> $mail_msg_file 1999*9e4fd900SJohn Levon build_extras_ok=n 2000*9e4fd900SJohn Levon fi 2001*9e4fd900SJohn Levon 2002*9e4fd900SJohn Levon # If there is an ELF-data directory from a previous build, 2003*9e4fd900SJohn Levon # then diff the attr files. These files contain information 2004*9e4fd900SJohn Levon # about dependencies, versioning, and runpaths. There is some 2005*9e4fd900SJohn Levon # overlap with the ABI checking done above, but this also 2006*9e4fd900SJohn Levon # flushes out non-ABI interface differences along with the 2007*9e4fd900SJohn Levon # other information. 2008*9e4fd900SJohn Levon echo "\n==== Diff ELF runtime attributes" \ 2009*9e4fd900SJohn Levon "(since last build) ====\n" | \ 2010*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 2011*9e4fd900SJohn Levon 2012*9e4fd900SJohn Levon if [[ -f $elf_ddir.ref/runtime.attr ]]; then 2013*9e4fd900SJohn Levon diff $elf_ddir.ref/runtime.attr \ 2014*9e4fd900SJohn Levon $elf_ddir/runtime.attr \ 2015*9e4fd900SJohn Levon >> $mail_msg_file 2016*9e4fd900SJohn Levon fi 2017*9e4fd900SJohn Levon fi 2018*9e4fd900SJohn Levon 2019*9e4fd900SJohn Levon # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 2020*9e4fd900SJohn Levon if [[ "$u_FLAG" = "y" ]]; then 2021*9e4fd900SJohn Levon p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 2022*9e4fd900SJohn Levon 2023*9e4fd900SJohn Levon # If parent lacks the ELF-data.$MACH directory, create it 2024*9e4fd900SJohn Levon if [[ ! -d $p_elf_ddir ]]; then 2025*9e4fd900SJohn Levon staffer mkdir -p $p_elf_ddir 2026*9e4fd900SJohn Levon fi 2027*9e4fd900SJohn Levon 2028*9e4fd900SJohn Levon # These files are used asynchronously by other builds for ABI 2029*9e4fd900SJohn Levon # verification, as above for the -A option. As such, we require 2030*9e4fd900SJohn Levon # the file replacement to be atomic. Copy the data to a temp 2031*9e4fd900SJohn Levon # file in the same filesystem and then rename into place. 2032*9e4fd900SJohn Levon ( 2033*9e4fd900SJohn Levon cd $elf_ddir 2034*9e4fd900SJohn Levon for elf_dfile in *; do 2035*9e4fd900SJohn Levon staffer cp $elf_dfile \ 2036*9e4fd900SJohn Levon ${p_elf_ddir}/${elf_dfile}.new 2037*9e4fd900SJohn Levon staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 2038*9e4fd900SJohn Levon ${p_elf_ddir}/${elf_dfile} 2039*9e4fd900SJohn Levon done 2040*9e4fd900SJohn Levon ) 2041*9e4fd900SJohn Levon fi 2042*9e4fd900SJohn Levonfi 2043*9e4fd900SJohn Levon 2044*9e4fd900SJohn Levon# DEBUG lint of kernel begins 2045*9e4fd900SJohn Levon 2046*9e4fd900SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 2047*9e4fd900SJohn Levon if [ "$LINTDIRS" = "" ]; then 2048*9e4fd900SJohn Levon # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 2049*9e4fd900SJohn Levon LINTDIRS="$SRC y" 2050*9e4fd900SJohn Levon fi 2051*9e4fd900SJohn Levon set $LINTDIRS 2052*9e4fd900SJohn Levon while [ $# -gt 0 ]; do 2053*9e4fd900SJohn Levon dolint $1 $2; shift; shift 2054*9e4fd900SJohn Levon done 2055*9e4fd900SJohn Levonelse 2056*9e4fd900SJohn Levon echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 2057*9e4fd900SJohn Levonfi 2058*9e4fd900SJohn Levon 2059*9e4fd900SJohn Levon# "make check" begins 2060*9e4fd900SJohn Levon 2061*9e4fd900SJohn Levonif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 2062*9e4fd900SJohn Levon # remove old check.out 2063*9e4fd900SJohn Levon rm -f $SRC/check.out 2064*9e4fd900SJohn Levon 2065*9e4fd900SJohn Levon rm -f $SRC/check-${MACH}.out 2066*9e4fd900SJohn Levon cd $SRC 2067*9e4fd900SJohn Levon $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 2068*9e4fd900SJohn Levon >> $LOGFILE 2069*9e4fd900SJohn Levon echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 2070*9e4fd900SJohn Levon 2071*9e4fd900SJohn Levon grep ":" $SRC/check-${MACH}.out | 2072*9e4fd900SJohn Levon egrep -v "Ignoring unknown host" | \ 2073*9e4fd900SJohn Levon sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 2074*9e4fd900SJohn Levon 2075*9e4fd900SJohn Levon if [[ -s $TMPDIR/check_errors ]]; then 2076*9e4fd900SJohn Levon build_extras_ok=n 2077*9e4fd900SJohn Levon fi 2078*9e4fd900SJohn Levonelse 2079*9e4fd900SJohn Levon echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 2080*9e4fd900SJohn Levonfi 2081*9e4fd900SJohn Levon 2082*9e4fd900SJohn Levonecho "\n==== Find core files ====\n" | \ 2083*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 2084*9e4fd900SJohn Levon 2085*9e4fd900SJohn Levonfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 2086*9e4fd900SJohn Levon tee -a $LOGFILE >> $mail_msg_file 2087*9e4fd900SJohn Levon 2088*9e4fd900SJohn Levonif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2089*9e4fd900SJohn Levon echo "\n==== Diff unreferenced files (since last build) ====\n" \ 2090*9e4fd900SJohn Levon | tee -a $LOGFILE >>$mail_msg_file 2091*9e4fd900SJohn Levon rm -f $SRC/unref-${MACH}.ref 2092*9e4fd900SJohn Levon if [ -f $SRC/unref-${MACH}.out ]; then 2093*9e4fd900SJohn Levon mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2094*9e4fd900SJohn Levon fi 2095*9e4fd900SJohn Levon 2096*9e4fd900SJohn Levon findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 2097*9e4fd900SJohn Levon ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 2098*9e4fd900SJohn Levon sort > $SRC/unref-${MACH}.out 2099*9e4fd900SJohn Levon 2100*9e4fd900SJohn Levon if [ ! -f $SRC/unref-${MACH}.ref ]; then 2101*9e4fd900SJohn Levon cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2102*9e4fd900SJohn Levon fi 2103*9e4fd900SJohn Levon 2104*9e4fd900SJohn Levon diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 2105*9e4fd900SJohn Levonfi 2106*9e4fd900SJohn Levon 2107*9e4fd900SJohn Levon# Verify that the usual lists of files, such as exception lists, 2108*9e4fd900SJohn Levon# contain only valid references to files. If the build has failed, 2109*9e4fd900SJohn Levon# then don't check the proto area. 2110*9e4fd900SJohn LevonCHECK_PATHS=${CHECK_PATHS:-y} 2111*9e4fd900SJohn Levonif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 2112*9e4fd900SJohn Levon echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 2113*9e4fd900SJohn Levon >>$mail_msg_file 2114*9e4fd900SJohn Levon arg=-b 2115*9e4fd900SJohn Levon [ "$build_ok" = y ] && arg= 2116*9e4fd900SJohn Levon checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 2117*9e4fd900SJohn Levon if [[ -s $SRC/check-paths.out ]]; then 2118*9e4fd900SJohn Levon tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 2119*9e4fd900SJohn Levon build_extras_ok=n 2120*9e4fd900SJohn Levon fi 2121*9e4fd900SJohn Levonfi 2122*9e4fd900SJohn Levon 2123*9e4fd900SJohn Levonif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2124*9e4fd900SJohn Levon echo "\n==== Impact on file permissions ====\n" \ 2125*9e4fd900SJohn Levon >> $mail_msg_file 2126*9e4fd900SJohn Levon 2127*9e4fd900SJohn Levon abspkg= 2128*9e4fd900SJohn Levon for d in $abssrcdirs; do 2129*9e4fd900SJohn Levon if [ -d "$d/pkg" ]; then 2130*9e4fd900SJohn Levon abspkg="$abspkg $d" 2131*9e4fd900SJohn Levon fi 2132*9e4fd900SJohn Levon done 2133*9e4fd900SJohn Levon 2134*9e4fd900SJohn Levon if [ -n "$abspkg" ]; then 2135*9e4fd900SJohn Levon for d in "$abspkg"; do 2136*9e4fd900SJohn Levon ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 2137*9e4fd900SJohn Levon done 2138*9e4fd900SJohn Levon fi 2139*9e4fd900SJohn Levonfi 2140*9e4fd900SJohn Levon 2141*9e4fd900SJohn Levonif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 2142*9e4fd900SJohn Levon if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 2143*9e4fd900SJohn Levon do_wsdiff DEBUG $ROOT.prev $ROOT 2144*9e4fd900SJohn Levon fi 2145*9e4fd900SJohn Levon 2146*9e4fd900SJohn Levon if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 2147*9e4fd900SJohn Levon do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 2148*9e4fd900SJohn Levon fi 2149*9e4fd900SJohn Levonfi 2150*9e4fd900SJohn Levon 2151*9e4fd900SJohn LevonEND_DATE=`date` 2152*9e4fd900SJohn Levonecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 2153*9e4fd900SJohn Levon tee -a $LOGFILE >> $build_time_file 2154*9e4fd900SJohn Levon 2155*9e4fd900SJohn Levontypeset -i10 hours 2156*9e4fd900SJohn Levontypeset -Z2 minutes 2157*9e4fd900SJohn Levontypeset -Z2 seconds 2158*9e4fd900SJohn Levon 2159*9e4fd900SJohn Levonelapsed_time=$SECONDS 2160*9e4fd900SJohn Levon((hours = elapsed_time / 3600 )) 2161*9e4fd900SJohn Levon((minutes = elapsed_time / 60 % 60)) 2162*9e4fd900SJohn Levon((seconds = elapsed_time % 60)) 2163*9e4fd900SJohn Levon 2164*9e4fd900SJohn Levonecho "\n==== Total build time ====" | \ 2165*9e4fd900SJohn Levon tee -a $LOGFILE >> $build_time_file 2166*9e4fd900SJohn Levonecho "\nreal ${hours}:${minutes}:${seconds}" | \ 2167*9e4fd900SJohn Levon tee -a $LOGFILE >> $build_time_file 2168*9e4fd900SJohn Levon 2169*9e4fd900SJohn Levonif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2170*9e4fd900SJohn Levon staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 2171*9e4fd900SJohn Levon 2172*9e4fd900SJohn Levon # 2173*9e4fd900SJohn Levon # Produce a master list of unreferenced files -- ideally, we'd 2174*9e4fd900SJohn Levon # generate the master just once after all of the nightlies 2175*9e4fd900SJohn Levon # have finished, but there's no simple way to know when that 2176*9e4fd900SJohn Levon # will be. Instead, we assume that we're the last nightly to 2177*9e4fd900SJohn Levon # finish and merge all of the unref-${MACH}.out files in 2178*9e4fd900SJohn Levon # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 2179*9e4fd900SJohn Levon # finish, then this file will be the authoritative master 2180*9e4fd900SJohn Levon # list. Otherwise, another ${MACH}'s nightly will eventually 2181*9e4fd900SJohn Levon # overwrite ours with its own master, but in the meantime our 2182*9e4fd900SJohn Levon # temporary "master" will be no worse than any older master 2183*9e4fd900SJohn Levon # which was already on the parent. 2184*9e4fd900SJohn Levon # 2185*9e4fd900SJohn Levon 2186*9e4fd900SJohn Levon set -- $PARENT_WS/usr/src/unref-*.out 2187*9e4fd900SJohn Levon cp "$1" ${TMPDIR}/unref.merge 2188*9e4fd900SJohn Levon shift 2189*9e4fd900SJohn Levon 2190*9e4fd900SJohn Levon for unreffile; do 2191*9e4fd900SJohn Levon comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 2192*9e4fd900SJohn Levon mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 2193*9e4fd900SJohn Levon done 2194*9e4fd900SJohn Levon 2195*9e4fd900SJohn Levon staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 2196*9e4fd900SJohn Levonfi 2197*9e4fd900SJohn Levon 2198*9e4fd900SJohn Levon# 2199*9e4fd900SJohn Levon# All done save for the sweeping up. 2200*9e4fd900SJohn Levon# (whichever exit we hit here will trigger the "cleanup" trap which 2201*9e4fd900SJohn Levon# optionally sends mail on completion). 2202*9e4fd900SJohn Levon# 2203*9e4fd900SJohn Levonif [[ "$build_ok" == "y" ]]; then 2204*9e4fd900SJohn Levon if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 2205*9e4fd900SJohn Levon exit 0 2206*9e4fd900SJohn Levon fi 2207*9e4fd900SJohn Levonfi 2208*9e4fd900SJohn Levon 2209*9e4fd900SJohn Levonexit 1 2210