17c478bd9Sstevel@tonic-gate#!/bin/ksh -p 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6fb23a357Skupfer# Common Development and Distribution License (the "License"). 7fb23a357Skupfer# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 224e5b757fSkupfer 237c478bd9Sstevel@tonic-gate# 24b83ec4edSjmcp# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 25445b6314SRichard Lowe# Copyright 2008, 2010, Richard Lowe 26d7693b08SRoland Mainz# Copyright 2011 Nexenta Systems, Inc. All rights reserved. 273cb00cf1SJoshua M. Clulow# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> 28d1c3d93aSPaul Dagnelie# Copyright (c) 2017 by Delphix. All rights reserved. 29*5ca82e69SJohn Levon# Copyright 2020 Joyent, Inc. 30300fdee2SAndy Fiddaman# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. 31be0ffda9SPeter Tribble# Copyright 2019 Peter Trible. 327c478bd9Sstevel@tonic-gate# 337c478bd9Sstevel@tonic-gate# Based on the nightly script from the integration folks, 347c478bd9Sstevel@tonic-gate# Mostly modified and owned by mike_s. 357c478bd9Sstevel@tonic-gate# Changes also by kjc, dmk. 367c478bd9Sstevel@tonic-gate# 377c478bd9Sstevel@tonic-gate# BRINGOVER_WS may be specified in the env file. 387c478bd9Sstevel@tonic-gate# The default is the old behavior of CLONE_WS 397c478bd9Sstevel@tonic-gate# 407c478bd9Sstevel@tonic-gate# -i on the command line, means fast options, so when it's on the 41be0ffda9SPeter Tribble# command line (only), check builds are skipped no matter what 42d77e7149Ssommerfe# the setting of their individual flags are in NIGHTLY_OPTIONS. 437c478bd9Sstevel@tonic-gate# 44c3e6cb59SRichard Lowe# OPTHOME may be set in the environment to override /opt 457c478bd9Sstevel@tonic-gate# 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate# 487c478bd9Sstevel@tonic-gate# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 497c478bd9Sstevel@tonic-gate# under certain circumstances, which can really screw things up; unset it. 507c478bd9Sstevel@tonic-gate# 517c478bd9Sstevel@tonic-gateunset CDPATH 527c478bd9Sstevel@tonic-gate 53cdf0c1d5Smjnelson# Get the absolute path of the nightly script that the user invoked. This 54cdf0c1d5Smjnelson# may be a relative path, and we need to do this before changing directory. 55cdf0c1d5Smjnelsonnightly_path=`whence $0` 56cdf0c1d5Smjnelson 57cdf0c1d5Smjnelson# 58cdf0c1d5Smjnelson# Keep track of where we found nightly so we can invoke the matching 59cdf0c1d5Smjnelson# which_scm script. If that doesn't work, don't go guessing, just rely 60cdf0c1d5Smjnelson# on the $PATH settings, which will generally give us either /opt/onbld 61cdf0c1d5Smjnelson# or the user's workspace. 62cdf0c1d5Smjnelson# 63cdf0c1d5SmjnelsonWHICH_SCM=$(dirname $nightly_path)/which_scm 64cdf0c1d5Smjnelsonif [[ ! -x $WHICH_SCM ]]; then 65cdf0c1d5Smjnelson WHICH_SCM=which_scm 66cdf0c1d5Smjnelsonfi 67cdf0c1d5Smjnelson 68d7693b08SRoland Mainzfunction fatal_error 69d7693b08SRoland Mainz{ 70d7693b08SRoland Mainz print -u2 "nightly: $*" 71d7693b08SRoland Mainz exit 1 72d7693b08SRoland Mainz} 73d7693b08SRoland Mainz 744e5b757fSkupfer# 754e5b757fSkupfer# Function to do a DEBUG and non-DEBUG build. Needed because we might 767c478bd9Sstevel@tonic-gate# need to do another for the source build, and since we only deliver DEBUG or 777c478bd9Sstevel@tonic-gate# non-DEBUG packages. 784e5b757fSkupfer# 79b83ec4edSjmcp# usage: normal_build 80ead1f93eSLiane Praza# 81597bd30bSMike Kupferfunction normal_build { 827c478bd9Sstevel@tonic-gate 8352a52aebSkupfer typeset orig_p_FLAG="$p_FLAG" 84597bd30bSMike Kupfer typeset crypto_signer="$CODESIGN_USER" 854e5b757fSkupfer 864e5b757fSkupfer suffix="" 87ead1f93eSLiane Praza 887c478bd9Sstevel@tonic-gate # non-DEBUG build begins 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate if [ "$F_FLAG" = "n" ]; then 914e5b757fSkupfer set_non_debug_build_flags 92597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 936ea3c060SGarrett D'Amore build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 947c478bd9Sstevel@tonic-gate else 9552a52aebSkupfer echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 967c478bd9Sstevel@tonic-gate fi 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate # non-DEBUG build ends 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate # DEBUG build begins 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate if [ "$D_FLAG" = "y" ]; then 1034e5b757fSkupfer set_debug_build_flags 104597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 1056ea3c060SGarrett D'Amore build "DEBUG" "$suffix" "" "$MULTI_PROTO" 1067c478bd9Sstevel@tonic-gate else 10752a52aebSkupfer echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 1087c478bd9Sstevel@tonic-gate fi 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate # DEBUG build ends 1114e5b757fSkupfer 11252a52aebSkupfer p_FLAG="$orig_p_FLAG" 1137c478bd9Sstevel@tonic-gate} 1147c478bd9Sstevel@tonic-gate 11547703246Ssommerfe# 11647703246Ssommerfe# usage: run_hook HOOKNAME ARGS... 11747703246Ssommerfe# 118fb23c574SRichard Lowe# If variable "$HOOKNAME" is defined, insert a section header into 11947703246Ssommerfe# our logs and then run the command with ARGS 12047703246Ssommerfe# 121597bd30bSMike Kupferfunction run_hook { 12247703246Ssommerfe HOOKNAME=$1 123fb23c574SRichard Lowe eval HOOKCMD=\$$HOOKNAME 12447703246Ssommerfe shift 12547703246Ssommerfe 126fb23c574SRichard Lowe if [ -n "$HOOKCMD" ]; then 127fb23c574SRichard Lowe ( 12847703246Ssommerfe echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 129fb23c574SRichard Lowe ( $HOOKCMD "$@" 2>&1 ) 13047703246Ssommerfe if [ "$?" -ne 0 ]; then 131fb23c574SRichard Lowe # Let exit status propagate up 132fb23c574SRichard Lowe touch $TMPDIR/abort 13347703246Ssommerfe fi 13447703246Ssommerfe ) | tee -a $mail_msg_file >> $LOGFILE 13547703246Ssommerfe 13647703246Ssommerfe if [ -f $TMPDIR/abort ]; then 13747703246Ssommerfe build_ok=n 13847703246Ssommerfe echo "\nAborting at request of $HOOKNAME" | 13947703246Ssommerfe tee -a $mail_msg_file >> $LOGFILE 14047703246Ssommerfe exit 1 14147703246Ssommerfe fi 14247703246Ssommerfe fi 14347703246Ssommerfe} 14447703246Ssommerfe 1454e5b757fSkupfer# Return library search directive as function of given root. 146597bd30bSMike Kupferfunction myldlibs { 1474e5b757fSkupfer echo "-L$1/lib -L$1/usr/lib" 1484e5b757fSkupfer} 1494e5b757fSkupfer 1504e5b757fSkupfer# Return header search directive as function of given root. 151597bd30bSMike Kupferfunction myheaders { 1524e5b757fSkupfer echo "-I$1/usr/include" 1534e5b757fSkupfer} 1547c478bd9Sstevel@tonic-gate 1554e5b757fSkupfer# 15678add226Sjmcp# Function to do the build, including package generation. 1576ea3c060SGarrett D'Amore# usage: build LABEL SUFFIX ND MULTIPROTO 1584e5b757fSkupfer# - LABEL is used to tag build output. 159ead1f93eSLiane Praza# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 160597bd30bSMike Kupfer# open-only vs full tree). 161ead1f93eSLiane Praza# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 1624e5b757fSkupfer# - If MULTIPROTO is "yes", it means to name the proto area according to 1634e5b757fSkupfer# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 1644e5b757fSkupfer# 165597bd30bSMike Kupferfunction build { 1667c478bd9Sstevel@tonic-gate LABEL=$1 1677c478bd9Sstevel@tonic-gate SUFFIX=$2 168597bd30bSMike Kupfer ND=$3 169597bd30bSMike Kupfer MULTIPROTO=$4 1707c478bd9Sstevel@tonic-gate INSTALLOG=install${SUFFIX}-${MACH} 1717c478bd9Sstevel@tonic-gate NOISE=noise${SUFFIX}-${MACH} 1727c478bd9Sstevel@tonic-gate PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 1737c478bd9Sstevel@tonic-gate 1744e5b757fSkupfer ORIGROOT=$ROOT 1754e5b757fSkupfer [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 1764e5b757fSkupfer 1774e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 1784e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 1794e5b757fSkupfer 1807c478bd9Sstevel@tonic-gate this_build_ok=y 1817c478bd9Sstevel@tonic-gate # 1827c478bd9Sstevel@tonic-gate # Build OS-Networking source 1837c478bd9Sstevel@tonic-gate # 1847c478bd9Sstevel@tonic-gate echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 1857c478bd9Sstevel@tonic-gate >> $LOGFILE 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate rm -f $SRC/${INSTALLOG}.out 1887c478bd9Sstevel@tonic-gate cd $SRC 1897c478bd9Sstevel@tonic-gate /bin/time $MAKE -e install 2>&1 | \ 1907c478bd9Sstevel@tonic-gate tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 19132f1e47bSsommerfe 1927c478bd9Sstevel@tonic-gate echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 1937c478bd9Sstevel@tonic-gate egrep ":" $SRC/${INSTALLOG}.out | 194d1c3d93aSPaul Dagnelie egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 195d1c3d93aSPaul Dagnelie egrep -v "Ignoring unknown host" | \ 196d1c3d93aSPaul Dagnelie egrep -v "cc .* -o error " | \ 197d1c3d93aSPaul Dagnelie egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 198d1c3d93aSPaul Dagnelie >> $mail_msg_file 199d1c3d93aSPaul Dagnelie sed -n "/^Undefined[ ]*first referenced$/,/^ld: fatal:/p" \ 200d1c3d93aSPaul Dagnelie < $SRC/${INSTALLOG}.out >> $mail_msg_file 201cb4d1691SRichard Lowe if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 2027c478bd9Sstevel@tonic-gate build_ok=n 2037c478bd9Sstevel@tonic-gate this_build_ok=n 2047c478bd9Sstevel@tonic-gate fi 2057c478bd9Sstevel@tonic-gate grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 2067c478bd9Sstevel@tonic-gate >> $mail_msg_file 2077c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 2087c478bd9Sstevel@tonic-gate build_ok=n 2097c478bd9Sstevel@tonic-gate this_build_ok=n 2107c478bd9Sstevel@tonic-gate fi 2117c478bd9Sstevel@tonic-gate 212c3e6cb59SRichard Lowe echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 2131f5207b7SJohn Levon egrep -i 'warn:|warning:' $SRC/${INSTALLOG}.out \ 214c3e6cb59SRichard Lowe | egrep -v '^tic:' \ 215c3e6cb59SRichard Lowe | egrep -v "symbol (\`|')timezone' has differing types:" \ 216c3e6cb59SRichard Lowe | egrep -v "parameter <PSTAMP> set to" \ 217c3e6cb59SRichard Lowe | egrep -v "Ignoring unknown host" \ 218c3e6cb59SRichard Lowe | egrep -v "redefining segment flags attribute for" \ 219cb4d1691SRichard Lowe | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 220cb4d1691SRichard Lowe if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 221cb4d1691SRichard Lowe build_ok=n 222cb4d1691SRichard Lowe this_build_ok=n 223cb4d1691SRichard Lowe fi 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 2267c478bd9Sstevel@tonic-gate >> $LOGFILE 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 2297c478bd9Sstevel@tonic-gate tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 2307c478bd9Sstevel@tonic-gate 231c3e6cb59SRichard Lowe if [ "$i_FLAG" = "n" ]; then 2327c478bd9Sstevel@tonic-gate rm -f $SRC/${NOISE}.ref 2337c478bd9Sstevel@tonic-gate if [ -f $SRC/${NOISE}.out ]; then 2347c478bd9Sstevel@tonic-gate mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 2357c478bd9Sstevel@tonic-gate fi 2367c478bd9Sstevel@tonic-gate grep : $SRC/${INSTALLOG}.out \ 2377c478bd9Sstevel@tonic-gate | egrep -v '^/' \ 2387c478bd9Sstevel@tonic-gate | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 2397c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 2407c478bd9Sstevel@tonic-gate | egrep -v '^mcs' \ 2417c478bd9Sstevel@tonic-gate | egrep -v '^LD_LIBRARY_PATH=' \ 2427c478bd9Sstevel@tonic-gate | egrep -v 'ar: creating' \ 2437c478bd9Sstevel@tonic-gate | egrep -v 'ar: writing' \ 2447c478bd9Sstevel@tonic-gate | egrep -v 'conflicts:' \ 2457c478bd9Sstevel@tonic-gate | egrep -v ':saved created' \ 2467c478bd9Sstevel@tonic-gate | egrep -v '^stty.*c:' \ 2477c478bd9Sstevel@tonic-gate | egrep -v '^mfgname.c:' \ 2487c478bd9Sstevel@tonic-gate | egrep -v '^uname-i.c:' \ 2497c478bd9Sstevel@tonic-gate | egrep -v '^volumes.c:' \ 2507c478bd9Sstevel@tonic-gate | egrep -v '^lint library construction:' \ 2517c478bd9Sstevel@tonic-gate | egrep -v 'tsort: INFORM:' \ 2527c478bd9Sstevel@tonic-gate | egrep -v 'stripalign:' \ 2537c478bd9Sstevel@tonic-gate | egrep -v 'chars, width' \ 25420272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 2557c478bd9Sstevel@tonic-gate | egrep -v 'PSTAMP' \ 2567c478bd9Sstevel@tonic-gate | egrep -v '^Manifying' \ 2577c478bd9Sstevel@tonic-gate | egrep -v 'Ignoring unknown host' \ 2587c478bd9Sstevel@tonic-gate | egrep -v 'Processing method:' \ 2597c478bd9Sstevel@tonic-gate | egrep -v '^Writing' \ 2607c478bd9Sstevel@tonic-gate | egrep -v 'spellin1:' \ 2617c478bd9Sstevel@tonic-gate | egrep -v '^adding:' \ 2627c478bd9Sstevel@tonic-gate | egrep -v "^echo 'msgid" \ 2637c478bd9Sstevel@tonic-gate | egrep -v '^echo ' \ 2647c478bd9Sstevel@tonic-gate | egrep -v '\.c:$' \ 2657c478bd9Sstevel@tonic-gate | egrep -v '^Adding file:' \ 2667c478bd9Sstevel@tonic-gate | egrep -v 'CLASSPATH=' \ 2677c478bd9Sstevel@tonic-gate | egrep -v '\/var\/mail\/:saved' \ 2687c478bd9Sstevel@tonic-gate | egrep -v -- '-DUTS_VERSION=' \ 2697c478bd9Sstevel@tonic-gate | egrep -v '^Running Mkbootstrap' \ 2707c478bd9Sstevel@tonic-gate | egrep -v '^Applet length read:' \ 2717c478bd9Sstevel@tonic-gate | egrep -v 'bytes written:' \ 2727c478bd9Sstevel@tonic-gate | egrep -v '^File:SolarisAuthApplet.bin' \ 2737c478bd9Sstevel@tonic-gate | egrep -v -i 'jibversion' \ 2747c478bd9Sstevel@tonic-gate | egrep -v '^Output size:' \ 2757c478bd9Sstevel@tonic-gate | egrep -v '^Solo size statistics:' \ 2767c478bd9Sstevel@tonic-gate | egrep -v '^Using ROM API Version' \ 2777c478bd9Sstevel@tonic-gate | egrep -v '^Zero Signature length:' \ 2787c478bd9Sstevel@tonic-gate | egrep -v '^Note \(probably harmless\):' \ 2797c478bd9Sstevel@tonic-gate | egrep -v '::' \ 280010b217aSwesolows | egrep -v '^\+' \ 281c817a439Sjohnz | egrep -v 'svccfg-native -s svc:/' \ 2827c478bd9Sstevel@tonic-gate | sort | uniq >$SRC/${NOISE}.out 2837c478bd9Sstevel@tonic-gate if [ ! -f $SRC/${NOISE}.ref ]; then 2847c478bd9Sstevel@tonic-gate cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 2857c478bd9Sstevel@tonic-gate fi 2867c478bd9Sstevel@tonic-gate echo "\n==== Build noise differences ($LABEL) ====\n" \ 2877c478bd9Sstevel@tonic-gate >>$mail_msg_file 2887c478bd9Sstevel@tonic-gate diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 2897c478bd9Sstevel@tonic-gate fi 2907c478bd9Sstevel@tonic-gate 29123259b79Srotondo # 29223259b79Srotondo # Re-sign selected binaries using signing server 29323259b79Srotondo # (gatekeeper builds only) 29423259b79Srotondo # 2952210853dSjohnz if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 29623259b79Srotondo echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 29723259b79Srotondo signing_file="${TMPDIR}/signing" 29823259b79Srotondo rm -f ${signing_file} 29923259b79Srotondo export CODESIGN_USER 30023259b79Srotondo signproto $SRC/tools/codesign/creds 2>&1 | \ 30123259b79Srotondo tee -a ${signing_file} >> $LOGFILE 30223259b79Srotondo echo "\n==== Finished signing proto area at `date` ====\n" \ 30323259b79Srotondo >> $LOGFILE 30423259b79Srotondo echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 30523259b79Srotondo >> $mail_msg_file 30623259b79Srotondo egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 307cdf0c1d5Smjnelson if (( $? == 0 )) ; then 3082210853dSjohnz build_ok=n 3092210853dSjohnz this_build_ok=n 3102210853dSjohnz fi 31123259b79Srotondo fi 31223259b79Srotondo 3137c478bd9Sstevel@tonic-gate # 3147c478bd9Sstevel@tonic-gate # Building Packages 3157c478bd9Sstevel@tonic-gate # 3167c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 317c3e6cb59SRichard Lowe if [ -d $SRC/pkg ]; then 318ead1f93eSLiane Praza echo "\n==== Creating $LABEL packages at `date` ====\n" \ 319d8fd4470Sjg >> $LOGFILE 320ead1f93eSLiane Praza echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 3216798c3f0SMark J. Nelson rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 3226798c3f0SMark J. Nelson mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 323d8fd4470Sjg 324c3e6cb59SRichard Lowe rm -f $SRC/pkg/${INSTALLOG}.out 325c3e6cb59SRichard Lowe cd $SRC/pkg 326c3e6cb59SRichard Lowe /bin/time $MAKE -e install 2>&1 | \ 327c3e6cb59SRichard Lowe tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 328ead1f93eSLiane Praza 329ead1f93eSLiane Praza echo "\n==== package build errors ($LABEL) ====\n" \ 330ead1f93eSLiane Praza >> $mail_msg_file 331ead1f93eSLiane Praza 332c3e6cb59SRichard Lowe egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 333c3e6cb59SRichard Lowe grep ':' | \ 334c3e6cb59SRichard Lowe grep -v PSTAMP | \ 335cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 336cb4d1691SRichard Lowe tee $TMPDIR/package >> $mail_msg_file 337cb4d1691SRichard Lowe if [[ -s $TMPDIR/package ]]; then 338cb4d1691SRichard Lowe build_extras_ok=n 339cb4d1691SRichard Lowe this_build_ok=n 340cb4d1691SRichard Lowe fi 3415d3b8cb7SBill Sommerfeld else 342ead1f93eSLiane Praza # 343c3e6cb59SRichard Lowe # Handle it gracefully if -p was set but there so 344c3e6cb59SRichard Lowe # no pkg directory. 345ead1f93eSLiane Praza # 346ead1f93eSLiane Praza echo "\n==== No $LABEL packages to build ====\n" \ 347ead1f93eSLiane Praza >> $LOGFILE 3485d3b8cb7SBill Sommerfeld fi 349ead1f93eSLiane Praza else 350ead1f93eSLiane Praza echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 3515d3b8cb7SBill Sommerfeld fi 3525d3b8cb7SBill Sommerfeld 3534e5b757fSkupfer ROOT=$ORIGROOT 3547c478bd9Sstevel@tonic-gate} 3557c478bd9Sstevel@tonic-gate 356391889ecSAndy Fiddaman# 357391889ecSAndy Fiddaman# Bootstrap build tools which are pre-requisites for the rest of the build. 358391889ecSAndy Fiddaman# 359391889ecSAndy Fiddamanfunction bootstrap_tools { 360391889ecSAndy Fiddaman echo "\n==== Bootstrapping tools at `date` ====\n" >> $LOGFILE 361391889ecSAndy Fiddaman 362391889ecSAndy Fiddaman typeset INSTALLOG=install-bootstrap-${MACH} 363391889ecSAndy Fiddaman 364391889ecSAndy Fiddaman rm -f $TMPDIR/make-state ${TOOLS}/$INSTALLOG.out 365391889ecSAndy Fiddaman cd ${TOOLS} 366391889ecSAndy Fiddaman /bin/time $MAKE -K $TMPDIR/make-state -e TARGET=install bootstrap \ 367391889ecSAndy Fiddaman 2>&1 | tee -a ${TOOLS}/$INSTALLOG.out >> $LOGFILE 368391889ecSAndy Fiddaman 369391889ecSAndy Fiddaman echo "\n==== Bootstrap build errors ====\n" >> $mail_msg_file 370391889ecSAndy Fiddaman 371391889ecSAndy Fiddaman egrep ":" ${TOOLS}/$INSTALLOG.out | 372391889ecSAndy Fiddaman egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 373391889ecSAndy Fiddaman egrep -v warning | tee $TMPDIR/bootstrap_errors >> $mail_msg_file 374391889ecSAndy Fiddaman 375391889ecSAndy Fiddaman [[ -s $TMPDIR/bootstrap_errors ]] && return 1 376391889ecSAndy Fiddaman return 0 377391889ecSAndy Fiddaman} 378391889ecSAndy Fiddaman 3794e5b757fSkupfer# 3804e5b757fSkupfer# Build and install the onbld tools. 3814e5b757fSkupfer# 3821fe69678Skupfer# usage: build_tools DESTROOT 3834e5b757fSkupfer# 3844e5b757fSkupfer# returns non-zero status if the build was successful. 3854e5b757fSkupfer# 386597bd30bSMike Kupferfunction build_tools { 3877c478bd9Sstevel@tonic-gate DESTROOT=$1 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate INSTALLOG=install-${MACH} 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate echo "\n==== Building tools at `date` ====\n" \ 3927c478bd9Sstevel@tonic-gate >> $LOGFILE 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/${INSTALLOG}.out 3957c478bd9Sstevel@tonic-gate cd ${TOOLS} 396ead1f93eSLiane Praza /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 3977c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate echo "\n==== Tools build errors ====\n" >> $mail_msg_file 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate egrep ":" ${TOOLS}/${INSTALLOG}.out | 4027c478bd9Sstevel@tonic-gate egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 4037c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 404cb4d1691SRichard Lowe egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 405cb4d1691SRichard Lowe 406cb4d1691SRichard Lowe if [[ -s $TMPDIR/tools_errors ]]; then 407cb4d1691SRichard Lowe return 1 408cb4d1691SRichard Lowe fi 409cb4d1691SRichard Lowe return 0 4104e5b757fSkupfer} 4114e5b757fSkupfer 412597bd30bSMike Kupferfunction staffer { 4137c478bd9Sstevel@tonic-gate if [ $ISUSER -ne 0 ]; then 4147c478bd9Sstevel@tonic-gate "$@" 4157c478bd9Sstevel@tonic-gate else 4167c478bd9Sstevel@tonic-gate arg="\"$1\"" 4177c478bd9Sstevel@tonic-gate shift 4187c478bd9Sstevel@tonic-gate for i 4197c478bd9Sstevel@tonic-gate do 4207c478bd9Sstevel@tonic-gate arg="$arg \"$i\"" 4217c478bd9Sstevel@tonic-gate done 4227c478bd9Sstevel@tonic-gate eval su $STAFFER -c \'$arg\' 4237c478bd9Sstevel@tonic-gate fi 4247c478bd9Sstevel@tonic-gate} 4257c478bd9Sstevel@tonic-gate 426085d331dSkupfer# 427c3e6cb59SRichard Lowe# Verify that the closed bins are present 428085d331dSkupfer# 429c3e6cb59SRichard Lowefunction check_closed_bins { 430cd277642SGarrett D'Amore if [[ -n "$ON_CLOSED_BINS" && ! -d "$ON_CLOSED_BINS" ]]; then 431c0e7977aSJosef 'Jeff' Sipek echo "ON_CLOSED_BINS must point to the closed binaries tree." 432c0e7977aSJosef 'Jeff' Sipek build_ok=n 433c0e7977aSJosef 'Jeff' Sipek exit 1 434085d331dSkupfer fi 435085d331dSkupfer} 4367c478bd9Sstevel@tonic-gate 4374e5b757fSkupfer# 4384e5b757fSkupfer# wrapper over wsdiff. 4394e5b757fSkupfer# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 4404e5b757fSkupfer# 441597bd30bSMike Kupferfunction do_wsdiff { 4424e5b757fSkupfer label=$1 4434e5b757fSkupfer oldproto=$2 4444e5b757fSkupfer newproto=$3 4454e5b757fSkupfer 4464e5b757fSkupfer wsdiff="wsdiff" 4474e5b757fSkupfer [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 4484e5b757fSkupfer 449598cc7dfSVladimir Kotal echo "\n==== Getting object changes since last build at `date`" \ 450598cc7dfSVladimir Kotal "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 451598cc7dfSVladimir Kotal $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 4524e5b757fSkupfer tee -a $LOGFILE >> $mail_msg_file 453598cc7dfSVladimir Kotal echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 454598cc7dfSVladimir Kotal tee -a $LOGFILE >> $mail_msg_file 4554e5b757fSkupfer} 4564e5b757fSkupfer 4574e5b757fSkupfer# 458ead1f93eSLiane Praza# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 4594e5b757fSkupfer# together. 4604e5b757fSkupfer# 4614e5b757fSkupfer 462597bd30bSMike Kupferfunction set_non_debug_build_flags { 4634e5b757fSkupfer export RELEASE_BUILD ; RELEASE_BUILD= 4644e5b757fSkupfer unset EXTRA_OPTIONS 4654e5b757fSkupfer unset EXTRA_CFLAGS 4663c562093SToomas Soome if [ -n "$RELEASE_CONSOLE_COLOR" ]; then 4673c562093SToomas Soome export DEFAULT_CONSOLE_COLOR="$RELEASE_CONSOLE_COLOR" 4683c562093SToomas Soome fi 4694e5b757fSkupfer} 4704e5b757fSkupfer 471597bd30bSMike Kupferfunction set_debug_build_flags { 4724e5b757fSkupfer unset RELEASE_BUILD 4734e5b757fSkupfer unset EXTRA_OPTIONS 4744e5b757fSkupfer unset EXTRA_CFLAGS 4753c562093SToomas Soome 4763c562093SToomas Soome if [ -n "$DEBUG_CONSOLE_COLOR" ]; then 4773c562093SToomas Soome export DEFAULT_CONSOLE_COLOR="$DEBUG_CONSOLE_COLOR" 4783c562093SToomas Soome fi 4794e5b757fSkupfer} 4804e5b757fSkupfer 481d77e7149Ssommerfe 4827c478bd9Sstevel@tonic-gateMACH=`uname -p` 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gateif [ "$OPTHOME" = "" ]; then 4857c478bd9Sstevel@tonic-gate OPTHOME=/opt 4867c478bd9Sstevel@tonic-gate export OPTHOME 4877c478bd9Sstevel@tonic-gatefi 4887c478bd9Sstevel@tonic-gate 4895110237aSJosef 'Jeff' SipekUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gateWhere: 492be0ffda9SPeter Tribble -i Fast incremental options (no clobber, check) 4937c478bd9Sstevel@tonic-gate -n Do not do a bringover 4945e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 4957c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate <env_file> file in Bourne shell syntax that sets and exports 4987c478bd9Sstevel@tonic-gate variables that configure the operation of this script and many of 4997c478bd9Sstevel@tonic-gate the scripts this one calls. If <env_file> does not exist, 5007c478bd9Sstevel@tonic-gate it will be looked for in $OPTHOME/onbld/env. 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gatenon-DEBUG is the default build type. Build options can be set in the 5037c478bd9Sstevel@tonic-gateNIGHTLY_OPTIONS variable in the <env_file> as follows: 5047c478bd9Sstevel@tonic-gate 5057c478bd9Sstevel@tonic-gate -A check for ABI differences in .so files 5067c478bd9Sstevel@tonic-gate -C check for cstyle/hdrchk errors 5077c478bd9Sstevel@tonic-gate -D do a build with DEBUG on 5087c478bd9Sstevel@tonic-gate -F do _not_ do a non-DEBUG build 5093c6aa570SMark J. Nelson -G gate keeper default group of options (-au) 5107c478bd9Sstevel@tonic-gate -I integration engineer default group of options (-ampu) 5117c478bd9Sstevel@tonic-gate -M do not run pmodes (safe file permission checker) 5127c478bd9Sstevel@tonic-gate -N do not run protocmp 5137c478bd9Sstevel@tonic-gate -R default group of options for building a release (-mp) 5147c478bd9Sstevel@tonic-gate -U update proto area in the parent 5157c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 5167c478bd9Sstevel@tonic-gate -f find unreferenced files 5177c478bd9Sstevel@tonic-gate -i do an incremental build (no "make clobber") 5187c478bd9Sstevel@tonic-gate -m send mail to $MAILTO at end of build 5197c478bd9Sstevel@tonic-gate -n do not do a bringover 5207c478bd9Sstevel@tonic-gate -p create packages 5217c478bd9Sstevel@tonic-gate -r check ELF runtime attributes in the proto area 5225e1b109eSPeter Dennis - Sustaining Engineer -t build and use the tools in $SRC/tools (default setting) 5235e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 5247c478bd9Sstevel@tonic-gate -u update proto_list_$MACH and friends in the parent workspace; 5257c478bd9Sstevel@tonic-gate when used with -f, also build an unrefmaster.out in the parent 52696ccc8cbSesaxe -w report on differences between previous and current proto areas 5277c478bd9Sstevel@tonic-gate' 5287c478bd9Sstevel@tonic-gate# 5297c478bd9Sstevel@tonic-gate# A log file will be generated under the name $LOGFILE 5301c79753fSdarrenm# for partially completed build and log.`date '+%F'` 5317c478bd9Sstevel@tonic-gate# in the same directory for fully completed builds. 5327c478bd9Sstevel@tonic-gate# 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate# default values for low-level FLAGS; G I R are group FLAGS 5357c478bd9Sstevel@tonic-gateA_FLAG=n 5367c478bd9Sstevel@tonic-gateC_FLAG=n 5376c3c9007SstevelD_FLAG=n 5387c478bd9Sstevel@tonic-gateF_FLAG=n 5397c478bd9Sstevel@tonic-gatef_FLAG=n 5407c478bd9Sstevel@tonic-gatei_FLAG=n; i_CMD_LINE_FLAG=n 5416c3c9007SstevelM_FLAG=n 5427c478bd9Sstevel@tonic-gatem_FLAG=n 5436c3c9007SstevelN_FLAG=n 5446c3c9007Ssteveln_FLAG=n 5457c478bd9Sstevel@tonic-gatep_FLAG=n 5467c478bd9Sstevel@tonic-gater_FLAG=n 547fd7cef36Ssuhat_FLAG=y 5487c478bd9Sstevel@tonic-gateU_FLAG=n 5496c3c9007Sstevelu_FLAG=n 5507c478bd9Sstevel@tonic-gateV_FLAG=n 5516c3c9007Sstevelw_FLAG=n 552cb4d1691SRichard LoweW_FLAG=n 5537c478bd9Sstevel@tonic-gate# 5547c478bd9Sstevel@tonic-gatebuild_ok=y 555cb4d1691SRichard Lowebuild_extras_ok=y 5561fe69678Skupfer 5577c478bd9Sstevel@tonic-gate# 5587c478bd9Sstevel@tonic-gate# examine arguments 5597c478bd9Sstevel@tonic-gate# 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gateOPTIND=1 562cb4d1691SRichard Lowewhile getopts +intV:W FLAG 5637c478bd9Sstevel@tonic-gatedo 5647c478bd9Sstevel@tonic-gate case $FLAG in 5657c478bd9Sstevel@tonic-gate i ) i_FLAG=y; i_CMD_LINE_FLAG=y 5667c478bd9Sstevel@tonic-gate ;; 5677c478bd9Sstevel@tonic-gate n ) n_FLAG=y 5687c478bd9Sstevel@tonic-gate ;; 569fd7cef36Ssuha +t ) t_FLAG=n 5707c478bd9Sstevel@tonic-gate ;; 5716c3c9007Sstevel V ) V_FLAG=y 5726c3c9007Sstevel V_ARG="$OPTARG" 5736c3c9007Sstevel ;; 574cb4d1691SRichard Lowe W ) W_FLAG=y 575cb4d1691SRichard Lowe ;; 5767c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 5777c478bd9Sstevel@tonic-gate exit 1 5787c478bd9Sstevel@tonic-gate ;; 5797c478bd9Sstevel@tonic-gate esac 5807c478bd9Sstevel@tonic-gatedone 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate# correct argument count after options 5837c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate# test that the path to the environment-setting file was given 5867c478bd9Sstevel@tonic-gateif [ $# -ne 1 ]; then 5877c478bd9Sstevel@tonic-gate echo "$USAGE" 5887c478bd9Sstevel@tonic-gate exit 1 5897c478bd9Sstevel@tonic-gatefi 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate# check if user is running nightly as root 5927c478bd9Sstevel@tonic-gate# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 5937c478bd9Sstevel@tonic-gate# when root invokes nightly. 5947c478bd9Sstevel@tonic-gate/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 5957c478bd9Sstevel@tonic-gateISUSER=$?; export ISUSER 5967c478bd9Sstevel@tonic-gate 5977c478bd9Sstevel@tonic-gate# 5987c478bd9Sstevel@tonic-gate# force locale to C 59991d74a54SRichard LoweLANG=C; export LANG 60091d74a54SRichard LoweLC_ALL=C; export LC_ALL 6017c478bd9Sstevel@tonic-gateLC_COLLATE=C; export LC_COLLATE 6027c478bd9Sstevel@tonic-gateLC_CTYPE=C; export LC_CTYPE 6037c478bd9Sstevel@tonic-gateLC_MESSAGES=C; export LC_MESSAGES 6047c478bd9Sstevel@tonic-gateLC_MONETARY=C; export LC_MONETARY 6057c478bd9Sstevel@tonic-gateLC_NUMERIC=C; export LC_NUMERIC 6067c478bd9Sstevel@tonic-gateLC_TIME=C; export LC_TIME 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate# clear environment variables we know to be bad for the build 6097c478bd9Sstevel@tonic-gateunset LD_OPTIONS 6107c478bd9Sstevel@tonic-gateunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 6117c478bd9Sstevel@tonic-gateunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 6127c478bd9Sstevel@tonic-gateunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 6137c478bd9Sstevel@tonic-gateunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 6147c478bd9Sstevel@tonic-gateunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 6157c478bd9Sstevel@tonic-gateunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 6167c478bd9Sstevel@tonic-gateunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 6177c478bd9Sstevel@tonic-gateunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 6187c478bd9Sstevel@tonic-gateunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 6197c478bd9Sstevel@tonic-gateunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 6207c478bd9Sstevel@tonic-gateunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 6217c478bd9Sstevel@tonic-gateunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 6227c478bd9Sstevel@tonic-gateunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 6237c478bd9Sstevel@tonic-gateunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 6247c478bd9Sstevel@tonic-gateunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 6257c478bd9Sstevel@tonic-gateunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 6267c478bd9Sstevel@tonic-gateunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 6277c478bd9Sstevel@tonic-gateunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 6287c478bd9Sstevel@tonic-gateunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 6297c478bd9Sstevel@tonic-gateunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 6307c478bd9Sstevel@tonic-gate 6317c478bd9Sstevel@tonic-gateunset CONFIG 6327c478bd9Sstevel@tonic-gateunset GROUP 6337c478bd9Sstevel@tonic-gateunset OWNER 6347c478bd9Sstevel@tonic-gateunset REMOTE 6357c478bd9Sstevel@tonic-gateunset ENV 6367c478bd9Sstevel@tonic-gateunset ARCH 6377c478bd9Sstevel@tonic-gateunset CLASSPATH 6387c478bd9Sstevel@tonic-gateunset NAME 6397c478bd9Sstevel@tonic-gate 640ead1f93eSLiane Praza# 641ead1f93eSLiane Praza# To get ONBLD_TOOLS from the environment, it must come from the env file. 642ead1f93eSLiane Praza# If it comes interactively, it is generally TOOLS_PROTO, which will be 643ead1f93eSLiane Praza# clobbered before the compiler version checks, which will therefore fail. 644ead1f93eSLiane Praza# 645ead1f93eSLiane Prazaunset ONBLD_TOOLS 646ead1f93eSLiane Praza 6477c478bd9Sstevel@tonic-gate# 6487c478bd9Sstevel@tonic-gate# Setup environmental variables 6497c478bd9Sstevel@tonic-gate# 65047703246Ssommerfeif [ -f /etc/nightly.conf ]; then 65147703246Ssommerfe . /etc/nightly.conf 652fb23c574SRichard Lowefi 65347703246Ssommerfe 6547c478bd9Sstevel@tonic-gateif [ -f $1 ]; then 6557c478bd9Sstevel@tonic-gate if [[ $1 = */* ]]; then 6567c478bd9Sstevel@tonic-gate . $1 6577c478bd9Sstevel@tonic-gate else 6587c478bd9Sstevel@tonic-gate . ./$1 6597c478bd9Sstevel@tonic-gate fi 6607c478bd9Sstevel@tonic-gateelse 6617c478bd9Sstevel@tonic-gate if [ -f $OPTHOME/onbld/env/$1 ]; then 6627c478bd9Sstevel@tonic-gate . $OPTHOME/onbld/env/$1 6637c478bd9Sstevel@tonic-gate else 6647c478bd9Sstevel@tonic-gate echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 6657c478bd9Sstevel@tonic-gate exit 1 6667c478bd9Sstevel@tonic-gate fi 6677c478bd9Sstevel@tonic-gatefi 6687c478bd9Sstevel@tonic-gate 669d7693b08SRoland Mainz# Check if we have sufficient data to continue... 670d7693b08SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 671220399b7SRoland Mainzif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 672220399b7SRoland Mainz # Check if the gate data are valid if we don't do a "bringover" below 673220399b7SRoland Mainz [[ -d "${CODEMGR_WS}" ]] || \ 674220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS} is not a directory." 675220399b7SRoland Mainz [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 676220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 677220399b7SRoland Mainzfi 678d7693b08SRoland Mainz 6797c478bd9Sstevel@tonic-gate# 6807c478bd9Sstevel@tonic-gate# place ourselves in a new task, respecting BUILD_PROJECT if set. 6817c478bd9Sstevel@tonic-gate# 6827c478bd9Sstevel@tonic-gateif [ -z "$BUILD_PROJECT" ]; then 6837c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ 6847c478bd9Sstevel@tonic-gateelse 6857c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ -p $BUILD_PROJECT 6867c478bd9Sstevel@tonic-gatefi 6877c478bd9Sstevel@tonic-gate 6887c478bd9Sstevel@tonic-gateps -o taskid= -p $$ | read build_taskid 6897c478bd9Sstevel@tonic-gateps -o project= -p $$ | read build_project 6907c478bd9Sstevel@tonic-gate 6917c478bd9Sstevel@tonic-gate# 6927c478bd9Sstevel@tonic-gate# See if NIGHTLY_OPTIONS is set 6937c478bd9Sstevel@tonic-gate# 6947c478bd9Sstevel@tonic-gateif [ "$NIGHTLY_OPTIONS" = "" ]; then 6957c478bd9Sstevel@tonic-gate NIGHTLY_OPTIONS="-aBm" 6967c478bd9Sstevel@tonic-gatefi 6977c478bd9Sstevel@tonic-gate 6987c478bd9Sstevel@tonic-gate# 6997c478bd9Sstevel@tonic-gate# If BRINGOVER_WS was not specified, let it default to CLONE_WS 7007c478bd9Sstevel@tonic-gate# 7017c478bd9Sstevel@tonic-gateif [ "$BRINGOVER_WS" = "" ]; then 7027c478bd9Sstevel@tonic-gate BRINGOVER_WS=$CLONE_WS 7037c478bd9Sstevel@tonic-gatefi 7047c478bd9Sstevel@tonic-gate 705a5c06a9eSmike_s# 706fb23a357Skupfer# If BRINGOVER_FILES was not specified, default to usr 707a5c06a9eSmike_s# 708a5c06a9eSmike_sif [ "$BRINGOVER_FILES" = "" ]; then 709fb23a357Skupfer BRINGOVER_FILES="usr" 710a5c06a9eSmike_sfi 711a5c06a9eSmike_s 712c3e6cb59SRichard Lowecheck_closed_bins 713fb9f9b97Skupfer 7147c478bd9Sstevel@tonic-gate# 7157c478bd9Sstevel@tonic-gate# Note: changes to the option letters here should also be applied to the 716b84bdc30Smeem# bldenv script. `d' is listed for backward compatibility. 7177c478bd9Sstevel@tonic-gate# 718d77e7149SsommerfeNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 7197c478bd9Sstevel@tonic-gateOPTIND=1 720be0ffda9SPeter Tribblewhile getopts +ABCDdFfGIiMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 7217c478bd9Sstevel@tonic-gatedo 7227c478bd9Sstevel@tonic-gate case $FLAG in 7237c478bd9Sstevel@tonic-gate A ) A_FLAG=y 7247c478bd9Sstevel@tonic-gate ;; 7257c478bd9Sstevel@tonic-gate B ) D_FLAG=y 7267c478bd9Sstevel@tonic-gate ;; # old version of D 7276c3c9007Sstevel C ) C_FLAG=y 7287c478bd9Sstevel@tonic-gate ;; 7297c478bd9Sstevel@tonic-gate D ) D_FLAG=y 7307c478bd9Sstevel@tonic-gate ;; 7316c3c9007Sstevel F ) F_FLAG=y 7327c478bd9Sstevel@tonic-gate ;; 7336c3c9007Sstevel f ) f_FLAG=y 7347c478bd9Sstevel@tonic-gate ;; 73578add226Sjmcp G ) u_FLAG=y 7367c478bd9Sstevel@tonic-gate ;; 73778add226Sjmcp I ) m_FLAG=y 7387c478bd9Sstevel@tonic-gate p_FLAG=y 7397c478bd9Sstevel@tonic-gate u_FLAG=y 7407c478bd9Sstevel@tonic-gate ;; 7416c3c9007Sstevel i ) i_FLAG=y 7427c478bd9Sstevel@tonic-gate ;; 7436c3c9007Sstevel M ) M_FLAG=y 7447c478bd9Sstevel@tonic-gate ;; 7456c3c9007Sstevel m ) m_FLAG=y 7466c3c9007Sstevel ;; 7476c3c9007Sstevel N ) N_FLAG=y 7487c478bd9Sstevel@tonic-gate ;; 7497c478bd9Sstevel@tonic-gate n ) n_FLAG=y 7507c478bd9Sstevel@tonic-gate ;; 7517c478bd9Sstevel@tonic-gate p ) p_FLAG=y 7527c478bd9Sstevel@tonic-gate ;; 7536c3c9007Sstevel R ) m_FLAG=y 7546c3c9007Sstevel p_FLAG=y 7557c478bd9Sstevel@tonic-gate ;; 7566c3c9007Sstevel r ) r_FLAG=y 7577c478bd9Sstevel@tonic-gate ;; 758fd7cef36Ssuha +t ) t_FLAG=n 7597c478bd9Sstevel@tonic-gate ;; 7606798c3f0SMark J. Nelson U ) if [ -z "${PARENT_ROOT}" ]; then 7617c478bd9Sstevel@tonic-gate echo "PARENT_ROOT must be set if the U flag is" \ 7627c478bd9Sstevel@tonic-gate "present in NIGHTLY_OPTIONS." 7637c478bd9Sstevel@tonic-gate exit 1 7647c478bd9Sstevel@tonic-gate fi 7656798c3f0SMark J. Nelson NIGHTLY_PARENT_ROOT=$PARENT_ROOT 7666798c3f0SMark J. Nelson if [ -n "${PARENT_TOOLS_ROOT}" ]; then 7676798c3f0SMark J. Nelson NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 768ead1f93eSLiane Praza fi 7697c478bd9Sstevel@tonic-gate U_FLAG=y 7707c478bd9Sstevel@tonic-gate ;; 7716c3c9007Sstevel u ) u_FLAG=y 7727c478bd9Sstevel@tonic-gate ;; 7736c3c9007Sstevel w ) w_FLAG=y 7747c478bd9Sstevel@tonic-gate ;; 775cb4d1691SRichard Lowe W ) W_FLAG=y 776cb4d1691SRichard Lowe ;; 7777c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 7787c478bd9Sstevel@tonic-gate exit 1 7797c478bd9Sstevel@tonic-gate ;; 7807c478bd9Sstevel@tonic-gate esac 7817c478bd9Sstevel@tonic-gatedone 7827c478bd9Sstevel@tonic-gate 7837c478bd9Sstevel@tonic-gateif [ $ISUSER -ne 0 ]; then 7847c478bd9Sstevel@tonic-gate # Set default value for STAFFER, if needed. 7857c478bd9Sstevel@tonic-gate if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 7867c478bd9Sstevel@tonic-gate STAFFER=`/usr/xpg4/bin/id -un` 7877c478bd9Sstevel@tonic-gate export STAFFER 7887c478bd9Sstevel@tonic-gate fi 7897c478bd9Sstevel@tonic-gatefi 7907c478bd9Sstevel@tonic-gate 7917c478bd9Sstevel@tonic-gateif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 7927c478bd9Sstevel@tonic-gate MAILTO=$STAFFER 7937c478bd9Sstevel@tonic-gate export MAILTO 7947c478bd9Sstevel@tonic-gatefi 7957c478bd9Sstevel@tonic-gate 796c168ccb7SMark J. NelsonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 797c3e6cb59SRichard LowePATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 798c168ccb7SMark J. NelsonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 7997c478bd9Sstevel@tonic-gateexport PATH 8007c478bd9Sstevel@tonic-gate 801fb23a357Skupfer# roots of source trees, both relative to $SRC and absolute. 802fb23a357Skupferrelsrcdirs="." 803c0e7977aSJosef 'Jeff' Sipekabssrcdirs="$SRC" 804fb23a357Skupfer 805c3e6cb59SRichard LowePROTOCMPTERSE="protocmp.terse -gu" 8067c478bd9Sstevel@tonic-gatePOUND_SIGN="#" 80748bc00d6Sjmcp# have we set RELEASE_DATE in our env file? 80848bc00d6Sjmcpif [ -z "$RELEASE_DATE" ]; then 80948bc00d6Sjmcp RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 81048bc00d6Sjmcpfi 81148bc00d6SjmcpBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 81248bc00d6SjmcpBASEWSDIR=$(basename $CODEMGR_WS) 81348bc00d6SjmcpDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 8147c478bd9Sstevel@tonic-gate 81548bc00d6Sjmcp# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 816c3e6cb59SRichard Lowe# by avoiding repeated shell invocations to evaluate Makefile.master 817c3e6cb59SRichard Lowe# definitions. 818c3e6cb59SRichard Loweexport POUND_SIGN RELEASE_DATE DEV_CM 8197c478bd9Sstevel@tonic-gate 820b84bdc30Smeemmaketype="distributed" 821e119f243SRobert Mustacchiif [[ -z "$MAKE" ]]; then 822e119f243SRobert Mustacchi MAKE=dmake 823e119f243SRobert Mustacchielif [[ ! -x "$MAKE" ]]; then 824e119f243SRobert Mustacchi echo "\$MAKE is set to garbage in the environment" 825fb23c574SRichard Lowe exit 1 826e119f243SRobert Mustacchifi 8277c478bd9Sstevel@tonic-gateexport PATH 8287c478bd9Sstevel@tonic-gateexport MAKE 8297c478bd9Sstevel@tonic-gate 8307c478bd9Sstevel@tonic-gateif [ "${SUNWSPRO}" != "" ]; then 8317c478bd9Sstevel@tonic-gate PATH="${SUNWSPRO}/bin:$PATH" 8327c478bd9Sstevel@tonic-gate export PATH 8337c478bd9Sstevel@tonic-gatefi 8347c478bd9Sstevel@tonic-gate 83599e4a37bSWill Fiveashhostname=$(uname -n) 83699e4a37bSWill Fiveashif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 83799e4a37bSWill Fiveashthen 83899e4a37bSWill Fiveash maxjobs= 83999e4a37bSWill Fiveash if [[ -f $HOME/.make.machines ]] 84099e4a37bSWill Fiveash then 84199e4a37bSWill Fiveash # Note: there is a hard tab and space character in the []s 84299e4a37bSWill Fiveash # below. 84399e4a37bSWill Fiveash egrep -i "^[ ]*$hostname[ \.]" \ 84499e4a37bSWill Fiveash $HOME/.make.machines | read host jobs 84599e4a37bSWill Fiveash maxjobs=${jobs##*=} 84699e4a37bSWill Fiveash fi 84799e4a37bSWill Fiveash 84899e4a37bSWill Fiveash if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 84999e4a37bSWill Fiveash then 85099e4a37bSWill Fiveash # default 85199e4a37bSWill Fiveash maxjobs=4 8527c478bd9Sstevel@tonic-gate fi 85399e4a37bSWill Fiveash 85499e4a37bSWill Fiveash export DMAKE_MAX_JOBS=$maxjobs 8557c478bd9Sstevel@tonic-gatefi 85699e4a37bSWill Fiveash 8577c478bd9Sstevel@tonic-gateDMAKE_MODE=parallel; 8587c478bd9Sstevel@tonic-gateexport DMAKE_MODE 8597c478bd9Sstevel@tonic-gate 8607c478bd9Sstevel@tonic-gateif [ -z "${ROOT}" ]; then 8617c478bd9Sstevel@tonic-gate echo "ROOT must be set." 8627c478bd9Sstevel@tonic-gate exit 1 8637c478bd9Sstevel@tonic-gatefi 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate# 8667c478bd9Sstevel@tonic-gate# if -V flag was given, reset VERSION to V_ARG 8677c478bd9Sstevel@tonic-gate# 8687c478bd9Sstevel@tonic-gateif [ "$V_FLAG" = "y" ]; then 8697c478bd9Sstevel@tonic-gate VERSION=$V_ARG 8707c478bd9Sstevel@tonic-gatefi 8717c478bd9Sstevel@tonic-gate 8727c478bd9Sstevel@tonic-gateTMPDIR="/tmp/nightly.tmpdir.$$" 8737c478bd9Sstevel@tonic-gateexport TMPDIR 8747c478bd9Sstevel@tonic-gaterm -rf ${TMPDIR} 8757c478bd9Sstevel@tonic-gatemkdir -p $TMPDIR || exit 1 87685f46905SMark J. Nelsonchmod 777 $TMPDIR 8777c478bd9Sstevel@tonic-gate 8787ed54634SRobert Mustacchi# 8797ed54634SRobert Mustacchi# Work around folks who have historically used GCC_ROOT and convert it to 8807ed54634SRobert Mustacchi# GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could 8817ed54634SRobert Mustacchi# mess up the case where multiple different gcc versions are being used to 8827ed54634SRobert Mustacchi# shadow). 8837ed54634SRobert Mustacchi# 8847ed54634SRobert Mustacchiif [[ -n "${GCC_ROOT}" ]]; then 8857ed54634SRobert Mustacchi export GNUC_ROOT=${GCC_ROOT} 8867ed54634SRobert Mustacchifi 8877ed54634SRobert Mustacchi 888ead1f93eSLiane Praza# 889ead1f93eSLiane Praza# Tools should only be built non-DEBUG. Keep track of the tools proto 890ead1f93eSLiane Praza# area path relative to $TOOLS, because the latter changes in an 891ead1f93eSLiane Praza# export build. 892ead1f93eSLiane Praza# 893ead1f93eSLiane Praza# TOOLS_PROTO is included below for builds other than usr/src/tools 894ead1f93eSLiane Praza# that look for this location. For usr/src/tools, this will be 895ead1f93eSLiane Praza# overridden on the $MAKE command line in build_tools(). 896ead1f93eSLiane Praza# 8977c478bd9Sstevel@tonic-gateTOOLS=${SRC}/tools 898ead1f93eSLiane PrazaTOOLS_PROTO_REL=proto/root_${MACH}-nd 899ead1f93eSLiane PrazaTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 900ead1f93eSLiane Praza 9017c478bd9Sstevel@tonic-gateunset CFLAGS LD_LIBRARY_PATH LDFLAGS 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate# create directories that are automatically removed if the nightly script 9047c478bd9Sstevel@tonic-gate# fails to start correctly 905597bd30bSMike Kupferfunction newdir { 9067c478bd9Sstevel@tonic-gate dir=$1 9077c478bd9Sstevel@tonic-gate toadd= 9087c478bd9Sstevel@tonic-gate while [ ! -d $dir ]; do 9097c478bd9Sstevel@tonic-gate toadd="$dir $toadd" 9107c478bd9Sstevel@tonic-gate dir=`dirname $dir` 9117c478bd9Sstevel@tonic-gate done 9127c478bd9Sstevel@tonic-gate torm= 9137c478bd9Sstevel@tonic-gate newlist= 9147c478bd9Sstevel@tonic-gate for dir in $toadd; do 9157c478bd9Sstevel@tonic-gate if staffer mkdir $dir; then 9167c478bd9Sstevel@tonic-gate newlist="$ISUSER $dir $newlist" 9177c478bd9Sstevel@tonic-gate torm="$dir $torm" 9187c478bd9Sstevel@tonic-gate else 9197c478bd9Sstevel@tonic-gate [ -z "$torm" ] || staffer rmdir $torm 9207c478bd9Sstevel@tonic-gate return 1 9217c478bd9Sstevel@tonic-gate fi 9227c478bd9Sstevel@tonic-gate done 9237c478bd9Sstevel@tonic-gate newdirlist="$newlist $newdirlist" 9247c478bd9Sstevel@tonic-gate return 0 9257c478bd9Sstevel@tonic-gate} 9267c478bd9Sstevel@tonic-gatenewdirlist= 9277c478bd9Sstevel@tonic-gate 9287c478bd9Sstevel@tonic-gate[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 9297c478bd9Sstevel@tonic-gate 9307c478bd9Sstevel@tonic-gate# since this script assumes the build is from full source, it nullifies 9317c478bd9Sstevel@tonic-gate# variables likely to have been set by a "ws" script; nullification 9327c478bd9Sstevel@tonic-gate# confines the search space for headers and libraries to the proto area 9337c478bd9Sstevel@tonic-gate# built from this immediate source. 9347c478bd9Sstevel@tonic-gateENVLDLIBS1= 9357c478bd9Sstevel@tonic-gateENVLDLIBS2= 9367c478bd9Sstevel@tonic-gateENVLDLIBS3= 9377c478bd9Sstevel@tonic-gateENVCPPFLAGS1= 9387c478bd9Sstevel@tonic-gateENVCPPFLAGS2= 9397c478bd9Sstevel@tonic-gateENVCPPFLAGS3= 9407c478bd9Sstevel@tonic-gateENVCPPFLAGS4= 9417c478bd9Sstevel@tonic-gatePARENT_ROOT= 9427c478bd9Sstevel@tonic-gate 9437c478bd9Sstevel@tonic-gateexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 944494f7e12SKeith M Wesolowski ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 9457c478bd9Sstevel@tonic-gate 9467c478bd9Sstevel@tonic-gatePKGARCHIVE_ORIG=$PKGARCHIVE 9477c478bd9Sstevel@tonic-gate 9487c478bd9Sstevel@tonic-gate# 9497c478bd9Sstevel@tonic-gate# Juggle the logs and optionally send mail on completion. 9507c478bd9Sstevel@tonic-gate# 9517c478bd9Sstevel@tonic-gate 952597bd30bSMike Kupferfunction logshuffle { 953fb23c574SRichard Lowe LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 9547c478bd9Sstevel@tonic-gate if [ -f $LLOG -o -d $LLOG ]; then 955fb23c574SRichard Lowe LLOG=$LLOG.$$ 9567c478bd9Sstevel@tonic-gate fi 957810d639eSJohn Levon 958810d639eSJohn Levon rm -f "$ATLOG/latest" 2>/dev/null 959810d639eSJohn Levon mkdir -p $LLOG 9604802ef38Srscott export LLOG 9617c478bd9Sstevel@tonic-gate 9627c478bd9Sstevel@tonic-gate if [ "$build_ok" = "y" ]; then 9637c478bd9Sstevel@tonic-gate mv $ATLOG/proto_list_${MACH} $LLOG 96496ccc8cbSesaxe 9652e02daeeSRainer Orth if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 9662e02daeeSRainer Orth mv $ATLOG/proto_list_tools_${MACH} $LLOG 9672e02daeeSRainer Orth fi 9682e02daeeSRainer Orth 96996ccc8cbSesaxe if [ -f $TMPDIR/wsdiff.results ]; then 970fb23c574SRichard Lowe mv $TMPDIR/wsdiff.results $LLOG 97196ccc8cbSesaxe fi 9724e5b757fSkupfer 9734e5b757fSkupfer if [ -f $TMPDIR/wsdiff-nd.results ]; then 9744e5b757fSkupfer mv $TMPDIR/wsdiff-nd.results $LLOG 9754e5b757fSkupfer fi 9767c478bd9Sstevel@tonic-gate fi 9777c478bd9Sstevel@tonic-gate 9787c478bd9Sstevel@tonic-gate # 9797c478bd9Sstevel@tonic-gate # Now that we're about to send mail, it's time to check the noise 9807c478bd9Sstevel@tonic-gate # file. In the event that an error occurs beyond this point, it will 9817c478bd9Sstevel@tonic-gate # be recorded in the nightly.log file, but nowhere else. This would 9827c478bd9Sstevel@tonic-gate # include only errors that cause the copying of the noise log to fail 9837c478bd9Sstevel@tonic-gate # or the mail itself not to be sent. 9847c478bd9Sstevel@tonic-gate # 9857c478bd9Sstevel@tonic-gate 9867c478bd9Sstevel@tonic-gate exec >>$LOGFILE 2>&1 9877c478bd9Sstevel@tonic-gate if [ -s $build_noise_file ]; then 988fb23c574SRichard Lowe echo "\n==== Nightly build noise ====\n" | 9897c478bd9Sstevel@tonic-gate tee -a $LOGFILE >>$mail_msg_file 9907c478bd9Sstevel@tonic-gate cat $build_noise_file >>$LOGFILE 9917c478bd9Sstevel@tonic-gate cat $build_noise_file >>$mail_msg_file 9927c478bd9Sstevel@tonic-gate echo | tee -a $LOGFILE >>$mail_msg_file 9937c478bd9Sstevel@tonic-gate fi 9947c478bd9Sstevel@tonic-gate rm -f $build_noise_file 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate case "$build_ok" in 9977c478bd9Sstevel@tonic-gate y) 9987c478bd9Sstevel@tonic-gate state=Completed 9997c478bd9Sstevel@tonic-gate ;; 10007c478bd9Sstevel@tonic-gate i) 10017c478bd9Sstevel@tonic-gate state=Interrupted 10027c478bd9Sstevel@tonic-gate ;; 10037c478bd9Sstevel@tonic-gate *) 1004fb23c574SRichard Lowe state=Failed 10057c478bd9Sstevel@tonic-gate ;; 10067c478bd9Sstevel@tonic-gate esac 1007cb4d1691SRichard Lowe 1008cb4d1691SRichard Lowe if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 1009cb4d1691SRichard Lowe state=Failed 1010cb4d1691SRichard Lowe fi 1011cb4d1691SRichard Lowe 101240bc9153Srscott NIGHTLY_STATUS=$state 101340bc9153Srscott export NIGHTLY_STATUS 1014d77e7149Ssommerfe 101547703246Ssommerfe run_hook POST_NIGHTLY $state 101647703246Ssommerfe run_hook SYS_POST_NIGHTLY $state 10174802ef38Srscott 10183cb00cf1SJoshua M. Clulow # 10193cb00cf1SJoshua M. Clulow # mailx(1) sets From: based on the -r flag 10203cb00cf1SJoshua M. Clulow # if it is given. 10213cb00cf1SJoshua M. Clulow # 10223cb00cf1SJoshua M. Clulow mailx_r= 10233cb00cf1SJoshua M. Clulow if [[ -n "${MAILFROM}" ]]; then 10243cb00cf1SJoshua M. Clulow mailx_r="-r ${MAILFROM}" 10253cb00cf1SJoshua M. Clulow fi 10263cb00cf1SJoshua M. Clulow 1027cdf0c1d5Smjnelson cat $build_time_file $build_environ_file $mail_msg_file \ 1028cdf0c1d5Smjnelson > ${LLOG}/mail_msg 10297c478bd9Sstevel@tonic-gate if [ "$m_FLAG" = "y" ]; then 1030fb23c574SRichard Lowe cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 10317c478bd9Sstevel@tonic-gate "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 10327c478bd9Sstevel@tonic-gate ${MAILTO} 10337c478bd9Sstevel@tonic-gate fi 10347c478bd9Sstevel@tonic-gate 10357c478bd9Sstevel@tonic-gate if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1036fb23c574SRichard Lowe staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 10377c478bd9Sstevel@tonic-gate staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 10387c478bd9Sstevel@tonic-gate fi 10397c478bd9Sstevel@tonic-gate 10407c478bd9Sstevel@tonic-gate mv $LOGFILE $LLOG 1041810d639eSJohn Levon 1042810d639eSJohn Levon ln -s "$LLOG" "$ATLOG/latest" 10437c478bd9Sstevel@tonic-gate} 10447c478bd9Sstevel@tonic-gate 10457c478bd9Sstevel@tonic-gate# 10467c478bd9Sstevel@tonic-gate# Remove the locks and temporary files on any exit 10477c478bd9Sstevel@tonic-gate# 1048597bd30bSMike Kupferfunction cleanup { 1049fb23c574SRichard Lowe logshuffle 10507c478bd9Sstevel@tonic-gate 10517c478bd9Sstevel@tonic-gate [ -z "$lockfile" ] || staffer rm -f $lockfile 10527c478bd9Sstevel@tonic-gate [ -z "$atloglockfile" ] || rm -f $atloglockfile 10537c478bd9Sstevel@tonic-gate [ -z "$ulockfile" ] || staffer rm -f $ulockfile 10547c478bd9Sstevel@tonic-gate [ -z "$Ulockfile" ] || rm -f $Ulockfile 10557c478bd9Sstevel@tonic-gate 10567c478bd9Sstevel@tonic-gate set -- $newdirlist 10577c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 10587c478bd9Sstevel@tonic-gate ISUSER=$1 staffer rmdir $2 10597c478bd9Sstevel@tonic-gate shift; shift 10607c478bd9Sstevel@tonic-gate done 10617c478bd9Sstevel@tonic-gate rm -rf $TMPDIR 10627c478bd9Sstevel@tonic-gate} 10637c478bd9Sstevel@tonic-gate 1064597bd30bSMike Kupferfunction cleanup_signal { 1065fb23c574SRichard Lowe build_ok=i 10667c478bd9Sstevel@tonic-gate # this will trigger cleanup(), above. 10677c478bd9Sstevel@tonic-gate exit 1 10687c478bd9Sstevel@tonic-gate} 10697c478bd9Sstevel@tonic-gate 10707c478bd9Sstevel@tonic-gatetrap cleanup 0 10717c478bd9Sstevel@tonic-gatetrap cleanup_signal 1 2 3 15 10727c478bd9Sstevel@tonic-gate 10737c478bd9Sstevel@tonic-gate# 10747c478bd9Sstevel@tonic-gate# Generic lock file processing -- make sure that the lock file doesn't 10757c478bd9Sstevel@tonic-gate# exist. If it does, it should name the build host and PID. If it 10767c478bd9Sstevel@tonic-gate# doesn't, then make sure we can create it. Clean up locks that are 10777c478bd9Sstevel@tonic-gate# known to be stale (assumes host name is unique among build systems 10787c478bd9Sstevel@tonic-gate# for the workspace). 1079cdf0c1d5Smjnelson# 1080597bd30bSMike Kupferfunction create_lock { 10817c478bd9Sstevel@tonic-gate lockf=$1 10827c478bd9Sstevel@tonic-gate lockvar=$2 10838312e758Sdduvall 10847c478bd9Sstevel@tonic-gate ldir=`dirname $lockf` 10857c478bd9Sstevel@tonic-gate [ -d $ldir ] || newdir $ldir || exit 1 10867c478bd9Sstevel@tonic-gate eval $lockvar=$lockf 10878312e758Sdduvall 10888312e758Sdduvall while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 10898312e758Sdduvall basews=`basename $CODEMGR_WS` 10908312e758Sdduvall ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 10918312e758Sdduvall if [ "$host" != "$hostname" ]; then 10928312e758Sdduvall echo "$MACH build of $basews apparently" \ 10938312e758Sdduvall "already started by $user on $host as $pid." 10948312e758Sdduvall exit 1 10958312e758Sdduvall elif kill -s 0 $pid 2>/dev/null; then 10968312e758Sdduvall echo "$MACH build of $basews already started" \ 10978312e758Sdduvall "by $user as $pid." 10988312e758Sdduvall exit 1 10998312e758Sdduvall else 11008312e758Sdduvall # stale lock; clear it out and try again 11018312e758Sdduvall rm -f $lockf 11028312e758Sdduvall fi 11038312e758Sdduvall done 11047c478bd9Sstevel@tonic-gate} 11057c478bd9Sstevel@tonic-gate 11064e5b757fSkupfer# 11074e5b757fSkupfer# Return the list of interesting proto areas, depending on the current 11084e5b757fSkupfer# options. 11094e5b757fSkupfer# 1110597bd30bSMike Kupferfunction allprotos { 1111c7453724SMike Kupfer typeset roots="$ROOT" 1112c7453724SMike Kupfer 1113c7453724SMike Kupfer if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1114c7453724SMike Kupfer roots="$roots $ROOT-nd" 11154e5b757fSkupfer fi 11164e5b757fSkupfer 11174e5b757fSkupfer echo $roots 11184e5b757fSkupfer} 11194e5b757fSkupfer 11207c478bd9Sstevel@tonic-gate# Ensure no other instance of this script is running on this host. 11217c478bd9Sstevel@tonic-gate# LOCKNAME can be set in <env_file>, and is by default, but is not 11227c478bd9Sstevel@tonic-gate# required due to the use of $ATLOG below. 11237c478bd9Sstevel@tonic-gateif [ -n "$LOCKNAME" ]; then 11247c478bd9Sstevel@tonic-gate create_lock /tmp/$LOCKNAME "lockfile" 11257c478bd9Sstevel@tonic-gatefi 11267c478bd9Sstevel@tonic-gate# 11277c478bd9Sstevel@tonic-gate# Create from one, two, or three other locks: 11287c478bd9Sstevel@tonic-gate# $ATLOG/nightly.lock 11297c478bd9Sstevel@tonic-gate# - protects against multiple builds in same workspace 11307c478bd9Sstevel@tonic-gate# $PARENT_WS/usr/src/nightly.$MACH.lock 11317c478bd9Sstevel@tonic-gate# - protects against multiple 'u' copy-backs 11327c478bd9Sstevel@tonic-gate# $NIGHTLY_PARENT_ROOT/nightly.lock 11337c478bd9Sstevel@tonic-gate# - protects against multiple 'U' copy-backs 11347c478bd9Sstevel@tonic-gate# 11357c478bd9Sstevel@tonic-gate# Overriding ISUSER to 1 causes the lock to be created as root if the 11367c478bd9Sstevel@tonic-gate# script is run as root. The default is to create it as $STAFFER. 11377c478bd9Sstevel@tonic-gateISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 11387c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" ]; then 11397c478bd9Sstevel@tonic-gate create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 11407c478bd9Sstevel@tonic-gatefi 11417c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" ]; then 11427c478bd9Sstevel@tonic-gate # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 11437c478bd9Sstevel@tonic-gate ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 11447c478bd9Sstevel@tonic-gatefi 11457c478bd9Sstevel@tonic-gate 11467c478bd9Sstevel@tonic-gate# Locks have been taken, so we're doing a build and we're committed to 11477c478bd9Sstevel@tonic-gate# the directories we may have created so far. 11487c478bd9Sstevel@tonic-gatenewdirlist= 11497c478bd9Sstevel@tonic-gate 11507c478bd9Sstevel@tonic-gate# 11517c478bd9Sstevel@tonic-gate# Create mail_msg_file 11527c478bd9Sstevel@tonic-gate# 11537c478bd9Sstevel@tonic-gatemail_msg_file="${TMPDIR}/mail_msg" 11547c478bd9Sstevel@tonic-gatetouch $mail_msg_file 11557c478bd9Sstevel@tonic-gatebuild_time_file="${TMPDIR}/build_time" 1156cdf0c1d5Smjnelsonbuild_environ_file="${TMPDIR}/build_environ" 1157cdf0c1d5Smjnelsontouch $build_environ_file 11587c478bd9Sstevel@tonic-gate# 11597c478bd9Sstevel@tonic-gate# Move old LOGFILE aside 11607c478bd9Sstevel@tonic-gate# ATLOG directory already made by 'create_lock' above 11617c478bd9Sstevel@tonic-gate# 11627c478bd9Sstevel@tonic-gateif [ -f $LOGFILE ]; then 11637c478bd9Sstevel@tonic-gate mv -f $LOGFILE ${LOGFILE}- 11647c478bd9Sstevel@tonic-gatefi 11657c478bd9Sstevel@tonic-gate# 11667c478bd9Sstevel@tonic-gate# Build OsNet source 11677c478bd9Sstevel@tonic-gate# 11687c478bd9Sstevel@tonic-gateSTART_DATE=`date` 11697c478bd9Sstevel@tonic-gateSECONDS=0 11707c478bd9Sstevel@tonic-gateecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 11717c478bd9Sstevel@tonic-gate | tee -a $LOGFILE > $build_time_file 11727c478bd9Sstevel@tonic-gate 1173cdf0c1d5Smjnelsonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1174cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 1175cdf0c1d5Smjnelson 11767c478bd9Sstevel@tonic-gate# make sure we log only to the nightly build file 11777c478bd9Sstevel@tonic-gatebuild_noise_file="${TMPDIR}/build_noise" 11787c478bd9Sstevel@tonic-gateexec </dev/null >$build_noise_file 2>&1 11797c478bd9Sstevel@tonic-gate 118047703246Ssommerferun_hook SYS_PRE_NIGHTLY 118147703246Ssommerferun_hook PRE_NIGHTLY 118247703246Ssommerfe 11837c478bd9Sstevel@tonic-gateecho "\n==== list of environment variables ====\n" >> $LOGFILE 11847c478bd9Sstevel@tonic-gateenv >> $LOGFILE 11857c478bd9Sstevel@tonic-gate 11867c478bd9Sstevel@tonic-gateecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 11877c478bd9Sstevel@tonic-gate 11885110237aSJosef 'Jeff' Sipekif [ "$N_FLAG" = "y" ]; then 11895110237aSJosef 'Jeff' Sipek if [ "$p_FLAG" = "y" ]; then 11905110237aSJosef 'Jeff' Sipek cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 11917c478bd9Sstevel@tonic-gateWARNING: the p option (create packages) is set, but so is the N option (do 11927c478bd9Sstevel@tonic-gate not run protocmp); this is dangerous; you should unset the N option 11937c478bd9Sstevel@tonic-gateEOF 11945110237aSJosef 'Jeff' Sipek else 11955110237aSJosef 'Jeff' Sipek cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 11967c478bd9Sstevel@tonic-gateWarning: the N option (do not run protocmp) is set; it probably shouldn't be 11977c478bd9Sstevel@tonic-gateEOF 11987c478bd9Sstevel@tonic-gate fi 11995110237aSJosef 'Jeff' Sipek echo "" | tee -a $mail_msg_file >> $LOGFILE 12007c478bd9Sstevel@tonic-gatefi 12017c478bd9Sstevel@tonic-gate 12027c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" ]; then 12037c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "y" ]; then 12047c478bd9Sstevel@tonic-gate echo "WARNING: the -f flag cannot be used during incremental" \ 12057c478bd9Sstevel@tonic-gate "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 12067c478bd9Sstevel@tonic-gate f_FLAG=n 12077c478bd9Sstevel@tonic-gate fi 1208be0ffda9SPeter Tribble if [ "${p_FLAG}" != "y" ]; then 1209be0ffda9SPeter Tribble echo "WARNING: the -f flag requires -p;" \ 121011a78ea0SMark J. Nelson "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 12117c478bd9Sstevel@tonic-gate f_FLAG=n 12127c478bd9Sstevel@tonic-gate fi 12137c478bd9Sstevel@tonic-gatefi 12147c478bd9Sstevel@tonic-gate 121596ccc8cbSesaxeif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 12164e5b757fSkupfer echo "WARNING: -w specified, but $ROOT does not exist;" \ 121796ccc8cbSesaxe "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 121896ccc8cbSesaxe w_FLAG=n 121996ccc8cbSesaxefi 122096ccc8cbSesaxe 12214e5b757fSkupfercase $MULTI_PROTO in 12224e5b757fSkupferyes|no) ;; 12234e5b757fSkupfer*) 12244e5b757fSkupfer echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 12254e5b757fSkupfer "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 12264e5b757fSkupfer echo "Setting MULTI_PROTO to \"no\".\n" | \ 12274e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 12284e5b757fSkupfer export MULTI_PROTO=no 12294e5b757fSkupfer ;; 12304e5b757fSkupferesac 12314e5b757fSkupfer 12327c478bd9Sstevel@tonic-gateecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 12337c478bd9Sstevel@tonic-gateecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 12347c478bd9Sstevel@tonic-gate 123596ccc8cbSesaxe# Save the current proto area if we're comparing against the last build 123696ccc8cbSesaxeif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 123796ccc8cbSesaxe if [ -d "$ROOT.prev" ]; then 123896ccc8cbSesaxe rm -rf $ROOT.prev 123996ccc8cbSesaxe fi 124096ccc8cbSesaxe mv $ROOT $ROOT.prev 124196ccc8cbSesaxefi 124296ccc8cbSesaxe 12434e5b757fSkupfer# Same for non-DEBUG proto area 12444e5b757fSkupferif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 12454e5b757fSkupfer if [ -d "$ROOT-nd.prev" ]; then 12464e5b757fSkupfer rm -rf $ROOT-nd.prev 12474e5b757fSkupfer fi 12484e5b757fSkupfer mv $ROOT-nd $ROOT-nd.prev 12494e5b757fSkupferfi 12504e5b757fSkupfer 1251445b6314SRichard Lowe# 1252445b6314SRichard Lowe# Echo the SCM type of the parent workspace, this can't just be which_scm 1253445b6314SRichard Lowe# as that does not know how to identify various network repositories. 1254445b6314SRichard Lowe# 1255445b6314SRichard Lowefunction parent_wstype { 1256445b6314SRichard Lowe typeset scm_type junk 125730635de9SJohn.Zolnowsky@Sun.COM 125830635de9SJohn.Zolnowsky@Sun.COM CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1259445b6314SRichard Lowe | read scm_type junk 1260445b6314SRichard Lowe if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 126130635de9SJohn.Zolnowsky@Sun.COM # Probe BRINGOVER_WS to determine its type 1262c3e6cb59SRichard Lowe if [[ $BRINGOVER_WS == ssh://* ]]; then 1263445b6314SRichard Lowe scm_type="mercurial" 126430635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == http://* ]] && \ 1265445b6314SRichard Lowe wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 126630635de9SJohn.Zolnowsky@Sun.COM egrep -s "application/mercurial" 2> /dev/null; then 1267445b6314SRichard Lowe scm_type="mercurial" 126830635de9SJohn.Zolnowsky@Sun.COM else 1269445b6314SRichard Lowe scm_type="none" 127030635de9SJohn.Zolnowsky@Sun.COM fi 1271fb23c574SRichard Lowe fi 127230635de9SJohn.Zolnowsky@Sun.COM 127330635de9SJohn.Zolnowsky@Sun.COM # fold both unsupported and unrecognized results into "none" 1274445b6314SRichard Lowe case "$scm_type" in 1275c3e6cb59SRichard Lowe mercurial) 127630635de9SJohn.Zolnowsky@Sun.COM ;; 1277445b6314SRichard Lowe *) scm_type=none 127830635de9SJohn.Zolnowsky@Sun.COM ;; 127930635de9SJohn.Zolnowsky@Sun.COM esac 1280445b6314SRichard Lowe 1281445b6314SRichard Lowe echo $scm_type 1282445b6314SRichard Lowe} 1283445b6314SRichard Lowe 1284445b6314SRichard Lowe# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1285445b6314SRichard Lowefunction child_wstype { 1286445b6314SRichard Lowe typeset scm_type junk 1287445b6314SRichard Lowe 1288445b6314SRichard Lowe # Probe CODEMGR_WS to determine its type 1289445b6314SRichard Lowe if [[ -d $CODEMGR_WS ]]; then 1290445b6314SRichard Lowe $WHICH_SCM | read scm_type junk || exit 1 1291445b6314SRichard Lowe fi 1292445b6314SRichard Lowe 1293445b6314SRichard Lowe case "$scm_type" in 1294c3e6cb59SRichard Lowe none|git|mercurial) 129530635de9SJohn.Zolnowsky@Sun.COM ;; 1296445b6314SRichard Lowe *) scm_type=none 129730635de9SJohn.Zolnowsky@Sun.COM ;; 129830635de9SJohn.Zolnowsky@Sun.COM esac 129930635de9SJohn.Zolnowsky@Sun.COM 1300445b6314SRichard Lowe echo $scm_type 130130635de9SJohn.Zolnowsky@Sun.COM} 130230635de9SJohn.Zolnowsky@Sun.COM 13035c70f01eSRichard LoweSCM_TYPE=$(child_wstype) 130430635de9SJohn.Zolnowsky@Sun.COM 13057c478bd9Sstevel@tonic-gate# 13067c478bd9Sstevel@tonic-gate# Decide whether to clobber 13077c478bd9Sstevel@tonic-gate# 13087c478bd9Sstevel@tonic-gateif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 13097c478bd9Sstevel@tonic-gate echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 13107c478bd9Sstevel@tonic-gate 13117c478bd9Sstevel@tonic-gate cd $SRC 13127c478bd9Sstevel@tonic-gate # remove old clobber file 13137c478bd9Sstevel@tonic-gate rm -f $SRC/clobber.out 13147c478bd9Sstevel@tonic-gate rm -f $SRC/clobber-${MACH}.out 13157c478bd9Sstevel@tonic-gate 13167c478bd9Sstevel@tonic-gate # Remove all .make.state* files, just in case we are restarting 13177c478bd9Sstevel@tonic-gate # the build after having interrupted a previous 'make clobber'. 13188bcea973SRichard Lowe find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1319cdf0c1d5Smjnelson -o -name 'interfaces.*' \) -prune \ 1320cdf0c1d5Smjnelson -o -name '.make.*' -print | xargs rm -f 13217c478bd9Sstevel@tonic-gate 13227c478bd9Sstevel@tonic-gate $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 13237c478bd9Sstevel@tonic-gate echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 13247c478bd9Sstevel@tonic-gate grep "$MAKE:" $SRC/clobber-${MACH}.out | 1325cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 1326cb4d1691SRichard Lowe tee $TMPDIR/clobber_errs >> $mail_msg_file 1327cb4d1691SRichard Lowe 1328cb4d1691SRichard Lowe if [[ -s $TMPDIR/clobber_errs ]]; then 1329cb4d1691SRichard Lowe build_extras_ok=n 1330cb4d1691SRichard Lowe fi 13317c478bd9Sstevel@tonic-gate 13325110237aSJosef 'Jeff' Sipek if [[ "$t_FLAG" = "y" ]]; then 13337c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 13347c478bd9Sstevel@tonic-gate cd ${TOOLS} 13357c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/clobber-${MACH}.out 1336ead1f93eSLiane Praza $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 13377c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 13387c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber ERRORS ====\n" \ 13397c478bd9Sstevel@tonic-gate >> $mail_msg_file 13407c478bd9Sstevel@tonic-gate grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 13417c478bd9Sstevel@tonic-gate >> $mail_msg_file 1342cb4d1691SRichard Lowe if (( $? == 0 )); then 1343cb4d1691SRichard Lowe build_extras_ok=n 1344cb4d1691SRichard Lowe fi 13457c478bd9Sstevel@tonic-gate rm -rf ${TOOLS_PROTO} 13467c478bd9Sstevel@tonic-gate mkdir -p ${TOOLS_PROTO} 13477c478bd9Sstevel@tonic-gate fi 134896ccc8cbSesaxe 1349c7453724SMike Kupfer typeset roots=$(allprotos) 1350c7453724SMike Kupfer echo "\n\nClearing $roots" >> "$LOGFILE" 1351c7453724SMike Kupfer rm -rf $roots 13527c478bd9Sstevel@tonic-gate 13537c478bd9Sstevel@tonic-gate # Get back to a clean workspace as much as possible to catch 13547c478bd9Sstevel@tonic-gate # problems that only occur on fresh workspaces. 13557c478bd9Sstevel@tonic-gate # Remove all .make.state* files, libraries, and .o's that may 1356fb23a357Skupfer # have been omitted from clobber. A couple of libraries are 1357cdf0c1d5Smjnelson # under source code control, so leave them alone. 13587c478bd9Sstevel@tonic-gate # We should probably blow away temporary directories too. 13597c478bd9Sstevel@tonic-gate cd $SRC 1360cdf0c1d5Smjnelson find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 13618bcea973SRichard Lowe -o -name .git -o -name 'interfaces.*' \) -prune -o \ 13627c478bd9Sstevel@tonic-gate \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1363fb23a357Skupfer -name '*.o' \) -print | \ 1364fb23a357Skupfer grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 13657c478bd9Sstevel@tonic-gateelse 13667c478bd9Sstevel@tonic-gate echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 13677c478bd9Sstevel@tonic-gatefi 13687c478bd9Sstevel@tonic-gate 1369597bd30bSMike Kupfertype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1370cdf0c1d5Smjnelson typeset -x PATH=$PATH 1371cdf0c1d5Smjnelson 1372cdf0c1d5Smjnelson # If the repository doesn't exist yet, then we want to populate it. 1373cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.hg ]]; then 1374cdf0c1d5Smjnelson staffer hg init $CODEMGR_WS 13758cca05f6SMark J. Nelson staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 13768cca05f6SMark J. Nelson staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1377f457028bSMark J. Nelson touch $TMPDIR/new_repository 13785c53ea7aSmjnelson fi 13795c53ea7aSmjnelson 1380cdf0c1d5Smjnelson typeset -x HGMERGE="/bin/false" 1381cdf0c1d5Smjnelson 1382cdf0c1d5Smjnelson # 13835c53ea7aSmjnelson # If the user has changes, regardless of whether those changes are 13845c53ea7aSmjnelson # committed, and regardless of whether those changes conflict, then 13855c53ea7aSmjnelson # we'll attempt to merge them either implicitly (uncommitted) or 13865c53ea7aSmjnelson # explicitly (committed). 13875c53ea7aSmjnelson # 13885c53ea7aSmjnelson # These are the messages we'll use to help clarify mercurial output 13895c53ea7aSmjnelson # in those cases. 13905c53ea7aSmjnelson # 13915c53ea7aSmjnelson typeset mergefailmsg="\ 13925c53ea7aSmjnelson***\n\ 13935c53ea7aSmjnelson*** nightly was unable to automatically merge your changes. You should\n\ 13945c53ea7aSmjnelson*** redo the full merge manually, following the steps outlined by mercurial\n\ 13955c53ea7aSmjnelson*** above, then restart nightly.\n\ 13965c53ea7aSmjnelson***\n" 13975c53ea7aSmjnelson typeset mergepassmsg="\ 13985c53ea7aSmjnelson***\n\ 13995c53ea7aSmjnelson*** nightly successfully merged your changes. This means that your working\n\ 14005c53ea7aSmjnelson*** directory has been updated, but those changes are not yet committed.\n\ 14015c53ea7aSmjnelson*** After nightly completes, you should validate the results of the merge,\n\ 14025c53ea7aSmjnelson*** then use hg commit manually.\n\ 14035c53ea7aSmjnelson***\n" 14045c53ea7aSmjnelson 14055c53ea7aSmjnelson # 14065c53ea7aSmjnelson # For each repository in turn: 14075c53ea7aSmjnelson # 14085c53ea7aSmjnelson # 1. Do the pull. If this fails, dump the output and bail out. 14095c53ea7aSmjnelson # 14105c53ea7aSmjnelson # 2. If the pull resulted in an extra head, do an explicit merge. 14115c53ea7aSmjnelson # If this fails, dump the output and bail out. 14125c53ea7aSmjnelson # 14135c53ea7aSmjnelson # Because we can't rely on Mercurial to exit with a failure code 14145c53ea7aSmjnelson # when a merge fails (Mercurial issue #186), we must grep the 14155c53ea7aSmjnelson # output of pull/merge to check for attempted and/or failed merges. 14165c53ea7aSmjnelson # 14175c53ea7aSmjnelson # 3. If a merge failed, set the message and fail the bringover. 14185c53ea7aSmjnelson # 14195c53ea7aSmjnelson # 4. Otherwise, if a merge succeeded, set the message 14205c53ea7aSmjnelson # 14215c53ea7aSmjnelson # 5. Dump the output, and any message from step 3 or 4. 14225c53ea7aSmjnelson # 14235c53ea7aSmjnelson 1424f457028bSMark J. Nelson typeset HG_SOURCE=$BRINGOVER_WS 1425f457028bSMark J. Nelson if [ ! -f $TMPDIR/new_repository ]; then 1426f457028bSMark J. Nelson HG_SOURCE=$TMPDIR/open_bundle.hg 1427f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1428f457028bSMark J. Nelson -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1429f457028bSMark J. Nelson 1430f457028bSMark J. Nelson # 1431f457028bSMark J. Nelson # If there are no incoming changesets, then incoming will 1432f457028bSMark J. Nelson # fail, and there will be no bundle file. Reset the source, 1433f457028bSMark J. Nelson # to allow the remaining logic to complete with no false 1434f457028bSMark J. Nelson # negatives. (Unlike incoming, pull will return success 1435f457028bSMark J. Nelson # for the no-change case.) 1436f457028bSMark J. Nelson # 1437f457028bSMark J. Nelson if (( $? != 0 )); then 1438f457028bSMark J. Nelson HG_SOURCE=$BRINGOVER_WS 1439f457028bSMark J. Nelson fi 1440f457028bSMark J. Nelson fi 1441f457028bSMark J. Nelson 1442f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 14435c53ea7aSmjnelson > $TMPDIR/pull_open.out 2>&1 14445c53ea7aSmjnelson if (( $? != 0 )); then 14455c53ea7aSmjnelson printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 14465c53ea7aSmjnelson cat $TMPDIR/pull_open.out 14475c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 14485c53ea7aSmjnelson printf "$mergefailmsg" 14495c53ea7aSmjnelson fi 1450cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1451cdf0c1d5Smjnelson return 1452cdf0c1d5Smjnelson fi 1453cdf0c1d5Smjnelson 14545c53ea7aSmjnelson if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 14555c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS merge \ 14565c53ea7aSmjnelson >> $TMPDIR/pull_open.out 2>&1 14575c53ea7aSmjnelson if (( $? != 0 )); then 14585c53ea7aSmjnelson printf "%s: merge failed as follows:\n\n" \ 14595c53ea7aSmjnelson "$CODEMGR_WS" 14605c53ea7aSmjnelson cat $TMPDIR/pull_open.out 14615c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out \ 14625c53ea7aSmjnelson > /dev/null 2>&1; then 14635c53ea7aSmjnelson printf "$mergefailmsg" 14645c53ea7aSmjnelson fi 1465cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1466cdf0c1d5Smjnelson return 1467cdf0c1d5Smjnelson fi 1468cdf0c1d5Smjnelson fi 1469cdf0c1d5Smjnelson 14705c53ea7aSmjnelson printf "updated %s with the following results:\n" "$CODEMGR_WS" 14715c53ea7aSmjnelson cat $TMPDIR/pull_open.out 14725c53ea7aSmjnelson if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 14735c53ea7aSmjnelson printf "$mergepassmsg" 1474cdf0c1d5Smjnelson fi 14755c53ea7aSmjnelson printf "\n" 1476cdf0c1d5Smjnelson 1477f457028bSMark J. Nelson # 1478f457028bSMark J. Nelson # Per-changeset output is neither useful nor manageable for a 1479f457028bSMark J. Nelson # newly-created repository. 1480f457028bSMark J. Nelson # 1481f457028bSMark J. Nelson if [ -f $TMPDIR/new_repository ]; then 1482f457028bSMark J. Nelson return 1483f457028bSMark J. Nelson fi 1484f457028bSMark J. Nelson 1485f457028bSMark J. Nelson printf "\nadded the following changesets to open repository:\n" 1486f457028bSMark J. Nelson cat $TMPDIR/incoming_open.out 1487cdf0c1d5Smjnelson} 1488cdf0c1d5Smjnelson 1489597bd30bSMike Kupfertype bringover_none > /dev/null 2>&1 || function bringover_none { 1490cdf0c1d5Smjnelson echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1491cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1492cdf0c1d5Smjnelson} 1493cdf0c1d5Smjnelson 1494cdf0c1d5Smjnelson# 1495cdf0c1d5Smjnelson# Decide whether to bringover to the codemgr workspace 1496cdf0c1d5Smjnelson# 1497cdf0c1d5Smjnelsonif [ "$n_FLAG" = "n" ]; then 1498445b6314SRichard Lowe PARENT_SCM_TYPE=$(parent_wstype) 1499ca0ac982Smjnelson 1500ca0ac982Smjnelson if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1501ca0ac982Smjnelson echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1502ca0ac982Smjnelson "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 1503ca0ac982Smjnelson exit 1 1504ca0ac982Smjnelson fi 1505ca0ac982Smjnelson 1506cdf0c1d5Smjnelson run_hook PRE_BRINGOVER 1507cdf0c1d5Smjnelson 1508cdf0c1d5Smjnelson echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1509cdf0c1d5Smjnelson echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1510cdf0c1d5Smjnelson 1511ca0ac982Smjnelson eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 1512cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 151332f1e47bSsommerfe 1514d77e7149Ssommerfe if [ -f $TMPDIR/bringover_failed ]; then 151532f1e47bSsommerfe rm -f $TMPDIR/bringover_failed 151632f1e47bSsommerfe build_ok=n 1517d77e7149Ssommerfe echo "trouble with bringover, quitting at `date`." | 151832f1e47bSsommerfe tee -a $mail_msg_file >> $LOGFILE 15197c478bd9Sstevel@tonic-gate exit 1 15207c478bd9Sstevel@tonic-gate fi 1521085d331dSkupfer 1522ca0ac982Smjnelson # 1523ca0ac982Smjnelson # It's possible that we used the bringover above to create 1524ca0ac982Smjnelson # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 1525ca0ac982Smjnelson # but should now be the same as $BRINGOVER_WS. 1526ca0ac982Smjnelson # 1527ca0ac982Smjnelson [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 1528ca0ac982Smjnelson 152947703246Ssommerfe run_hook POST_BRINGOVER 153047703246Ssommerfe 1531c3e6cb59SRichard Lowe check_closed_bins 1532b83ec4edSjmcp 15337c478bd9Sstevel@tonic-gateelse 15347c478bd9Sstevel@tonic-gate echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 15357c478bd9Sstevel@tonic-gatefi 15367c478bd9Sstevel@tonic-gate 1537220399b7SRoland Mainz# Safeguards 1538220399b7SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 1539220399b7SRoland Mainz[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 1540220399b7SRoland Mainz[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 1541220399b7SRoland Mainz 1542305fdadfSYuri Pankovif [[ "$t_FLAG" = "y" ]]; then 1543391889ecSAndy Fiddaman set_non_debug_build_flags 1544391889ecSAndy Fiddaman bootstrap_tools || fatal_error "Error: could not bootstrap tools" 1545305fdadfSYuri Pankov 1546305fdadfSYuri Pankov # Switch ONBLD_TOOLS early if -t is specified so that 1547305fdadfSYuri Pankov # we could use bootstrapped cw for compiler checks. 1548305fdadfSYuri Pankov ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld 1549305fdadfSYuri Pankov export ONBLD_TOOLS 1550305fdadfSYuri Pankovfi 1551305fdadfSYuri Pankov 1552cdf0c1d5Smjnelsonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 1553cdf0c1d5Smjnelson 1554cdf0c1d5Smjnelson# System 1555cdf0c1d5Smjnelsonwhence uname | tee -a $build_environ_file >> $LOGFILE 1556cdf0c1d5Smjnelsonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 1557cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1558cdf0c1d5Smjnelson 1559cdf0c1d5Smjnelson# make 1560cdf0c1d5Smjnelsonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 1561cdf0c1d5Smjnelson$MAKE -v | tee -a $build_environ_file >> $LOGFILE 1562cdf0c1d5Smjnelsonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1563cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1564cdf0c1d5Smjnelson 1565cdf0c1d5Smjnelson# 1566cdf0c1d5Smjnelson# Report the compiler versions. 1567cdf0c1d5Smjnelson# 1568cdf0c1d5Smjnelson 1569cdf0c1d5Smjnelsonif [[ ! -f $SRC/Makefile ]]; then 1570cdf0c1d5Smjnelson build_ok=n 1571cdf0c1d5Smjnelson echo "\nUnable to find \"Makefile\" in $SRC." | \ 1572cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1573cdf0c1d5Smjnelson exit 1 1574cdf0c1d5Smjnelsonfi 1575cdf0c1d5Smjnelson 1576cdf0c1d5Smjnelson( cd $SRC 1577aa9ef484SJohn Levon for target in cc-version java-version openssl-version; do 1578cdf0c1d5Smjnelson echo 1579cdf0c1d5Smjnelson # 1580cdf0c1d5Smjnelson # Put statefile somewhere we know we can write to rather than trip 1581cdf0c1d5Smjnelson # over a read-only $srcroot. 1582cdf0c1d5Smjnelson # 1583cdf0c1d5Smjnelson rm -f $TMPDIR/make-state 1584cdf0c1d5Smjnelson export SRC 1585cdf0c1d5Smjnelson if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1586cdf0c1d5Smjnelson continue 1587cdf0c1d5Smjnelson fi 1588cdf0c1d5Smjnelson touch $TMPDIR/nocompiler 1589cdf0c1d5Smjnelson done 1590cdf0c1d5Smjnelson echo 1591cdf0c1d5Smjnelson) | tee -a $build_environ_file >> $LOGFILE 1592cdf0c1d5Smjnelson 1593cdf0c1d5Smjnelsonif [ -f $TMPDIR/nocompiler ]; then 1594cdf0c1d5Smjnelson rm -f $TMPDIR/nocompiler 1595cdf0c1d5Smjnelson build_ok=n 1596cdf0c1d5Smjnelson echo "Aborting due to missing compiler." | 1597cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1598cdf0c1d5Smjnelson exit 1 1599cdf0c1d5Smjnelsonfi 1600cdf0c1d5Smjnelson 1601cdf0c1d5Smjnelson# as 1602cdf0c1d5Smjnelsonwhence as | tee -a $build_environ_file >> $LOGFILE 1603cdf0c1d5Smjnelsonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 1604cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1605cdf0c1d5Smjnelson 1606cdf0c1d5Smjnelson# Check that we're running a capable link-editor 1607cdf0c1d5Smjnelsonwhence ld | tee -a $build_environ_file >> $LOGFILE 1608cdf0c1d5SmjnelsonLDVER=`ld -V 2>&1` 1609cdf0c1d5Smjnelsonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 161070087ad3SRichard LoweLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 1611cdf0c1d5Smjnelsonif [ `expr $LDVER \< 422` -eq 1 ]; then 1612cdf0c1d5Smjnelson echo "The link-editor needs to be at version 422 or higher to build" | \ 1613cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1614cdf0c1d5Smjnelson echo "the latest stuff. Hope your build works." | \ 1615cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1616cdf0c1d5Smjnelsonfi 1617cdf0c1d5Smjnelson 16187c478bd9Sstevel@tonic-gate# 16194e5b757fSkupfer# Build and use the workspace's tools if requested 16207c478bd9Sstevel@tonic-gate# 16215110237aSJosef 'Jeff' Sipekif [[ "$t_FLAG" = "y" ]]; then 16224e5b757fSkupfer set_non_debug_build_flags 16237c478bd9Sstevel@tonic-gate 16247c478bd9Sstevel@tonic-gate build_tools ${TOOLS_PROTO} 1625cb4d1691SRichard Lowe if (( $? != 0 )); then 1626cb4d1691SRichard Lowe build_ok=n 1627cb4d1691SRichard Lowe else 1628305fdadfSYuri Pankov STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs 1629305fdadfSYuri Pankov export STABS 1630305fdadfSYuri Pankov CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs 1631305fdadfSYuri Pankov export CTFSTABS 1632305fdadfSYuri Pankov GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets 1633305fdadfSYuri Pankov export GENOFFSETS 1634305fdadfSYuri Pankov 1635305fdadfSYuri Pankov CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert 1636305fdadfSYuri Pankov export CTFCONVERT 1637305fdadfSYuri Pankov CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge 1638305fdadfSYuri Pankov export CTFMERGE 1639305fdadfSYuri Pankov 1640305fdadfSYuri Pankov PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}" 1641305fdadfSYuri Pankov PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}" 1642305fdadfSYuri Pankov export PATH 1643305fdadfSYuri Pankov 1644305fdadfSYuri Pankov echo "\n==== New environment settings. ====\n" >> $LOGFILE 1645305fdadfSYuri Pankov echo "STABS=${STABS}" >> $LOGFILE 1646305fdadfSYuri Pankov echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 1647305fdadfSYuri Pankov echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 1648305fdadfSYuri Pankov echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 1649305fdadfSYuri Pankov echo "PATH=${PATH}" >> $LOGFILE 1650305fdadfSYuri Pankov echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 16514e5b757fSkupfer fi 16527c478bd9Sstevel@tonic-gatefi 16537c478bd9Sstevel@tonic-gate 16545110237aSJosef 'Jeff' Sipek# timestamp the start of the normal build; the findunref tool uses it. 16555110237aSJosef 'Jeff' Sipektouch $SRC/.build.tstamp 16565d715dd7Skupfer 16575110237aSJosef 'Jeff' Sipeknormal_build 16585d715dd7Skupfer 16597c478bd9Sstevel@tonic-gateORIG_SRC=$SRC 16607c478bd9Sstevel@tonic-gateBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 16617c478bd9Sstevel@tonic-gate 16627c478bd9Sstevel@tonic-gate 16634e5b757fSkupfer# 16644e5b757fSkupfer# There are several checks that need to look at the proto area, but 16654e5b757fSkupfer# they only need to look at one, and they don't care whether it's 16664e5b757fSkupfer# DEBUG or non-DEBUG. 16674e5b757fSkupfer# 16684e5b757fSkupferif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 16694e5b757fSkupfer checkroot=$ROOT-nd 16704e5b757fSkupferelse 16714e5b757fSkupfer checkroot=$ROOT 16724e5b757fSkupferfi 16734e5b757fSkupfer 16747c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 16757c478bd9Sstevel@tonic-gate echo "\n==== Creating protolist system file at `date` ====" \ 16767c478bd9Sstevel@tonic-gate >> $LOGFILE 16774e5b757fSkupfer protolist $checkroot > $ATLOG/proto_list_${MACH} 16787c478bd9Sstevel@tonic-gate echo "==== protolist system file created at `date` ====\n" \ 16797c478bd9Sstevel@tonic-gate >> $LOGFILE 16807c478bd9Sstevel@tonic-gate 16817c478bd9Sstevel@tonic-gate if [ "$N_FLAG" != "y" ]; then 16827c478bd9Sstevel@tonic-gate 1683ead1f93eSLiane Praza E1= 1684ead1f93eSLiane Praza f1= 1685ead1f93eSLiane Praza for f in $f1; do 1686ead1f93eSLiane Praza if [ -f "$f" ]; then 1687ead1f93eSLiane Praza E1="$E1 -e $f" 1688ead1f93eSLiane Praza fi 1689ead1f93eSLiane Praza done 1690ead1f93eSLiane Praza 1691ead1f93eSLiane Praza E2= 1692ead1f93eSLiane Praza f2= 1693ead1f93eSLiane Praza if [ -d "$SRC/pkg" ]; then 1694ead1f93eSLiane Praza f2="$f2 exceptions/packaging" 16956fec3625Sdduvall fi 16967c478bd9Sstevel@tonic-gate 1697ead1f93eSLiane Praza for f in $f2; do 1698ead1f93eSLiane Praza if [ -f "$f" ]; then 1699ead1f93eSLiane Praza E2="$E2 -e $f" 1700ead1f93eSLiane Praza fi 1701ead1f93eSLiane Praza done 1702ead1f93eSLiane Praza fi 17037c478bd9Sstevel@tonic-gate 1704ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 1705ead1f93eSLiane Praza echo "\n==== Validating manifests against proto area ====\n" \ 1706ead1f93eSLiane Praza >> $mail_msg_file 1707cb4d1691SRichard Lowe ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1708cb4d1691SRichard Lowe tee $TMPDIR/protocmp_noise >> $mail_msg_file 1709cb4d1691SRichard Lowe if [[ -s $TMPDIR/protocmp_noise ]]; then 1710cb4d1691SRichard Lowe build_extras_ok=n 1711cb4d1691SRichard Lowe fi 1712ead1f93eSLiane Praza fi 1713ead1f93eSLiane Praza 1714ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 1715ead1f93eSLiane Praza echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 1716ead1f93eSLiane Praza if [ -n "$E2" ]; then 1717ead1f93eSLiane Praza ELIST=$E2 1718ead1f93eSLiane Praza else 1719ead1f93eSLiane Praza ELIST=$E1 1720ead1f93eSLiane Praza fi 1721ead1f93eSLiane Praza $PROTOCMPTERSE \ 1722ead1f93eSLiane Praza "Files in yesterday's proto area, but not today's:" \ 1723ead1f93eSLiane Praza "Files in today's proto area, but not yesterday's:" \ 1724ead1f93eSLiane Praza "Files that changed between yesterday and today:" \ 1725ead1f93eSLiane Praza ${ELIST} \ 1726ead1f93eSLiane Praza -d $REF_PROTO_LIST \ 1727ead1f93eSLiane Praza $ATLOG/proto_list_${MACH} \ 1728ead1f93eSLiane Praza >> $mail_msg_file 17297c478bd9Sstevel@tonic-gate fi 17307c478bd9Sstevel@tonic-gatefi 17317c478bd9Sstevel@tonic-gate 1732cb4d1691SRichard Loweif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 1733cb4d1691SRichard Lowe "$build_extras_ok" == "y" ]]; then 17347c478bd9Sstevel@tonic-gate staffer cp $ATLOG/proto_list_${MACH} \ 17357c478bd9Sstevel@tonic-gate $PARENT_WS/usr/src/proto_list_${MACH} 17367c478bd9Sstevel@tonic-gatefi 17377c478bd9Sstevel@tonic-gate 17387c478bd9Sstevel@tonic-gate# Update parent proto area if necessary. This is done now 17397c478bd9Sstevel@tonic-gate# so that the proto area has either DEBUG or non-DEBUG kernels. 17407c478bd9Sstevel@tonic-gate# Note that this clears out the lock file, so we can dispense with 17417c478bd9Sstevel@tonic-gate# the variable now. 17427c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 17437c478bd9Sstevel@tonic-gate echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 17447c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 1745ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT/* 17467c478bd9Sstevel@tonic-gate unset Ulockfile 17477c478bd9Sstevel@tonic-gate mkdir -p $NIGHTLY_PARENT_ROOT 17484e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1749ead1f93eSLiane Praza ( cd $ROOT; tar cf - . | 17504e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 17514e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 17524e5b757fSkupfer fi 17534e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 1754ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT-nd/* 17554e5b757fSkupfer mkdir -p $NIGHTLY_PARENT_ROOT-nd 17564e5b757fSkupfer cd $ROOT-nd 17574e5b757fSkupfer ( tar cf - . | 17584e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 17594e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 17604e5b757fSkupfer fi 17616798c3f0SMark J. Nelson if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 17626798c3f0SMark J. Nelson echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 17636798c3f0SMark J. Nelson tee -a $LOGFILE >> $mail_msg_file 17646798c3f0SMark J. Nelson rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 17656798c3f0SMark J. Nelson mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 17666798c3f0SMark J. Nelson if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 17676798c3f0SMark J. Nelson ( cd $TOOLS_PROTO; tar cf - . | 1768fb23c574SRichard Lowe ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 17696798c3f0SMark J. Nelson umask 0; tar xpf - ) ) 2>&1 | 17706798c3f0SMark J. Nelson tee -a $mail_msg_file >> $LOGFILE 17716798c3f0SMark J. Nelson fi 1772ead1f93eSLiane Praza fi 17737c478bd9Sstevel@tonic-gatefi 17747c478bd9Sstevel@tonic-gate 17757c478bd9Sstevel@tonic-gate# 177675ce41a5SAli Bahrami# ELF verification: ABI (-A) and runtime (-r) checks 17777c478bd9Sstevel@tonic-gate# 1778cb4d1691SRichard Loweif [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 177975ce41a5SAli Bahrami # Directory ELF-data.$MACH holds the files produced by these tests. 178075ce41a5SAli Bahrami elf_ddir=$SRC/ELF-data.$MACH 17817c478bd9Sstevel@tonic-gate 178275ce41a5SAli Bahrami # If there is a previous ELF-data backup directory, remove it. Then, 178375ce41a5SAli Bahrami # rotate current ELF-data directory into its place and create a new 178475ce41a5SAli Bahrami # empty directory 178575ce41a5SAli Bahrami rm -rf $elf_ddir.ref 178675ce41a5SAli Bahrami if [[ -d $elf_ddir ]]; then 178775ce41a5SAli Bahrami mv $elf_ddir $elf_ddir.ref 17887c478bd9Sstevel@tonic-gate fi 178975ce41a5SAli Bahrami mkdir -p $elf_ddir 17907c478bd9Sstevel@tonic-gate 179175ce41a5SAli Bahrami # Call find_elf to produce a list of the ELF objects in the proto area. 179275ce41a5SAli Bahrami # This list is passed to check_rtime and interface_check, preventing 179375ce41a5SAli Bahrami # them from separately calling find_elf to do the same work twice. 179475ce41a5SAli Bahrami find_elf -fr $checkroot > $elf_ddir/object_list 17957c478bd9Sstevel@tonic-gate 179675ce41a5SAli Bahrami if [[ $A_FLAG = y ]]; then 1797fb23c574SRichard Lowe echo "\n==== Check versioning and ABI information ====\n" | \ 179875ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file 17997c478bd9Sstevel@tonic-gate 180075ce41a5SAli Bahrami # Produce interface description for the proto. Report errors. 180175ce41a5SAli Bahrami interface_check -o -w $elf_ddir -f object_list \ 180275ce41a5SAli Bahrami -i interface -E interface.err 180375ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.err ]]; then 180475ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/interface.err \ 1805cb4d1691SRichard Lowe >> $mail_msg_file 1806cb4d1691SRichard Lowe build_extras_ok=n 18077c478bd9Sstevel@tonic-gate fi 18087c478bd9Sstevel@tonic-gate 18095253169eSAli Bahrami # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 18105253169eSAli Bahrami # description file to that from the baseline gate. Issue a 18115253169eSAli Bahrami # warning if the baseline is not present, and keep going. 18125253169eSAli Bahrami if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 18135253169eSAli Bahrami base_ifile="$ELF_DATA_BASELINE_DIR/interface" 18145253169eSAli Bahrami 1815be0ffda9SPeter Tribble echo "\n==== Compare versioning and ABI information" \ 1816e599109eSAli Bahrami "to baseline ====\n" | \ 18175253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 1818fb23c574SRichard Lowe echo "Baseline: $base_ifile\n" >> $LOGFILE 18195253169eSAli Bahrami 18205253169eSAli Bahrami if [[ -f $base_ifile ]]; then 18215253169eSAli Bahrami interface_cmp -d -o $base_ifile \ 18225253169eSAli Bahrami $elf_ddir/interface > $elf_ddir/interface.cmp 18235253169eSAli Bahrami if [[ -s $elf_ddir/interface.cmp ]]; then 18245253169eSAli Bahrami echo | tee -a $LOGFILE >> $mail_msg_file 18255253169eSAli Bahrami tee -a $LOGFILE < \ 18265253169eSAli Bahrami $elf_ddir/interface.cmp \ 18275253169eSAli Bahrami >> $mail_msg_file 1828cb4d1691SRichard Lowe build_extras_ok=n 18295253169eSAli Bahrami fi 18305253169eSAli Bahrami else 1831fb23c574SRichard Lowe echo "baseline not available. comparison" \ 18325253169eSAli Bahrami "skipped" | \ 18335253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 18345253169eSAli Bahrami fi 18357c478bd9Sstevel@tonic-gate 183675ce41a5SAli Bahrami fi 18377c478bd9Sstevel@tonic-gate fi 18387c478bd9Sstevel@tonic-gate 183975ce41a5SAli Bahrami if [[ $r_FLAG = y ]]; then 184075ce41a5SAli Bahrami echo "\n==== Check ELF runtime attributes ====\n" | \ 184175ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file 18427c478bd9Sstevel@tonic-gate 1843ead1f93eSLiane Praza # If we're doing a DEBUG build the proto area will be left 184475ce41a5SAli Bahrami # with debuggable objects, thus don't assert -s. 184575ce41a5SAli Bahrami if [[ $D_FLAG = y ]]; then 184675ce41a5SAli Bahrami rtime_sflag="" 184775ce41a5SAli Bahrami else 184875ce41a5SAli Bahrami rtime_sflag="-s" 184975ce41a5SAli Bahrami fi 185075ce41a5SAli Bahrami check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 185175ce41a5SAli Bahrami -D object_list -f object_list -E runtime.err \ 1852622090e3SAli Bahrami -I runtime.attr.raw 1853cb4d1691SRichard Lowe if (( $? != 0 )); then 1854cb4d1691SRichard Lowe build_extras_ok=n 1855cb4d1691SRichard Lowe fi 1856622090e3SAli Bahrami 1857fb23c574SRichard Lowe # check_rtime -I output needs to be sorted in order to 1858622090e3SAli Bahrami # compare it to that from previous builds. 1859622090e3SAli Bahrami sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 1860622090e3SAli Bahrami rm $elf_ddir/runtime.attr.raw 18617c478bd9Sstevel@tonic-gate 186275ce41a5SAli Bahrami # Report errors 186375ce41a5SAli Bahrami if [[ -s $elf_ddir/runtime.err ]]; then 186475ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/runtime.err \ 186575ce41a5SAli Bahrami >> $mail_msg_file 1866cb4d1691SRichard Lowe build_extras_ok=n 186775ce41a5SAli Bahrami fi 18687c478bd9Sstevel@tonic-gate 186975ce41a5SAli Bahrami # If there is an ELF-data directory from a previous build, 187075ce41a5SAli Bahrami # then diff the attr files. These files contain information 187175ce41a5SAli Bahrami # about dependencies, versioning, and runpaths. There is some 187275ce41a5SAli Bahrami # overlap with the ABI checking done above, but this also 187375ce41a5SAli Bahrami # flushes out non-ABI interface differences along with the 187475ce41a5SAli Bahrami # other information. 187575ce41a5SAli Bahrami echo "\n==== Diff ELF runtime attributes" \ 187675ce41a5SAli Bahrami "(since last build) ====\n" | \ 187775ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 187875ce41a5SAli Bahrami 187975ce41a5SAli Bahrami if [[ -f $elf_ddir.ref/runtime.attr ]]; then 188075ce41a5SAli Bahrami diff $elf_ddir.ref/runtime.attr \ 188175ce41a5SAli Bahrami $elf_ddir/runtime.attr \ 188275ce41a5SAli Bahrami >> $mail_msg_file 188375ce41a5SAli Bahrami fi 18847c478bd9Sstevel@tonic-gate fi 18855253169eSAli Bahrami 18865253169eSAli Bahrami # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 18875253169eSAli Bahrami if [[ "$u_FLAG" = "y" ]]; then 18885253169eSAli Bahrami p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 18895253169eSAli Bahrami 18905253169eSAli Bahrami # If parent lacks the ELF-data.$MACH directory, create it 18915253169eSAli Bahrami if [[ ! -d $p_elf_ddir ]]; then 18925253169eSAli Bahrami staffer mkdir -p $p_elf_ddir 18935253169eSAli Bahrami fi 18945253169eSAli Bahrami 18955253169eSAli Bahrami # These files are used asynchronously by other builds for ABI 18965253169eSAli Bahrami # verification, as above for the -A option. As such, we require 18975253169eSAli Bahrami # the file replacement to be atomic. Copy the data to a temp 1898fb23c574SRichard Lowe # file in the same filesystem and then rename into place. 18995253169eSAli Bahrami ( 19005253169eSAli Bahrami cd $elf_ddir 19015253169eSAli Bahrami for elf_dfile in *; do 19025253169eSAli Bahrami staffer cp $elf_dfile \ 19035253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile}.new 19045253169eSAli Bahrami staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 19055253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile} 19065253169eSAli Bahrami done 19075253169eSAli Bahrami ) 19085253169eSAli Bahrami fi 19097c478bd9Sstevel@tonic-gatefi 19107c478bd9Sstevel@tonic-gate 19117c478bd9Sstevel@tonic-gate# "make check" begins 19127c478bd9Sstevel@tonic-gate 19137c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 19147c478bd9Sstevel@tonic-gate # remove old check.out 19157c478bd9Sstevel@tonic-gate rm -f $SRC/check.out 19167c478bd9Sstevel@tonic-gate 19177c478bd9Sstevel@tonic-gate rm -f $SRC/check-${MACH}.out 19187c478bd9Sstevel@tonic-gate cd $SRC 1919170832d3SAlbert Lee $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 1920170832d3SAlbert Lee >> $LOGFILE 19217c478bd9Sstevel@tonic-gate echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 19227c478bd9Sstevel@tonic-gate 19237c478bd9Sstevel@tonic-gate grep ":" $SRC/check-${MACH}.out | 19247c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 1925cb4d1691SRichard Lowe sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 1926cb4d1691SRichard Lowe 1927cb4d1691SRichard Lowe if [[ -s $TMPDIR/check_errors ]]; then 1928cb4d1691SRichard Lowe build_extras_ok=n 1929cb4d1691SRichard Lowe fi 19307c478bd9Sstevel@tonic-gateelse 19317c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 19327c478bd9Sstevel@tonic-gatefi 19337c478bd9Sstevel@tonic-gate 19347c478bd9Sstevel@tonic-gateecho "\n==== Find core files ====\n" | \ 19357c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 19367c478bd9Sstevel@tonic-gate 1937fb23a357Skupferfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 19387c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 19397c478bd9Sstevel@tonic-gate 19407c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 19417c478bd9Sstevel@tonic-gate echo "\n==== Diff unreferenced files (since last build) ====\n" \ 19427c478bd9Sstevel@tonic-gate | tee -a $LOGFILE >>$mail_msg_file 19437c478bd9Sstevel@tonic-gate rm -f $SRC/unref-${MACH}.ref 19447c478bd9Sstevel@tonic-gate if [ -f $SRC/unref-${MACH}.out ]; then 19457c478bd9Sstevel@tonic-gate mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 19467c478bd9Sstevel@tonic-gate fi 19477c478bd9Sstevel@tonic-gate 19489730304dSmeem findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 1949cdf0c1d5Smjnelson ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 19509730304dSmeem sort > $SRC/unref-${MACH}.out 19517c478bd9Sstevel@tonic-gate 19527c478bd9Sstevel@tonic-gate if [ ! -f $SRC/unref-${MACH}.ref ]; then 19537c478bd9Sstevel@tonic-gate cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 19547c478bd9Sstevel@tonic-gate fi 19557c478bd9Sstevel@tonic-gate 19567c478bd9Sstevel@tonic-gate diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 19577c478bd9Sstevel@tonic-gatefi 19587c478bd9Sstevel@tonic-gate 19597c478bd9Sstevel@tonic-gate# Verify that the usual lists of files, such as exception lists, 19607c478bd9Sstevel@tonic-gate# contain only valid references to files. If the build has failed, 19617c478bd9Sstevel@tonic-gate# then don't check the proto area. 19627c478bd9Sstevel@tonic-gateCHECK_PATHS=${CHECK_PATHS:-y} 19637c478bd9Sstevel@tonic-gateif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 19647c478bd9Sstevel@tonic-gate echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 19657c478bd9Sstevel@tonic-gate >>$mail_msg_file 19667c478bd9Sstevel@tonic-gate arg=-b 19677c478bd9Sstevel@tonic-gate [ "$build_ok" = y ] && arg= 1968e2c8add4SRichard PALO checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 1969e2c8add4SRichard PALO if [[ -s $SRC/check-paths.out ]]; then 1970e2c8add4SRichard PALO tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 1971cb4d1691SRichard Lowe build_extras_ok=n 1972cb4d1691SRichard Lowe fi 19737c478bd9Sstevel@tonic-gatefi 19747c478bd9Sstevel@tonic-gate 19757c478bd9Sstevel@tonic-gateif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 19767c478bd9Sstevel@tonic-gate echo "\n==== Impact on file permissions ====\n" \ 19777c478bd9Sstevel@tonic-gate >> $mail_msg_file 1978ead1f93eSLiane Praza 1979ead1f93eSLiane Praza abspkg= 1980ead1f93eSLiane Praza for d in $abssrcdirs; do 1981ead1f93eSLiane Praza if [ -d "$d/pkg" ]; then 1982ead1f93eSLiane Praza abspkg="$abspkg $d" 1983ead1f93eSLiane Praza fi 1984ead1f93eSLiane Praza done 1985ead1f93eSLiane Praza 1986ead1f93eSLiane Praza if [ -n "$abspkg" ]; then 1987ead1f93eSLiane Praza for d in "$abspkg"; do 1988ead1f93eSLiane Praza ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 1989ead1f93eSLiane Praza done 1990ead1f93eSLiane Praza fi 19917c478bd9Sstevel@tonic-gatefi 19927c478bd9Sstevel@tonic-gate 199396ccc8cbSesaxeif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 19944e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 19954e5b757fSkupfer do_wsdiff DEBUG $ROOT.prev $ROOT 19964e5b757fSkupfer fi 199796ccc8cbSesaxe 19984e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 19994e5b757fSkupfer do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 200096ccc8cbSesaxe fi 200196ccc8cbSesaxefi 200296ccc8cbSesaxe 20037c478bd9Sstevel@tonic-gateEND_DATE=`date` 20047c478bd9Sstevel@tonic-gateecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 20057c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 20067c478bd9Sstevel@tonic-gate 2007c341b28aSDarren Moffattypeset -i10 hours 20087c478bd9Sstevel@tonic-gatetypeset -Z2 minutes 20097c478bd9Sstevel@tonic-gatetypeset -Z2 seconds 20107c478bd9Sstevel@tonic-gate 20117c478bd9Sstevel@tonic-gateelapsed_time=$SECONDS 20127c478bd9Sstevel@tonic-gate((hours = elapsed_time / 3600 )) 20137c478bd9Sstevel@tonic-gate((minutes = elapsed_time / 60 % 60)) 20147c478bd9Sstevel@tonic-gate((seconds = elapsed_time % 60)) 20157c478bd9Sstevel@tonic-gate 20167c478bd9Sstevel@tonic-gateecho "\n==== Total build time ====" | \ 20177c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 20187c478bd9Sstevel@tonic-gateecho "\nreal ${hours}:${minutes}:${seconds}" | \ 20197c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 20207c478bd9Sstevel@tonic-gate 20217c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 20227c478bd9Sstevel@tonic-gate staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 20237c478bd9Sstevel@tonic-gate 20247c478bd9Sstevel@tonic-gate # 20257c478bd9Sstevel@tonic-gate # Produce a master list of unreferenced files -- ideally, we'd 20267c478bd9Sstevel@tonic-gate # generate the master just once after all of the nightlies 20277c478bd9Sstevel@tonic-gate # have finished, but there's no simple way to know when that 20287c478bd9Sstevel@tonic-gate # will be. Instead, we assume that we're the last nightly to 20297c478bd9Sstevel@tonic-gate # finish and merge all of the unref-${MACH}.out files in 20307c478bd9Sstevel@tonic-gate # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 20317c478bd9Sstevel@tonic-gate # finish, then this file will be the authoritative master 20327c478bd9Sstevel@tonic-gate # list. Otherwise, another ${MACH}'s nightly will eventually 20337c478bd9Sstevel@tonic-gate # overwrite ours with its own master, but in the meantime our 20347c478bd9Sstevel@tonic-gate # temporary "master" will be no worse than any older master 20357c478bd9Sstevel@tonic-gate # which was already on the parent. 20367c478bd9Sstevel@tonic-gate # 20377c478bd9Sstevel@tonic-gate 20387c478bd9Sstevel@tonic-gate set -- $PARENT_WS/usr/src/unref-*.out 20397c478bd9Sstevel@tonic-gate cp "$1" ${TMPDIR}/unref.merge 20407c478bd9Sstevel@tonic-gate shift 20417c478bd9Sstevel@tonic-gate 20427c478bd9Sstevel@tonic-gate for unreffile; do 20437c478bd9Sstevel@tonic-gate comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 20447c478bd9Sstevel@tonic-gate mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 20457c478bd9Sstevel@tonic-gate done 20467c478bd9Sstevel@tonic-gate 20477c478bd9Sstevel@tonic-gate staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 20487c478bd9Sstevel@tonic-gatefi 20497c478bd9Sstevel@tonic-gate 20507c478bd9Sstevel@tonic-gate# 20517c478bd9Sstevel@tonic-gate# All done save for the sweeping up. 2052d77e7149Ssommerfe# (whichever exit we hit here will trigger the "cleanup" trap which 20537c478bd9Sstevel@tonic-gate# optionally sends mail on completion). 20547c478bd9Sstevel@tonic-gate# 2055cb4d1691SRichard Loweif [[ "$build_ok" == "y" ]]; then 2056cb4d1691SRichard Lowe if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 2057cb4d1691SRichard Lowe exit 0 2058cb4d1691SRichard Lowe fi 20597c478bd9Sstevel@tonic-gatefi 2060cb4d1691SRichard Lowe 20617c478bd9Sstevel@tonic-gateexit 1 2062