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. 295ca82e69SJohn Levon# Copyright 2020 Joyent, Inc. 30be0ffda9SPeter Tribble# Copyright 2019 Peter Trible. 316112cec5SJoshua M. Clulow# Copyright 2020 Oxide Computer Company 32069e6b7eSAndy Fiddaman# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 337c478bd9Sstevel@tonic-gate# 347c478bd9Sstevel@tonic-gate# Based on the nightly script from the integration folks, 357c478bd9Sstevel@tonic-gate# Mostly modified and owned by mike_s. 367c478bd9Sstevel@tonic-gate# Changes also by kjc, dmk. 377c478bd9Sstevel@tonic-gate# 387c478bd9Sstevel@tonic-gate# BRINGOVER_WS may be specified in the env file. 397c478bd9Sstevel@tonic-gate# The default is the old behavior of CLONE_WS 407c478bd9Sstevel@tonic-gate# 417c478bd9Sstevel@tonic-gate# -i on the command line, means fast options, so when it's on the 42be0ffda9SPeter Tribble# command line (only), check builds are skipped no matter what 43d77e7149Ssommerfe# the setting of their individual flags are in NIGHTLY_OPTIONS. 447c478bd9Sstevel@tonic-gate# 45c3e6cb59SRichard Lowe# OPTHOME may be set in the environment to override /opt 467c478bd9Sstevel@tonic-gate# 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate# 497c478bd9Sstevel@tonic-gate# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 507c478bd9Sstevel@tonic-gate# under certain circumstances, which can really screw things up; unset it. 517c478bd9Sstevel@tonic-gate# 527c478bd9Sstevel@tonic-gateunset CDPATH 537c478bd9Sstevel@tonic-gate 54cdf0c1d5Smjnelson# Get the absolute path of the nightly script that the user invoked. This 55cdf0c1d5Smjnelson# may be a relative path, and we need to do this before changing directory. 56cdf0c1d5Smjnelsonnightly_path=`whence $0` 57cdf0c1d5Smjnelson 58cdf0c1d5Smjnelson# 59cdf0c1d5Smjnelson# Keep track of where we found nightly so we can invoke the matching 60cdf0c1d5Smjnelson# which_scm script. If that doesn't work, don't go guessing, just rely 61cdf0c1d5Smjnelson# on the $PATH settings, which will generally give us either /opt/onbld 62cdf0c1d5Smjnelson# or the user's workspace. 63cdf0c1d5Smjnelson# 64cdf0c1d5SmjnelsonWHICH_SCM=$(dirname $nightly_path)/which_scm 65cdf0c1d5Smjnelsonif [[ ! -x $WHICH_SCM ]]; then 66cdf0c1d5Smjnelson WHICH_SCM=which_scm 67cdf0c1d5Smjnelsonfi 68cdf0c1d5Smjnelson 69d7693b08SRoland Mainzfunction fatal_error 70d7693b08SRoland Mainz{ 71d7693b08SRoland Mainz print -u2 "nightly: $*" 72d7693b08SRoland Mainz exit 1 73d7693b08SRoland Mainz} 74d7693b08SRoland Mainz 754e5b757fSkupfer# 764e5b757fSkupfer# Function to do a DEBUG and non-DEBUG build. Needed because we might 777c478bd9Sstevel@tonic-gate# need to do another for the source build, and since we only deliver DEBUG or 787c478bd9Sstevel@tonic-gate# non-DEBUG packages. 794e5b757fSkupfer# 80b83ec4edSjmcp# usage: normal_build 81ead1f93eSLiane Praza# 82597bd30bSMike Kupferfunction normal_build { 837c478bd9Sstevel@tonic-gate 8452a52aebSkupfer typeset orig_p_FLAG="$p_FLAG" 85597bd30bSMike Kupfer typeset crypto_signer="$CODESIGN_USER" 864e5b757fSkupfer 874e5b757fSkupfer suffix="" 88ead1f93eSLiane Praza 897c478bd9Sstevel@tonic-gate # non-DEBUG build begins 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate if [ "$F_FLAG" = "n" ]; then 924e5b757fSkupfer set_non_debug_build_flags 93597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 946ea3c060SGarrett D'Amore build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 957c478bd9Sstevel@tonic-gate else 9652a52aebSkupfer echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 977c478bd9Sstevel@tonic-gate fi 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate # non-DEBUG build ends 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate # DEBUG build begins 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate if [ "$D_FLAG" = "y" ]; then 1044e5b757fSkupfer set_debug_build_flags 105597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 1066ea3c060SGarrett D'Amore build "DEBUG" "$suffix" "" "$MULTI_PROTO" 1077c478bd9Sstevel@tonic-gate else 10852a52aebSkupfer echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 1097c478bd9Sstevel@tonic-gate fi 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate # DEBUG build ends 1124e5b757fSkupfer 11352a52aebSkupfer p_FLAG="$orig_p_FLAG" 1147c478bd9Sstevel@tonic-gate} 1157c478bd9Sstevel@tonic-gate 11647703246Ssommerfe# 11747703246Ssommerfe# usage: run_hook HOOKNAME ARGS... 11847703246Ssommerfe# 119fb23c574SRichard Lowe# If variable "$HOOKNAME" is defined, insert a section header into 12047703246Ssommerfe# our logs and then run the command with ARGS 12147703246Ssommerfe# 122597bd30bSMike Kupferfunction run_hook { 12347703246Ssommerfe HOOKNAME=$1 124fb23c574SRichard Lowe eval HOOKCMD=\$$HOOKNAME 12547703246Ssommerfe shift 12647703246Ssommerfe 127fb23c574SRichard Lowe if [ -n "$HOOKCMD" ]; then 128fb23c574SRichard Lowe ( 12947703246Ssommerfe echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 130fb23c574SRichard Lowe ( $HOOKCMD "$@" 2>&1 ) 13147703246Ssommerfe if [ "$?" -ne 0 ]; then 132fb23c574SRichard Lowe # Let exit status propagate up 133fb23c574SRichard Lowe touch $TMPDIR/abort 13447703246Ssommerfe fi 13547703246Ssommerfe ) | tee -a $mail_msg_file >> $LOGFILE 13647703246Ssommerfe 13747703246Ssommerfe if [ -f $TMPDIR/abort ]; then 13847703246Ssommerfe build_ok=n 13947703246Ssommerfe echo "\nAborting at request of $HOOKNAME" | 14047703246Ssommerfe tee -a $mail_msg_file >> $LOGFILE 14147703246Ssommerfe exit 1 14247703246Ssommerfe fi 14347703246Ssommerfe fi 14447703246Ssommerfe} 14547703246Ssommerfe 1464e5b757fSkupfer# Return library search directive as function of given root. 147597bd30bSMike Kupferfunction myldlibs { 1484e5b757fSkupfer echo "-L$1/lib -L$1/usr/lib" 1494e5b757fSkupfer} 1504e5b757fSkupfer 1514e5b757fSkupfer# Return header search directive as function of given root. 152597bd30bSMike Kupferfunction myheaders { 1534e5b757fSkupfer echo "-I$1/usr/include" 1544e5b757fSkupfer} 1557c478bd9Sstevel@tonic-gate 1564e5b757fSkupfer# 15778add226Sjmcp# Function to do the build, including package generation. 1586ea3c060SGarrett D'Amore# usage: build LABEL SUFFIX ND MULTIPROTO 1594e5b757fSkupfer# - LABEL is used to tag build output. 160ead1f93eSLiane Praza# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 161597bd30bSMike Kupfer# open-only vs full tree). 162ead1f93eSLiane Praza# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 1634e5b757fSkupfer# - If MULTIPROTO is "yes", it means to name the proto area according to 1644e5b757fSkupfer# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 1654e5b757fSkupfer# 166597bd30bSMike Kupferfunction build { 1677c478bd9Sstevel@tonic-gate LABEL=$1 1687c478bd9Sstevel@tonic-gate SUFFIX=$2 169597bd30bSMike Kupfer ND=$3 170597bd30bSMike Kupfer MULTIPROTO=$4 1717c478bd9Sstevel@tonic-gate INSTALLOG=install${SUFFIX}-${MACH} 1727c478bd9Sstevel@tonic-gate NOISE=noise${SUFFIX}-${MACH} 1737c478bd9Sstevel@tonic-gate PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 1747c478bd9Sstevel@tonic-gate 1754e5b757fSkupfer ORIGROOT=$ROOT 1764e5b757fSkupfer [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 1774e5b757fSkupfer 1784e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 1794e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 1804e5b757fSkupfer 1817c478bd9Sstevel@tonic-gate this_build_ok=y 1827c478bd9Sstevel@tonic-gate # 1837c478bd9Sstevel@tonic-gate # Build OS-Networking source 1847c478bd9Sstevel@tonic-gate # 1857c478bd9Sstevel@tonic-gate echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 1867c478bd9Sstevel@tonic-gate >> $LOGFILE 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate rm -f $SRC/${INSTALLOG}.out 1897c478bd9Sstevel@tonic-gate cd $SRC 1907c478bd9Sstevel@tonic-gate /bin/time $MAKE -e install 2>&1 | \ 1917c478bd9Sstevel@tonic-gate tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 19232f1e47bSsommerfe 1937c478bd9Sstevel@tonic-gate echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 1947c478bd9Sstevel@tonic-gate egrep ":" $SRC/${INSTALLOG}.out | 19520de283bSJohn Levon egrep -e "(^${MAKE}:|[ ]error[: \n]|ld: guidance:)" | \ 196d1c3d93aSPaul Dagnelie egrep -v "Ignoring unknown host" | \ 197d1c3d93aSPaul Dagnelie egrep -v "cc .* -o error " | \ 198d1c3d93aSPaul Dagnelie egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 199d1c3d93aSPaul Dagnelie >> $mail_msg_file 200d1c3d93aSPaul Dagnelie sed -n "/^Undefined[ ]*first referenced$/,/^ld: fatal:/p" \ 201d1c3d93aSPaul Dagnelie < $SRC/${INSTALLOG}.out >> $mail_msg_file 202cb4d1691SRichard Lowe if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 2037c478bd9Sstevel@tonic-gate build_ok=n 2047c478bd9Sstevel@tonic-gate this_build_ok=n 2057c478bd9Sstevel@tonic-gate fi 2067c478bd9Sstevel@tonic-gate grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 2077c478bd9Sstevel@tonic-gate >> $mail_msg_file 2087c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 2097c478bd9Sstevel@tonic-gate build_ok=n 2107c478bd9Sstevel@tonic-gate this_build_ok=n 2117c478bd9Sstevel@tonic-gate fi 2127c478bd9Sstevel@tonic-gate 213c3e6cb59SRichard Lowe echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 2141f5207b7SJohn Levon egrep -i 'warn:|warning:' $SRC/${INSTALLOG}.out \ 215c3e6cb59SRichard Lowe | egrep -v '^tic:' \ 216c3e6cb59SRichard Lowe | egrep -v "symbol (\`|')timezone' has differing types:" \ 217c3e6cb59SRichard Lowe | egrep -v "parameter <PSTAMP> set to" \ 218c3e6cb59SRichard Lowe | egrep -v "Ignoring unknown host" \ 219c3e6cb59SRichard Lowe | egrep -v "redefining segment flags attribute for" \ 220cb4d1691SRichard Lowe | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 221cb4d1691SRichard Lowe if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 222cb4d1691SRichard Lowe build_ok=n 223cb4d1691SRichard Lowe this_build_ok=n 224cb4d1691SRichard Lowe fi 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 2277c478bd9Sstevel@tonic-gate >> $LOGFILE 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 2307c478bd9Sstevel@tonic-gate tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 2317c478bd9Sstevel@tonic-gate 232c3e6cb59SRichard Lowe if [ "$i_FLAG" = "n" ]; then 2337c478bd9Sstevel@tonic-gate rm -f $SRC/${NOISE}.ref 2347c478bd9Sstevel@tonic-gate if [ -f $SRC/${NOISE}.out ]; then 2357c478bd9Sstevel@tonic-gate mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 2367c478bd9Sstevel@tonic-gate fi 2377c478bd9Sstevel@tonic-gate grep : $SRC/${INSTALLOG}.out \ 2387c478bd9Sstevel@tonic-gate | egrep -v '^/' \ 2397c478bd9Sstevel@tonic-gate | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 2407c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 2417c478bd9Sstevel@tonic-gate | egrep -v '^mcs' \ 2427c478bd9Sstevel@tonic-gate | egrep -v '^LD_LIBRARY_PATH=' \ 2437c478bd9Sstevel@tonic-gate | egrep -v 'ar: creating' \ 2447c478bd9Sstevel@tonic-gate | egrep -v 'ar: writing' \ 2457c478bd9Sstevel@tonic-gate | egrep -v 'conflicts:' \ 2467c478bd9Sstevel@tonic-gate | egrep -v ':saved created' \ 2477c478bd9Sstevel@tonic-gate | egrep -v '^stty.*c:' \ 2487c478bd9Sstevel@tonic-gate | egrep -v '^mfgname.c:' \ 2497c478bd9Sstevel@tonic-gate | egrep -v '^uname-i.c:' \ 2507c478bd9Sstevel@tonic-gate | egrep -v '^volumes.c:' \ 2517c478bd9Sstevel@tonic-gate | egrep -v '^lint library construction:' \ 2527c478bd9Sstevel@tonic-gate | egrep -v 'tsort: INFORM:' \ 2537c478bd9Sstevel@tonic-gate | egrep -v 'stripalign:' \ 2547c478bd9Sstevel@tonic-gate | egrep -v 'chars, width' \ 25520272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 2567c478bd9Sstevel@tonic-gate | egrep -v 'PSTAMP' \ 2577c478bd9Sstevel@tonic-gate | egrep -v '^Manifying' \ 2587c478bd9Sstevel@tonic-gate | egrep -v 'Ignoring unknown host' \ 2597c478bd9Sstevel@tonic-gate | egrep -v 'Processing method:' \ 2607c478bd9Sstevel@tonic-gate | egrep -v '^Writing' \ 2617c478bd9Sstevel@tonic-gate | egrep -v 'spellin1:' \ 2627c478bd9Sstevel@tonic-gate | egrep -v '^adding:' \ 2637c478bd9Sstevel@tonic-gate | egrep -v "^echo 'msgid" \ 2647c478bd9Sstevel@tonic-gate | egrep -v '^echo ' \ 2657c478bd9Sstevel@tonic-gate | egrep -v '\.c:$' \ 2667c478bd9Sstevel@tonic-gate | egrep -v '^Adding file:' \ 2677c478bd9Sstevel@tonic-gate | egrep -v 'CLASSPATH=' \ 2687c478bd9Sstevel@tonic-gate | egrep -v '\/var\/mail\/:saved' \ 2697c478bd9Sstevel@tonic-gate | egrep -v -- '-DUTS_VERSION=' \ 2707c478bd9Sstevel@tonic-gate | egrep -v '^Running Mkbootstrap' \ 2717c478bd9Sstevel@tonic-gate | egrep -v '^Applet length read:' \ 2727c478bd9Sstevel@tonic-gate | egrep -v 'bytes written:' \ 2737c478bd9Sstevel@tonic-gate | egrep -v '^File:SolarisAuthApplet.bin' \ 2747c478bd9Sstevel@tonic-gate | egrep -v -i 'jibversion' \ 2757c478bd9Sstevel@tonic-gate | egrep -v '^Output size:' \ 2767c478bd9Sstevel@tonic-gate | egrep -v '^Solo size statistics:' \ 2777c478bd9Sstevel@tonic-gate | egrep -v '^Using ROM API Version' \ 2787c478bd9Sstevel@tonic-gate | egrep -v '^Zero Signature length:' \ 2797c478bd9Sstevel@tonic-gate | egrep -v '^Note \(probably harmless\):' \ 2807c478bd9Sstevel@tonic-gate | egrep -v '::' \ 281010b217aSwesolows | egrep -v '^\+' \ 282c817a439Sjohnz | egrep -v 'svccfg-native -s svc:/' \ 2837c478bd9Sstevel@tonic-gate | sort | uniq >$SRC/${NOISE}.out 2847c478bd9Sstevel@tonic-gate if [ ! -f $SRC/${NOISE}.ref ]; then 2857c478bd9Sstevel@tonic-gate cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 2867c478bd9Sstevel@tonic-gate fi 2877c478bd9Sstevel@tonic-gate echo "\n==== Build noise differences ($LABEL) ====\n" \ 2887c478bd9Sstevel@tonic-gate >>$mail_msg_file 2897c478bd9Sstevel@tonic-gate diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 2907c478bd9Sstevel@tonic-gate fi 2917c478bd9Sstevel@tonic-gate 29223259b79Srotondo # 29323259b79Srotondo # Re-sign selected binaries using signing server 29423259b79Srotondo # (gatekeeper builds only) 29523259b79Srotondo # 2962210853dSjohnz if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 29723259b79Srotondo echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 29823259b79Srotondo signing_file="${TMPDIR}/signing" 29923259b79Srotondo rm -f ${signing_file} 30023259b79Srotondo export CODESIGN_USER 30123259b79Srotondo signproto $SRC/tools/codesign/creds 2>&1 | \ 30223259b79Srotondo tee -a ${signing_file} >> $LOGFILE 30323259b79Srotondo echo "\n==== Finished signing proto area at `date` ====\n" \ 30423259b79Srotondo >> $LOGFILE 30523259b79Srotondo echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 30623259b79Srotondo >> $mail_msg_file 30723259b79Srotondo egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 308cdf0c1d5Smjnelson if (( $? == 0 )) ; then 3092210853dSjohnz build_ok=n 3102210853dSjohnz this_build_ok=n 3112210853dSjohnz fi 31223259b79Srotondo fi 31323259b79Srotondo 3147c478bd9Sstevel@tonic-gate # 3157c478bd9Sstevel@tonic-gate # Building Packages 3167c478bd9Sstevel@tonic-gate # 3177c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 318c3e6cb59SRichard Lowe if [ -d $SRC/pkg ]; then 319ead1f93eSLiane Praza echo "\n==== Creating $LABEL packages at `date` ====\n" \ 320d8fd4470Sjg >> $LOGFILE 321ead1f93eSLiane Praza echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 3226798c3f0SMark J. Nelson rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 3236798c3f0SMark J. Nelson mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 324d8fd4470Sjg 325c3e6cb59SRichard Lowe rm -f $SRC/pkg/${INSTALLOG}.out 326c3e6cb59SRichard Lowe cd $SRC/pkg 327c3e6cb59SRichard Lowe /bin/time $MAKE -e install 2>&1 | \ 328c3e6cb59SRichard Lowe tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 329ead1f93eSLiane Praza 330ead1f93eSLiane Praza echo "\n==== package build errors ($LABEL) ====\n" \ 331ead1f93eSLiane Praza >> $mail_msg_file 332ead1f93eSLiane Praza 333c3e6cb59SRichard Lowe egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 334c3e6cb59SRichard Lowe grep ':' | \ 335c3e6cb59SRichard Lowe grep -v PSTAMP | \ 336cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 337cb4d1691SRichard Lowe tee $TMPDIR/package >> $mail_msg_file 338cb4d1691SRichard Lowe if [[ -s $TMPDIR/package ]]; then 339cb4d1691SRichard Lowe build_extras_ok=n 340cb4d1691SRichard Lowe this_build_ok=n 341cb4d1691SRichard Lowe fi 3425d3b8cb7SBill Sommerfeld else 343ead1f93eSLiane Praza # 344c3e6cb59SRichard Lowe # Handle it gracefully if -p was set but there so 345c3e6cb59SRichard Lowe # no pkg directory. 346ead1f93eSLiane Praza # 347ead1f93eSLiane Praza echo "\n==== No $LABEL packages to build ====\n" \ 348ead1f93eSLiane Praza >> $LOGFILE 3495d3b8cb7SBill Sommerfeld fi 350ead1f93eSLiane Praza else 351ead1f93eSLiane Praza echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 3525d3b8cb7SBill Sommerfeld fi 3535d3b8cb7SBill Sommerfeld 3544e5b757fSkupfer ROOT=$ORIGROOT 3557c478bd9Sstevel@tonic-gate} 3567c478bd9Sstevel@tonic-gate 357391889ecSAndy Fiddaman# 358391889ecSAndy Fiddaman# Bootstrap build tools which are pre-requisites for the rest of the build. 359391889ecSAndy Fiddaman# 360391889ecSAndy Fiddamanfunction bootstrap_tools { 361391889ecSAndy Fiddaman echo "\n==== Bootstrapping tools at `date` ====\n" >> $LOGFILE 362391889ecSAndy Fiddaman 363391889ecSAndy Fiddaman typeset INSTALLOG=install-bootstrap-${MACH} 364391889ecSAndy Fiddaman 365391889ecSAndy Fiddaman rm -f $TMPDIR/make-state ${TOOLS}/$INSTALLOG.out 366391889ecSAndy Fiddaman cd ${TOOLS} 367391889ecSAndy Fiddaman /bin/time $MAKE -K $TMPDIR/make-state -e TARGET=install bootstrap \ 368391889ecSAndy Fiddaman 2>&1 | tee -a ${TOOLS}/$INSTALLOG.out >> $LOGFILE 369391889ecSAndy Fiddaman 370391889ecSAndy Fiddaman echo "\n==== Bootstrap build errors ====\n" >> $mail_msg_file 371391889ecSAndy Fiddaman 372391889ecSAndy Fiddaman egrep ":" ${TOOLS}/$INSTALLOG.out | 373391889ecSAndy Fiddaman egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 374391889ecSAndy Fiddaman egrep -v warning | tee $TMPDIR/bootstrap_errors >> $mail_msg_file 375391889ecSAndy Fiddaman 376391889ecSAndy Fiddaman [[ -s $TMPDIR/bootstrap_errors ]] && return 1 377391889ecSAndy Fiddaman return 0 378391889ecSAndy Fiddaman} 379391889ecSAndy Fiddaman 3804e5b757fSkupfer# 3814e5b757fSkupfer# Build and install the onbld tools. 3824e5b757fSkupfer# 3831fe69678Skupfer# usage: build_tools DESTROOT 3844e5b757fSkupfer# 3854e5b757fSkupfer# returns non-zero status if the build was successful. 3864e5b757fSkupfer# 387597bd30bSMike Kupferfunction build_tools { 3887c478bd9Sstevel@tonic-gate DESTROOT=$1 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate INSTALLOG=install-${MACH} 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate echo "\n==== Building tools at `date` ====\n" \ 3937c478bd9Sstevel@tonic-gate >> $LOGFILE 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/${INSTALLOG}.out 3967c478bd9Sstevel@tonic-gate cd ${TOOLS} 397ead1f93eSLiane Praza /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 3987c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate echo "\n==== Tools build errors ====\n" >> $mail_msg_file 4017c478bd9Sstevel@tonic-gate 4027c478bd9Sstevel@tonic-gate egrep ":" ${TOOLS}/${INSTALLOG}.out | 4037c478bd9Sstevel@tonic-gate egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 4047c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 405cb4d1691SRichard Lowe egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 406cb4d1691SRichard Lowe 407cb4d1691SRichard Lowe if [[ -s $TMPDIR/tools_errors ]]; then 408cb4d1691SRichard Lowe return 1 409cb4d1691SRichard Lowe fi 410cb4d1691SRichard Lowe return 0 4114e5b757fSkupfer} 4124e5b757fSkupfer 413597bd30bSMike Kupferfunction staffer { 4147c478bd9Sstevel@tonic-gate if [ $ISUSER -ne 0 ]; then 4157c478bd9Sstevel@tonic-gate "$@" 4167c478bd9Sstevel@tonic-gate else 4177c478bd9Sstevel@tonic-gate arg="\"$1\"" 4187c478bd9Sstevel@tonic-gate shift 4197c478bd9Sstevel@tonic-gate for i 4207c478bd9Sstevel@tonic-gate do 4217c478bd9Sstevel@tonic-gate arg="$arg \"$i\"" 4227c478bd9Sstevel@tonic-gate done 4237c478bd9Sstevel@tonic-gate eval su $STAFFER -c \'$arg\' 4247c478bd9Sstevel@tonic-gate fi 4257c478bd9Sstevel@tonic-gate} 4267c478bd9Sstevel@tonic-gate 427085d331dSkupfer# 428c3e6cb59SRichard Lowe# Verify that the closed bins are present 429085d331dSkupfer# 430c3e6cb59SRichard Lowefunction check_closed_bins { 431cd277642SGarrett D'Amore if [[ -n "$ON_CLOSED_BINS" && ! -d "$ON_CLOSED_BINS" ]]; then 432c0e7977aSJosef 'Jeff' Sipek echo "ON_CLOSED_BINS must point to the closed binaries tree." 433c0e7977aSJosef 'Jeff' Sipek build_ok=n 434c0e7977aSJosef 'Jeff' Sipek exit 1 435085d331dSkupfer fi 436085d331dSkupfer} 4377c478bd9Sstevel@tonic-gate 4384e5b757fSkupfer# 4394e5b757fSkupfer# wrapper over wsdiff. 4404e5b757fSkupfer# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 4414e5b757fSkupfer# 442597bd30bSMike Kupferfunction do_wsdiff { 4434e5b757fSkupfer label=$1 4444e5b757fSkupfer oldproto=$2 4454e5b757fSkupfer newproto=$3 4464e5b757fSkupfer 4474e5b757fSkupfer wsdiff="wsdiff" 4484e5b757fSkupfer [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 4494e5b757fSkupfer 450598cc7dfSVladimir Kotal echo "\n==== Getting object changes since last build at `date`" \ 451598cc7dfSVladimir Kotal "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 452598cc7dfSVladimir Kotal $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 4534e5b757fSkupfer tee -a $LOGFILE >> $mail_msg_file 454598cc7dfSVladimir Kotal echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 455598cc7dfSVladimir Kotal tee -a $LOGFILE >> $mail_msg_file 4564e5b757fSkupfer} 4574e5b757fSkupfer 4584e5b757fSkupfer# 459ead1f93eSLiane Praza# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 4604e5b757fSkupfer# together. 4614e5b757fSkupfer# 4624e5b757fSkupfer 463597bd30bSMike Kupferfunction set_non_debug_build_flags { 4644e5b757fSkupfer export RELEASE_BUILD ; RELEASE_BUILD= 4654e5b757fSkupfer unset EXTRA_OPTIONS 4664e5b757fSkupfer unset EXTRA_CFLAGS 4673c562093SToomas Soome if [ -n "$RELEASE_CONSOLE_COLOR" ]; then 4683c562093SToomas Soome export DEFAULT_CONSOLE_COLOR="$RELEASE_CONSOLE_COLOR" 4693c562093SToomas Soome fi 4704e5b757fSkupfer} 4714e5b757fSkupfer 472597bd30bSMike Kupferfunction set_debug_build_flags { 4734e5b757fSkupfer unset RELEASE_BUILD 4744e5b757fSkupfer unset EXTRA_OPTIONS 4754e5b757fSkupfer unset EXTRA_CFLAGS 4763c562093SToomas Soome 4773c562093SToomas Soome if [ -n "$DEBUG_CONSOLE_COLOR" ]; then 4783c562093SToomas Soome export DEFAULT_CONSOLE_COLOR="$DEBUG_CONSOLE_COLOR" 4793c562093SToomas Soome fi 4804e5b757fSkupfer} 4814e5b757fSkupfer 482d77e7149Ssommerfe 4837c478bd9Sstevel@tonic-gateMACH=`uname -p` 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gateif [ "$OPTHOME" = "" ]; then 4867c478bd9Sstevel@tonic-gate OPTHOME=/opt 4877c478bd9Sstevel@tonic-gate export OPTHOME 4887c478bd9Sstevel@tonic-gatefi 4897c478bd9Sstevel@tonic-gate 4905110237aSJosef 'Jeff' SipekUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gateWhere: 493be0ffda9SPeter Tribble -i Fast incremental options (no clobber, check) 4947c478bd9Sstevel@tonic-gate -n Do not do a bringover 4955e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 4967c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate <env_file> file in Bourne shell syntax that sets and exports 4997c478bd9Sstevel@tonic-gate variables that configure the operation of this script and many of 5007c478bd9Sstevel@tonic-gate the scripts this one calls. If <env_file> does not exist, 5017c478bd9Sstevel@tonic-gate it will be looked for in $OPTHOME/onbld/env. 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gatenon-DEBUG is the default build type. Build options can be set in the 5047c478bd9Sstevel@tonic-gateNIGHTLY_OPTIONS variable in the <env_file> as follows: 5057c478bd9Sstevel@tonic-gate 5067c478bd9Sstevel@tonic-gate -A check for ABI differences in .so files 5077c478bd9Sstevel@tonic-gate -C check for cstyle/hdrchk errors 5087c478bd9Sstevel@tonic-gate -D do a build with DEBUG on 5097c478bd9Sstevel@tonic-gate -F do _not_ do a non-DEBUG build 5103c6aa570SMark J. Nelson -G gate keeper default group of options (-au) 5117c478bd9Sstevel@tonic-gate -I integration engineer default group of options (-ampu) 512069e6b7eSAndy Fiddaman -L do not run pkglint 5137c478bd9Sstevel@tonic-gate -M do not run pmodes (safe file permission checker) 5147c478bd9Sstevel@tonic-gate -N do not run protocmp 5157c478bd9Sstevel@tonic-gate -R default group of options for building a release (-mp) 5167c478bd9Sstevel@tonic-gate -U update proto area in the parent 5177c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 5187c478bd9Sstevel@tonic-gate -f find unreferenced files 5197c478bd9Sstevel@tonic-gate -i do an incremental build (no "make clobber") 5207c478bd9Sstevel@tonic-gate -m send mail to $MAILTO at end of build 5217c478bd9Sstevel@tonic-gate -n do not do a bringover 5227c478bd9Sstevel@tonic-gate -p create packages 5237c478bd9Sstevel@tonic-gate -r check ELF runtime attributes in the proto area 5245e1b109eSPeter Dennis - Sustaining Engineer -t build and use the tools in $SRC/tools (default setting) 5255e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 5267c478bd9Sstevel@tonic-gate -u update proto_list_$MACH and friends in the parent workspace; 5277c478bd9Sstevel@tonic-gate when used with -f, also build an unrefmaster.out in the parent 52896ccc8cbSesaxe -w report on differences between previous and current proto areas 5297c478bd9Sstevel@tonic-gate' 5307c478bd9Sstevel@tonic-gate# 5317c478bd9Sstevel@tonic-gate# A log file will be generated under the name $LOGFILE 5321c79753fSdarrenm# for partially completed build and log.`date '+%F'` 5337c478bd9Sstevel@tonic-gate# in the same directory for fully completed builds. 5347c478bd9Sstevel@tonic-gate# 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate# default values for low-level FLAGS; G I R are group FLAGS 5377c478bd9Sstevel@tonic-gateA_FLAG=n 5387c478bd9Sstevel@tonic-gateC_FLAG=n 5396c3c9007SstevelD_FLAG=n 5407c478bd9Sstevel@tonic-gateF_FLAG=n 5417c478bd9Sstevel@tonic-gatef_FLAG=n 5427c478bd9Sstevel@tonic-gatei_FLAG=n; i_CMD_LINE_FLAG=n 543069e6b7eSAndy FiddamanL_FLAG=n 5446c3c9007SstevelM_FLAG=n 5457c478bd9Sstevel@tonic-gatem_FLAG=n 5466c3c9007SstevelN_FLAG=n 5476c3c9007Ssteveln_FLAG=n 5487c478bd9Sstevel@tonic-gatep_FLAG=n 5497c478bd9Sstevel@tonic-gater_FLAG=n 550fd7cef36Ssuhat_FLAG=y 5517c478bd9Sstevel@tonic-gateU_FLAG=n 5526c3c9007Sstevelu_FLAG=n 5537c478bd9Sstevel@tonic-gateV_FLAG=n 5546c3c9007Sstevelw_FLAG=n 555cb4d1691SRichard LoweW_FLAG=n 5567c478bd9Sstevel@tonic-gate# 5577c478bd9Sstevel@tonic-gatebuild_ok=y 558cb4d1691SRichard Lowebuild_extras_ok=y 5591fe69678Skupfer 5607c478bd9Sstevel@tonic-gate# 5617c478bd9Sstevel@tonic-gate# examine arguments 5627c478bd9Sstevel@tonic-gate# 5637c478bd9Sstevel@tonic-gate 5647c478bd9Sstevel@tonic-gateOPTIND=1 565cb4d1691SRichard Lowewhile getopts +intV:W FLAG 5667c478bd9Sstevel@tonic-gatedo 5677c478bd9Sstevel@tonic-gate case $FLAG in 5687c478bd9Sstevel@tonic-gate i ) i_FLAG=y; i_CMD_LINE_FLAG=y 5697c478bd9Sstevel@tonic-gate ;; 5707c478bd9Sstevel@tonic-gate n ) n_FLAG=y 5717c478bd9Sstevel@tonic-gate ;; 572fd7cef36Ssuha +t ) t_FLAG=n 5737c478bd9Sstevel@tonic-gate ;; 5746c3c9007Sstevel V ) V_FLAG=y 5756c3c9007Sstevel V_ARG="$OPTARG" 5766c3c9007Sstevel ;; 577cb4d1691SRichard Lowe W ) W_FLAG=y 578cb4d1691SRichard Lowe ;; 5797c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 5807c478bd9Sstevel@tonic-gate exit 1 5817c478bd9Sstevel@tonic-gate ;; 5827c478bd9Sstevel@tonic-gate esac 5837c478bd9Sstevel@tonic-gatedone 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate# correct argument count after options 5867c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate# test that the path to the environment-setting file was given 5897c478bd9Sstevel@tonic-gateif [ $# -ne 1 ]; then 5907c478bd9Sstevel@tonic-gate echo "$USAGE" 5917c478bd9Sstevel@tonic-gate exit 1 5927c478bd9Sstevel@tonic-gatefi 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate# check if user is running nightly as root 5957c478bd9Sstevel@tonic-gate# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 5967c478bd9Sstevel@tonic-gate# when root invokes nightly. 5977c478bd9Sstevel@tonic-gate/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 5987c478bd9Sstevel@tonic-gateISUSER=$?; export ISUSER 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate# 6017c478bd9Sstevel@tonic-gate# force locale to C 60291d74a54SRichard LoweLANG=C; export LANG 60391d74a54SRichard LoweLC_ALL=C; export LC_ALL 6047c478bd9Sstevel@tonic-gateLC_COLLATE=C; export LC_COLLATE 6057c478bd9Sstevel@tonic-gateLC_CTYPE=C; export LC_CTYPE 6067c478bd9Sstevel@tonic-gateLC_MESSAGES=C; export LC_MESSAGES 6077c478bd9Sstevel@tonic-gateLC_MONETARY=C; export LC_MONETARY 6087c478bd9Sstevel@tonic-gateLC_NUMERIC=C; export LC_NUMERIC 6097c478bd9Sstevel@tonic-gateLC_TIME=C; export LC_TIME 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate# clear environment variables we know to be bad for the build 6127c478bd9Sstevel@tonic-gateunset LD_OPTIONS 6137c478bd9Sstevel@tonic-gateunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 6147c478bd9Sstevel@tonic-gateunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 6157c478bd9Sstevel@tonic-gateunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 6167c478bd9Sstevel@tonic-gateunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 6177c478bd9Sstevel@tonic-gateunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 6187c478bd9Sstevel@tonic-gateunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 6197c478bd9Sstevel@tonic-gateunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 6207c478bd9Sstevel@tonic-gateunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 6217c478bd9Sstevel@tonic-gateunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 6227c478bd9Sstevel@tonic-gateunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 6237c478bd9Sstevel@tonic-gateunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 6247c478bd9Sstevel@tonic-gateunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 6257c478bd9Sstevel@tonic-gateunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 6267c478bd9Sstevel@tonic-gateunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 6277c478bd9Sstevel@tonic-gateunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 6287c478bd9Sstevel@tonic-gateunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 6297c478bd9Sstevel@tonic-gateunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 6307c478bd9Sstevel@tonic-gateunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 6317c478bd9Sstevel@tonic-gateunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 6327c478bd9Sstevel@tonic-gateunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gateunset CONFIG 6357c478bd9Sstevel@tonic-gateunset GROUP 6367c478bd9Sstevel@tonic-gateunset OWNER 6377c478bd9Sstevel@tonic-gateunset REMOTE 6387c478bd9Sstevel@tonic-gateunset ENV 6397c478bd9Sstevel@tonic-gateunset ARCH 6407c478bd9Sstevel@tonic-gateunset CLASSPATH 6417c478bd9Sstevel@tonic-gateunset NAME 6427c478bd9Sstevel@tonic-gate 643ead1f93eSLiane Praza# 644ead1f93eSLiane Praza# To get ONBLD_TOOLS from the environment, it must come from the env file. 645ead1f93eSLiane Praza# If it comes interactively, it is generally TOOLS_PROTO, which will be 646ead1f93eSLiane Praza# clobbered before the compiler version checks, which will therefore fail. 647ead1f93eSLiane Praza# 648ead1f93eSLiane Prazaunset ONBLD_TOOLS 649ead1f93eSLiane Praza 6507c478bd9Sstevel@tonic-gate# 6517c478bd9Sstevel@tonic-gate# Setup environmental variables 6527c478bd9Sstevel@tonic-gate# 65347703246Ssommerfeif [ -f /etc/nightly.conf ]; then 65447703246Ssommerfe . /etc/nightly.conf 655fb23c574SRichard Lowefi 65647703246Ssommerfe 6577c478bd9Sstevel@tonic-gateif [ -f $1 ]; then 6587c478bd9Sstevel@tonic-gate if [[ $1 = */* ]]; then 6597c478bd9Sstevel@tonic-gate . $1 6607c478bd9Sstevel@tonic-gate else 6617c478bd9Sstevel@tonic-gate . ./$1 6627c478bd9Sstevel@tonic-gate fi 6637c478bd9Sstevel@tonic-gateelse 6647c478bd9Sstevel@tonic-gate if [ -f $OPTHOME/onbld/env/$1 ]; then 6657c478bd9Sstevel@tonic-gate . $OPTHOME/onbld/env/$1 6667c478bd9Sstevel@tonic-gate else 6677c478bd9Sstevel@tonic-gate echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 6687c478bd9Sstevel@tonic-gate exit 1 6697c478bd9Sstevel@tonic-gate fi 6707c478bd9Sstevel@tonic-gatefi 6717c478bd9Sstevel@tonic-gate 672d7693b08SRoland Mainz# Check if we have sufficient data to continue... 673d7693b08SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 674220399b7SRoland Mainzif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 675220399b7SRoland Mainz # Check if the gate data are valid if we don't do a "bringover" below 676220399b7SRoland Mainz [[ -d "${CODEMGR_WS}" ]] || \ 677220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS} is not a directory." 678220399b7SRoland Mainz [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 679220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 680220399b7SRoland Mainzfi 681d7693b08SRoland Mainz 6827c478bd9Sstevel@tonic-gate# 6837c478bd9Sstevel@tonic-gate# place ourselves in a new task, respecting BUILD_PROJECT if set. 6847c478bd9Sstevel@tonic-gate# 6857c478bd9Sstevel@tonic-gateif [ -z "$BUILD_PROJECT" ]; then 6867c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ 6877c478bd9Sstevel@tonic-gateelse 6887c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ -p $BUILD_PROJECT 6897c478bd9Sstevel@tonic-gatefi 6907c478bd9Sstevel@tonic-gate 6917c478bd9Sstevel@tonic-gateps -o taskid= -p $$ | read build_taskid 6927c478bd9Sstevel@tonic-gateps -o project= -p $$ | read build_project 6937c478bd9Sstevel@tonic-gate 6947c478bd9Sstevel@tonic-gate# 6957c478bd9Sstevel@tonic-gate# See if NIGHTLY_OPTIONS is set 6967c478bd9Sstevel@tonic-gate# 6977c478bd9Sstevel@tonic-gateif [ "$NIGHTLY_OPTIONS" = "" ]; then 6987c478bd9Sstevel@tonic-gate NIGHTLY_OPTIONS="-aBm" 6997c478bd9Sstevel@tonic-gatefi 7007c478bd9Sstevel@tonic-gate 7017c478bd9Sstevel@tonic-gate# 7027c478bd9Sstevel@tonic-gate# If BRINGOVER_WS was not specified, let it default to CLONE_WS 7037c478bd9Sstevel@tonic-gate# 7047c478bd9Sstevel@tonic-gateif [ "$BRINGOVER_WS" = "" ]; then 7057c478bd9Sstevel@tonic-gate BRINGOVER_WS=$CLONE_WS 7067c478bd9Sstevel@tonic-gatefi 7077c478bd9Sstevel@tonic-gate 708a5c06a9eSmike_s# 709fb23a357Skupfer# If BRINGOVER_FILES was not specified, default to usr 710a5c06a9eSmike_s# 711a5c06a9eSmike_sif [ "$BRINGOVER_FILES" = "" ]; then 712fb23a357Skupfer BRINGOVER_FILES="usr" 713a5c06a9eSmike_sfi 714a5c06a9eSmike_s 715c3e6cb59SRichard Lowecheck_closed_bins 716fb9f9b97Skupfer 7177c478bd9Sstevel@tonic-gate# 7187c478bd9Sstevel@tonic-gate# Note: changes to the option letters here should also be applied to the 719b84bdc30Smeem# bldenv script. `d' is listed for backward compatibility. 7207c478bd9Sstevel@tonic-gate# 721d77e7149SsommerfeNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 7227c478bd9Sstevel@tonic-gateOPTIND=1 723069e6b7eSAndy Fiddamanwhile getopts +ABCDdFfGIiLMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 7247c478bd9Sstevel@tonic-gatedo 7257c478bd9Sstevel@tonic-gate case $FLAG in 7267c478bd9Sstevel@tonic-gate A ) A_FLAG=y 7277c478bd9Sstevel@tonic-gate ;; 7287c478bd9Sstevel@tonic-gate B ) D_FLAG=y 7297c478bd9Sstevel@tonic-gate ;; # old version of D 7306c3c9007Sstevel C ) C_FLAG=y 7317c478bd9Sstevel@tonic-gate ;; 7327c478bd9Sstevel@tonic-gate D ) D_FLAG=y 7337c478bd9Sstevel@tonic-gate ;; 7346c3c9007Sstevel F ) F_FLAG=y 7357c478bd9Sstevel@tonic-gate ;; 7366c3c9007Sstevel f ) f_FLAG=y 7377c478bd9Sstevel@tonic-gate ;; 73878add226Sjmcp G ) u_FLAG=y 7397c478bd9Sstevel@tonic-gate ;; 74078add226Sjmcp I ) m_FLAG=y 7417c478bd9Sstevel@tonic-gate p_FLAG=y 7427c478bd9Sstevel@tonic-gate u_FLAG=y 7437c478bd9Sstevel@tonic-gate ;; 7446c3c9007Sstevel i ) i_FLAG=y 7457c478bd9Sstevel@tonic-gate ;; 746069e6b7eSAndy Fiddaman L ) L_FLAG=y 747069e6b7eSAndy Fiddaman ;; 7486c3c9007Sstevel M ) M_FLAG=y 7497c478bd9Sstevel@tonic-gate ;; 7506c3c9007Sstevel m ) m_FLAG=y 7516c3c9007Sstevel ;; 7526c3c9007Sstevel N ) N_FLAG=y 7537c478bd9Sstevel@tonic-gate ;; 7547c478bd9Sstevel@tonic-gate n ) n_FLAG=y 7557c478bd9Sstevel@tonic-gate ;; 7567c478bd9Sstevel@tonic-gate p ) p_FLAG=y 7577c478bd9Sstevel@tonic-gate ;; 7586c3c9007Sstevel R ) m_FLAG=y 7596c3c9007Sstevel p_FLAG=y 7607c478bd9Sstevel@tonic-gate ;; 7616c3c9007Sstevel r ) r_FLAG=y 7627c478bd9Sstevel@tonic-gate ;; 763fd7cef36Ssuha +t ) t_FLAG=n 7647c478bd9Sstevel@tonic-gate ;; 7656798c3f0SMark J. Nelson U ) if [ -z "${PARENT_ROOT}" ]; then 7667c478bd9Sstevel@tonic-gate echo "PARENT_ROOT must be set if the U flag is" \ 7677c478bd9Sstevel@tonic-gate "present in NIGHTLY_OPTIONS." 7687c478bd9Sstevel@tonic-gate exit 1 7697c478bd9Sstevel@tonic-gate fi 7706798c3f0SMark J. Nelson NIGHTLY_PARENT_ROOT=$PARENT_ROOT 7716798c3f0SMark J. Nelson if [ -n "${PARENT_TOOLS_ROOT}" ]; then 7726798c3f0SMark J. Nelson NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 773ead1f93eSLiane Praza fi 7747c478bd9Sstevel@tonic-gate U_FLAG=y 7757c478bd9Sstevel@tonic-gate ;; 7766c3c9007Sstevel u ) u_FLAG=y 7777c478bd9Sstevel@tonic-gate ;; 7786c3c9007Sstevel w ) w_FLAG=y 7797c478bd9Sstevel@tonic-gate ;; 780cb4d1691SRichard Lowe W ) W_FLAG=y 781cb4d1691SRichard Lowe ;; 7827c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 7837c478bd9Sstevel@tonic-gate exit 1 7847c478bd9Sstevel@tonic-gate ;; 7857c478bd9Sstevel@tonic-gate esac 7867c478bd9Sstevel@tonic-gatedone 7877c478bd9Sstevel@tonic-gate 788*9cc2e6acSMatt Fiddaman# Skip pkglint if packages aren't being built 789*9cc2e6acSMatt Fiddaman[ $p_FLAG = n ] && L_FLAG=y 790*9cc2e6acSMatt Fiddaman 7917c478bd9Sstevel@tonic-gateif [ $ISUSER -ne 0 ]; then 7927c478bd9Sstevel@tonic-gate # Set default value for STAFFER, if needed. 7937c478bd9Sstevel@tonic-gate if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 7947c478bd9Sstevel@tonic-gate STAFFER=`/usr/xpg4/bin/id -un` 7957c478bd9Sstevel@tonic-gate export STAFFER 7967c478bd9Sstevel@tonic-gate fi 7977c478bd9Sstevel@tonic-gatefi 7987c478bd9Sstevel@tonic-gate 7997c478bd9Sstevel@tonic-gateif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 8007c478bd9Sstevel@tonic-gate MAILTO=$STAFFER 8017c478bd9Sstevel@tonic-gate export MAILTO 8027c478bd9Sstevel@tonic-gatefi 8037c478bd9Sstevel@tonic-gate 804c168ccb7SMark J. NelsonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 805c3e6cb59SRichard LowePATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 806c168ccb7SMark J. NelsonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 8077c478bd9Sstevel@tonic-gateexport PATH 8087c478bd9Sstevel@tonic-gate 809fb23a357Skupfer# roots of source trees, both relative to $SRC and absolute. 810fb23a357Skupferrelsrcdirs="." 811c0e7977aSJosef 'Jeff' Sipekabssrcdirs="$SRC" 812fb23a357Skupfer 813c3e6cb59SRichard LowePROTOCMPTERSE="protocmp.terse -gu" 8147c478bd9Sstevel@tonic-gatePOUND_SIGN="#" 8156112cec5SJoshua M. Clulowbasews="$(basename "$CODEMGR_WS")" 81648bc00d6Sjmcp# have we set RELEASE_DATE in our env file? 81748bc00d6Sjmcpif [ -z "$RELEASE_DATE" ]; then 81848bc00d6Sjmcp RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 81948bc00d6Sjmcpfi 8206112cec5SJoshua M. Clulownow=$(LC_ALL=C date +%Y-%b-%d) 8216112cec5SJoshua M. ClulowDEV_CM_TAIL="development build: $LOGNAME $now [$basews]" 8227c478bd9Sstevel@tonic-gate 8236112cec5SJoshua M. Clulow# 8246112cec5SJoshua M. Clulow# We export POUND_SIGN, RELEASE_DATE and DEV_CM_TAIL to speed up the build 8256112cec5SJoshua M. Clulow# process by avoiding repeated shell invocations to evaluate Makefile.master 826c3e6cb59SRichard Lowe# definitions. 8276112cec5SJoshua M. Clulow# 8286112cec5SJoshua M. Clulowexport POUND_SIGN RELEASE_DATE DEV_CM_TAIL 8297c478bd9Sstevel@tonic-gate 830b84bdc30Smeemmaketype="distributed" 831e119f243SRobert Mustacchiif [[ -z "$MAKE" ]]; then 832e119f243SRobert Mustacchi MAKE=dmake 833e119f243SRobert Mustacchielif [[ ! -x "$MAKE" ]]; then 834e119f243SRobert Mustacchi echo "\$MAKE is set to garbage in the environment" 835fb23c574SRichard Lowe exit 1 836e119f243SRobert Mustacchifi 8377c478bd9Sstevel@tonic-gateexport PATH 8387c478bd9Sstevel@tonic-gateexport MAKE 8397c478bd9Sstevel@tonic-gate 8407c478bd9Sstevel@tonic-gateif [ "${SUNWSPRO}" != "" ]; then 8417c478bd9Sstevel@tonic-gate PATH="${SUNWSPRO}/bin:$PATH" 8427c478bd9Sstevel@tonic-gate export PATH 8437c478bd9Sstevel@tonic-gatefi 8447c478bd9Sstevel@tonic-gate 84599e4a37bSWill Fiveashhostname=$(uname -n) 84699e4a37bSWill Fiveashif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 84799e4a37bSWill Fiveashthen 84899e4a37bSWill Fiveash maxjobs= 84999e4a37bSWill Fiveash if [[ -f $HOME/.make.machines ]] 85099e4a37bSWill Fiveash then 85199e4a37bSWill Fiveash # Note: there is a hard tab and space character in the []s 85299e4a37bSWill Fiveash # below. 85399e4a37bSWill Fiveash egrep -i "^[ ]*$hostname[ \.]" \ 85499e4a37bSWill Fiveash $HOME/.make.machines | read host jobs 85599e4a37bSWill Fiveash maxjobs=${jobs##*=} 85699e4a37bSWill Fiveash fi 85799e4a37bSWill Fiveash 85899e4a37bSWill Fiveash if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 85999e4a37bSWill Fiveash then 86099e4a37bSWill Fiveash # default 86199e4a37bSWill Fiveash maxjobs=4 8627c478bd9Sstevel@tonic-gate fi 86399e4a37bSWill Fiveash 86499e4a37bSWill Fiveash export DMAKE_MAX_JOBS=$maxjobs 8657c478bd9Sstevel@tonic-gatefi 86699e4a37bSWill Fiveash 8677c478bd9Sstevel@tonic-gateDMAKE_MODE=parallel; 8687c478bd9Sstevel@tonic-gateexport DMAKE_MODE 8697c478bd9Sstevel@tonic-gate 8707c478bd9Sstevel@tonic-gateif [ -z "${ROOT}" ]; then 8717c478bd9Sstevel@tonic-gate echo "ROOT must be set." 8727c478bd9Sstevel@tonic-gate exit 1 8737c478bd9Sstevel@tonic-gatefi 8747c478bd9Sstevel@tonic-gate 8757c478bd9Sstevel@tonic-gate# 8767c478bd9Sstevel@tonic-gate# if -V flag was given, reset VERSION to V_ARG 8777c478bd9Sstevel@tonic-gate# 8787c478bd9Sstevel@tonic-gateif [ "$V_FLAG" = "y" ]; then 8797c478bd9Sstevel@tonic-gate VERSION=$V_ARG 8807c478bd9Sstevel@tonic-gatefi 8817c478bd9Sstevel@tonic-gate 8827c478bd9Sstevel@tonic-gateTMPDIR="/tmp/nightly.tmpdir.$$" 8837c478bd9Sstevel@tonic-gateexport TMPDIR 8847c478bd9Sstevel@tonic-gaterm -rf ${TMPDIR} 8857c478bd9Sstevel@tonic-gatemkdir -p $TMPDIR || exit 1 88685f46905SMark J. Nelsonchmod 777 $TMPDIR 8877c478bd9Sstevel@tonic-gate 8887ed54634SRobert Mustacchi# 8897ed54634SRobert Mustacchi# Work around folks who have historically used GCC_ROOT and convert it to 8907ed54634SRobert Mustacchi# GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could 8917ed54634SRobert Mustacchi# mess up the case where multiple different gcc versions are being used to 8927ed54634SRobert Mustacchi# shadow). 8937ed54634SRobert Mustacchi# 8947ed54634SRobert Mustacchiif [[ -n "${GCC_ROOT}" ]]; then 8957ed54634SRobert Mustacchi export GNUC_ROOT=${GCC_ROOT} 8967ed54634SRobert Mustacchifi 8977ed54634SRobert Mustacchi 898ead1f93eSLiane Praza# 899ead1f93eSLiane Praza# Tools should only be built non-DEBUG. Keep track of the tools proto 900ead1f93eSLiane Praza# area path relative to $TOOLS, because the latter changes in an 901ead1f93eSLiane Praza# export build. 902ead1f93eSLiane Praza# 903ead1f93eSLiane Praza# TOOLS_PROTO is included below for builds other than usr/src/tools 904ead1f93eSLiane Praza# that look for this location. For usr/src/tools, this will be 905ead1f93eSLiane Praza# overridden on the $MAKE command line in build_tools(). 906ead1f93eSLiane Praza# 9077c478bd9Sstevel@tonic-gateTOOLS=${SRC}/tools 908ead1f93eSLiane PrazaTOOLS_PROTO_REL=proto/root_${MACH}-nd 909ead1f93eSLiane PrazaTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 910ead1f93eSLiane Praza 9117c478bd9Sstevel@tonic-gateunset CFLAGS LD_LIBRARY_PATH LDFLAGS 9127c478bd9Sstevel@tonic-gate 9137c478bd9Sstevel@tonic-gate# create directories that are automatically removed if the nightly script 9147c478bd9Sstevel@tonic-gate# fails to start correctly 915597bd30bSMike Kupferfunction newdir { 9167c478bd9Sstevel@tonic-gate dir=$1 9177c478bd9Sstevel@tonic-gate toadd= 9187c478bd9Sstevel@tonic-gate while [ ! -d $dir ]; do 9197c478bd9Sstevel@tonic-gate toadd="$dir $toadd" 9207c478bd9Sstevel@tonic-gate dir=`dirname $dir` 9217c478bd9Sstevel@tonic-gate done 9227c478bd9Sstevel@tonic-gate torm= 9237c478bd9Sstevel@tonic-gate newlist= 9247c478bd9Sstevel@tonic-gate for dir in $toadd; do 9257c478bd9Sstevel@tonic-gate if staffer mkdir $dir; then 9267c478bd9Sstevel@tonic-gate newlist="$ISUSER $dir $newlist" 9277c478bd9Sstevel@tonic-gate torm="$dir $torm" 9287c478bd9Sstevel@tonic-gate else 9297c478bd9Sstevel@tonic-gate [ -z "$torm" ] || staffer rmdir $torm 9307c478bd9Sstevel@tonic-gate return 1 9317c478bd9Sstevel@tonic-gate fi 9327c478bd9Sstevel@tonic-gate done 9337c478bd9Sstevel@tonic-gate newdirlist="$newlist $newdirlist" 9347c478bd9Sstevel@tonic-gate return 0 9357c478bd9Sstevel@tonic-gate} 9367c478bd9Sstevel@tonic-gatenewdirlist= 9377c478bd9Sstevel@tonic-gate 9387c478bd9Sstevel@tonic-gate[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 9397c478bd9Sstevel@tonic-gate 9407c478bd9Sstevel@tonic-gate# since this script assumes the build is from full source, it nullifies 9417c478bd9Sstevel@tonic-gate# variables likely to have been set by a "ws" script; nullification 9427c478bd9Sstevel@tonic-gate# confines the search space for headers and libraries to the proto area 9437c478bd9Sstevel@tonic-gate# built from this immediate source. 9447c478bd9Sstevel@tonic-gateENVLDLIBS1= 9457c478bd9Sstevel@tonic-gateENVLDLIBS2= 9467c478bd9Sstevel@tonic-gateENVLDLIBS3= 9477c478bd9Sstevel@tonic-gateENVCPPFLAGS1= 9487c478bd9Sstevel@tonic-gateENVCPPFLAGS2= 9497c478bd9Sstevel@tonic-gateENVCPPFLAGS3= 9507c478bd9Sstevel@tonic-gateENVCPPFLAGS4= 9517c478bd9Sstevel@tonic-gatePARENT_ROOT= 9527c478bd9Sstevel@tonic-gate 9537c478bd9Sstevel@tonic-gateexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 954494f7e12SKeith M Wesolowski ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 9557c478bd9Sstevel@tonic-gate 9567c478bd9Sstevel@tonic-gatePKGARCHIVE_ORIG=$PKGARCHIVE 9577c478bd9Sstevel@tonic-gate 9587c478bd9Sstevel@tonic-gate# 9597c478bd9Sstevel@tonic-gate# Juggle the logs and optionally send mail on completion. 9607c478bd9Sstevel@tonic-gate# 9617c478bd9Sstevel@tonic-gate 962597bd30bSMike Kupferfunction logshuffle { 963fb23c574SRichard Lowe LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 9647c478bd9Sstevel@tonic-gate if [ -f $LLOG -o -d $LLOG ]; then 965fb23c574SRichard Lowe LLOG=$LLOG.$$ 9667c478bd9Sstevel@tonic-gate fi 967810d639eSJohn Levon 968810d639eSJohn Levon rm -f "$ATLOG/latest" 2>/dev/null 969810d639eSJohn Levon mkdir -p $LLOG 9704802ef38Srscott export LLOG 9717c478bd9Sstevel@tonic-gate 9727c478bd9Sstevel@tonic-gate if [ "$build_ok" = "y" ]; then 9737c478bd9Sstevel@tonic-gate mv $ATLOG/proto_list_${MACH} $LLOG 97496ccc8cbSesaxe 9752e02daeeSRainer Orth if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 9762e02daeeSRainer Orth mv $ATLOG/proto_list_tools_${MACH} $LLOG 9772e02daeeSRainer Orth fi 9782e02daeeSRainer Orth 97996ccc8cbSesaxe if [ -f $TMPDIR/wsdiff.results ]; then 980fb23c574SRichard Lowe mv $TMPDIR/wsdiff.results $LLOG 98196ccc8cbSesaxe fi 9824e5b757fSkupfer 9834e5b757fSkupfer if [ -f $TMPDIR/wsdiff-nd.results ]; then 9844e5b757fSkupfer mv $TMPDIR/wsdiff-nd.results $LLOG 9854e5b757fSkupfer fi 9867c478bd9Sstevel@tonic-gate fi 9877c478bd9Sstevel@tonic-gate 9887c478bd9Sstevel@tonic-gate # 9897c478bd9Sstevel@tonic-gate # Now that we're about to send mail, it's time to check the noise 9907c478bd9Sstevel@tonic-gate # file. In the event that an error occurs beyond this point, it will 9917c478bd9Sstevel@tonic-gate # be recorded in the nightly.log file, but nowhere else. This would 9927c478bd9Sstevel@tonic-gate # include only errors that cause the copying of the noise log to fail 9937c478bd9Sstevel@tonic-gate # or the mail itself not to be sent. 9947c478bd9Sstevel@tonic-gate # 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate exec >>$LOGFILE 2>&1 9977c478bd9Sstevel@tonic-gate if [ -s $build_noise_file ]; then 998fb23c574SRichard Lowe echo "\n==== Nightly build noise ====\n" | 9997c478bd9Sstevel@tonic-gate tee -a $LOGFILE >>$mail_msg_file 10007c478bd9Sstevel@tonic-gate cat $build_noise_file >>$LOGFILE 10017c478bd9Sstevel@tonic-gate cat $build_noise_file >>$mail_msg_file 10027c478bd9Sstevel@tonic-gate echo | tee -a $LOGFILE >>$mail_msg_file 10037c478bd9Sstevel@tonic-gate fi 10047c478bd9Sstevel@tonic-gate rm -f $build_noise_file 10057c478bd9Sstevel@tonic-gate 10067c478bd9Sstevel@tonic-gate case "$build_ok" in 10077c478bd9Sstevel@tonic-gate y) 10087c478bd9Sstevel@tonic-gate state=Completed 10097c478bd9Sstevel@tonic-gate ;; 10107c478bd9Sstevel@tonic-gate i) 10117c478bd9Sstevel@tonic-gate state=Interrupted 10127c478bd9Sstevel@tonic-gate ;; 10137c478bd9Sstevel@tonic-gate *) 1014fb23c574SRichard Lowe state=Failed 10157c478bd9Sstevel@tonic-gate ;; 10167c478bd9Sstevel@tonic-gate esac 1017cb4d1691SRichard Lowe 1018cb4d1691SRichard Lowe if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 1019cb4d1691SRichard Lowe state=Failed 1020cb4d1691SRichard Lowe fi 1021cb4d1691SRichard Lowe 102240bc9153Srscott NIGHTLY_STATUS=$state 102340bc9153Srscott export NIGHTLY_STATUS 1024d77e7149Ssommerfe 102547703246Ssommerfe run_hook POST_NIGHTLY $state 102647703246Ssommerfe run_hook SYS_POST_NIGHTLY $state 10274802ef38Srscott 10283cb00cf1SJoshua M. Clulow # 10293cb00cf1SJoshua M. Clulow # mailx(1) sets From: based on the -r flag 10303cb00cf1SJoshua M. Clulow # if it is given. 10313cb00cf1SJoshua M. Clulow # 10323cb00cf1SJoshua M. Clulow mailx_r= 10333cb00cf1SJoshua M. Clulow if [[ -n "${MAILFROM}" ]]; then 10343cb00cf1SJoshua M. Clulow mailx_r="-r ${MAILFROM}" 10353cb00cf1SJoshua M. Clulow fi 10363cb00cf1SJoshua M. Clulow 1037cdf0c1d5Smjnelson cat $build_time_file $build_environ_file $mail_msg_file \ 1038cdf0c1d5Smjnelson > ${LLOG}/mail_msg 10397c478bd9Sstevel@tonic-gate if [ "$m_FLAG" = "y" ]; then 10406112cec5SJoshua M. Clulow /usr/bin/mailx ${mailx_r} -s \ 10416112cec5SJoshua M. Clulow "Nightly ${MACH} Build of ${basews} ${state}." \ 10426112cec5SJoshua M. Clulow "${MAILTO}" < "${LLOG}/mail_msg" 10437c478bd9Sstevel@tonic-gate fi 10447c478bd9Sstevel@tonic-gate 10457c478bd9Sstevel@tonic-gate if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1046fb23c574SRichard Lowe staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 10477c478bd9Sstevel@tonic-gate staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 10487c478bd9Sstevel@tonic-gate fi 10497c478bd9Sstevel@tonic-gate 10507c478bd9Sstevel@tonic-gate mv $LOGFILE $LLOG 1051810d639eSJohn Levon 1052810d639eSJohn Levon ln -s "$LLOG" "$ATLOG/latest" 10537c478bd9Sstevel@tonic-gate} 10547c478bd9Sstevel@tonic-gate 10557c478bd9Sstevel@tonic-gate# 10567c478bd9Sstevel@tonic-gate# Remove the locks and temporary files on any exit 10577c478bd9Sstevel@tonic-gate# 1058597bd30bSMike Kupferfunction cleanup { 1059fb23c574SRichard Lowe logshuffle 10607c478bd9Sstevel@tonic-gate 10617c478bd9Sstevel@tonic-gate [ -z "$lockfile" ] || staffer rm -f $lockfile 10627c478bd9Sstevel@tonic-gate [ -z "$atloglockfile" ] || rm -f $atloglockfile 10637c478bd9Sstevel@tonic-gate [ -z "$ulockfile" ] || staffer rm -f $ulockfile 10647c478bd9Sstevel@tonic-gate [ -z "$Ulockfile" ] || rm -f $Ulockfile 10657c478bd9Sstevel@tonic-gate 10667c478bd9Sstevel@tonic-gate set -- $newdirlist 10677c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 10687c478bd9Sstevel@tonic-gate ISUSER=$1 staffer rmdir $2 10697c478bd9Sstevel@tonic-gate shift; shift 10707c478bd9Sstevel@tonic-gate done 10717c478bd9Sstevel@tonic-gate rm -rf $TMPDIR 10727c478bd9Sstevel@tonic-gate} 10737c478bd9Sstevel@tonic-gate 1074597bd30bSMike Kupferfunction cleanup_signal { 1075fb23c574SRichard Lowe build_ok=i 10767c478bd9Sstevel@tonic-gate # this will trigger cleanup(), above. 10777c478bd9Sstevel@tonic-gate exit 1 10787c478bd9Sstevel@tonic-gate} 10797c478bd9Sstevel@tonic-gate 10807c478bd9Sstevel@tonic-gatetrap cleanup 0 10817c478bd9Sstevel@tonic-gatetrap cleanup_signal 1 2 3 15 10827c478bd9Sstevel@tonic-gate 10837c478bd9Sstevel@tonic-gate# 10847c478bd9Sstevel@tonic-gate# Generic lock file processing -- make sure that the lock file doesn't 10857c478bd9Sstevel@tonic-gate# exist. If it does, it should name the build host and PID. If it 10867c478bd9Sstevel@tonic-gate# doesn't, then make sure we can create it. Clean up locks that are 10877c478bd9Sstevel@tonic-gate# known to be stale (assumes host name is unique among build systems 10887c478bd9Sstevel@tonic-gate# for the workspace). 1089cdf0c1d5Smjnelson# 1090597bd30bSMike Kupferfunction create_lock { 10917c478bd9Sstevel@tonic-gate lockf=$1 10927c478bd9Sstevel@tonic-gate lockvar=$2 10938312e758Sdduvall 10947c478bd9Sstevel@tonic-gate ldir=`dirname $lockf` 10957c478bd9Sstevel@tonic-gate [ -d $ldir ] || newdir $ldir || exit 1 10967c478bd9Sstevel@tonic-gate eval $lockvar=$lockf 10978312e758Sdduvall 10988312e758Sdduvall while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 10998312e758Sdduvall ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 11008312e758Sdduvall if [ "$host" != "$hostname" ]; then 11018312e758Sdduvall echo "$MACH build of $basews apparently" \ 11028312e758Sdduvall "already started by $user on $host as $pid." 11038312e758Sdduvall exit 1 11048312e758Sdduvall elif kill -s 0 $pid 2>/dev/null; then 11058312e758Sdduvall echo "$MACH build of $basews already started" \ 11068312e758Sdduvall "by $user as $pid." 11078312e758Sdduvall exit 1 11088312e758Sdduvall else 11098312e758Sdduvall # stale lock; clear it out and try again 11108312e758Sdduvall rm -f $lockf 11118312e758Sdduvall fi 11128312e758Sdduvall done 11137c478bd9Sstevel@tonic-gate} 11147c478bd9Sstevel@tonic-gate 11154e5b757fSkupfer# 11164e5b757fSkupfer# Return the list of interesting proto areas, depending on the current 11174e5b757fSkupfer# options. 11184e5b757fSkupfer# 1119597bd30bSMike Kupferfunction allprotos { 1120c7453724SMike Kupfer typeset roots="$ROOT" 1121c7453724SMike Kupfer 1122c7453724SMike Kupfer if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1123c7453724SMike Kupfer roots="$roots $ROOT-nd" 11244e5b757fSkupfer fi 11254e5b757fSkupfer 11264e5b757fSkupfer echo $roots 11274e5b757fSkupfer} 11284e5b757fSkupfer 11297c478bd9Sstevel@tonic-gate# Ensure no other instance of this script is running on this host. 11307c478bd9Sstevel@tonic-gate# LOCKNAME can be set in <env_file>, and is by default, but is not 11317c478bd9Sstevel@tonic-gate# required due to the use of $ATLOG below. 11327c478bd9Sstevel@tonic-gateif [ -n "$LOCKNAME" ]; then 11337c478bd9Sstevel@tonic-gate create_lock /tmp/$LOCKNAME "lockfile" 11347c478bd9Sstevel@tonic-gatefi 11357c478bd9Sstevel@tonic-gate# 11367c478bd9Sstevel@tonic-gate# Create from one, two, or three other locks: 11377c478bd9Sstevel@tonic-gate# $ATLOG/nightly.lock 11387c478bd9Sstevel@tonic-gate# - protects against multiple builds in same workspace 11397c478bd9Sstevel@tonic-gate# $PARENT_WS/usr/src/nightly.$MACH.lock 11407c478bd9Sstevel@tonic-gate# - protects against multiple 'u' copy-backs 11417c478bd9Sstevel@tonic-gate# $NIGHTLY_PARENT_ROOT/nightly.lock 11427c478bd9Sstevel@tonic-gate# - protects against multiple 'U' copy-backs 11437c478bd9Sstevel@tonic-gate# 11447c478bd9Sstevel@tonic-gate# Overriding ISUSER to 1 causes the lock to be created as root if the 11457c478bd9Sstevel@tonic-gate# script is run as root. The default is to create it as $STAFFER. 11467c478bd9Sstevel@tonic-gateISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 11477c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" ]; then 11487c478bd9Sstevel@tonic-gate create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 11497c478bd9Sstevel@tonic-gatefi 11507c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" ]; then 11517c478bd9Sstevel@tonic-gate # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 11527c478bd9Sstevel@tonic-gate ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 11537c478bd9Sstevel@tonic-gatefi 11547c478bd9Sstevel@tonic-gate 11557c478bd9Sstevel@tonic-gate# Locks have been taken, so we're doing a build and we're committed to 11567c478bd9Sstevel@tonic-gate# the directories we may have created so far. 11577c478bd9Sstevel@tonic-gatenewdirlist= 11587c478bd9Sstevel@tonic-gate 11597c478bd9Sstevel@tonic-gate# 11607c478bd9Sstevel@tonic-gate# Create mail_msg_file 11617c478bd9Sstevel@tonic-gate# 11627c478bd9Sstevel@tonic-gatemail_msg_file="${TMPDIR}/mail_msg" 11637c478bd9Sstevel@tonic-gatetouch $mail_msg_file 11647c478bd9Sstevel@tonic-gatebuild_time_file="${TMPDIR}/build_time" 1165cdf0c1d5Smjnelsonbuild_environ_file="${TMPDIR}/build_environ" 1166cdf0c1d5Smjnelsontouch $build_environ_file 11677c478bd9Sstevel@tonic-gate# 11687c478bd9Sstevel@tonic-gate# Move old LOGFILE aside 11697c478bd9Sstevel@tonic-gate# ATLOG directory already made by 'create_lock' above 11707c478bd9Sstevel@tonic-gate# 11717c478bd9Sstevel@tonic-gateif [ -f $LOGFILE ]; then 11727c478bd9Sstevel@tonic-gate mv -f $LOGFILE ${LOGFILE}- 11737c478bd9Sstevel@tonic-gatefi 11747c478bd9Sstevel@tonic-gate# 11757c478bd9Sstevel@tonic-gate# Build OsNet source 11767c478bd9Sstevel@tonic-gate# 11777c478bd9Sstevel@tonic-gateSTART_DATE=`date` 11787c478bd9Sstevel@tonic-gateSECONDS=0 11797c478bd9Sstevel@tonic-gateecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 11807c478bd9Sstevel@tonic-gate | tee -a $LOGFILE > $build_time_file 11817c478bd9Sstevel@tonic-gate 1182cdf0c1d5Smjnelsonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1183cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 1184cdf0c1d5Smjnelson 11857c478bd9Sstevel@tonic-gate# make sure we log only to the nightly build file 11867c478bd9Sstevel@tonic-gatebuild_noise_file="${TMPDIR}/build_noise" 11877c478bd9Sstevel@tonic-gateexec </dev/null >$build_noise_file 2>&1 11887c478bd9Sstevel@tonic-gate 118947703246Ssommerferun_hook SYS_PRE_NIGHTLY 119047703246Ssommerferun_hook PRE_NIGHTLY 119147703246Ssommerfe 11927c478bd9Sstevel@tonic-gateecho "\n==== list of environment variables ====\n" >> $LOGFILE 11937c478bd9Sstevel@tonic-gateenv >> $LOGFILE 11947c478bd9Sstevel@tonic-gate 11957c478bd9Sstevel@tonic-gateecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 11967c478bd9Sstevel@tonic-gate 11975110237aSJosef 'Jeff' Sipekif [ "$N_FLAG" = "y" ]; then 11985110237aSJosef 'Jeff' Sipek if [ "$p_FLAG" = "y" ]; then 11995110237aSJosef 'Jeff' Sipek cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 12007c478bd9Sstevel@tonic-gateWARNING: the p option (create packages) is set, but so is the N option (do 12017c478bd9Sstevel@tonic-gate not run protocmp); this is dangerous; you should unset the N option 12027c478bd9Sstevel@tonic-gateEOF 12035110237aSJosef 'Jeff' Sipek else 12045110237aSJosef 'Jeff' Sipek cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 12057c478bd9Sstevel@tonic-gateWarning: the N option (do not run protocmp) is set; it probably shouldn't be 12067c478bd9Sstevel@tonic-gateEOF 12077c478bd9Sstevel@tonic-gate fi 12085110237aSJosef 'Jeff' Sipek echo "" | tee -a $mail_msg_file >> $LOGFILE 12097c478bd9Sstevel@tonic-gatefi 12107c478bd9Sstevel@tonic-gate 12117c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" ]; then 12127c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "y" ]; then 12137c478bd9Sstevel@tonic-gate echo "WARNING: the -f flag cannot be used during incremental" \ 12147c478bd9Sstevel@tonic-gate "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 12157c478bd9Sstevel@tonic-gate f_FLAG=n 12167c478bd9Sstevel@tonic-gate fi 1217be0ffda9SPeter Tribble if [ "${p_FLAG}" != "y" ]; then 1218be0ffda9SPeter Tribble echo "WARNING: the -f flag requires -p;" \ 121911a78ea0SMark J. Nelson "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 12207c478bd9Sstevel@tonic-gate f_FLAG=n 12217c478bd9Sstevel@tonic-gate fi 12227c478bd9Sstevel@tonic-gatefi 12237c478bd9Sstevel@tonic-gate 122496ccc8cbSesaxeif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 12254e5b757fSkupfer echo "WARNING: -w specified, but $ROOT does not exist;" \ 122696ccc8cbSesaxe "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 122796ccc8cbSesaxe w_FLAG=n 122896ccc8cbSesaxefi 122996ccc8cbSesaxe 12304e5b757fSkupfercase $MULTI_PROTO in 12314e5b757fSkupferyes|no) ;; 12324e5b757fSkupfer*) 12334e5b757fSkupfer echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 12344e5b757fSkupfer "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 12354e5b757fSkupfer echo "Setting MULTI_PROTO to \"no\".\n" | \ 12364e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 12374e5b757fSkupfer export MULTI_PROTO=no 12384e5b757fSkupfer ;; 12394e5b757fSkupferesac 12404e5b757fSkupfer 12417c478bd9Sstevel@tonic-gateecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 12427c478bd9Sstevel@tonic-gateecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 12437c478bd9Sstevel@tonic-gate 124496ccc8cbSesaxe# Save the current proto area if we're comparing against the last build 124596ccc8cbSesaxeif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 124696ccc8cbSesaxe if [ -d "$ROOT.prev" ]; then 124796ccc8cbSesaxe rm -rf $ROOT.prev 124896ccc8cbSesaxe fi 124996ccc8cbSesaxe mv $ROOT $ROOT.prev 125096ccc8cbSesaxefi 125196ccc8cbSesaxe 12524e5b757fSkupfer# Same for non-DEBUG proto area 12534e5b757fSkupferif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 12544e5b757fSkupfer if [ -d "$ROOT-nd.prev" ]; then 12554e5b757fSkupfer rm -rf $ROOT-nd.prev 12564e5b757fSkupfer fi 12574e5b757fSkupfer mv $ROOT-nd $ROOT-nd.prev 12584e5b757fSkupferfi 12594e5b757fSkupfer 1260445b6314SRichard Lowe# 1261445b6314SRichard Lowe# Echo the SCM type of the parent workspace, this can't just be which_scm 1262445b6314SRichard Lowe# as that does not know how to identify various network repositories. 1263445b6314SRichard Lowe# 1264445b6314SRichard Lowefunction parent_wstype { 1265445b6314SRichard Lowe typeset scm_type junk 126630635de9SJohn.Zolnowsky@Sun.COM 126730635de9SJohn.Zolnowsky@Sun.COM CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1268445b6314SRichard Lowe | read scm_type junk 1269445b6314SRichard Lowe if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 127030635de9SJohn.Zolnowsky@Sun.COM # Probe BRINGOVER_WS to determine its type 1271c3e6cb59SRichard Lowe if [[ $BRINGOVER_WS == ssh://* ]]; then 1272445b6314SRichard Lowe scm_type="mercurial" 127330635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == http://* ]] && \ 1274445b6314SRichard Lowe wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 127530635de9SJohn.Zolnowsky@Sun.COM egrep -s "application/mercurial" 2> /dev/null; then 1276445b6314SRichard Lowe scm_type="mercurial" 127730635de9SJohn.Zolnowsky@Sun.COM else 1278445b6314SRichard Lowe scm_type="none" 127930635de9SJohn.Zolnowsky@Sun.COM fi 1280fb23c574SRichard Lowe fi 128130635de9SJohn.Zolnowsky@Sun.COM 128230635de9SJohn.Zolnowsky@Sun.COM # fold both unsupported and unrecognized results into "none" 1283445b6314SRichard Lowe case "$scm_type" in 1284c3e6cb59SRichard Lowe mercurial) 128530635de9SJohn.Zolnowsky@Sun.COM ;; 1286445b6314SRichard Lowe *) scm_type=none 128730635de9SJohn.Zolnowsky@Sun.COM ;; 128830635de9SJohn.Zolnowsky@Sun.COM esac 1289445b6314SRichard Lowe 1290445b6314SRichard Lowe echo $scm_type 1291445b6314SRichard Lowe} 1292445b6314SRichard Lowe 1293445b6314SRichard Lowe# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1294445b6314SRichard Lowefunction child_wstype { 1295445b6314SRichard Lowe typeset scm_type junk 1296445b6314SRichard Lowe 1297445b6314SRichard Lowe # Probe CODEMGR_WS to determine its type 1298445b6314SRichard Lowe if [[ -d $CODEMGR_WS ]]; then 1299445b6314SRichard Lowe $WHICH_SCM | read scm_type junk || exit 1 1300445b6314SRichard Lowe fi 1301445b6314SRichard Lowe 1302445b6314SRichard Lowe case "$scm_type" in 1303c3e6cb59SRichard Lowe none|git|mercurial) 130430635de9SJohn.Zolnowsky@Sun.COM ;; 1305445b6314SRichard Lowe *) scm_type=none 130630635de9SJohn.Zolnowsky@Sun.COM ;; 130730635de9SJohn.Zolnowsky@Sun.COM esac 130830635de9SJohn.Zolnowsky@Sun.COM 1309445b6314SRichard Lowe echo $scm_type 131030635de9SJohn.Zolnowsky@Sun.COM} 131130635de9SJohn.Zolnowsky@Sun.COM 13125c70f01eSRichard LoweSCM_TYPE=$(child_wstype) 131330635de9SJohn.Zolnowsky@Sun.COM 13147c478bd9Sstevel@tonic-gate# 13157c478bd9Sstevel@tonic-gate# Decide whether to clobber 13167c478bd9Sstevel@tonic-gate# 13177c478bd9Sstevel@tonic-gateif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 13187c478bd9Sstevel@tonic-gate echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 13197c478bd9Sstevel@tonic-gate 13207c478bd9Sstevel@tonic-gate cd $SRC 13217c478bd9Sstevel@tonic-gate # remove old clobber file 13227c478bd9Sstevel@tonic-gate rm -f $SRC/clobber.out 13237c478bd9Sstevel@tonic-gate rm -f $SRC/clobber-${MACH}.out 13247c478bd9Sstevel@tonic-gate 13257c478bd9Sstevel@tonic-gate # Remove all .make.state* files, just in case we are restarting 13267c478bd9Sstevel@tonic-gate # the build after having interrupted a previous 'make clobber'. 13278bcea973SRichard Lowe find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1328cdf0c1d5Smjnelson -o -name 'interfaces.*' \) -prune \ 1329cdf0c1d5Smjnelson -o -name '.make.*' -print | xargs rm -f 13307c478bd9Sstevel@tonic-gate 13317c478bd9Sstevel@tonic-gate $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 13327c478bd9Sstevel@tonic-gate echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 13337c478bd9Sstevel@tonic-gate grep "$MAKE:" $SRC/clobber-${MACH}.out | 1334cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 1335cb4d1691SRichard Lowe tee $TMPDIR/clobber_errs >> $mail_msg_file 1336cb4d1691SRichard Lowe 1337cb4d1691SRichard Lowe if [[ -s $TMPDIR/clobber_errs ]]; then 1338cb4d1691SRichard Lowe build_extras_ok=n 1339cb4d1691SRichard Lowe fi 13407c478bd9Sstevel@tonic-gate 13415110237aSJosef 'Jeff' Sipek if [[ "$t_FLAG" = "y" ]]; then 13427c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 13437c478bd9Sstevel@tonic-gate cd ${TOOLS} 13447c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/clobber-${MACH}.out 1345ead1f93eSLiane Praza $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 13467c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 13477c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber ERRORS ====\n" \ 13487c478bd9Sstevel@tonic-gate >> $mail_msg_file 13497c478bd9Sstevel@tonic-gate grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 13507c478bd9Sstevel@tonic-gate >> $mail_msg_file 1351cb4d1691SRichard Lowe if (( $? == 0 )); then 1352cb4d1691SRichard Lowe build_extras_ok=n 1353cb4d1691SRichard Lowe fi 13547c478bd9Sstevel@tonic-gate rm -rf ${TOOLS_PROTO} 13557c478bd9Sstevel@tonic-gate mkdir -p ${TOOLS_PROTO} 13567c478bd9Sstevel@tonic-gate fi 135796ccc8cbSesaxe 1358c7453724SMike Kupfer typeset roots=$(allprotos) 1359c7453724SMike Kupfer echo "\n\nClearing $roots" >> "$LOGFILE" 1360c7453724SMike Kupfer rm -rf $roots 13617c478bd9Sstevel@tonic-gate 13627c478bd9Sstevel@tonic-gate # Get back to a clean workspace as much as possible to catch 13637c478bd9Sstevel@tonic-gate # problems that only occur on fresh workspaces. 13647c478bd9Sstevel@tonic-gate # Remove all .make.state* files, libraries, and .o's that may 1365fb23a357Skupfer # have been omitted from clobber. A couple of libraries are 1366cdf0c1d5Smjnelson # under source code control, so leave them alone. 13677c478bd9Sstevel@tonic-gate # We should probably blow away temporary directories too. 13687c478bd9Sstevel@tonic-gate cd $SRC 1369cdf0c1d5Smjnelson find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 13708bcea973SRichard Lowe -o -name .git -o -name 'interfaces.*' \) -prune -o \ 13717c478bd9Sstevel@tonic-gate \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1372fb23a357Skupfer -name '*.o' \) -print | \ 1373fb23a357Skupfer grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 13747c478bd9Sstevel@tonic-gateelse 13757c478bd9Sstevel@tonic-gate echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 13767c478bd9Sstevel@tonic-gatefi 13777c478bd9Sstevel@tonic-gate 1378597bd30bSMike Kupfertype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1379cdf0c1d5Smjnelson typeset -x PATH=$PATH 1380cdf0c1d5Smjnelson 1381cdf0c1d5Smjnelson # If the repository doesn't exist yet, then we want to populate it. 1382cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.hg ]]; then 1383cdf0c1d5Smjnelson staffer hg init $CODEMGR_WS 13848cca05f6SMark J. Nelson staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 13858cca05f6SMark J. Nelson staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1386f457028bSMark J. Nelson touch $TMPDIR/new_repository 13875c53ea7aSmjnelson fi 13885c53ea7aSmjnelson 1389cdf0c1d5Smjnelson typeset -x HGMERGE="/bin/false" 1390cdf0c1d5Smjnelson 1391cdf0c1d5Smjnelson # 13925c53ea7aSmjnelson # If the user has changes, regardless of whether those changes are 13935c53ea7aSmjnelson # committed, and regardless of whether those changes conflict, then 13945c53ea7aSmjnelson # we'll attempt to merge them either implicitly (uncommitted) or 13955c53ea7aSmjnelson # explicitly (committed). 13965c53ea7aSmjnelson # 13975c53ea7aSmjnelson # These are the messages we'll use to help clarify mercurial output 13985c53ea7aSmjnelson # in those cases. 13995c53ea7aSmjnelson # 14005c53ea7aSmjnelson typeset mergefailmsg="\ 14015c53ea7aSmjnelson***\n\ 14025c53ea7aSmjnelson*** nightly was unable to automatically merge your changes. You should\n\ 14035c53ea7aSmjnelson*** redo the full merge manually, following the steps outlined by mercurial\n\ 14045c53ea7aSmjnelson*** above, then restart nightly.\n\ 14055c53ea7aSmjnelson***\n" 14065c53ea7aSmjnelson typeset mergepassmsg="\ 14075c53ea7aSmjnelson***\n\ 14085c53ea7aSmjnelson*** nightly successfully merged your changes. This means that your working\n\ 14095c53ea7aSmjnelson*** directory has been updated, but those changes are not yet committed.\n\ 14105c53ea7aSmjnelson*** After nightly completes, you should validate the results of the merge,\n\ 14115c53ea7aSmjnelson*** then use hg commit manually.\n\ 14125c53ea7aSmjnelson***\n" 14135c53ea7aSmjnelson 14145c53ea7aSmjnelson # 14155c53ea7aSmjnelson # For each repository in turn: 14165c53ea7aSmjnelson # 14175c53ea7aSmjnelson # 1. Do the pull. If this fails, dump the output and bail out. 14185c53ea7aSmjnelson # 14195c53ea7aSmjnelson # 2. If the pull resulted in an extra head, do an explicit merge. 14205c53ea7aSmjnelson # If this fails, dump the output and bail out. 14215c53ea7aSmjnelson # 14225c53ea7aSmjnelson # Because we can't rely on Mercurial to exit with a failure code 14235c53ea7aSmjnelson # when a merge fails (Mercurial issue #186), we must grep the 14245c53ea7aSmjnelson # output of pull/merge to check for attempted and/or failed merges. 14255c53ea7aSmjnelson # 14265c53ea7aSmjnelson # 3. If a merge failed, set the message and fail the bringover. 14275c53ea7aSmjnelson # 14285c53ea7aSmjnelson # 4. Otherwise, if a merge succeeded, set the message 14295c53ea7aSmjnelson # 14305c53ea7aSmjnelson # 5. Dump the output, and any message from step 3 or 4. 14315c53ea7aSmjnelson # 14325c53ea7aSmjnelson 1433f457028bSMark J. Nelson typeset HG_SOURCE=$BRINGOVER_WS 1434f457028bSMark J. Nelson if [ ! -f $TMPDIR/new_repository ]; then 1435f457028bSMark J. Nelson HG_SOURCE=$TMPDIR/open_bundle.hg 1436f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1437f457028bSMark J. Nelson -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1438f457028bSMark J. Nelson 1439f457028bSMark J. Nelson # 1440f457028bSMark J. Nelson # If there are no incoming changesets, then incoming will 1441f457028bSMark J. Nelson # fail, and there will be no bundle file. Reset the source, 1442f457028bSMark J. Nelson # to allow the remaining logic to complete with no false 1443f457028bSMark J. Nelson # negatives. (Unlike incoming, pull will return success 1444f457028bSMark J. Nelson # for the no-change case.) 1445f457028bSMark J. Nelson # 1446f457028bSMark J. Nelson if (( $? != 0 )); then 1447f457028bSMark J. Nelson HG_SOURCE=$BRINGOVER_WS 1448f457028bSMark J. Nelson fi 1449f457028bSMark J. Nelson fi 1450f457028bSMark J. Nelson 1451f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 14525c53ea7aSmjnelson > $TMPDIR/pull_open.out 2>&1 14535c53ea7aSmjnelson if (( $? != 0 )); then 14545c53ea7aSmjnelson printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 14555c53ea7aSmjnelson cat $TMPDIR/pull_open.out 14565c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 14575c53ea7aSmjnelson printf "$mergefailmsg" 14585c53ea7aSmjnelson fi 1459cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1460cdf0c1d5Smjnelson return 1461cdf0c1d5Smjnelson fi 1462cdf0c1d5Smjnelson 14635c53ea7aSmjnelson if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 14645c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS merge \ 14655c53ea7aSmjnelson >> $TMPDIR/pull_open.out 2>&1 14665c53ea7aSmjnelson if (( $? != 0 )); then 14675c53ea7aSmjnelson printf "%s: merge failed as follows:\n\n" \ 14685c53ea7aSmjnelson "$CODEMGR_WS" 14695c53ea7aSmjnelson cat $TMPDIR/pull_open.out 14705c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out \ 14715c53ea7aSmjnelson > /dev/null 2>&1; then 14725c53ea7aSmjnelson printf "$mergefailmsg" 14735c53ea7aSmjnelson fi 1474cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1475cdf0c1d5Smjnelson return 1476cdf0c1d5Smjnelson fi 1477cdf0c1d5Smjnelson fi 1478cdf0c1d5Smjnelson 14795c53ea7aSmjnelson printf "updated %s with the following results:\n" "$CODEMGR_WS" 14805c53ea7aSmjnelson cat $TMPDIR/pull_open.out 14815c53ea7aSmjnelson if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 14825c53ea7aSmjnelson printf "$mergepassmsg" 1483cdf0c1d5Smjnelson fi 14845c53ea7aSmjnelson printf "\n" 1485cdf0c1d5Smjnelson 1486f457028bSMark J. Nelson # 1487f457028bSMark J. Nelson # Per-changeset output is neither useful nor manageable for a 1488f457028bSMark J. Nelson # newly-created repository. 1489f457028bSMark J. Nelson # 1490f457028bSMark J. Nelson if [ -f $TMPDIR/new_repository ]; then 1491f457028bSMark J. Nelson return 1492f457028bSMark J. Nelson fi 1493f457028bSMark J. Nelson 1494f457028bSMark J. Nelson printf "\nadded the following changesets to open repository:\n" 1495f457028bSMark J. Nelson cat $TMPDIR/incoming_open.out 1496cdf0c1d5Smjnelson} 1497cdf0c1d5Smjnelson 1498597bd30bSMike Kupfertype bringover_none > /dev/null 2>&1 || function bringover_none { 1499cdf0c1d5Smjnelson echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1500cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1501cdf0c1d5Smjnelson} 1502cdf0c1d5Smjnelson 1503cdf0c1d5Smjnelson# 1504cdf0c1d5Smjnelson# Decide whether to bringover to the codemgr workspace 1505cdf0c1d5Smjnelson# 1506cdf0c1d5Smjnelsonif [ "$n_FLAG" = "n" ]; then 1507445b6314SRichard Lowe PARENT_SCM_TYPE=$(parent_wstype) 1508ca0ac982Smjnelson 1509ca0ac982Smjnelson if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1510ca0ac982Smjnelson echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1511ca0ac982Smjnelson "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 1512ca0ac982Smjnelson exit 1 1513ca0ac982Smjnelson fi 1514ca0ac982Smjnelson 1515cdf0c1d5Smjnelson run_hook PRE_BRINGOVER 1516cdf0c1d5Smjnelson 1517cdf0c1d5Smjnelson echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1518cdf0c1d5Smjnelson echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1519cdf0c1d5Smjnelson 1520ca0ac982Smjnelson eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 1521cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 152232f1e47bSsommerfe 1523d77e7149Ssommerfe if [ -f $TMPDIR/bringover_failed ]; then 152432f1e47bSsommerfe rm -f $TMPDIR/bringover_failed 152532f1e47bSsommerfe build_ok=n 1526d77e7149Ssommerfe echo "trouble with bringover, quitting at `date`." | 152732f1e47bSsommerfe tee -a $mail_msg_file >> $LOGFILE 15287c478bd9Sstevel@tonic-gate exit 1 15297c478bd9Sstevel@tonic-gate fi 1530085d331dSkupfer 1531ca0ac982Smjnelson # 1532ca0ac982Smjnelson # It's possible that we used the bringover above to create 1533ca0ac982Smjnelson # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 1534ca0ac982Smjnelson # but should now be the same as $BRINGOVER_WS. 1535ca0ac982Smjnelson # 1536ca0ac982Smjnelson [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 1537ca0ac982Smjnelson 153847703246Ssommerfe run_hook POST_BRINGOVER 153947703246Ssommerfe 1540c3e6cb59SRichard Lowe check_closed_bins 1541b83ec4edSjmcp 15427c478bd9Sstevel@tonic-gateelse 15437c478bd9Sstevel@tonic-gate echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 15447c478bd9Sstevel@tonic-gatefi 15457c478bd9Sstevel@tonic-gate 1546220399b7SRoland Mainz# Safeguards 1547220399b7SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 1548220399b7SRoland Mainz[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 1549220399b7SRoland Mainz[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 1550220399b7SRoland Mainz 1551305fdadfSYuri Pankovif [[ "$t_FLAG" = "y" ]]; then 1552391889ecSAndy Fiddaman set_non_debug_build_flags 1553391889ecSAndy Fiddaman bootstrap_tools || fatal_error "Error: could not bootstrap tools" 1554305fdadfSYuri Pankov 1555305fdadfSYuri Pankov # Switch ONBLD_TOOLS early if -t is specified so that 1556305fdadfSYuri Pankov # we could use bootstrapped cw for compiler checks. 1557305fdadfSYuri Pankov ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld 1558305fdadfSYuri Pankov export ONBLD_TOOLS 1559305fdadfSYuri Pankovfi 1560305fdadfSYuri Pankov 1561cdf0c1d5Smjnelsonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 1562cdf0c1d5Smjnelson 1563cdf0c1d5Smjnelson# System 1564cdf0c1d5Smjnelsonwhence uname | tee -a $build_environ_file >> $LOGFILE 1565cdf0c1d5Smjnelsonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 1566cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1567cdf0c1d5Smjnelson 1568cdf0c1d5Smjnelson# make 1569cdf0c1d5Smjnelsonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 1570cdf0c1d5Smjnelson$MAKE -v | tee -a $build_environ_file >> $LOGFILE 1571cdf0c1d5Smjnelsonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1572cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1573cdf0c1d5Smjnelson 1574cdf0c1d5Smjnelson# 1575cdf0c1d5Smjnelson# Report the compiler versions. 1576cdf0c1d5Smjnelson# 1577cdf0c1d5Smjnelson 1578cdf0c1d5Smjnelsonif [[ ! -f $SRC/Makefile ]]; then 1579cdf0c1d5Smjnelson build_ok=n 1580cdf0c1d5Smjnelson echo "\nUnable to find \"Makefile\" in $SRC." | \ 1581cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1582cdf0c1d5Smjnelson exit 1 1583cdf0c1d5Smjnelsonfi 1584cdf0c1d5Smjnelson 1585cdf0c1d5Smjnelson( cd $SRC 1586aa9ef484SJohn Levon for target in cc-version java-version openssl-version; do 1587cdf0c1d5Smjnelson echo 1588cdf0c1d5Smjnelson # 1589cdf0c1d5Smjnelson # Put statefile somewhere we know we can write to rather than trip 1590cdf0c1d5Smjnelson # over a read-only $srcroot. 1591cdf0c1d5Smjnelson # 1592cdf0c1d5Smjnelson rm -f $TMPDIR/make-state 1593cdf0c1d5Smjnelson export SRC 1594cdf0c1d5Smjnelson if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1595cdf0c1d5Smjnelson continue 1596cdf0c1d5Smjnelson fi 1597cdf0c1d5Smjnelson touch $TMPDIR/nocompiler 1598cdf0c1d5Smjnelson done 1599cdf0c1d5Smjnelson echo 1600cdf0c1d5Smjnelson) | tee -a $build_environ_file >> $LOGFILE 1601cdf0c1d5Smjnelson 1602cdf0c1d5Smjnelsonif [ -f $TMPDIR/nocompiler ]; then 1603cdf0c1d5Smjnelson rm -f $TMPDIR/nocompiler 1604cdf0c1d5Smjnelson build_ok=n 1605cdf0c1d5Smjnelson echo "Aborting due to missing compiler." | 1606cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1607cdf0c1d5Smjnelson exit 1 1608cdf0c1d5Smjnelsonfi 1609cdf0c1d5Smjnelson 1610cdf0c1d5Smjnelson# as 1611cdf0c1d5Smjnelsonwhence as | tee -a $build_environ_file >> $LOGFILE 1612cdf0c1d5Smjnelsonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 1613cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1614cdf0c1d5Smjnelson 1615cdf0c1d5Smjnelson# Check that we're running a capable link-editor 1616cdf0c1d5Smjnelsonwhence ld | tee -a $build_environ_file >> $LOGFILE 1617cdf0c1d5SmjnelsonLDVER=`ld -V 2>&1` 1618cdf0c1d5Smjnelsonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 161970087ad3SRichard LoweLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 1620cdf0c1d5Smjnelsonif [ `expr $LDVER \< 422` -eq 1 ]; then 1621cdf0c1d5Smjnelson echo "The link-editor needs to be at version 422 or higher to build" | \ 1622cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1623cdf0c1d5Smjnelson echo "the latest stuff. Hope your build works." | \ 1624cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1625cdf0c1d5Smjnelsonfi 1626cdf0c1d5Smjnelson 16277c478bd9Sstevel@tonic-gate# 16284e5b757fSkupfer# Build and use the workspace's tools if requested 16297c478bd9Sstevel@tonic-gate# 16305110237aSJosef 'Jeff' Sipekif [[ "$t_FLAG" = "y" ]]; then 16314e5b757fSkupfer set_non_debug_build_flags 16327c478bd9Sstevel@tonic-gate 16337c478bd9Sstevel@tonic-gate build_tools ${TOOLS_PROTO} 1634cb4d1691SRichard Lowe if (( $? != 0 )); then 1635cb4d1691SRichard Lowe build_ok=n 1636cb4d1691SRichard Lowe else 1637305fdadfSYuri Pankov STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs 1638305fdadfSYuri Pankov export STABS 1639305fdadfSYuri Pankov CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs 1640305fdadfSYuri Pankov export CTFSTABS 1641305fdadfSYuri Pankov GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets 1642305fdadfSYuri Pankov export GENOFFSETS 1643305fdadfSYuri Pankov 1644305fdadfSYuri Pankov CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert 1645305fdadfSYuri Pankov export CTFCONVERT 1646305fdadfSYuri Pankov CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge 1647305fdadfSYuri Pankov export CTFMERGE 1648305fdadfSYuri Pankov 1649305fdadfSYuri Pankov PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}" 1650305fdadfSYuri Pankov PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}" 1651305fdadfSYuri Pankov export PATH 1652305fdadfSYuri Pankov 1653305fdadfSYuri Pankov echo "\n==== New environment settings. ====\n" >> $LOGFILE 1654305fdadfSYuri Pankov echo "STABS=${STABS}" >> $LOGFILE 1655305fdadfSYuri Pankov echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 1656305fdadfSYuri Pankov echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 1657305fdadfSYuri Pankov echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 1658305fdadfSYuri Pankov echo "PATH=${PATH}" >> $LOGFILE 1659305fdadfSYuri Pankov echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 16604e5b757fSkupfer fi 16617c478bd9Sstevel@tonic-gatefi 16627c478bd9Sstevel@tonic-gate 16635110237aSJosef 'Jeff' Sipek# timestamp the start of the normal build; the findunref tool uses it. 16645110237aSJosef 'Jeff' Sipektouch $SRC/.build.tstamp 16655d715dd7Skupfer 16665110237aSJosef 'Jeff' Sipeknormal_build 16675d715dd7Skupfer 16687c478bd9Sstevel@tonic-gateORIG_SRC=$SRC 16697c478bd9Sstevel@tonic-gateBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 16707c478bd9Sstevel@tonic-gate 16717c478bd9Sstevel@tonic-gate 16724e5b757fSkupfer# 16734e5b757fSkupfer# There are several checks that need to look at the proto area, but 16744e5b757fSkupfer# they only need to look at one, and they don't care whether it's 16754e5b757fSkupfer# DEBUG or non-DEBUG. 16764e5b757fSkupfer# 16774e5b757fSkupferif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 16784e5b757fSkupfer checkroot=$ROOT-nd 16794e5b757fSkupferelse 16804e5b757fSkupfer checkroot=$ROOT 16814e5b757fSkupferfi 16824e5b757fSkupfer 16837c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 16847c478bd9Sstevel@tonic-gate echo "\n==== Creating protolist system file at `date` ====" \ 16857c478bd9Sstevel@tonic-gate >> $LOGFILE 16864e5b757fSkupfer protolist $checkroot > $ATLOG/proto_list_${MACH} 16877c478bd9Sstevel@tonic-gate echo "==== protolist system file created at `date` ====\n" \ 16887c478bd9Sstevel@tonic-gate >> $LOGFILE 16897c478bd9Sstevel@tonic-gate 16907c478bd9Sstevel@tonic-gate if [ "$N_FLAG" != "y" ]; then 16917c478bd9Sstevel@tonic-gate 1692ead1f93eSLiane Praza E1= 1693ead1f93eSLiane Praza f1= 1694ead1f93eSLiane Praza for f in $f1; do 1695ead1f93eSLiane Praza if [ -f "$f" ]; then 1696ead1f93eSLiane Praza E1="$E1 -e $f" 1697ead1f93eSLiane Praza fi 1698ead1f93eSLiane Praza done 1699ead1f93eSLiane Praza 1700ead1f93eSLiane Praza E2= 1701ead1f93eSLiane Praza f2= 1702ead1f93eSLiane Praza if [ -d "$SRC/pkg" ]; then 1703ead1f93eSLiane Praza f2="$f2 exceptions/packaging" 17046fec3625Sdduvall fi 17057c478bd9Sstevel@tonic-gate 1706ead1f93eSLiane Praza for f in $f2; do 1707ead1f93eSLiane Praza if [ -f "$f" ]; then 1708ead1f93eSLiane Praza E2="$E2 -e $f" 1709ead1f93eSLiane Praza fi 1710ead1f93eSLiane Praza done 1711ead1f93eSLiane Praza fi 17127c478bd9Sstevel@tonic-gate 1713ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 1714ead1f93eSLiane Praza echo "\n==== Validating manifests against proto area ====\n" \ 1715ead1f93eSLiane Praza >> $mail_msg_file 1716cb4d1691SRichard Lowe ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1717cb4d1691SRichard Lowe tee $TMPDIR/protocmp_noise >> $mail_msg_file 1718cb4d1691SRichard Lowe if [[ -s $TMPDIR/protocmp_noise ]]; then 1719cb4d1691SRichard Lowe build_extras_ok=n 1720cb4d1691SRichard Lowe fi 1721ead1f93eSLiane Praza fi 1722ead1f93eSLiane Praza 1723ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 1724ead1f93eSLiane Praza echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 1725ead1f93eSLiane Praza if [ -n "$E2" ]; then 1726ead1f93eSLiane Praza ELIST=$E2 1727ead1f93eSLiane Praza else 1728ead1f93eSLiane Praza ELIST=$E1 1729ead1f93eSLiane Praza fi 1730ead1f93eSLiane Praza $PROTOCMPTERSE \ 1731ead1f93eSLiane Praza "Files in yesterday's proto area, but not today's:" \ 1732ead1f93eSLiane Praza "Files in today's proto area, but not yesterday's:" \ 1733ead1f93eSLiane Praza "Files that changed between yesterday and today:" \ 1734ead1f93eSLiane Praza ${ELIST} \ 1735ead1f93eSLiane Praza -d $REF_PROTO_LIST \ 1736ead1f93eSLiane Praza $ATLOG/proto_list_${MACH} \ 1737ead1f93eSLiane Praza >> $mail_msg_file 17387c478bd9Sstevel@tonic-gate fi 17397c478bd9Sstevel@tonic-gatefi 17407c478bd9Sstevel@tonic-gate 1741cb4d1691SRichard Loweif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 1742cb4d1691SRichard Lowe "$build_extras_ok" == "y" ]]; then 17437c478bd9Sstevel@tonic-gate staffer cp $ATLOG/proto_list_${MACH} \ 17447c478bd9Sstevel@tonic-gate $PARENT_WS/usr/src/proto_list_${MACH} 17457c478bd9Sstevel@tonic-gatefi 17467c478bd9Sstevel@tonic-gate 17477c478bd9Sstevel@tonic-gate# Update parent proto area if necessary. This is done now 17487c478bd9Sstevel@tonic-gate# so that the proto area has either DEBUG or non-DEBUG kernels. 17497c478bd9Sstevel@tonic-gate# Note that this clears out the lock file, so we can dispense with 17507c478bd9Sstevel@tonic-gate# the variable now. 17517c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 17527c478bd9Sstevel@tonic-gate echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 17537c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 1754ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT/* 17557c478bd9Sstevel@tonic-gate unset Ulockfile 17567c478bd9Sstevel@tonic-gate mkdir -p $NIGHTLY_PARENT_ROOT 17574e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1758ead1f93eSLiane Praza ( cd $ROOT; tar cf - . | 17594e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 17604e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 17614e5b757fSkupfer fi 17624e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 1763ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT-nd/* 17644e5b757fSkupfer mkdir -p $NIGHTLY_PARENT_ROOT-nd 17654e5b757fSkupfer cd $ROOT-nd 17664e5b757fSkupfer ( tar cf - . | 17674e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 17684e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 17694e5b757fSkupfer fi 17706798c3f0SMark J. Nelson if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 17716798c3f0SMark J. Nelson echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 17726798c3f0SMark J. Nelson tee -a $LOGFILE >> $mail_msg_file 17736798c3f0SMark J. Nelson rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 17746798c3f0SMark J. Nelson mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 17756798c3f0SMark J. Nelson if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 17766798c3f0SMark J. Nelson ( cd $TOOLS_PROTO; tar cf - . | 1777fb23c574SRichard Lowe ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 17786798c3f0SMark J. Nelson umask 0; tar xpf - ) ) 2>&1 | 17796798c3f0SMark J. Nelson tee -a $mail_msg_file >> $LOGFILE 17806798c3f0SMark J. Nelson fi 1781ead1f93eSLiane Praza fi 17827c478bd9Sstevel@tonic-gatefi 17837c478bd9Sstevel@tonic-gate 17847c478bd9Sstevel@tonic-gate# 178575ce41a5SAli Bahrami# ELF verification: ABI (-A) and runtime (-r) checks 17867c478bd9Sstevel@tonic-gate# 1787cb4d1691SRichard Loweif [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 178875ce41a5SAli Bahrami # Directory ELF-data.$MACH holds the files produced by these tests. 178975ce41a5SAli Bahrami elf_ddir=$SRC/ELF-data.$MACH 17907c478bd9Sstevel@tonic-gate 179175ce41a5SAli Bahrami # If there is a previous ELF-data backup directory, remove it. Then, 179275ce41a5SAli Bahrami # rotate current ELF-data directory into its place and create a new 179375ce41a5SAli Bahrami # empty directory 179475ce41a5SAli Bahrami rm -rf $elf_ddir.ref 179575ce41a5SAli Bahrami if [[ -d $elf_ddir ]]; then 179675ce41a5SAli Bahrami mv $elf_ddir $elf_ddir.ref 17977c478bd9Sstevel@tonic-gate fi 179875ce41a5SAli Bahrami mkdir -p $elf_ddir 17997c478bd9Sstevel@tonic-gate 180075ce41a5SAli Bahrami # Call find_elf to produce a list of the ELF objects in the proto area. 180175ce41a5SAli Bahrami # This list is passed to check_rtime and interface_check, preventing 180275ce41a5SAli Bahrami # them from separately calling find_elf to do the same work twice. 180375ce41a5SAli Bahrami find_elf -fr $checkroot > $elf_ddir/object_list 18047c478bd9Sstevel@tonic-gate 180575ce41a5SAli Bahrami if [[ $A_FLAG = y ]]; then 1806fb23c574SRichard Lowe echo "\n==== Check versioning and ABI information ====\n" | \ 180775ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file 18087c478bd9Sstevel@tonic-gate 180975ce41a5SAli Bahrami # Produce interface description for the proto. Report errors. 181075ce41a5SAli Bahrami interface_check -o -w $elf_ddir -f object_list \ 181175ce41a5SAli Bahrami -i interface -E interface.err 181275ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.err ]]; then 181375ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/interface.err \ 1814cb4d1691SRichard Lowe >> $mail_msg_file 1815cb4d1691SRichard Lowe build_extras_ok=n 18167c478bd9Sstevel@tonic-gate fi 18177c478bd9Sstevel@tonic-gate 18185253169eSAli Bahrami # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 18195253169eSAli Bahrami # description file to that from the baseline gate. Issue a 18205253169eSAli Bahrami # warning if the baseline is not present, and keep going. 18215253169eSAli Bahrami if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 18225253169eSAli Bahrami base_ifile="$ELF_DATA_BASELINE_DIR/interface" 18235253169eSAli Bahrami 1824be0ffda9SPeter Tribble echo "\n==== Compare versioning and ABI information" \ 1825e599109eSAli Bahrami "to baseline ====\n" | \ 18265253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 1827fb23c574SRichard Lowe echo "Baseline: $base_ifile\n" >> $LOGFILE 18285253169eSAli Bahrami 18295253169eSAli Bahrami if [[ -f $base_ifile ]]; then 18305253169eSAli Bahrami interface_cmp -d -o $base_ifile \ 18315253169eSAli Bahrami $elf_ddir/interface > $elf_ddir/interface.cmp 18325253169eSAli Bahrami if [[ -s $elf_ddir/interface.cmp ]]; then 18335253169eSAli Bahrami echo | tee -a $LOGFILE >> $mail_msg_file 18345253169eSAli Bahrami tee -a $LOGFILE < \ 18355253169eSAli Bahrami $elf_ddir/interface.cmp \ 18365253169eSAli Bahrami >> $mail_msg_file 1837cb4d1691SRichard Lowe build_extras_ok=n 18385253169eSAli Bahrami fi 18395253169eSAli Bahrami else 1840fb23c574SRichard Lowe echo "baseline not available. comparison" \ 18415253169eSAli Bahrami "skipped" | \ 18425253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 18435253169eSAli Bahrami fi 18447c478bd9Sstevel@tonic-gate 184575ce41a5SAli Bahrami fi 18467c478bd9Sstevel@tonic-gate fi 18477c478bd9Sstevel@tonic-gate 184875ce41a5SAli Bahrami if [[ $r_FLAG = y ]]; then 184975ce41a5SAli Bahrami echo "\n==== Check ELF runtime attributes ====\n" | \ 185075ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file 18517c478bd9Sstevel@tonic-gate 1852ead1f93eSLiane Praza # If we're doing a DEBUG build the proto area will be left 185375ce41a5SAli Bahrami # with debuggable objects, thus don't assert -s. 185475ce41a5SAli Bahrami if [[ $D_FLAG = y ]]; then 185575ce41a5SAli Bahrami rtime_sflag="" 185675ce41a5SAli Bahrami else 185775ce41a5SAli Bahrami rtime_sflag="-s" 185875ce41a5SAli Bahrami fi 185975ce41a5SAli Bahrami check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 186075ce41a5SAli Bahrami -D object_list -f object_list -E runtime.err \ 1861622090e3SAli Bahrami -I runtime.attr.raw 1862cb4d1691SRichard Lowe if (( $? != 0 )); then 1863cb4d1691SRichard Lowe build_extras_ok=n 1864cb4d1691SRichard Lowe fi 1865622090e3SAli Bahrami 1866fb23c574SRichard Lowe # check_rtime -I output needs to be sorted in order to 1867622090e3SAli Bahrami # compare it to that from previous builds. 1868622090e3SAli Bahrami sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 1869622090e3SAli Bahrami rm $elf_ddir/runtime.attr.raw 18707c478bd9Sstevel@tonic-gate 187175ce41a5SAli Bahrami # Report errors 187275ce41a5SAli Bahrami if [[ -s $elf_ddir/runtime.err ]]; then 187375ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/runtime.err \ 187475ce41a5SAli Bahrami >> $mail_msg_file 1875cb4d1691SRichard Lowe build_extras_ok=n 187675ce41a5SAli Bahrami fi 18777c478bd9Sstevel@tonic-gate 187875ce41a5SAli Bahrami # If there is an ELF-data directory from a previous build, 187975ce41a5SAli Bahrami # then diff the attr files. These files contain information 188075ce41a5SAli Bahrami # about dependencies, versioning, and runpaths. There is some 188175ce41a5SAli Bahrami # overlap with the ABI checking done above, but this also 188275ce41a5SAli Bahrami # flushes out non-ABI interface differences along with the 188375ce41a5SAli Bahrami # other information. 188475ce41a5SAli Bahrami echo "\n==== Diff ELF runtime attributes" \ 188575ce41a5SAli Bahrami "(since last build) ====\n" | \ 188675ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 188775ce41a5SAli Bahrami 188875ce41a5SAli Bahrami if [[ -f $elf_ddir.ref/runtime.attr ]]; then 188975ce41a5SAli Bahrami diff $elf_ddir.ref/runtime.attr \ 189075ce41a5SAli Bahrami $elf_ddir/runtime.attr \ 189175ce41a5SAli Bahrami >> $mail_msg_file 189275ce41a5SAli Bahrami fi 18937c478bd9Sstevel@tonic-gate fi 18945253169eSAli Bahrami 18955253169eSAli Bahrami # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 18965253169eSAli Bahrami if [[ "$u_FLAG" = "y" ]]; then 18975253169eSAli Bahrami p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 18985253169eSAli Bahrami 18995253169eSAli Bahrami # If parent lacks the ELF-data.$MACH directory, create it 19005253169eSAli Bahrami if [[ ! -d $p_elf_ddir ]]; then 19015253169eSAli Bahrami staffer mkdir -p $p_elf_ddir 19025253169eSAli Bahrami fi 19035253169eSAli Bahrami 19045253169eSAli Bahrami # These files are used asynchronously by other builds for ABI 19055253169eSAli Bahrami # verification, as above for the -A option. As such, we require 19065253169eSAli Bahrami # the file replacement to be atomic. Copy the data to a temp 1907fb23c574SRichard Lowe # file in the same filesystem and then rename into place. 19085253169eSAli Bahrami ( 19095253169eSAli Bahrami cd $elf_ddir 19105253169eSAli Bahrami for elf_dfile in *; do 19115253169eSAli Bahrami staffer cp $elf_dfile \ 19125253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile}.new 19135253169eSAli Bahrami staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 19145253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile} 19155253169eSAli Bahrami done 19165253169eSAli Bahrami ) 19175253169eSAli Bahrami fi 19187c478bd9Sstevel@tonic-gatefi 19197c478bd9Sstevel@tonic-gate 19207c478bd9Sstevel@tonic-gate# "make check" begins 19217c478bd9Sstevel@tonic-gate 19227c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 19237c478bd9Sstevel@tonic-gate # remove old check.out 19247c478bd9Sstevel@tonic-gate rm -f $SRC/check.out 19257c478bd9Sstevel@tonic-gate 19267c478bd9Sstevel@tonic-gate rm -f $SRC/check-${MACH}.out 19277c478bd9Sstevel@tonic-gate cd $SRC 1928170832d3SAlbert Lee $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 1929170832d3SAlbert Lee >> $LOGFILE 19307c478bd9Sstevel@tonic-gate echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 19317c478bd9Sstevel@tonic-gate 19327c478bd9Sstevel@tonic-gate grep ":" $SRC/check-${MACH}.out | 19337c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 1934cb4d1691SRichard Lowe sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 1935cb4d1691SRichard Lowe 1936cb4d1691SRichard Lowe if [[ -s $TMPDIR/check_errors ]]; then 1937cb4d1691SRichard Lowe build_extras_ok=n 1938cb4d1691SRichard Lowe fi 19397c478bd9Sstevel@tonic-gateelse 19407c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 19417c478bd9Sstevel@tonic-gatefi 19427c478bd9Sstevel@tonic-gate 19437c478bd9Sstevel@tonic-gateecho "\n==== Find core files ====\n" | \ 19447c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 19457c478bd9Sstevel@tonic-gate 1946fb23a357Skupferfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 19477c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 19487c478bd9Sstevel@tonic-gate 19497c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 19507c478bd9Sstevel@tonic-gate echo "\n==== Diff unreferenced files (since last build) ====\n" \ 19517c478bd9Sstevel@tonic-gate | tee -a $LOGFILE >>$mail_msg_file 19527c478bd9Sstevel@tonic-gate rm -f $SRC/unref-${MACH}.ref 19537c478bd9Sstevel@tonic-gate if [ -f $SRC/unref-${MACH}.out ]; then 19547c478bd9Sstevel@tonic-gate mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 19557c478bd9Sstevel@tonic-gate fi 19567c478bd9Sstevel@tonic-gate 19579730304dSmeem findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 1958cdf0c1d5Smjnelson ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 19599730304dSmeem sort > $SRC/unref-${MACH}.out 19607c478bd9Sstevel@tonic-gate 19617c478bd9Sstevel@tonic-gate if [ ! -f $SRC/unref-${MACH}.ref ]; then 19627c478bd9Sstevel@tonic-gate cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 19637c478bd9Sstevel@tonic-gate fi 19647c478bd9Sstevel@tonic-gate 19657c478bd9Sstevel@tonic-gate diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 19667c478bd9Sstevel@tonic-gatefi 19677c478bd9Sstevel@tonic-gate 19687c478bd9Sstevel@tonic-gate# Verify that the usual lists of files, such as exception lists, 19697c478bd9Sstevel@tonic-gate# contain only valid references to files. If the build has failed, 19707c478bd9Sstevel@tonic-gate# then don't check the proto area. 19717c478bd9Sstevel@tonic-gateCHECK_PATHS=${CHECK_PATHS:-y} 19727c478bd9Sstevel@tonic-gateif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 19737c478bd9Sstevel@tonic-gate echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 19747c478bd9Sstevel@tonic-gate >>$mail_msg_file 19757c478bd9Sstevel@tonic-gate arg=-b 19767c478bd9Sstevel@tonic-gate [ "$build_ok" = y ] && arg= 1977e2c8add4SRichard PALO checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 1978e2c8add4SRichard PALO if [[ -s $SRC/check-paths.out ]]; then 1979e2c8add4SRichard PALO tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 1980cb4d1691SRichard Lowe build_extras_ok=n 1981cb4d1691SRichard Lowe fi 19827c478bd9Sstevel@tonic-gatefi 19837c478bd9Sstevel@tonic-gate 1984069e6b7eSAndy Fiddamanabspkg= 1985069e6b7eSAndy Fiddamanfor d in $abssrcdirs; do 1986069e6b7eSAndy Fiddaman if [ -d "$d/pkg" ]; then 1987069e6b7eSAndy Fiddaman abspkg="$abspkg $d" 1988069e6b7eSAndy Fiddaman fi 1989069e6b7eSAndy Fiddamandone 1990069e6b7eSAndy Fiddaman 19917c478bd9Sstevel@tonic-gateif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 19927c478bd9Sstevel@tonic-gate echo "\n==== Impact on file permissions ====\n" \ 19937c478bd9Sstevel@tonic-gate >> $mail_msg_file 1994ead1f93eSLiane Praza 1995ead1f93eSLiane Praza if [ -n "$abspkg" ]; then 1996ead1f93eSLiane Praza for d in "$abspkg"; do 1997ead1f93eSLiane Praza ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 1998ead1f93eSLiane Praza done 1999ead1f93eSLiane Praza fi 20007c478bd9Sstevel@tonic-gatefi 20017c478bd9Sstevel@tonic-gate 2002069e6b7eSAndy Fiddamanif [ "$L_FLAG" != "y" -a "$build_ok" = y ]; then 2003069e6b7eSAndy Fiddaman echo "\n==== Linting packages ====\n" | \ 2004069e6b7eSAndy Fiddaman tee -a $LOGFILE >> $mail_msg_file 2005069e6b7eSAndy Fiddaman 2006069e6b7eSAndy Fiddaman if [ -n "$abspkg" ]; then 2007069e6b7eSAndy Fiddaman for d in "$abspkg"; do 2008069e6b7eSAndy Fiddaman ( cd $d/pkg ; $MAKE -e pkglint ) | \ 2009069e6b7eSAndy Fiddaman tee -a $LOGFILE | \ 2010069e6b7eSAndy Fiddaman egrep -v 'Lint engine setup|Starting lint run' 2011069e6b7eSAndy Fiddaman done 2>&1 | tee $TMPDIR/pkglint_noise >> $mail_msg_file 2012069e6b7eSAndy Fiddaman if [[ -s $TMPDIR/pkglint_noise ]]; then 2013069e6b7eSAndy Fiddaman build_extras_ok=n 2014069e6b7eSAndy Fiddaman fi 2015069e6b7eSAndy Fiddaman fi 2016069e6b7eSAndy Fiddamanfi 2017069e6b7eSAndy Fiddaman 201896ccc8cbSesaxeif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 20194e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 20204e5b757fSkupfer do_wsdiff DEBUG $ROOT.prev $ROOT 20214e5b757fSkupfer fi 202296ccc8cbSesaxe 20234e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 20244e5b757fSkupfer do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 202596ccc8cbSesaxe fi 202696ccc8cbSesaxefi 202796ccc8cbSesaxe 20287c478bd9Sstevel@tonic-gateEND_DATE=`date` 20297c478bd9Sstevel@tonic-gateecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 20307c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 20317c478bd9Sstevel@tonic-gate 2032c341b28aSDarren Moffattypeset -i10 hours 20337c478bd9Sstevel@tonic-gatetypeset -Z2 minutes 20347c478bd9Sstevel@tonic-gatetypeset -Z2 seconds 20357c478bd9Sstevel@tonic-gate 20367c478bd9Sstevel@tonic-gateelapsed_time=$SECONDS 20377c478bd9Sstevel@tonic-gate((hours = elapsed_time / 3600 )) 20387c478bd9Sstevel@tonic-gate((minutes = elapsed_time / 60 % 60)) 20397c478bd9Sstevel@tonic-gate((seconds = elapsed_time % 60)) 20407c478bd9Sstevel@tonic-gate 20417c478bd9Sstevel@tonic-gateecho "\n==== Total build time ====" | \ 20427c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 20437c478bd9Sstevel@tonic-gateecho "\nreal ${hours}:${minutes}:${seconds}" | \ 20447c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 20457c478bd9Sstevel@tonic-gate 20467c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 20477c478bd9Sstevel@tonic-gate staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 20487c478bd9Sstevel@tonic-gate 20497c478bd9Sstevel@tonic-gate # 20507c478bd9Sstevel@tonic-gate # Produce a master list of unreferenced files -- ideally, we'd 20517c478bd9Sstevel@tonic-gate # generate the master just once after all of the nightlies 20527c478bd9Sstevel@tonic-gate # have finished, but there's no simple way to know when that 20537c478bd9Sstevel@tonic-gate # will be. Instead, we assume that we're the last nightly to 20547c478bd9Sstevel@tonic-gate # finish and merge all of the unref-${MACH}.out files in 20557c478bd9Sstevel@tonic-gate # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 20567c478bd9Sstevel@tonic-gate # finish, then this file will be the authoritative master 20577c478bd9Sstevel@tonic-gate # list. Otherwise, another ${MACH}'s nightly will eventually 20587c478bd9Sstevel@tonic-gate # overwrite ours with its own master, but in the meantime our 20597c478bd9Sstevel@tonic-gate # temporary "master" will be no worse than any older master 20607c478bd9Sstevel@tonic-gate # which was already on the parent. 20617c478bd9Sstevel@tonic-gate # 20627c478bd9Sstevel@tonic-gate 20637c478bd9Sstevel@tonic-gate set -- $PARENT_WS/usr/src/unref-*.out 20647c478bd9Sstevel@tonic-gate cp "$1" ${TMPDIR}/unref.merge 20657c478bd9Sstevel@tonic-gate shift 20667c478bd9Sstevel@tonic-gate 20677c478bd9Sstevel@tonic-gate for unreffile; do 20687c478bd9Sstevel@tonic-gate comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 20697c478bd9Sstevel@tonic-gate mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 20707c478bd9Sstevel@tonic-gate done 20717c478bd9Sstevel@tonic-gate 20727c478bd9Sstevel@tonic-gate staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 20737c478bd9Sstevel@tonic-gatefi 20747c478bd9Sstevel@tonic-gate 20757c478bd9Sstevel@tonic-gate# 20767c478bd9Sstevel@tonic-gate# All done save for the sweeping up. 2077d77e7149Ssommerfe# (whichever exit we hit here will trigger the "cleanup" trap which 20787c478bd9Sstevel@tonic-gate# optionally sends mail on completion). 20797c478bd9Sstevel@tonic-gate# 2080cb4d1691SRichard Loweif [[ "$build_ok" == "y" ]]; then 2081cb4d1691SRichard Lowe if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 2082cb4d1691SRichard Lowe exit 0 2083cb4d1691SRichard Lowe fi 20847c478bd9Sstevel@tonic-gatefi 2085cb4d1691SRichard Lowe 20867c478bd9Sstevel@tonic-gateexit 1 2087