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