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> 287c478bd9Sstevel@tonic-gate# 297c478bd9Sstevel@tonic-gate# Based on the nightly script from the integration folks, 307c478bd9Sstevel@tonic-gate# Mostly modified and owned by mike_s. 317c478bd9Sstevel@tonic-gate# Changes also by kjc, dmk. 327c478bd9Sstevel@tonic-gate# 337c478bd9Sstevel@tonic-gate# BRINGOVER_WS may be specified in the env file. 347c478bd9Sstevel@tonic-gate# The default is the old behavior of CLONE_WS 357c478bd9Sstevel@tonic-gate# 367c478bd9Sstevel@tonic-gate# -i on the command line, means fast options, so when it's on the 37d77e7149Ssommerfe# command line (only), lint and check builds are skipped no matter what 38d77e7149Ssommerfe# the setting of their individual flags are in NIGHTLY_OPTIONS. 397c478bd9Sstevel@tonic-gate# 407c478bd9Sstevel@tonic-gate# LINTDIRS can be set in the env file, format is a list of: 417c478bd9Sstevel@tonic-gate# 427c478bd9Sstevel@tonic-gate# /dirname-to-run-lint-on flag 437c478bd9Sstevel@tonic-gate# 447c478bd9Sstevel@tonic-gate# Where flag is: y - enable lint noise diff output 457c478bd9Sstevel@tonic-gate# n - disable lint noise diff output 467c478bd9Sstevel@tonic-gate# 477c478bd9Sstevel@tonic-gate# For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y" 487c478bd9Sstevel@tonic-gate# 49c3e6cb59SRichard Lowe# OPTHOME may be set in the environment to override /opt 507c478bd9Sstevel@tonic-gate# 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate# 537c478bd9Sstevel@tonic-gate# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 547c478bd9Sstevel@tonic-gate# under certain circumstances, which can really screw things up; unset it. 557c478bd9Sstevel@tonic-gate# 567c478bd9Sstevel@tonic-gateunset CDPATH 577c478bd9Sstevel@tonic-gate 58cdf0c1d5Smjnelson# Get the absolute path of the nightly script that the user invoked. This 59cdf0c1d5Smjnelson# may be a relative path, and we need to do this before changing directory. 60cdf0c1d5Smjnelsonnightly_path=`whence $0` 61cdf0c1d5Smjnelson 62cdf0c1d5Smjnelson# 63cdf0c1d5Smjnelson# Keep track of where we found nightly so we can invoke the matching 64cdf0c1d5Smjnelson# which_scm script. If that doesn't work, don't go guessing, just rely 65cdf0c1d5Smjnelson# on the $PATH settings, which will generally give us either /opt/onbld 66cdf0c1d5Smjnelson# or the user's workspace. 67cdf0c1d5Smjnelson# 68cdf0c1d5SmjnelsonWHICH_SCM=$(dirname $nightly_path)/which_scm 69cdf0c1d5Smjnelsonif [[ ! -x $WHICH_SCM ]]; then 70cdf0c1d5Smjnelson WHICH_SCM=which_scm 71cdf0c1d5Smjnelsonfi 72cdf0c1d5Smjnelson 73d7693b08SRoland Mainzfunction fatal_error 74d7693b08SRoland Mainz{ 75d7693b08SRoland Mainz print -u2 "nightly: $*" 76d7693b08SRoland Mainz exit 1 77d7693b08SRoland Mainz} 78d7693b08SRoland Mainz 794e5b757fSkupfer# 804e5b757fSkupfer# Function to do a DEBUG and non-DEBUG build. Needed because we might 817c478bd9Sstevel@tonic-gate# need to do another for the source build, and since we only deliver DEBUG or 827c478bd9Sstevel@tonic-gate# non-DEBUG packages. 834e5b757fSkupfer# 84b83ec4edSjmcp# usage: normal_build 85ead1f93eSLiane Praza# 86597bd30bSMike Kupferfunction normal_build { 877c478bd9Sstevel@tonic-gate 8852a52aebSkupfer typeset orig_p_FLAG="$p_FLAG" 89597bd30bSMike Kupfer typeset crypto_signer="$CODESIGN_USER" 904e5b757fSkupfer 914e5b757fSkupfer suffix="" 92ead1f93eSLiane Praza 937c478bd9Sstevel@tonic-gate # non-DEBUG build begins 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate if [ "$F_FLAG" = "n" ]; then 964e5b757fSkupfer set_non_debug_build_flags 97597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 986ea3c060SGarrett D'Amore build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 997c478bd9Sstevel@tonic-gate else 10052a52aebSkupfer echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 1017c478bd9Sstevel@tonic-gate fi 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate # non-DEBUG build ends 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate # DEBUG build begins 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate if [ "$D_FLAG" = "y" ]; then 1084e5b757fSkupfer set_debug_build_flags 109597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 1106ea3c060SGarrett D'Amore build "DEBUG" "$suffix" "" "$MULTI_PROTO" 1117c478bd9Sstevel@tonic-gate else 11252a52aebSkupfer echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 1137c478bd9Sstevel@tonic-gate fi 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate # DEBUG build ends 1164e5b757fSkupfer 11752a52aebSkupfer p_FLAG="$orig_p_FLAG" 1187c478bd9Sstevel@tonic-gate} 1197c478bd9Sstevel@tonic-gate 1201fe69678Skupfer# 12147703246Ssommerfe# usage: run_hook HOOKNAME ARGS... 12247703246Ssommerfe# 12347703246Ssommerfe# If variable "$HOOKNAME" is defined, insert a section header into 12447703246Ssommerfe# our logs and then run the command with ARGS 12547703246Ssommerfe# 126597bd30bSMike Kupferfunction run_hook { 12747703246Ssommerfe HOOKNAME=$1 12847703246Ssommerfe eval HOOKCMD=\$$HOOKNAME 12947703246Ssommerfe shift 13047703246Ssommerfe 13147703246Ssommerfe if [ -n "$HOOKCMD" ]; then 13247703246Ssommerfe ( 13347703246Ssommerfe echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 13447703246Ssommerfe ( $HOOKCMD "$@" 2>&1 ) 13547703246Ssommerfe if [ "$?" -ne 0 ]; then 13647703246Ssommerfe # Let exit status propagate up 13747703246Ssommerfe touch $TMPDIR/abort 13847703246Ssommerfe fi 13947703246Ssommerfe ) | tee -a $mail_msg_file >> $LOGFILE 14047703246Ssommerfe 14147703246Ssommerfe if [ -f $TMPDIR/abort ]; then 14247703246Ssommerfe build_ok=n 14347703246Ssommerfe echo "\nAborting at request of $HOOKNAME" | 14447703246Ssommerfe tee -a $mail_msg_file >> $LOGFILE 14547703246Ssommerfe exit 1 14647703246Ssommerfe fi 14747703246Ssommerfe fi 14847703246Ssommerfe} 14947703246Ssommerfe 1504e5b757fSkupfer# Return library search directive as function of given root. 151597bd30bSMike Kupferfunction myldlibs { 1524e5b757fSkupfer echo "-L$1/lib -L$1/usr/lib" 1534e5b757fSkupfer} 1547c478bd9Sstevel@tonic-gate 1554e5b757fSkupfer# Return header search directive as function of given root. 156597bd30bSMike Kupferfunction myheaders { 1574e5b757fSkupfer echo "-I$1/usr/include" 1584e5b757fSkupfer} 1594e5b757fSkupfer 1604e5b757fSkupfer# 16178add226Sjmcp# Function to do the build, including package generation. 1626ea3c060SGarrett D'Amore# usage: build LABEL SUFFIX ND MULTIPROTO 1634e5b757fSkupfer# - LABEL is used to tag build output. 164ead1f93eSLiane Praza# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 165597bd30bSMike Kupfer# open-only vs full tree). 166ead1f93eSLiane Praza# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 1674e5b757fSkupfer# - If MULTIPROTO is "yes", it means to name the proto area according to 1684e5b757fSkupfer# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 1694e5b757fSkupfer# 170597bd30bSMike Kupferfunction build { 1717c478bd9Sstevel@tonic-gate LABEL=$1 1727c478bd9Sstevel@tonic-gate SUFFIX=$2 173597bd30bSMike Kupfer ND=$3 174597bd30bSMike Kupfer MULTIPROTO=$4 1757c478bd9Sstevel@tonic-gate INSTALLOG=install${SUFFIX}-${MACH} 1767c478bd9Sstevel@tonic-gate NOISE=noise${SUFFIX}-${MACH} 1777c478bd9Sstevel@tonic-gate PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 1787c478bd9Sstevel@tonic-gate 1794e5b757fSkupfer ORIGROOT=$ROOT 1804e5b757fSkupfer [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 1814e5b757fSkupfer 1824e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 1834e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 1844e5b757fSkupfer 1857c478bd9Sstevel@tonic-gate this_build_ok=y 1867c478bd9Sstevel@tonic-gate # 1877c478bd9Sstevel@tonic-gate # Build OS-Networking source 1887c478bd9Sstevel@tonic-gate # 1897c478bd9Sstevel@tonic-gate echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 1907c478bd9Sstevel@tonic-gate >> $LOGFILE 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate rm -f $SRC/${INSTALLOG}.out 1937c478bd9Sstevel@tonic-gate cd $SRC 1947c478bd9Sstevel@tonic-gate /bin/time $MAKE -e install 2>&1 | \ 1957c478bd9Sstevel@tonic-gate tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 19632f1e47bSsommerfe 1977c478bd9Sstevel@tonic-gate echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 1987c478bd9Sstevel@tonic-gate egrep ":" $SRC/${INSTALLOG}.out | 1997c478bd9Sstevel@tonic-gate egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 2007c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 2017c478bd9Sstevel@tonic-gate egrep -v "cc .* -o error " | \ 202cb4d1691SRichard Lowe egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ 203cb4d1691SRichard Lowe >> $mail_msg_file 204cb4d1691SRichard Lowe if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then 2057c478bd9Sstevel@tonic-gate build_ok=n 2067c478bd9Sstevel@tonic-gate this_build_ok=n 2077c478bd9Sstevel@tonic-gate fi 2087c478bd9Sstevel@tonic-gate grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 2097c478bd9Sstevel@tonic-gate >> $mail_msg_file 2107c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 2117c478bd9Sstevel@tonic-gate build_ok=n 2127c478bd9Sstevel@tonic-gate this_build_ok=n 2137c478bd9Sstevel@tonic-gate fi 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 2167c478bd9Sstevel@tonic-gate egrep -i warning: $SRC/${INSTALLOG}.out \ 2177c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 21820272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 2197c478bd9Sstevel@tonic-gate | egrep -v "parameter <PSTAMP> set to" \ 2207c478bd9Sstevel@tonic-gate | egrep -v "Ignoring unknown host" \ 2217c478bd9Sstevel@tonic-gate | egrep -v "redefining segment flags attribute for" \ 222cb4d1691SRichard Lowe | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file 223cb4d1691SRichard Lowe if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then 224cb4d1691SRichard Lowe build_ok=n 225cb4d1691SRichard Lowe this_build_ok=n 226cb4d1691SRichard Lowe fi 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 2297c478bd9Sstevel@tonic-gate >> $LOGFILE 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 2327c478bd9Sstevel@tonic-gate tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 2337c478bd9Sstevel@tonic-gate 234c3e6cb59SRichard Lowe if [ "$i_FLAG" = "n" ]; then 2357c478bd9Sstevel@tonic-gate rm -f $SRC/${NOISE}.ref 2367c478bd9Sstevel@tonic-gate if [ -f $SRC/${NOISE}.out ]; then 2377c478bd9Sstevel@tonic-gate mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 2387c478bd9Sstevel@tonic-gate fi 2397c478bd9Sstevel@tonic-gate grep : $SRC/${INSTALLOG}.out \ 2407c478bd9Sstevel@tonic-gate | egrep -v '^/' \ 2417c478bd9Sstevel@tonic-gate | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 2427c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 2437c478bd9Sstevel@tonic-gate | egrep -v '^mcs' \ 2447c478bd9Sstevel@tonic-gate | egrep -v '^LD_LIBRARY_PATH=' \ 2457c478bd9Sstevel@tonic-gate | egrep -v 'ar: creating' \ 2467c478bd9Sstevel@tonic-gate | egrep -v 'ar: writing' \ 2477c478bd9Sstevel@tonic-gate | egrep -v 'conflicts:' \ 2487c478bd9Sstevel@tonic-gate | egrep -v ':saved created' \ 2497c478bd9Sstevel@tonic-gate | egrep -v '^stty.*c:' \ 2507c478bd9Sstevel@tonic-gate | egrep -v '^mfgname.c:' \ 2517c478bd9Sstevel@tonic-gate | egrep -v '^uname-i.c:' \ 2527c478bd9Sstevel@tonic-gate | egrep -v '^volumes.c:' \ 2537c478bd9Sstevel@tonic-gate | egrep -v '^lint library construction:' \ 2547c478bd9Sstevel@tonic-gate | egrep -v 'tsort: INFORM:' \ 2557c478bd9Sstevel@tonic-gate | egrep -v 'stripalign:' \ 2567c478bd9Sstevel@tonic-gate | egrep -v 'chars, width' \ 25720272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 2587c478bd9Sstevel@tonic-gate | egrep -v 'PSTAMP' \ 2597c478bd9Sstevel@tonic-gate | egrep -v '|%WHOANDWHERE%|' \ 2607c478bd9Sstevel@tonic-gate | egrep -v '^Manifying' \ 2617c478bd9Sstevel@tonic-gate | egrep -v 'Ignoring unknown host' \ 2627c478bd9Sstevel@tonic-gate | egrep -v 'Processing method:' \ 2637c478bd9Sstevel@tonic-gate | egrep -v '^Writing' \ 2647c478bd9Sstevel@tonic-gate | egrep -v 'spellin1:' \ 2657c478bd9Sstevel@tonic-gate | egrep -v '^adding:' \ 2667c478bd9Sstevel@tonic-gate | egrep -v "^echo 'msgid" \ 2677c478bd9Sstevel@tonic-gate | egrep -v '^echo ' \ 2687c478bd9Sstevel@tonic-gate | egrep -v '\.c:$' \ 2697c478bd9Sstevel@tonic-gate | egrep -v '^Adding file:' \ 2707c478bd9Sstevel@tonic-gate | egrep -v 'CLASSPATH=' \ 2717c478bd9Sstevel@tonic-gate | egrep -v '\/var\/mail\/:saved' \ 2727c478bd9Sstevel@tonic-gate | egrep -v -- '-DUTS_VERSION=' \ 2737c478bd9Sstevel@tonic-gate | egrep -v '^Running Mkbootstrap' \ 2747c478bd9Sstevel@tonic-gate | egrep -v '^Applet length read:' \ 2757c478bd9Sstevel@tonic-gate | egrep -v 'bytes written:' \ 2767c478bd9Sstevel@tonic-gate | egrep -v '^File:SolarisAuthApplet.bin' \ 2777c478bd9Sstevel@tonic-gate | egrep -v -i 'jibversion' \ 2787c478bd9Sstevel@tonic-gate | egrep -v '^Output size:' \ 2797c478bd9Sstevel@tonic-gate | egrep -v '^Solo size statistics:' \ 2807c478bd9Sstevel@tonic-gate | egrep -v '^Using ROM API Version' \ 2817c478bd9Sstevel@tonic-gate | egrep -v '^Zero Signature length:' \ 2827c478bd9Sstevel@tonic-gate | egrep -v '^Note \(probably harmless\):' \ 2837c478bd9Sstevel@tonic-gate | egrep -v '::' \ 2847c478bd9Sstevel@tonic-gate | egrep -v -- '-xcache' \ 285010b217aSwesolows | egrep -v '^\+' \ 28603eb5f54Swesolows | egrep -v '^cc1: note: -fwritable-strings' \ 287c817a439Sjohnz | egrep -v 'svccfg-native -s svc:/' \ 2887c478bd9Sstevel@tonic-gate | sort | uniq >$SRC/${NOISE}.out 2897c478bd9Sstevel@tonic-gate if [ ! -f $SRC/${NOISE}.ref ]; then 2907c478bd9Sstevel@tonic-gate cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 2917c478bd9Sstevel@tonic-gate fi 2927c478bd9Sstevel@tonic-gate echo "\n==== Build noise differences ($LABEL) ====\n" \ 2937c478bd9Sstevel@tonic-gate >>$mail_msg_file 2947c478bd9Sstevel@tonic-gate diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 2957c478bd9Sstevel@tonic-gate fi 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate # 29823259b79Srotondo # Re-sign selected binaries using signing server 29923259b79Srotondo # (gatekeeper builds only) 30023259b79Srotondo # 3012210853dSjohnz if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 30223259b79Srotondo echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 30323259b79Srotondo signing_file="${TMPDIR}/signing" 30423259b79Srotondo rm -f ${signing_file} 30523259b79Srotondo export CODESIGN_USER 30623259b79Srotondo signproto $SRC/tools/codesign/creds 2>&1 | \ 30723259b79Srotondo tee -a ${signing_file} >> $LOGFILE 30823259b79Srotondo echo "\n==== Finished signing proto area at `date` ====\n" \ 30923259b79Srotondo >> $LOGFILE 31023259b79Srotondo echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 31123259b79Srotondo >> $mail_msg_file 31223259b79Srotondo egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 313cdf0c1d5Smjnelson if (( $? == 0 )) ; then 3142210853dSjohnz build_ok=n 3152210853dSjohnz this_build_ok=n 3162210853dSjohnz fi 31723259b79Srotondo fi 31823259b79Srotondo 31923259b79Srotondo # 3207c478bd9Sstevel@tonic-gate # Building Packages 3217c478bd9Sstevel@tonic-gate # 3227c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 323c3e6cb59SRichard Lowe if [ -d $SRC/pkg ]; then 3247c478bd9Sstevel@tonic-gate echo "\n==== Creating $LABEL packages at `date` ====\n" \ 3257c478bd9Sstevel@tonic-gate >> $LOGFILE 326ead1f93eSLiane Praza echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 3276798c3f0SMark J. Nelson rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 3286798c3f0SMark J. Nelson mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 329d8fd4470Sjg 330c3e6cb59SRichard Lowe rm -f $SRC/pkg/${INSTALLOG}.out 331c3e6cb59SRichard Lowe cd $SRC/pkg 332ead1f93eSLiane Praza /bin/time $MAKE -e install 2>&1 | \ 333c3e6cb59SRichard Lowe tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE 334ead1f93eSLiane Praza 335ead1f93eSLiane Praza echo "\n==== package build errors ($LABEL) ====\n" \ 336ead1f93eSLiane Praza >> $mail_msg_file 337ead1f93eSLiane Praza 338c3e6cb59SRichard Lowe egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \ 3397c478bd9Sstevel@tonic-gate grep ':' | \ 3407c478bd9Sstevel@tonic-gate grep -v PSTAMP | \ 341cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 342cb4d1691SRichard Lowe tee $TMPDIR/package >> $mail_msg_file 343cb4d1691SRichard Lowe if [[ -s $TMPDIR/package ]]; then 344cb4d1691SRichard Lowe build_extras_ok=n 345cb4d1691SRichard Lowe this_build_ok=n 346cb4d1691SRichard Lowe fi 347ead1f93eSLiane Praza else 348ead1f93eSLiane Praza # 349c3e6cb59SRichard Lowe # Handle it gracefully if -p was set but there so 350c3e6cb59SRichard Lowe # no pkg directory. 351ead1f93eSLiane Praza # 352ead1f93eSLiane Praza echo "\n==== No $LABEL packages to build ====\n" \ 353ead1f93eSLiane Praza >> $LOGFILE 354ead1f93eSLiane Praza fi 3557c478bd9Sstevel@tonic-gate else 3567c478bd9Sstevel@tonic-gate echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 3577c478bd9Sstevel@tonic-gate fi 3584e5b757fSkupfer 3594e5b757fSkupfer ROOT=$ORIGROOT 3607c478bd9Sstevel@tonic-gate} 3617c478bd9Sstevel@tonic-gate 3621fe69678Skupfer# Usage: dolint /dir y|n 3637c478bd9Sstevel@tonic-gate# Arg. 2 is a flag to turn on/off the lint diff output 364597bd30bSMike Kupferfunction dolint { 3657c478bd9Sstevel@tonic-gate if [ ! -d "$1" ]; then 3661fe69678Skupfer echo "dolint error: $1 is not a directory" 3677c478bd9Sstevel@tonic-gate exit 1 3687c478bd9Sstevel@tonic-gate fi 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate if [ "$2" != "y" -a "$2" != "n" ]; then 3711fe69678Skupfer echo "dolint internal error: $2 should be 'y' or 'n'" 3727c478bd9Sstevel@tonic-gate exit 1 3737c478bd9Sstevel@tonic-gate fi 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate lintdir=$1 3767c478bd9Sstevel@tonic-gate dodiff=$2 3777c478bd9Sstevel@tonic-gate base=`basename $lintdir` 3787c478bd9Sstevel@tonic-gate LINTOUT=$lintdir/lint-${MACH}.out 3797c478bd9Sstevel@tonic-gate LINTNOISE=$lintdir/lint-noise-${MACH} 3804e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 3814e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 3827c478bd9Sstevel@tonic-gate 3834e5b757fSkupfer set_debug_build_flags 3847c478bd9Sstevel@tonic-gate 3857c478bd9Sstevel@tonic-gate # 3867c478bd9Sstevel@tonic-gate # '$MAKE lint' in $lintdir 3877c478bd9Sstevel@tonic-gate # 3887c478bd9Sstevel@tonic-gate echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate # remove old lint.out 3917c478bd9Sstevel@tonic-gate rm -f $lintdir/lint.out $lintdir/lint-noise.out 3927c478bd9Sstevel@tonic-gate if [ -f $lintdir/lint-noise.ref ]; then 3937c478bd9Sstevel@tonic-gate mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 3947c478bd9Sstevel@tonic-gate fi 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate rm -f $LINTOUT 3977c478bd9Sstevel@tonic-gate cd $lintdir 3987c478bd9Sstevel@tonic-gate # 3997c478bd9Sstevel@tonic-gate # Remove all .ln files to ensure a full reference file 4007c478bd9Sstevel@tonic-gate # 4017c478bd9Sstevel@tonic-gate rm -f Nothing_to_remove \ 4028bcea973SRichard Lowe `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \ 403cdf0c1d5Smjnelson -prune -o -type f -name '*.ln' -print ` 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate /bin/time $MAKE -ek lint 2>&1 | \ 4067c478bd9Sstevel@tonic-gate tee -a $LINTOUT >> $LOGFILE 407cb4d1691SRichard Lowe 4087c478bd9Sstevel@tonic-gate echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 409cb4d1691SRichard Lowe 4107c478bd9Sstevel@tonic-gate grep "$MAKE:" $LINTOUT | 411cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 412cb4d1691SRichard Lowe tee $TMPDIR/lint_errs >> $mail_msg_file 413cb4d1691SRichard Lowe if [[ -s $TMPDIR/lint_errs ]]; then 414cb4d1691SRichard Lowe build_extras_ok=n 415cb4d1691SRichard Lowe fi 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 4207c478bd9Sstevel@tonic-gate >>$mail_msg_file 4217c478bd9Sstevel@tonic-gate tail -3 $LINTOUT >>$mail_msg_file 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate rm -f ${LINTNOISE}.ref 4247c478bd9Sstevel@tonic-gate if [ -f ${LINTNOISE}.out ]; then 4257c478bd9Sstevel@tonic-gate mv ${LINTNOISE}.out ${LINTNOISE}.ref 4267c478bd9Sstevel@tonic-gate fi 4277c478bd9Sstevel@tonic-gate grep : $LINTOUT | \ 4287c478bd9Sstevel@tonic-gate egrep -v '^(real|user|sys)' | 4297c478bd9Sstevel@tonic-gate egrep -v '(library construction)' | \ 4307c478bd9Sstevel@tonic-gate egrep -v ': global crosschecks' | \ 4317c478bd9Sstevel@tonic-gate egrep -v 'Ignoring unknown host' | \ 4327c478bd9Sstevel@tonic-gate egrep -v '\.c:$' | \ 4337c478bd9Sstevel@tonic-gate sort | uniq > ${LINTNOISE}.out 4347c478bd9Sstevel@tonic-gate if [ ! -f ${LINTNOISE}.ref ]; then 4357c478bd9Sstevel@tonic-gate cp ${LINTNOISE}.out ${LINTNOISE}.ref 4367c478bd9Sstevel@tonic-gate fi 437cb4d1691SRichard Lowe 4387c478bd9Sstevel@tonic-gate if [ "$dodiff" != "n" ]; then 4397c478bd9Sstevel@tonic-gate echo "\n==== lint warnings $base ====\n" \ 4407c478bd9Sstevel@tonic-gate >>$mail_msg_file 4417c478bd9Sstevel@tonic-gate # should be none, though there are a few that were filtered out 4427c478bd9Sstevel@tonic-gate # above 4437c478bd9Sstevel@tonic-gate egrep -i '(warning|lint):' ${LINTNOISE}.out \ 444cb4d1691SRichard Lowe | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file 445cb4d1691SRichard Lowe if [[ -s $TMPDIR/lint_warns ]]; then 446cb4d1691SRichard Lowe build_extras_ok=n 447cb4d1691SRichard Lowe fi 4487c478bd9Sstevel@tonic-gate echo "\n==== lint noise differences $base ====\n" \ 4497c478bd9Sstevel@tonic-gate >> $mail_msg_file 4507c478bd9Sstevel@tonic-gate diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 4517c478bd9Sstevel@tonic-gate >> $mail_msg_file 4527c478bd9Sstevel@tonic-gate fi 4537c478bd9Sstevel@tonic-gate} 4547c478bd9Sstevel@tonic-gate 4554e5b757fSkupfer# 4564e5b757fSkupfer# Build and install the onbld tools. 4574e5b757fSkupfer# 4581fe69678Skupfer# usage: build_tools DESTROOT 4594e5b757fSkupfer# 4604e5b757fSkupfer# returns non-zero status if the build was successful. 4614e5b757fSkupfer# 462597bd30bSMike Kupferfunction build_tools { 4637c478bd9Sstevel@tonic-gate DESTROOT=$1 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate INSTALLOG=install-${MACH} 4667c478bd9Sstevel@tonic-gate 4677c478bd9Sstevel@tonic-gate echo "\n==== Building tools at `date` ====\n" \ 4687c478bd9Sstevel@tonic-gate >> $LOGFILE 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/${INSTALLOG}.out 4717c478bd9Sstevel@tonic-gate cd ${TOOLS} 472ead1f93eSLiane Praza /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 4737c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 4747c478bd9Sstevel@tonic-gate 4757c478bd9Sstevel@tonic-gate echo "\n==== Tools build errors ====\n" >> $mail_msg_file 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate egrep ":" ${TOOLS}/${INSTALLOG}.out | 4787c478bd9Sstevel@tonic-gate egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 4797c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 480cb4d1691SRichard Lowe egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file 481cb4d1691SRichard Lowe 482cb4d1691SRichard Lowe if [[ -s $TMPDIR/tools_errors ]]; then 483cb4d1691SRichard Lowe return 1 484cb4d1691SRichard Lowe fi 485cb4d1691SRichard Lowe return 0 4864e5b757fSkupfer} 4874e5b757fSkupfer 4884e5b757fSkupfer# 4894e5b757fSkupfer# Set up to use locally installed tools. 4904e5b757fSkupfer# 4914e5b757fSkupfer# usage: use_tools TOOLSROOT 4924e5b757fSkupfer# 493597bd30bSMike Kupferfunction use_tools { 4944e5b757fSkupfer TOOLSROOT=$1 4954e5b757fSkupfer 496c168ccb7SMark J. Nelson # 497c168ccb7SMark J. Nelson # If we're not building ON workspace, then the TOOLSROOT 498c168ccb7SMark J. Nelson # settings here are clearly ignored by the workspace 499c168ccb7SMark J. Nelson # makefiles, prepending nonexistent directories to PATH is 500c168ccb7SMark J. Nelson # harmless, and we clearly do not wish to override 501c168ccb7SMark J. Nelson # ONBLD_TOOLS. 502c168ccb7SMark J. Nelson # 503c168ccb7SMark J. Nelson # If we're building an ON workspace, then the prepended PATH 504c168ccb7SMark J. Nelson # elements should supercede the preexisting ONBLD_TOOLS paths, 505c168ccb7SMark J. Nelson # and we want to override ONBLD_TOOLS to catch the tools that 506c168ccb7SMark J. Nelson # don't have specific path env vars here. 507c168ccb7SMark J. Nelson # 508c168ccb7SMark J. Nelson # So the only conditional behavior is overriding ONBLD_TOOLS, 509c168ccb7SMark J. Nelson # and we check for "an ON workspace" by looking for 510c168ccb7SMark J. Nelson # ${TOOLSROOT}/opt/onbld. 511c168ccb7SMark J. Nelson # 512c168ccb7SMark J. Nelson 5134e5b757fSkupfer STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs 5147c478bd9Sstevel@tonic-gate export STABS 5154e5b757fSkupfer CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs 5167c478bd9Sstevel@tonic-gate export CTFSTABS 5174e5b757fSkupfer GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets 5187c478bd9Sstevel@tonic-gate export GENOFFSETS 5197c478bd9Sstevel@tonic-gate 5204e5b757fSkupfer CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert 5217c478bd9Sstevel@tonic-gate export CTFCONVERT 5224e5b757fSkupfer CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge 5237c478bd9Sstevel@tonic-gate export CTFMERGE 5247c478bd9Sstevel@tonic-gate 5254e5b757fSkupfer CTFCVTPTBL=${TOOLSROOT}/opt/onbld/bin/ctfcvtptbl 5267c478bd9Sstevel@tonic-gate export CTFCVTPTBL 5274e5b757fSkupfer CTFFINDMOD=${TOOLSROOT}/opt/onbld/bin/ctffindmod 5287c478bd9Sstevel@tonic-gate export CTFFINDMOD 5297c478bd9Sstevel@tonic-gate 5307c478bd9Sstevel@tonic-gate if [ "$VERIFY_ELFSIGN" = "y" ]; then 5314e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 5327c478bd9Sstevel@tonic-gate else 5334e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 5347c478bd9Sstevel@tonic-gate fi 5357c478bd9Sstevel@tonic-gate export ELFSIGN 5367c478bd9Sstevel@tonic-gate 537c168ccb7SMark J. Nelson PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 5384e5b757fSkupfer PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 5397c478bd9Sstevel@tonic-gate export PATH 5407c478bd9Sstevel@tonic-gate 541c168ccb7SMark J. Nelson if [ -d "${TOOLSROOT}/opt/onbld" ]; then 542b06f2c55SMark J. Nelson ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 5431d9a8b8dSDan Mick export ONBLD_TOOLS 544c168ccb7SMark J. Nelson fi 5451d9a8b8dSDan Mick 5467c478bd9Sstevel@tonic-gate echo "\n==== New environment settings. ====\n" >> $LOGFILE 5477c478bd9Sstevel@tonic-gate echo "STABS=${STABS}" >> $LOGFILE 5487c478bd9Sstevel@tonic-gate echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 5497c478bd9Sstevel@tonic-gate echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 5507c478bd9Sstevel@tonic-gate echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 5517c478bd9Sstevel@tonic-gate echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE 5527c478bd9Sstevel@tonic-gate echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE 5537c478bd9Sstevel@tonic-gate echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 5547c478bd9Sstevel@tonic-gate echo "PATH=${PATH}" >> $LOGFILE 5551d9a8b8dSDan Mick echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 5567c478bd9Sstevel@tonic-gate} 5577c478bd9Sstevel@tonic-gate 558597bd30bSMike Kupferfunction staffer { 5597c478bd9Sstevel@tonic-gate if [ $ISUSER -ne 0 ]; then 5607c478bd9Sstevel@tonic-gate "$@" 5617c478bd9Sstevel@tonic-gate else 5627c478bd9Sstevel@tonic-gate arg="\"$1\"" 5637c478bd9Sstevel@tonic-gate shift 5647c478bd9Sstevel@tonic-gate for i 5657c478bd9Sstevel@tonic-gate do 5667c478bd9Sstevel@tonic-gate arg="$arg \"$i\"" 5677c478bd9Sstevel@tonic-gate done 5687c478bd9Sstevel@tonic-gate eval su $STAFFER -c \'$arg\' 5697c478bd9Sstevel@tonic-gate fi 5707c478bd9Sstevel@tonic-gate} 5717c478bd9Sstevel@tonic-gate 572085d331dSkupfer# 573c3e6cb59SRichard Lowe# Verify that the closed bins are present 574085d331dSkupfer# 575c3e6cb59SRichard Lowefunction check_closed_bins { 576c0e7977aSJosef 'Jeff' Sipek if [[ ! -d "$ON_CLOSED_BINS" ]]; then 577c0e7977aSJosef 'Jeff' Sipek echo "ON_CLOSED_BINS must point to the closed binaries tree." 578cdf0c1d5Smjnelson build_ok=n 579085d331dSkupfer exit 1 580085d331dSkupfer fi 581085d331dSkupfer} 5827c478bd9Sstevel@tonic-gate 5834e5b757fSkupfer# 5844e5b757fSkupfer# wrapper over wsdiff. 5854e5b757fSkupfer# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 5864e5b757fSkupfer# 587597bd30bSMike Kupferfunction do_wsdiff { 5884e5b757fSkupfer label=$1 5894e5b757fSkupfer oldproto=$2 5904e5b757fSkupfer newproto=$3 5914e5b757fSkupfer 5924e5b757fSkupfer wsdiff="wsdiff" 5934e5b757fSkupfer [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 5944e5b757fSkupfer 595598cc7dfSVladimir Kotal echo "\n==== Getting object changes since last build at `date`" \ 596598cc7dfSVladimir Kotal "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 597598cc7dfSVladimir Kotal $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 598598cc7dfSVladimir Kotal tee -a $LOGFILE >> $mail_msg_file 599598cc7dfSVladimir Kotal echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 6004e5b757fSkupfer tee -a $LOGFILE >> $mail_msg_file 6014e5b757fSkupfer} 6024e5b757fSkupfer 6034e5b757fSkupfer# 604ead1f93eSLiane Praza# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 6054e5b757fSkupfer# together. 6064e5b757fSkupfer# 6074e5b757fSkupfer 608597bd30bSMike Kupferfunction set_non_debug_build_flags { 6094e5b757fSkupfer export RELEASE_BUILD ; RELEASE_BUILD= 6104e5b757fSkupfer unset EXTRA_OPTIONS 6114e5b757fSkupfer unset EXTRA_CFLAGS 6124e5b757fSkupfer} 6134e5b757fSkupfer 614597bd30bSMike Kupferfunction set_debug_build_flags { 6154e5b757fSkupfer unset RELEASE_BUILD 6164e5b757fSkupfer unset EXTRA_OPTIONS 6174e5b757fSkupfer unset EXTRA_CFLAGS 6184e5b757fSkupfer} 6194e5b757fSkupfer 620d77e7149Ssommerfe 6217c478bd9Sstevel@tonic-gateMACH=`uname -p` 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gateif [ "$OPTHOME" = "" ]; then 6247c478bd9Sstevel@tonic-gate OPTHOME=/opt 6257c478bd9Sstevel@tonic-gate export OPTHOME 6267c478bd9Sstevel@tonic-gatefi 6277c478bd9Sstevel@tonic-gate 6285110237aSJosef 'Jeff' SipekUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gateWhere: 631d77e7149Ssommerfe -i Fast incremental options (no clobber, lint, check) 6327c478bd9Sstevel@tonic-gate -n Do not do a bringover 6335e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 6347c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 6357c478bd9Sstevel@tonic-gate 6367c478bd9Sstevel@tonic-gate <env_file> file in Bourne shell syntax that sets and exports 6377c478bd9Sstevel@tonic-gate variables that configure the operation of this script and many of 6387c478bd9Sstevel@tonic-gate the scripts this one calls. If <env_file> does not exist, 6397c478bd9Sstevel@tonic-gate it will be looked for in $OPTHOME/onbld/env. 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gatenon-DEBUG is the default build type. Build options can be set in the 6427c478bd9Sstevel@tonic-gateNIGHTLY_OPTIONS variable in the <env_file> as follows: 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate -A check for ABI differences in .so files 6457c478bd9Sstevel@tonic-gate -C check for cstyle/hdrchk errors 6467c478bd9Sstevel@tonic-gate -D do a build with DEBUG on 6477c478bd9Sstevel@tonic-gate -F do _not_ do a non-DEBUG build 6483c6aa570SMark J. Nelson -G gate keeper default group of options (-au) 6497c478bd9Sstevel@tonic-gate -I integration engineer default group of options (-ampu) 6507c478bd9Sstevel@tonic-gate -M do not run pmodes (safe file permission checker) 6517c478bd9Sstevel@tonic-gate -N do not run protocmp 6527c478bd9Sstevel@tonic-gate -R default group of options for building a release (-mp) 6537c478bd9Sstevel@tonic-gate -U update proto area in the parent 6547c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 6557c478bd9Sstevel@tonic-gate -f find unreferenced files 6567c478bd9Sstevel@tonic-gate -i do an incremental build (no "make clobber") 6577c478bd9Sstevel@tonic-gate -l do "make lint" in $LINTDIRS (default: $SRC y) 6587c478bd9Sstevel@tonic-gate -m send mail to $MAILTO at end of build 6597c478bd9Sstevel@tonic-gate -n do not do a bringover 6607c478bd9Sstevel@tonic-gate -p create packages 6617c478bd9Sstevel@tonic-gate -r check ELF runtime attributes in the proto area 6625e1b109eSPeter Dennis - Sustaining Engineer -t build and use the tools in $SRC/tools (default setting) 6635e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 6647c478bd9Sstevel@tonic-gate -u update proto_list_$MACH and friends in the parent workspace; 6657c478bd9Sstevel@tonic-gate when used with -f, also build an unrefmaster.out in the parent 66696ccc8cbSesaxe -w report on differences between previous and current proto areas 6677c478bd9Sstevel@tonic-gate' 6687c478bd9Sstevel@tonic-gate# 6697c478bd9Sstevel@tonic-gate# A log file will be generated under the name $LOGFILE 6701c79753fSdarrenm# for partially completed build and log.`date '+%F'` 6717c478bd9Sstevel@tonic-gate# in the same directory for fully completed builds. 6727c478bd9Sstevel@tonic-gate# 6737c478bd9Sstevel@tonic-gate 6747c478bd9Sstevel@tonic-gate# default values for low-level FLAGS; G I R are group FLAGS 6757c478bd9Sstevel@tonic-gateA_FLAG=n 6767c478bd9Sstevel@tonic-gateC_FLAG=n 6776c3c9007SstevelD_FLAG=n 6787c478bd9Sstevel@tonic-gateF_FLAG=n 6797c478bd9Sstevel@tonic-gatef_FLAG=n 6807c478bd9Sstevel@tonic-gatei_FLAG=n; i_CMD_LINE_FLAG=n 6817c478bd9Sstevel@tonic-gatel_FLAG=n 6826c3c9007SstevelM_FLAG=n 6837c478bd9Sstevel@tonic-gatem_FLAG=n 6846c3c9007SstevelN_FLAG=n 6856c3c9007Ssteveln_FLAG=n 6867c478bd9Sstevel@tonic-gatep_FLAG=n 6877c478bd9Sstevel@tonic-gater_FLAG=n 688fd7cef36Ssuhat_FLAG=y 6897c478bd9Sstevel@tonic-gateU_FLAG=n 6906c3c9007Sstevelu_FLAG=n 6917c478bd9Sstevel@tonic-gateV_FLAG=n 6926c3c9007Sstevelw_FLAG=n 693cb4d1691SRichard LoweW_FLAG=n 6947c478bd9Sstevel@tonic-gate# 6957c478bd9Sstevel@tonic-gatebuild_ok=y 696cb4d1691SRichard Lowebuild_extras_ok=y 6971fe69678Skupfer 6987c478bd9Sstevel@tonic-gate# 6997c478bd9Sstevel@tonic-gate# examine arguments 7007c478bd9Sstevel@tonic-gate# 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gateOPTIND=1 703cb4d1691SRichard Lowewhile getopts +intV:W FLAG 7047c478bd9Sstevel@tonic-gatedo 7057c478bd9Sstevel@tonic-gate case $FLAG in 7067c478bd9Sstevel@tonic-gate i ) i_FLAG=y; i_CMD_LINE_FLAG=y 7077c478bd9Sstevel@tonic-gate ;; 7087c478bd9Sstevel@tonic-gate n ) n_FLAG=y 7097c478bd9Sstevel@tonic-gate ;; 710fd7cef36Ssuha +t ) t_FLAG=n 7117c478bd9Sstevel@tonic-gate ;; 7126c3c9007Sstevel V ) V_FLAG=y 7136c3c9007Sstevel V_ARG="$OPTARG" 7146c3c9007Sstevel ;; 715cb4d1691SRichard Lowe W ) W_FLAG=y 716cb4d1691SRichard Lowe ;; 7177c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 7187c478bd9Sstevel@tonic-gate exit 1 7197c478bd9Sstevel@tonic-gate ;; 7207c478bd9Sstevel@tonic-gate esac 7217c478bd9Sstevel@tonic-gatedone 7227c478bd9Sstevel@tonic-gate 7237c478bd9Sstevel@tonic-gate# correct argument count after options 7247c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 7257c478bd9Sstevel@tonic-gate 7267c478bd9Sstevel@tonic-gate# test that the path to the environment-setting file was given 7277c478bd9Sstevel@tonic-gateif [ $# -ne 1 ]; then 7287c478bd9Sstevel@tonic-gate echo "$USAGE" 7297c478bd9Sstevel@tonic-gate exit 1 7307c478bd9Sstevel@tonic-gatefi 7317c478bd9Sstevel@tonic-gate 7327c478bd9Sstevel@tonic-gate# check if user is running nightly as root 7337c478bd9Sstevel@tonic-gate# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 7347c478bd9Sstevel@tonic-gate# when root invokes nightly. 7357c478bd9Sstevel@tonic-gate/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 7367c478bd9Sstevel@tonic-gateISUSER=$?; export ISUSER 7377c478bd9Sstevel@tonic-gate 7387c478bd9Sstevel@tonic-gate# 7397c478bd9Sstevel@tonic-gate# force locale to C 74091d74a54SRichard LoweLANG=C; export LANG 74191d74a54SRichard LoweLC_ALL=C; export LC_ALL 7427c478bd9Sstevel@tonic-gateLC_COLLATE=C; export LC_COLLATE 7437c478bd9Sstevel@tonic-gateLC_CTYPE=C; export LC_CTYPE 7447c478bd9Sstevel@tonic-gateLC_MESSAGES=C; export LC_MESSAGES 7457c478bd9Sstevel@tonic-gateLC_MONETARY=C; export LC_MONETARY 7467c478bd9Sstevel@tonic-gateLC_NUMERIC=C; export LC_NUMERIC 7477c478bd9Sstevel@tonic-gateLC_TIME=C; export LC_TIME 7487c478bd9Sstevel@tonic-gate 7497c478bd9Sstevel@tonic-gate# clear environment variables we know to be bad for the build 7507c478bd9Sstevel@tonic-gateunset LD_OPTIONS 7517c478bd9Sstevel@tonic-gateunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 7527c478bd9Sstevel@tonic-gateunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 7537c478bd9Sstevel@tonic-gateunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 7547c478bd9Sstevel@tonic-gateunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 7557c478bd9Sstevel@tonic-gateunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 7567c478bd9Sstevel@tonic-gateunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 7577c478bd9Sstevel@tonic-gateunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 7587c478bd9Sstevel@tonic-gateunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 7597c478bd9Sstevel@tonic-gateunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 7607c478bd9Sstevel@tonic-gateunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 7617c478bd9Sstevel@tonic-gateunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 7627c478bd9Sstevel@tonic-gateunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 7637c478bd9Sstevel@tonic-gateunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 7647c478bd9Sstevel@tonic-gateunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 7657c478bd9Sstevel@tonic-gateunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 7667c478bd9Sstevel@tonic-gateunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 7677c478bd9Sstevel@tonic-gateunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 7687c478bd9Sstevel@tonic-gateunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 7697c478bd9Sstevel@tonic-gateunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 7707c478bd9Sstevel@tonic-gateunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 7717c478bd9Sstevel@tonic-gate 7727c478bd9Sstevel@tonic-gateunset CONFIG 7737c478bd9Sstevel@tonic-gateunset GROUP 7747c478bd9Sstevel@tonic-gateunset OWNER 7757c478bd9Sstevel@tonic-gateunset REMOTE 7767c478bd9Sstevel@tonic-gateunset ENV 7777c478bd9Sstevel@tonic-gateunset ARCH 7787c478bd9Sstevel@tonic-gateunset CLASSPATH 7797c478bd9Sstevel@tonic-gateunset NAME 7807c478bd9Sstevel@tonic-gate 7817c478bd9Sstevel@tonic-gate# 782ead1f93eSLiane Praza# To get ONBLD_TOOLS from the environment, it must come from the env file. 783ead1f93eSLiane Praza# If it comes interactively, it is generally TOOLS_PROTO, which will be 784ead1f93eSLiane Praza# clobbered before the compiler version checks, which will therefore fail. 785ead1f93eSLiane Praza# 786ead1f93eSLiane Prazaunset ONBLD_TOOLS 787ead1f93eSLiane Praza 788ead1f93eSLiane Praza# 7897c478bd9Sstevel@tonic-gate# Setup environmental variables 7907c478bd9Sstevel@tonic-gate# 79147703246Ssommerfeif [ -f /etc/nightly.conf ]; then 79247703246Ssommerfe . /etc/nightly.conf 79347703246Ssommerfefi 79447703246Ssommerfe 7957c478bd9Sstevel@tonic-gateif [ -f $1 ]; then 7967c478bd9Sstevel@tonic-gate if [[ $1 = */* ]]; then 7977c478bd9Sstevel@tonic-gate . $1 7987c478bd9Sstevel@tonic-gate else 7997c478bd9Sstevel@tonic-gate . ./$1 8007c478bd9Sstevel@tonic-gate fi 8017c478bd9Sstevel@tonic-gateelse 8027c478bd9Sstevel@tonic-gate if [ -f $OPTHOME/onbld/env/$1 ]; then 8037c478bd9Sstevel@tonic-gate . $OPTHOME/onbld/env/$1 8047c478bd9Sstevel@tonic-gate else 8057c478bd9Sstevel@tonic-gate echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 8067c478bd9Sstevel@tonic-gate exit 1 8077c478bd9Sstevel@tonic-gate fi 8087c478bd9Sstevel@tonic-gatefi 8097c478bd9Sstevel@tonic-gate 8101fe69678Skupfer# contents of stdenv.sh inserted after next line: 8111fe69678Skupfer# STDENV_START 8121fe69678Skupfer# STDENV_END 8131fe69678Skupfer 814d7693b08SRoland Mainz# Check if we have sufficient data to continue... 815d7693b08SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 816220399b7SRoland Mainzif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 817220399b7SRoland Mainz # Check if the gate data are valid if we don't do a "bringover" below 818220399b7SRoland Mainz [[ -d "${CODEMGR_WS}" ]] || \ 819220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS} is not a directory." 820220399b7SRoland Mainz [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 821220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 822220399b7SRoland Mainzfi 823d7693b08SRoland Mainz 8247c478bd9Sstevel@tonic-gate# 8257c478bd9Sstevel@tonic-gate# place ourselves in a new task, respecting BUILD_PROJECT if set. 8267c478bd9Sstevel@tonic-gate# 8277c478bd9Sstevel@tonic-gateif [ -z "$BUILD_PROJECT" ]; then 8287c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ 8297c478bd9Sstevel@tonic-gateelse 8307c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ -p $BUILD_PROJECT 8317c478bd9Sstevel@tonic-gatefi 8327c478bd9Sstevel@tonic-gate 8337c478bd9Sstevel@tonic-gateps -o taskid= -p $$ | read build_taskid 8347c478bd9Sstevel@tonic-gateps -o project= -p $$ | read build_project 8357c478bd9Sstevel@tonic-gate 8367c478bd9Sstevel@tonic-gate# 8377c478bd9Sstevel@tonic-gate# See if NIGHTLY_OPTIONS is set 8387c478bd9Sstevel@tonic-gate# 8397c478bd9Sstevel@tonic-gateif [ "$NIGHTLY_OPTIONS" = "" ]; then 8407c478bd9Sstevel@tonic-gate NIGHTLY_OPTIONS="-aBm" 8417c478bd9Sstevel@tonic-gatefi 8427c478bd9Sstevel@tonic-gate 8437c478bd9Sstevel@tonic-gate# 8447c478bd9Sstevel@tonic-gate# If BRINGOVER_WS was not specified, let it default to CLONE_WS 8457c478bd9Sstevel@tonic-gate# 8467c478bd9Sstevel@tonic-gateif [ "$BRINGOVER_WS" = "" ]; then 8477c478bd9Sstevel@tonic-gate BRINGOVER_WS=$CLONE_WS 8487c478bd9Sstevel@tonic-gatefi 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate# 851fb23a357Skupfer# If BRINGOVER_FILES was not specified, default to usr 852a5c06a9eSmike_s# 853a5c06a9eSmike_sif [ "$BRINGOVER_FILES" = "" ]; then 854fb23a357Skupfer BRINGOVER_FILES="usr" 855a5c06a9eSmike_sfi 856a5c06a9eSmike_s 857c3e6cb59SRichard Lowecheck_closed_bins 858fb9f9b97Skupfer 859a5c06a9eSmike_s# 8607c478bd9Sstevel@tonic-gate# Note: changes to the option letters here should also be applied to the 861b84bdc30Smeem# bldenv script. `d' is listed for backward compatibility. 8627c478bd9Sstevel@tonic-gate# 863d77e7149SsommerfeNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 8647c478bd9Sstevel@tonic-gateOPTIND=1 865cb4d1691SRichard Lowewhile getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 8667c478bd9Sstevel@tonic-gatedo 8677c478bd9Sstevel@tonic-gate case $FLAG in 8687c478bd9Sstevel@tonic-gate A ) A_FLAG=y 8697c478bd9Sstevel@tonic-gate ;; 8707c478bd9Sstevel@tonic-gate B ) D_FLAG=y 8717c478bd9Sstevel@tonic-gate ;; # old version of D 8726c3c9007Sstevel C ) C_FLAG=y 8737c478bd9Sstevel@tonic-gate ;; 8747c478bd9Sstevel@tonic-gate D ) D_FLAG=y 8757c478bd9Sstevel@tonic-gate ;; 8766c3c9007Sstevel F ) F_FLAG=y 8777c478bd9Sstevel@tonic-gate ;; 8786c3c9007Sstevel f ) f_FLAG=y 8797c478bd9Sstevel@tonic-gate ;; 88078add226Sjmcp G ) u_FLAG=y 8817c478bd9Sstevel@tonic-gate ;; 88278add226Sjmcp I ) m_FLAG=y 8837c478bd9Sstevel@tonic-gate p_FLAG=y 8847c478bd9Sstevel@tonic-gate u_FLAG=y 8857c478bd9Sstevel@tonic-gate ;; 8867c478bd9Sstevel@tonic-gate i ) i_FLAG=y 8877c478bd9Sstevel@tonic-gate ;; 8886c3c9007Sstevel l ) l_FLAG=y 8896c3c9007Sstevel ;; 8906c3c9007Sstevel M ) M_FLAG=y 8916c3c9007Sstevel ;; 8926c3c9007Sstevel m ) m_FLAG=y 8936c3c9007Sstevel ;; 8946c3c9007Sstevel N ) N_FLAG=y 8956c3c9007Sstevel ;; 8967c478bd9Sstevel@tonic-gate n ) n_FLAG=y 8977c478bd9Sstevel@tonic-gate ;; 8987c478bd9Sstevel@tonic-gate p ) p_FLAG=y 8997c478bd9Sstevel@tonic-gate ;; 9006c3c9007Sstevel R ) m_FLAG=y 9016c3c9007Sstevel p_FLAG=y 9026c3c9007Sstevel ;; 9037c478bd9Sstevel@tonic-gate r ) r_FLAG=y 9047c478bd9Sstevel@tonic-gate ;; 905fd7cef36Ssuha +t ) t_FLAG=n 9067c478bd9Sstevel@tonic-gate ;; 9076798c3f0SMark J. Nelson U ) if [ -z "${PARENT_ROOT}" ]; then 9087c478bd9Sstevel@tonic-gate echo "PARENT_ROOT must be set if the U flag is" \ 9097c478bd9Sstevel@tonic-gate "present in NIGHTLY_OPTIONS." 9107c478bd9Sstevel@tonic-gate exit 1 9117c478bd9Sstevel@tonic-gate fi 9126798c3f0SMark J. Nelson NIGHTLY_PARENT_ROOT=$PARENT_ROOT 9136798c3f0SMark J. Nelson if [ -n "${PARENT_TOOLS_ROOT}" ]; then 9146798c3f0SMark J. Nelson NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 915ead1f93eSLiane Praza fi 9167c478bd9Sstevel@tonic-gate U_FLAG=y 9177c478bd9Sstevel@tonic-gate ;; 9186c3c9007Sstevel u ) u_FLAG=y 9197c478bd9Sstevel@tonic-gate ;; 9206c3c9007Sstevel w ) w_FLAG=y 9217c478bd9Sstevel@tonic-gate ;; 922cb4d1691SRichard Lowe W ) W_FLAG=y 923cb4d1691SRichard Lowe ;; 9247c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 9257c478bd9Sstevel@tonic-gate exit 1 9267c478bd9Sstevel@tonic-gate ;; 9277c478bd9Sstevel@tonic-gate esac 9287c478bd9Sstevel@tonic-gatedone 9297c478bd9Sstevel@tonic-gate 9307c478bd9Sstevel@tonic-gateif [ $ISUSER -ne 0 ]; then 9317c478bd9Sstevel@tonic-gate # Set default value for STAFFER, if needed. 9327c478bd9Sstevel@tonic-gate if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 9337c478bd9Sstevel@tonic-gate STAFFER=`/usr/xpg4/bin/id -un` 9347c478bd9Sstevel@tonic-gate export STAFFER 9357c478bd9Sstevel@tonic-gate fi 9367c478bd9Sstevel@tonic-gatefi 9377c478bd9Sstevel@tonic-gate 9387c478bd9Sstevel@tonic-gateif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 9397c478bd9Sstevel@tonic-gate MAILTO=$STAFFER 9407c478bd9Sstevel@tonic-gate export MAILTO 9417c478bd9Sstevel@tonic-gatefi 9427c478bd9Sstevel@tonic-gate 943c168ccb7SMark J. NelsonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 944c3e6cb59SRichard LowePATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 945c168ccb7SMark J. NelsonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 9467c478bd9Sstevel@tonic-gateexport PATH 9477c478bd9Sstevel@tonic-gate 948fb23a357Skupfer# roots of source trees, both relative to $SRC and absolute. 949fb23a357Skupferrelsrcdirs="." 950c0e7977aSJosef 'Jeff' Sipekabssrcdirs="$SRC" 951fb23a357Skupfer 9527c478bd9Sstevel@tonic-gatePROTOCMPTERSE="protocmp.terse -gu" 9537c478bd9Sstevel@tonic-gatePOUND_SIGN="#" 95448bc00d6Sjmcp# have we set RELEASE_DATE in our env file? 95548bc00d6Sjmcpif [ -z "$RELEASE_DATE" ]; then 95648bc00d6Sjmcp RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 95748bc00d6Sjmcpfi 95848bc00d6SjmcpBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 95948bc00d6SjmcpBASEWSDIR=$(basename $CODEMGR_WS) 96048bc00d6SjmcpDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 9617c478bd9Sstevel@tonic-gate 96248bc00d6Sjmcp# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 963c3e6cb59SRichard Lowe# by avoiding repeated shell invocations to evaluate Makefile.master 964c3e6cb59SRichard Lowe# definitions. 965c3e6cb59SRichard Loweexport POUND_SIGN RELEASE_DATE DEV_CM 9667c478bd9Sstevel@tonic-gate 9677c478bd9Sstevel@tonic-gatemaketype="distributed" 968e119f243SRobert Mustacchiif [[ -z "$MAKE" ]]; then 9697c478bd9Sstevel@tonic-gate MAKE=dmake 970e119f243SRobert Mustacchielif [[ ! -x "$MAKE" ]]; then 971e119f243SRobert Mustacchi echo "\$MAKE is set to garbage in the environment" 972e119f243SRobert Mustacchi exit 1 973e119f243SRobert Mustacchifi 9747c478bd9Sstevel@tonic-gate# get the dmake version string alone 9757c478bd9Sstevel@tonic-gateDMAKE_VERSION=$( $MAKE -v ) 9767c478bd9Sstevel@tonic-gateDMAKE_VERSION=${DMAKE_VERSION#*: } 9777c478bd9Sstevel@tonic-gate# focus in on just the dotted version number alone 9787c478bd9Sstevel@tonic-gateDMAKE_MAJOR=$( echo $DMAKE_VERSION | \ 9797c478bd9Sstevel@tonic-gate sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' ) 9807c478bd9Sstevel@tonic-gate# extract the second (or final) integer 9817c478bd9Sstevel@tonic-gateDMAKE_MINOR=${DMAKE_MAJOR#*.} 9827c478bd9Sstevel@tonic-gateDMAKE_MINOR=${DMAKE_MINOR%%.*} 9837c478bd9Sstevel@tonic-gate# extract the first integer 9847c478bd9Sstevel@tonic-gateDMAKE_MAJOR=${DMAKE_MAJOR%%.*} 9857c478bd9Sstevel@tonic-gateCHECK_DMAKE=${CHECK_DMAKE:-y} 9867c478bd9Sstevel@tonic-gate# x86 was built on the 12th, sparc on the 13th. 9877c478bd9Sstevel@tonic-gateif [ "$CHECK_DMAKE" = "y" -a \ 9887c478bd9Sstevel@tonic-gate "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \ 9897c478bd9Sstevel@tonic-gate "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \ 9907c478bd9Sstevel@tonic-gate "$DMAKE_MAJOR" -lt 7 -o \ 9917c478bd9Sstevel@tonic-gate "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then 9927c478bd9Sstevel@tonic-gate if [ -z "$DMAKE_VERSION" ]; then 9937c478bd9Sstevel@tonic-gate echo "$MAKE is missing." 9947c478bd9Sstevel@tonic-gate exit 1 9957c478bd9Sstevel@tonic-gate fi 9967c478bd9Sstevel@tonic-gate echo `whence $MAKE`" version is:" 9977c478bd9Sstevel@tonic-gate echo " ${DMAKE_VERSION}" 9987c478bd9Sstevel@tonic-gate cat <<EOF 9997c478bd9Sstevel@tonic-gate 1000c3e6cb59SRichard LoweThis version may not be safe for use, if you really want to use this version 1001c3e6cb59SRichard Loweanyway add the following to your environment to disable this check: 10027c478bd9Sstevel@tonic-gate 10037c478bd9Sstevel@tonic-gate CHECK_DMAKE=n 10047c478bd9Sstevel@tonic-gateEOF 10057c478bd9Sstevel@tonic-gate exit 1 10067c478bd9Sstevel@tonic-gatefi 10077c478bd9Sstevel@tonic-gateexport PATH 10087c478bd9Sstevel@tonic-gateexport MAKE 10097c478bd9Sstevel@tonic-gate 10107c478bd9Sstevel@tonic-gateif [ "${SUNWSPRO}" != "" ]; then 10117c478bd9Sstevel@tonic-gate PATH="${SUNWSPRO}/bin:$PATH" 10127c478bd9Sstevel@tonic-gate export PATH 10137c478bd9Sstevel@tonic-gatefi 10147c478bd9Sstevel@tonic-gate 101599e4a37bSWill Fiveashhostname=$(uname -n) 101699e4a37bSWill Fiveashif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 101799e4a37bSWill Fiveashthen 101899e4a37bSWill Fiveash maxjobs= 101999e4a37bSWill Fiveash if [[ -f $HOME/.make.machines ]] 102099e4a37bSWill Fiveash then 102199e4a37bSWill Fiveash # Note: there is a hard tab and space character in the []s 102299e4a37bSWill Fiveash # below. 102399e4a37bSWill Fiveash egrep -i "^[ ]*$hostname[ \.]" \ 102499e4a37bSWill Fiveash $HOME/.make.machines | read host jobs 102599e4a37bSWill Fiveash maxjobs=${jobs##*=} 10267c478bd9Sstevel@tonic-gate fi 102799e4a37bSWill Fiveash 102899e4a37bSWill Fiveash if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 102999e4a37bSWill Fiveash then 103099e4a37bSWill Fiveash # default 103199e4a37bSWill Fiveash maxjobs=4 10327c478bd9Sstevel@tonic-gate fi 103399e4a37bSWill Fiveash 103499e4a37bSWill Fiveash export DMAKE_MAX_JOBS=$maxjobs 103599e4a37bSWill Fiveashfi 103699e4a37bSWill Fiveash 10377c478bd9Sstevel@tonic-gateDMAKE_MODE=parallel; 10387c478bd9Sstevel@tonic-gateexport DMAKE_MODE 10397c478bd9Sstevel@tonic-gate 10407c478bd9Sstevel@tonic-gateif [ -z "${ROOT}" ]; then 10417c478bd9Sstevel@tonic-gate echo "ROOT must be set." 10427c478bd9Sstevel@tonic-gate exit 1 10437c478bd9Sstevel@tonic-gatefi 10447c478bd9Sstevel@tonic-gate 10457c478bd9Sstevel@tonic-gate# 10467c478bd9Sstevel@tonic-gate# if -V flag was given, reset VERSION to V_ARG 10477c478bd9Sstevel@tonic-gate# 10487c478bd9Sstevel@tonic-gateif [ "$V_FLAG" = "y" ]; then 10497c478bd9Sstevel@tonic-gate VERSION=$V_ARG 10507c478bd9Sstevel@tonic-gatefi 10517c478bd9Sstevel@tonic-gate 10527c478bd9Sstevel@tonic-gateTMPDIR="/tmp/nightly.tmpdir.$$" 10537c478bd9Sstevel@tonic-gateexport TMPDIR 10547c478bd9Sstevel@tonic-gaterm -rf ${TMPDIR} 10557c478bd9Sstevel@tonic-gatemkdir -p $TMPDIR || exit 1 105685f46905SMark J. Nelsonchmod 777 $TMPDIR 10577c478bd9Sstevel@tonic-gate 10587c478bd9Sstevel@tonic-gate# 10597c478bd9Sstevel@tonic-gate# Keep elfsign's use of pkcs11_softtoken from looking in the user home 10607c478bd9Sstevel@tonic-gate# directory, which doesn't always work. Needed until all build machines 10617c478bd9Sstevel@tonic-gate# have the fix for 6271754 10627c478bd9Sstevel@tonic-gate# 10637c478bd9Sstevel@tonic-gateSOFTTOKEN_DIR=$TMPDIR 10647c478bd9Sstevel@tonic-gateexport SOFTTOKEN_DIR 10657c478bd9Sstevel@tonic-gate 1066ead1f93eSLiane Praza# 1067ead1f93eSLiane Praza# Tools should only be built non-DEBUG. Keep track of the tools proto 1068ead1f93eSLiane Praza# area path relative to $TOOLS, because the latter changes in an 1069ead1f93eSLiane Praza# export build. 1070ead1f93eSLiane Praza# 1071ead1f93eSLiane Praza# TOOLS_PROTO is included below for builds other than usr/src/tools 1072ead1f93eSLiane Praza# that look for this location. For usr/src/tools, this will be 1073ead1f93eSLiane Praza# overridden on the $MAKE command line in build_tools(). 1074ead1f93eSLiane Praza# 10757c478bd9Sstevel@tonic-gateTOOLS=${SRC}/tools 1076ead1f93eSLiane PrazaTOOLS_PROTO_REL=proto/root_${MACH}-nd 1077ead1f93eSLiane PrazaTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1078ead1f93eSLiane Praza 10797c478bd9Sstevel@tonic-gateunset CFLAGS LD_LIBRARY_PATH LDFLAGS 10807c478bd9Sstevel@tonic-gate 10817c478bd9Sstevel@tonic-gate# create directories that are automatically removed if the nightly script 10827c478bd9Sstevel@tonic-gate# fails to start correctly 1083597bd30bSMike Kupferfunction newdir { 10847c478bd9Sstevel@tonic-gate dir=$1 10857c478bd9Sstevel@tonic-gate toadd= 10867c478bd9Sstevel@tonic-gate while [ ! -d $dir ]; do 10877c478bd9Sstevel@tonic-gate toadd="$dir $toadd" 10887c478bd9Sstevel@tonic-gate dir=`dirname $dir` 10897c478bd9Sstevel@tonic-gate done 10907c478bd9Sstevel@tonic-gate torm= 10917c478bd9Sstevel@tonic-gate newlist= 10927c478bd9Sstevel@tonic-gate for dir in $toadd; do 10937c478bd9Sstevel@tonic-gate if staffer mkdir $dir; then 10947c478bd9Sstevel@tonic-gate newlist="$ISUSER $dir $newlist" 10957c478bd9Sstevel@tonic-gate torm="$dir $torm" 10967c478bd9Sstevel@tonic-gate else 10977c478bd9Sstevel@tonic-gate [ -z "$torm" ] || staffer rmdir $torm 10987c478bd9Sstevel@tonic-gate return 1 10997c478bd9Sstevel@tonic-gate fi 11007c478bd9Sstevel@tonic-gate done 11017c478bd9Sstevel@tonic-gate newdirlist="$newlist $newdirlist" 11027c478bd9Sstevel@tonic-gate return 0 11037c478bd9Sstevel@tonic-gate} 11047c478bd9Sstevel@tonic-gatenewdirlist= 11057c478bd9Sstevel@tonic-gate 11067c478bd9Sstevel@tonic-gate[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 11077c478bd9Sstevel@tonic-gate 11087c478bd9Sstevel@tonic-gate# since this script assumes the build is from full source, it nullifies 11097c478bd9Sstevel@tonic-gate# variables likely to have been set by a "ws" script; nullification 11107c478bd9Sstevel@tonic-gate# confines the search space for headers and libraries to the proto area 11117c478bd9Sstevel@tonic-gate# built from this immediate source. 11127c478bd9Sstevel@tonic-gateENVLDLIBS1= 11137c478bd9Sstevel@tonic-gateENVLDLIBS2= 11147c478bd9Sstevel@tonic-gateENVLDLIBS3= 11157c478bd9Sstevel@tonic-gateENVCPPFLAGS1= 11167c478bd9Sstevel@tonic-gateENVCPPFLAGS2= 11177c478bd9Sstevel@tonic-gateENVCPPFLAGS3= 11187c478bd9Sstevel@tonic-gateENVCPPFLAGS4= 11197c478bd9Sstevel@tonic-gatePARENT_ROOT= 11207c478bd9Sstevel@tonic-gate 11217c478bd9Sstevel@tonic-gateexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1122494f7e12SKeith M Wesolowski ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 11237c478bd9Sstevel@tonic-gate 11247c478bd9Sstevel@tonic-gatePKGARCHIVE_ORIG=$PKGARCHIVE 11257c478bd9Sstevel@tonic-gate 11267c478bd9Sstevel@tonic-gate# 11277c478bd9Sstevel@tonic-gate# Juggle the logs and optionally send mail on completion. 11287c478bd9Sstevel@tonic-gate# 11297c478bd9Sstevel@tonic-gate 1130597bd30bSMike Kupferfunction logshuffle { 1131fd7cef36Ssuha LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 11327c478bd9Sstevel@tonic-gate if [ -f $LLOG -o -d $LLOG ]; then 11337c478bd9Sstevel@tonic-gate LLOG=$LLOG.$$ 11347c478bd9Sstevel@tonic-gate fi 11357c478bd9Sstevel@tonic-gate mkdir $LLOG 11364802ef38Srscott export LLOG 11377c478bd9Sstevel@tonic-gate 11387c478bd9Sstevel@tonic-gate if [ "$build_ok" = "y" ]; then 11397c478bd9Sstevel@tonic-gate mv $ATLOG/proto_list_${MACH} $LLOG 114096ccc8cbSesaxe 11412e02daeeSRainer Orth if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 11422e02daeeSRainer Orth mv $ATLOG/proto_list_tools_${MACH} $LLOG 11432e02daeeSRainer Orth fi 11442e02daeeSRainer Orth 114596ccc8cbSesaxe if [ -f $TMPDIR/wsdiff.results ]; then 114696ccc8cbSesaxe mv $TMPDIR/wsdiff.results $LLOG 114796ccc8cbSesaxe fi 11484e5b757fSkupfer 11494e5b757fSkupfer if [ -f $TMPDIR/wsdiff-nd.results ]; then 11504e5b757fSkupfer mv $TMPDIR/wsdiff-nd.results $LLOG 11514e5b757fSkupfer fi 11527c478bd9Sstevel@tonic-gate fi 11537c478bd9Sstevel@tonic-gate 11547c478bd9Sstevel@tonic-gate # 11557c478bd9Sstevel@tonic-gate # Now that we're about to send mail, it's time to check the noise 11567c478bd9Sstevel@tonic-gate # file. In the event that an error occurs beyond this point, it will 11577c478bd9Sstevel@tonic-gate # be recorded in the nightly.log file, but nowhere else. This would 11587c478bd9Sstevel@tonic-gate # include only errors that cause the copying of the noise log to fail 11597c478bd9Sstevel@tonic-gate # or the mail itself not to be sent. 11607c478bd9Sstevel@tonic-gate # 11617c478bd9Sstevel@tonic-gate 11627c478bd9Sstevel@tonic-gate exec >>$LOGFILE 2>&1 11637c478bd9Sstevel@tonic-gate if [ -s $build_noise_file ]; then 11647c478bd9Sstevel@tonic-gate echo "\n==== Nightly build noise ====\n" | 11657c478bd9Sstevel@tonic-gate tee -a $LOGFILE >>$mail_msg_file 11667c478bd9Sstevel@tonic-gate cat $build_noise_file >>$LOGFILE 11677c478bd9Sstevel@tonic-gate cat $build_noise_file >>$mail_msg_file 11687c478bd9Sstevel@tonic-gate echo | tee -a $LOGFILE >>$mail_msg_file 11697c478bd9Sstevel@tonic-gate fi 11707c478bd9Sstevel@tonic-gate rm -f $build_noise_file 11717c478bd9Sstevel@tonic-gate 11727c478bd9Sstevel@tonic-gate case "$build_ok" in 11737c478bd9Sstevel@tonic-gate y) 11747c478bd9Sstevel@tonic-gate state=Completed 11757c478bd9Sstevel@tonic-gate ;; 11767c478bd9Sstevel@tonic-gate i) 11777c478bd9Sstevel@tonic-gate state=Interrupted 11787c478bd9Sstevel@tonic-gate ;; 11797c478bd9Sstevel@tonic-gate *) 11807c478bd9Sstevel@tonic-gate state=Failed 11817c478bd9Sstevel@tonic-gate ;; 11827c478bd9Sstevel@tonic-gate esac 1183cb4d1691SRichard Lowe 1184cb4d1691SRichard Lowe if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 1185cb4d1691SRichard Lowe state=Failed 1186cb4d1691SRichard Lowe fi 1187cb4d1691SRichard Lowe 118840bc9153Srscott NIGHTLY_STATUS=$state 118940bc9153Srscott export NIGHTLY_STATUS 11907c478bd9Sstevel@tonic-gate 119147703246Ssommerfe run_hook POST_NIGHTLY $state 119247703246Ssommerfe run_hook SYS_POST_NIGHTLY $state 11934802ef38Srscott 11943cb00cf1SJoshua M. Clulow # 11953cb00cf1SJoshua M. Clulow # mailx(1) sets From: based on the -r flag 11963cb00cf1SJoshua M. Clulow # if it is given. 11973cb00cf1SJoshua M. Clulow # 11983cb00cf1SJoshua M. Clulow mailx_r= 11993cb00cf1SJoshua M. Clulow if [[ -n "${MAILFROM}" ]]; then 12003cb00cf1SJoshua M. Clulow mailx_r="-r ${MAILFROM}" 12013cb00cf1SJoshua M. Clulow fi 12023cb00cf1SJoshua M. Clulow 1203cdf0c1d5Smjnelson cat $build_time_file $build_environ_file $mail_msg_file \ 1204cdf0c1d5Smjnelson > ${LLOG}/mail_msg 12057c478bd9Sstevel@tonic-gate if [ "$m_FLAG" = "y" ]; then 12063cb00cf1SJoshua M. Clulow cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 12077c478bd9Sstevel@tonic-gate "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 12087c478bd9Sstevel@tonic-gate ${MAILTO} 12097c478bd9Sstevel@tonic-gate fi 12107c478bd9Sstevel@tonic-gate 12117c478bd9Sstevel@tonic-gate if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 12127c478bd9Sstevel@tonic-gate staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 12137c478bd9Sstevel@tonic-gate staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 12147c478bd9Sstevel@tonic-gate fi 12157c478bd9Sstevel@tonic-gate 12167c478bd9Sstevel@tonic-gate mv $LOGFILE $LLOG 12177c478bd9Sstevel@tonic-gate} 12187c478bd9Sstevel@tonic-gate 12197c478bd9Sstevel@tonic-gate# 12207c478bd9Sstevel@tonic-gate# Remove the locks and temporary files on any exit 12217c478bd9Sstevel@tonic-gate# 1222597bd30bSMike Kupferfunction cleanup { 12237c478bd9Sstevel@tonic-gate logshuffle 12247c478bd9Sstevel@tonic-gate 12257c478bd9Sstevel@tonic-gate [ -z "$lockfile" ] || staffer rm -f $lockfile 12267c478bd9Sstevel@tonic-gate [ -z "$atloglockfile" ] || rm -f $atloglockfile 12277c478bd9Sstevel@tonic-gate [ -z "$ulockfile" ] || staffer rm -f $ulockfile 12287c478bd9Sstevel@tonic-gate [ -z "$Ulockfile" ] || rm -f $Ulockfile 12297c478bd9Sstevel@tonic-gate 12307c478bd9Sstevel@tonic-gate set -- $newdirlist 12317c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 12327c478bd9Sstevel@tonic-gate ISUSER=$1 staffer rmdir $2 12337c478bd9Sstevel@tonic-gate shift; shift 12347c478bd9Sstevel@tonic-gate done 12357c478bd9Sstevel@tonic-gate rm -rf $TMPDIR 12367c478bd9Sstevel@tonic-gate} 12377c478bd9Sstevel@tonic-gate 1238597bd30bSMike Kupferfunction cleanup_signal { 12397c478bd9Sstevel@tonic-gate build_ok=i 12407c478bd9Sstevel@tonic-gate # this will trigger cleanup(), above. 12417c478bd9Sstevel@tonic-gate exit 1 12427c478bd9Sstevel@tonic-gate} 12437c478bd9Sstevel@tonic-gate 12447c478bd9Sstevel@tonic-gatetrap cleanup 0 12457c478bd9Sstevel@tonic-gatetrap cleanup_signal 1 2 3 15 12467c478bd9Sstevel@tonic-gate 12477c478bd9Sstevel@tonic-gate# 12487c478bd9Sstevel@tonic-gate# Generic lock file processing -- make sure that the lock file doesn't 12497c478bd9Sstevel@tonic-gate# exist. If it does, it should name the build host and PID. If it 12507c478bd9Sstevel@tonic-gate# doesn't, then make sure we can create it. Clean up locks that are 12517c478bd9Sstevel@tonic-gate# known to be stale (assumes host name is unique among build systems 12527c478bd9Sstevel@tonic-gate# for the workspace). 1253cdf0c1d5Smjnelson# 1254597bd30bSMike Kupferfunction create_lock { 12557c478bd9Sstevel@tonic-gate lockf=$1 12567c478bd9Sstevel@tonic-gate lockvar=$2 12578312e758Sdduvall 12587c478bd9Sstevel@tonic-gate ldir=`dirname $lockf` 12597c478bd9Sstevel@tonic-gate [ -d $ldir ] || newdir $ldir || exit 1 12607c478bd9Sstevel@tonic-gate eval $lockvar=$lockf 12618312e758Sdduvall 12628312e758Sdduvall while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 12638312e758Sdduvall basews=`basename $CODEMGR_WS` 12648312e758Sdduvall ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 12658312e758Sdduvall if [ "$host" != "$hostname" ]; then 12668312e758Sdduvall echo "$MACH build of $basews apparently" \ 12678312e758Sdduvall "already started by $user on $host as $pid." 12688312e758Sdduvall exit 1 12698312e758Sdduvall elif kill -s 0 $pid 2>/dev/null; then 12708312e758Sdduvall echo "$MACH build of $basews already started" \ 12718312e758Sdduvall "by $user as $pid." 12728312e758Sdduvall exit 1 12738312e758Sdduvall else 12748312e758Sdduvall # stale lock; clear it out and try again 12758312e758Sdduvall rm -f $lockf 12768312e758Sdduvall fi 12778312e758Sdduvall done 12787c478bd9Sstevel@tonic-gate} 12797c478bd9Sstevel@tonic-gate 12804e5b757fSkupfer# 12814e5b757fSkupfer# Return the list of interesting proto areas, depending on the current 12824e5b757fSkupfer# options. 12834e5b757fSkupfer# 1284597bd30bSMike Kupferfunction allprotos { 1285c7453724SMike Kupfer typeset roots="$ROOT" 1286b83ec4edSjmcp 1287c7453724SMike Kupfer if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1288c7453724SMike Kupfer roots="$roots $ROOT-nd" 12894e5b757fSkupfer fi 12904e5b757fSkupfer 12914e5b757fSkupfer echo $roots 12924e5b757fSkupfer} 12934e5b757fSkupfer 12947c478bd9Sstevel@tonic-gate# Ensure no other instance of this script is running on this host. 12957c478bd9Sstevel@tonic-gate# LOCKNAME can be set in <env_file>, and is by default, but is not 12967c478bd9Sstevel@tonic-gate# required due to the use of $ATLOG below. 12977c478bd9Sstevel@tonic-gateif [ -n "$LOCKNAME" ]; then 12987c478bd9Sstevel@tonic-gate create_lock /tmp/$LOCKNAME "lockfile" 12997c478bd9Sstevel@tonic-gatefi 13007c478bd9Sstevel@tonic-gate# 13017c478bd9Sstevel@tonic-gate# Create from one, two, or three other locks: 13027c478bd9Sstevel@tonic-gate# $ATLOG/nightly.lock 13037c478bd9Sstevel@tonic-gate# - protects against multiple builds in same workspace 13047c478bd9Sstevel@tonic-gate# $PARENT_WS/usr/src/nightly.$MACH.lock 13057c478bd9Sstevel@tonic-gate# - protects against multiple 'u' copy-backs 13067c478bd9Sstevel@tonic-gate# $NIGHTLY_PARENT_ROOT/nightly.lock 13077c478bd9Sstevel@tonic-gate# - protects against multiple 'U' copy-backs 13087c478bd9Sstevel@tonic-gate# 13097c478bd9Sstevel@tonic-gate# Overriding ISUSER to 1 causes the lock to be created as root if the 13107c478bd9Sstevel@tonic-gate# script is run as root. The default is to create it as $STAFFER. 13117c478bd9Sstevel@tonic-gateISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 13127c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" ]; then 13137c478bd9Sstevel@tonic-gate create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 13147c478bd9Sstevel@tonic-gatefi 13157c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" ]; then 13167c478bd9Sstevel@tonic-gate # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 13177c478bd9Sstevel@tonic-gate ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 13187c478bd9Sstevel@tonic-gatefi 13197c478bd9Sstevel@tonic-gate 13207c478bd9Sstevel@tonic-gate# Locks have been taken, so we're doing a build and we're committed to 13217c478bd9Sstevel@tonic-gate# the directories we may have created so far. 13227c478bd9Sstevel@tonic-gatenewdirlist= 13237c478bd9Sstevel@tonic-gate 13247c478bd9Sstevel@tonic-gate# 13257c478bd9Sstevel@tonic-gate# Create mail_msg_file 13267c478bd9Sstevel@tonic-gate# 13277c478bd9Sstevel@tonic-gatemail_msg_file="${TMPDIR}/mail_msg" 13287c478bd9Sstevel@tonic-gatetouch $mail_msg_file 13297c478bd9Sstevel@tonic-gatebuild_time_file="${TMPDIR}/build_time" 1330cdf0c1d5Smjnelsonbuild_environ_file="${TMPDIR}/build_environ" 1331cdf0c1d5Smjnelsontouch $build_environ_file 13327c478bd9Sstevel@tonic-gate# 13337c478bd9Sstevel@tonic-gate# Move old LOGFILE aside 13347c478bd9Sstevel@tonic-gate# ATLOG directory already made by 'create_lock' above 13357c478bd9Sstevel@tonic-gate# 13367c478bd9Sstevel@tonic-gateif [ -f $LOGFILE ]; then 13377c478bd9Sstevel@tonic-gate mv -f $LOGFILE ${LOGFILE}- 13387c478bd9Sstevel@tonic-gatefi 13397c478bd9Sstevel@tonic-gate# 13407c478bd9Sstevel@tonic-gate# Build OsNet source 13417c478bd9Sstevel@tonic-gate# 13427c478bd9Sstevel@tonic-gateSTART_DATE=`date` 13437c478bd9Sstevel@tonic-gateSECONDS=0 13447c478bd9Sstevel@tonic-gateecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 13457c478bd9Sstevel@tonic-gate | tee -a $LOGFILE > $build_time_file 13467c478bd9Sstevel@tonic-gate 1347cdf0c1d5Smjnelsonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1348cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 1349cdf0c1d5Smjnelson 13507c478bd9Sstevel@tonic-gate# make sure we log only to the nightly build file 13517c478bd9Sstevel@tonic-gatebuild_noise_file="${TMPDIR}/build_noise" 13527c478bd9Sstevel@tonic-gateexec </dev/null >$build_noise_file 2>&1 13537c478bd9Sstevel@tonic-gate 135447703246Ssommerferun_hook SYS_PRE_NIGHTLY 135547703246Ssommerferun_hook PRE_NIGHTLY 135647703246Ssommerfe 13577c478bd9Sstevel@tonic-gateecho "\n==== list of environment variables ====\n" >> $LOGFILE 13587c478bd9Sstevel@tonic-gateenv >> $LOGFILE 13597c478bd9Sstevel@tonic-gate 13607c478bd9Sstevel@tonic-gateecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 13617c478bd9Sstevel@tonic-gate 13627c478bd9Sstevel@tonic-gateif [ "$N_FLAG" = "y" ]; then 13637c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" ]; then 13647c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13657c478bd9Sstevel@tonic-gateWARNING: the p option (create packages) is set, but so is the N option (do 13667c478bd9Sstevel@tonic-gate not run protocmp); this is dangerous; you should unset the N option 13677c478bd9Sstevel@tonic-gateEOF 13687c478bd9Sstevel@tonic-gate else 13697c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13707c478bd9Sstevel@tonic-gateWarning: the N option (do not run protocmp) is set; it probably shouldn't be 13717c478bd9Sstevel@tonic-gateEOF 13727c478bd9Sstevel@tonic-gate fi 13737c478bd9Sstevel@tonic-gate echo "" | tee -a $mail_msg_file >> $LOGFILE 13747c478bd9Sstevel@tonic-gatefi 13757c478bd9Sstevel@tonic-gate 13767c478bd9Sstevel@tonic-gateif [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 13774e5b757fSkupfer # 13784e5b757fSkupfer # In the past we just complained but went ahead with the lint 1379ead1f93eSLiane Praza # pass, even though the proto area was built non-DEBUG. It's 1380ead1f93eSLiane Praza # unlikely that non-DEBUG headers will make a difference, but 13814e5b757fSkupfer # rather than assuming it's a safe combination, force the user 1382ead1f93eSLiane Praza # to specify a DEBUG build. 13834e5b757fSkupfer # 13844e5b757fSkupfer echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 13857c478bd9Sstevel@tonic-gate | tee -a $mail_msg_file >> $LOGFILE 13864e5b757fSkupfer l_FLAG=n 13877c478bd9Sstevel@tonic-gatefi 13887c478bd9Sstevel@tonic-gate 13897c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" ]; then 13907c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "y" ]; then 13917c478bd9Sstevel@tonic-gate echo "WARNING: the -f flag cannot be used during incremental" \ 13927c478bd9Sstevel@tonic-gate "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13937c478bd9Sstevel@tonic-gate f_FLAG=n 13947c478bd9Sstevel@tonic-gate fi 139511a78ea0SMark J. Nelson if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 139611a78ea0SMark J. Nelson echo "WARNING: the -f flag requires -l, and -p;" \ 139711a78ea0SMark J. Nelson "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13987c478bd9Sstevel@tonic-gate f_FLAG=n 13997c478bd9Sstevel@tonic-gate fi 14007c478bd9Sstevel@tonic-gatefi 14017c478bd9Sstevel@tonic-gate 140296ccc8cbSesaxeif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 14034e5b757fSkupfer echo "WARNING: -w specified, but $ROOT does not exist;" \ 140496ccc8cbSesaxe "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 140596ccc8cbSesaxe w_FLAG=n 140696ccc8cbSesaxefi 140796ccc8cbSesaxe 14087c478bd9Sstevel@tonic-gateif [ "$t_FLAG" = "n" ]; then 14097c478bd9Sstevel@tonic-gate # 14107c478bd9Sstevel@tonic-gate # We're not doing a tools build, so make sure elfsign(1) is 14117c478bd9Sstevel@tonic-gate # new enough to safely sign non-crypto binaries. We test 14127c478bd9Sstevel@tonic-gate # debugging output from elfsign to detect the old version. 14137c478bd9Sstevel@tonic-gate # 14147c478bd9Sstevel@tonic-gate newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 14157c478bd9Sstevel@tonic-gate -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 14167c478bd9Sstevel@tonic-gate | egrep algorithmOID` 14177c478bd9Sstevel@tonic-gate if [ -z "$newelfsigntest" ]; then 14187c478bd9Sstevel@tonic-gate echo "WARNING: /usr/bin/elfsign out of date;" \ 14197c478bd9Sstevel@tonic-gate "will only sign crypto modules\n" | \ 14207c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 14217c478bd9Sstevel@tonic-gate export ELFSIGN_OBJECT=true 14227c478bd9Sstevel@tonic-gate elif [ "$VERIFY_ELFSIGN" = "y" ]; then 14237c478bd9Sstevel@tonic-gate echo "WARNING: VERIFY_ELFSIGN=y requires" \ 14247c478bd9Sstevel@tonic-gate "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 14257c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 14267c478bd9Sstevel@tonic-gate fi 14277c478bd9Sstevel@tonic-gatefi 14287c478bd9Sstevel@tonic-gate 14294e5b757fSkupfercase $MULTI_PROTO in 14304e5b757fSkupferyes|no) ;; 14314e5b757fSkupfer*) 14324e5b757fSkupfer echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 14334e5b757fSkupfer "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 14344e5b757fSkupfer echo "Setting MULTI_PROTO to \"no\".\n" | \ 14354e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 14364e5b757fSkupfer export MULTI_PROTO=no 14374e5b757fSkupfer ;; 14384e5b757fSkupferesac 14394e5b757fSkupfer 14407c478bd9Sstevel@tonic-gateecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 14417c478bd9Sstevel@tonic-gateecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 14427c478bd9Sstevel@tonic-gate 144396ccc8cbSesaxe# Save the current proto area if we're comparing against the last build 144496ccc8cbSesaxeif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 144596ccc8cbSesaxe if [ -d "$ROOT.prev" ]; then 144696ccc8cbSesaxe rm -rf $ROOT.prev 144796ccc8cbSesaxe fi 144896ccc8cbSesaxe mv $ROOT $ROOT.prev 144996ccc8cbSesaxefi 145096ccc8cbSesaxe 14514e5b757fSkupfer# Same for non-DEBUG proto area 14524e5b757fSkupferif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 14534e5b757fSkupfer if [ -d "$ROOT-nd.prev" ]; then 14544e5b757fSkupfer rm -rf $ROOT-nd.prev 14554e5b757fSkupfer fi 14564e5b757fSkupfer mv $ROOT-nd $ROOT-nd.prev 14574e5b757fSkupferfi 14584e5b757fSkupfer 1459445b6314SRichard Lowe# 1460445b6314SRichard Lowe# Echo the SCM type of the parent workspace, this can't just be which_scm 1461445b6314SRichard Lowe# as that does not know how to identify various network repositories. 1462445b6314SRichard Lowe# 1463445b6314SRichard Lowefunction parent_wstype { 1464445b6314SRichard Lowe typeset scm_type junk 146530635de9SJohn.Zolnowsky@Sun.COM 146630635de9SJohn.Zolnowsky@Sun.COM CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1467445b6314SRichard Lowe | read scm_type junk 1468445b6314SRichard Lowe if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 146930635de9SJohn.Zolnowsky@Sun.COM # Probe BRINGOVER_WS to determine its type 1470c3e6cb59SRichard Lowe if [[ $BRINGOVER_WS == ssh://* ]]; then 1471445b6314SRichard Lowe scm_type="mercurial" 147230635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == http://* ]] && \ 1473445b6314SRichard Lowe wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 147430635de9SJohn.Zolnowsky@Sun.COM egrep -s "application/mercurial" 2> /dev/null; then 1475445b6314SRichard Lowe scm_type="mercurial" 147630635de9SJohn.Zolnowsky@Sun.COM else 1477445b6314SRichard Lowe scm_type="none" 147830635de9SJohn.Zolnowsky@Sun.COM fi 147930635de9SJohn.Zolnowsky@Sun.COM fi 148030635de9SJohn.Zolnowsky@Sun.COM 148130635de9SJohn.Zolnowsky@Sun.COM # fold both unsupported and unrecognized results into "none" 1482445b6314SRichard Lowe case "$scm_type" in 1483c3e6cb59SRichard Lowe mercurial) 148430635de9SJohn.Zolnowsky@Sun.COM ;; 1485445b6314SRichard Lowe *) scm_type=none 148630635de9SJohn.Zolnowsky@Sun.COM ;; 148730635de9SJohn.Zolnowsky@Sun.COM esac 148830635de9SJohn.Zolnowsky@Sun.COM 1489445b6314SRichard Lowe echo $scm_type 149030635de9SJohn.Zolnowsky@Sun.COM} 149130635de9SJohn.Zolnowsky@Sun.COM 1492445b6314SRichard Lowe# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1493445b6314SRichard Lowefunction child_wstype { 1494445b6314SRichard Lowe typeset scm_type junk 1495445b6314SRichard Lowe 1496445b6314SRichard Lowe # Probe CODEMGR_WS to determine its type 1497445b6314SRichard Lowe if [[ -d $CODEMGR_WS ]]; then 1498445b6314SRichard Lowe $WHICH_SCM | read scm_type junk || exit 1 1499445b6314SRichard Lowe fi 1500445b6314SRichard Lowe 1501445b6314SRichard Lowe case "$scm_type" in 1502c3e6cb59SRichard Lowe none|git|mercurial) 1503445b6314SRichard Lowe ;; 1504445b6314SRichard Lowe *) scm_type=none 1505445b6314SRichard Lowe ;; 1506445b6314SRichard Lowe esac 1507445b6314SRichard Lowe 1508445b6314SRichard Lowe echo $scm_type 1509445b6314SRichard Lowe} 1510445b6314SRichard Lowe 15115c70f01eSRichard LoweSCM_TYPE=$(child_wstype) 151230635de9SJohn.Zolnowsky@Sun.COM 15137c478bd9Sstevel@tonic-gate# 15147c478bd9Sstevel@tonic-gate# Decide whether to clobber 15157c478bd9Sstevel@tonic-gate# 15167c478bd9Sstevel@tonic-gateif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 15177c478bd9Sstevel@tonic-gate echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 15187c478bd9Sstevel@tonic-gate 15197c478bd9Sstevel@tonic-gate cd $SRC 15207c478bd9Sstevel@tonic-gate # remove old clobber file 15217c478bd9Sstevel@tonic-gate rm -f $SRC/clobber.out 15227c478bd9Sstevel@tonic-gate rm -f $SRC/clobber-${MACH}.out 15237c478bd9Sstevel@tonic-gate 15247c478bd9Sstevel@tonic-gate # Remove all .make.state* files, just in case we are restarting 15257c478bd9Sstevel@tonic-gate # the build after having interrupted a previous 'make clobber'. 15268bcea973SRichard Lowe find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1527cdf0c1d5Smjnelson -o -name 'interfaces.*' \) -prune \ 15287c478bd9Sstevel@tonic-gate -o -name '.make.*' -print | xargs rm -f 15297c478bd9Sstevel@tonic-gate 15307c478bd9Sstevel@tonic-gate $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 15317c478bd9Sstevel@tonic-gate echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 15327c478bd9Sstevel@tonic-gate grep "$MAKE:" $SRC/clobber-${MACH}.out | 1533cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 1534cb4d1691SRichard Lowe tee $TMPDIR/clobber_errs >> $mail_msg_file 1535cb4d1691SRichard Lowe 1536cb4d1691SRichard Lowe if [[ -s $TMPDIR/clobber_errs ]]; then 1537cb4d1691SRichard Lowe build_extras_ok=n 1538cb4d1691SRichard Lowe fi 15397c478bd9Sstevel@tonic-gate 15405110237aSJosef 'Jeff' Sipek if [[ "$t_FLAG" = "y" ]]; then 15417c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 15427c478bd9Sstevel@tonic-gate cd ${TOOLS} 15437c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/clobber-${MACH}.out 1544ead1f93eSLiane Praza $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 15457c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 15467c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber ERRORS ====\n" \ 15477c478bd9Sstevel@tonic-gate >> $mail_msg_file 15487c478bd9Sstevel@tonic-gate grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 15497c478bd9Sstevel@tonic-gate >> $mail_msg_file 1550cb4d1691SRichard Lowe if (( $? == 0 )); then 1551cb4d1691SRichard Lowe build_extras_ok=n 1552cb4d1691SRichard Lowe fi 15537c478bd9Sstevel@tonic-gate rm -rf ${TOOLS_PROTO} 15547c478bd9Sstevel@tonic-gate mkdir -p ${TOOLS_PROTO} 15557c478bd9Sstevel@tonic-gate fi 155696ccc8cbSesaxe 1557c7453724SMike Kupfer typeset roots=$(allprotos) 1558c7453724SMike Kupfer echo "\n\nClearing $roots" >> "$LOGFILE" 1559c7453724SMike Kupfer rm -rf $roots 15607c478bd9Sstevel@tonic-gate 15617c478bd9Sstevel@tonic-gate # Get back to a clean workspace as much as possible to catch 15627c478bd9Sstevel@tonic-gate # problems that only occur on fresh workspaces. 15637c478bd9Sstevel@tonic-gate # Remove all .make.state* files, libraries, and .o's that may 1564fb23a357Skupfer # have been omitted from clobber. A couple of libraries are 1565cdf0c1d5Smjnelson # under source code control, so leave them alone. 15667c478bd9Sstevel@tonic-gate # We should probably blow away temporary directories too. 15677c478bd9Sstevel@tonic-gate cd $SRC 1568cdf0c1d5Smjnelson find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 15698bcea973SRichard Lowe -o -name .git -o -name 'interfaces.*' \) -prune -o \ 15707c478bd9Sstevel@tonic-gate \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1571fb23a357Skupfer -name '*.o' \) -print | \ 1572fb23a357Skupfer grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 15737c478bd9Sstevel@tonic-gateelse 15747c478bd9Sstevel@tonic-gate echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 15757c478bd9Sstevel@tonic-gatefi 15767c478bd9Sstevel@tonic-gate 1577597bd30bSMike Kupfertype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1578cdf0c1d5Smjnelson typeset -x PATH=$PATH 1579cdf0c1d5Smjnelson 1580cdf0c1d5Smjnelson # If the repository doesn't exist yet, then we want to populate it. 1581cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.hg ]]; then 1582cdf0c1d5Smjnelson staffer hg init $CODEMGR_WS 15838cca05f6SMark J. Nelson staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 15848cca05f6SMark J. Nelson staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1585f457028bSMark J. Nelson touch $TMPDIR/new_repository 1586cdf0c1d5Smjnelson fi 15875c53ea7aSmjnelson 1588cdf0c1d5Smjnelson typeset -x HGMERGE="/bin/false" 1589cdf0c1d5Smjnelson 1590cdf0c1d5Smjnelson # 15915c53ea7aSmjnelson # If the user has changes, regardless of whether those changes are 15925c53ea7aSmjnelson # committed, and regardless of whether those changes conflict, then 15935c53ea7aSmjnelson # we'll attempt to merge them either implicitly (uncommitted) or 15945c53ea7aSmjnelson # explicitly (committed). 1595cdf0c1d5Smjnelson # 15965c53ea7aSmjnelson # These are the messages we'll use to help clarify mercurial output 15975c53ea7aSmjnelson # in those cases. 15985c53ea7aSmjnelson # 15995c53ea7aSmjnelson typeset mergefailmsg="\ 16005c53ea7aSmjnelson***\n\ 16015c53ea7aSmjnelson*** nightly was unable to automatically merge your changes. You should\n\ 16025c53ea7aSmjnelson*** redo the full merge manually, following the steps outlined by mercurial\n\ 16035c53ea7aSmjnelson*** above, then restart nightly.\n\ 16045c53ea7aSmjnelson***\n" 16055c53ea7aSmjnelson typeset mergepassmsg="\ 16065c53ea7aSmjnelson***\n\ 16075c53ea7aSmjnelson*** nightly successfully merged your changes. This means that your working\n\ 16085c53ea7aSmjnelson*** directory has been updated, but those changes are not yet committed.\n\ 16095c53ea7aSmjnelson*** After nightly completes, you should validate the results of the merge,\n\ 16105c53ea7aSmjnelson*** then use hg commit manually.\n\ 16115c53ea7aSmjnelson***\n" 16125c53ea7aSmjnelson 16135c53ea7aSmjnelson # 16145c53ea7aSmjnelson # For each repository in turn: 16155c53ea7aSmjnelson # 16165c53ea7aSmjnelson # 1. Do the pull. If this fails, dump the output and bail out. 16175c53ea7aSmjnelson # 16185c53ea7aSmjnelson # 2. If the pull resulted in an extra head, do an explicit merge. 16195c53ea7aSmjnelson # If this fails, dump the output and bail out. 16205c53ea7aSmjnelson # 16215c53ea7aSmjnelson # Because we can't rely on Mercurial to exit with a failure code 16225c53ea7aSmjnelson # when a merge fails (Mercurial issue #186), we must grep the 16235c53ea7aSmjnelson # output of pull/merge to check for attempted and/or failed merges. 16245c53ea7aSmjnelson # 16255c53ea7aSmjnelson # 3. If a merge failed, set the message and fail the bringover. 16265c53ea7aSmjnelson # 16275c53ea7aSmjnelson # 4. Otherwise, if a merge succeeded, set the message 16285c53ea7aSmjnelson # 16295c53ea7aSmjnelson # 5. Dump the output, and any message from step 3 or 4. 16305c53ea7aSmjnelson # 16315c53ea7aSmjnelson 1632f457028bSMark J. Nelson typeset HG_SOURCE=$BRINGOVER_WS 1633f457028bSMark J. Nelson if [ ! -f $TMPDIR/new_repository ]; then 1634f457028bSMark J. Nelson HG_SOURCE=$TMPDIR/open_bundle.hg 1635f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1636f457028bSMark J. Nelson -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1637f457028bSMark J. Nelson 1638f457028bSMark J. Nelson # 1639f457028bSMark J. Nelson # If there are no incoming changesets, then incoming will 1640f457028bSMark J. Nelson # fail, and there will be no bundle file. Reset the source, 1641f457028bSMark J. Nelson # to allow the remaining logic to complete with no false 1642f457028bSMark J. Nelson # negatives. (Unlike incoming, pull will return success 1643f457028bSMark J. Nelson # for the no-change case.) 1644f457028bSMark J. Nelson # 1645f457028bSMark J. Nelson if (( $? != 0 )); then 1646f457028bSMark J. Nelson HG_SOURCE=$BRINGOVER_WS 1647f457028bSMark J. Nelson fi 1648f457028bSMark J. Nelson fi 1649f457028bSMark J. Nelson 1650f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 16515c53ea7aSmjnelson > $TMPDIR/pull_open.out 2>&1 16525c53ea7aSmjnelson if (( $? != 0 )); then 16535c53ea7aSmjnelson printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 16545c53ea7aSmjnelson cat $TMPDIR/pull_open.out 16555c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16565c53ea7aSmjnelson printf "$mergefailmsg" 16575c53ea7aSmjnelson fi 16585c53ea7aSmjnelson touch $TMPDIR/bringover_failed 16595c53ea7aSmjnelson return 16605c53ea7aSmjnelson fi 16615c53ea7aSmjnelson 1662cdf0c1d5Smjnelson if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16635c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS merge \ 16645c53ea7aSmjnelson >> $TMPDIR/pull_open.out 2>&1 16655c53ea7aSmjnelson if (( $? != 0 )); then 16665c53ea7aSmjnelson printf "%s: merge failed as follows:\n\n" \ 16675c53ea7aSmjnelson "$CODEMGR_WS" 16685c53ea7aSmjnelson cat $TMPDIR/pull_open.out 16695c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out \ 16705c53ea7aSmjnelson > /dev/null 2>&1; then 16715c53ea7aSmjnelson printf "$mergefailmsg" 16725c53ea7aSmjnelson fi 1673cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 16745c53ea7aSmjnelson return 1675cdf0c1d5Smjnelson fi 1676cdf0c1d5Smjnelson fi 16775c53ea7aSmjnelson 16785c53ea7aSmjnelson printf "updated %s with the following results:\n" "$CODEMGR_WS" 16795c53ea7aSmjnelson cat $TMPDIR/pull_open.out 16805c53ea7aSmjnelson if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 16815c53ea7aSmjnelson printf "$mergepassmsg" 16825c53ea7aSmjnelson fi 16835c53ea7aSmjnelson printf "\n" 16845c53ea7aSmjnelson 16855c53ea7aSmjnelson # 1686f457028bSMark J. Nelson # Per-changeset output is neither useful nor manageable for a 1687f457028bSMark J. Nelson # newly-created repository. 1688f457028bSMark J. Nelson # 1689f457028bSMark J. Nelson if [ -f $TMPDIR/new_repository ]; then 1690f457028bSMark J. Nelson return 1691f457028bSMark J. Nelson fi 1692f457028bSMark J. Nelson 1693f457028bSMark J. Nelson printf "\nadded the following changesets to open repository:\n" 1694f457028bSMark J. Nelson cat $TMPDIR/incoming_open.out 1695cdf0c1d5Smjnelson} 1696cdf0c1d5Smjnelson 1697597bd30bSMike Kupfertype bringover_none > /dev/null 2>&1 || function bringover_none { 1698cdf0c1d5Smjnelson echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1699cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1700cdf0c1d5Smjnelson} 1701cdf0c1d5Smjnelson 1702cdf0c1d5Smjnelson# 1703cdf0c1d5Smjnelson# Decide whether to bringover to the codemgr workspace 1704cdf0c1d5Smjnelson# 1705cdf0c1d5Smjnelsonif [ "$n_FLAG" = "n" ]; then 1706445b6314SRichard Lowe PARENT_SCM_TYPE=$(parent_wstype) 1707ca0ac982Smjnelson 1708ca0ac982Smjnelson if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1709ca0ac982Smjnelson echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1710ca0ac982Smjnelson "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 1711ca0ac982Smjnelson exit 1 1712ca0ac982Smjnelson fi 1713ca0ac982Smjnelson 1714cdf0c1d5Smjnelson run_hook PRE_BRINGOVER 1715cdf0c1d5Smjnelson 1716cdf0c1d5Smjnelson echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1717cdf0c1d5Smjnelson echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1718cdf0c1d5Smjnelson 1719ca0ac982Smjnelson eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 1720cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 172132f1e47bSsommerfe 172232f1e47bSsommerfe if [ -f $TMPDIR/bringover_failed ]; then 172332f1e47bSsommerfe rm -f $TMPDIR/bringover_failed 172432f1e47bSsommerfe build_ok=n 172532f1e47bSsommerfe echo "trouble with bringover, quitting at `date`." | 17267c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 17277c478bd9Sstevel@tonic-gate exit 1 17287c478bd9Sstevel@tonic-gate fi 1729085d331dSkupfer 1730ca0ac982Smjnelson # 1731ca0ac982Smjnelson # It's possible that we used the bringover above to create 1732ca0ac982Smjnelson # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 1733ca0ac982Smjnelson # but should now be the same as $BRINGOVER_WS. 1734ca0ac982Smjnelson # 1735ca0ac982Smjnelson [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 1736ca0ac982Smjnelson 173747703246Ssommerfe run_hook POST_BRINGOVER 173847703246Ssommerfe 1739c3e6cb59SRichard Lowe check_closed_bins 1740b83ec4edSjmcp 17417c478bd9Sstevel@tonic-gateelse 17427c478bd9Sstevel@tonic-gate echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 17437c478bd9Sstevel@tonic-gatefi 17447c478bd9Sstevel@tonic-gate 1745220399b7SRoland Mainz# Safeguards 1746220399b7SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 1747220399b7SRoland Mainz[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 1748220399b7SRoland Mainz[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 1749220399b7SRoland Mainz 1750cdf0c1d5Smjnelsonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 1751cdf0c1d5Smjnelson 1752cdf0c1d5Smjnelson# System 1753cdf0c1d5Smjnelsonwhence uname | tee -a $build_environ_file >> $LOGFILE 1754cdf0c1d5Smjnelsonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 1755cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1756cdf0c1d5Smjnelson 1757cdf0c1d5Smjnelson# make 1758cdf0c1d5Smjnelsonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 1759cdf0c1d5Smjnelson$MAKE -v | tee -a $build_environ_file >> $LOGFILE 1760cdf0c1d5Smjnelsonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1761cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1762cdf0c1d5Smjnelson 1763cdf0c1d5Smjnelson# 1764cdf0c1d5Smjnelson# Report the compiler versions. 1765cdf0c1d5Smjnelson# 1766cdf0c1d5Smjnelson 1767cdf0c1d5Smjnelsonif [[ ! -f $SRC/Makefile ]]; then 1768cdf0c1d5Smjnelson build_ok=n 1769cdf0c1d5Smjnelson echo "\nUnable to find \"Makefile\" in $SRC." | \ 1770cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1771cdf0c1d5Smjnelson exit 1 1772cdf0c1d5Smjnelsonfi 1773cdf0c1d5Smjnelson 1774cdf0c1d5Smjnelson( cd $SRC 1775cdf0c1d5Smjnelson for target in cc-version cc64-version java-version; do 1776cdf0c1d5Smjnelson echo 1777cdf0c1d5Smjnelson # 1778cdf0c1d5Smjnelson # Put statefile somewhere we know we can write to rather than trip 1779cdf0c1d5Smjnelson # over a read-only $srcroot. 1780cdf0c1d5Smjnelson # 1781cdf0c1d5Smjnelson rm -f $TMPDIR/make-state 1782cdf0c1d5Smjnelson export SRC 1783cdf0c1d5Smjnelson if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1784cdf0c1d5Smjnelson continue 1785cdf0c1d5Smjnelson fi 1786cdf0c1d5Smjnelson touch $TMPDIR/nocompiler 1787cdf0c1d5Smjnelson done 1788cdf0c1d5Smjnelson echo 1789cdf0c1d5Smjnelson) | tee -a $build_environ_file >> $LOGFILE 1790cdf0c1d5Smjnelson 1791cdf0c1d5Smjnelsonif [ -f $TMPDIR/nocompiler ]; then 1792cdf0c1d5Smjnelson rm -f $TMPDIR/nocompiler 1793cdf0c1d5Smjnelson build_ok=n 1794cdf0c1d5Smjnelson echo "Aborting due to missing compiler." | 1795cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1796cdf0c1d5Smjnelson exit 1 1797cdf0c1d5Smjnelsonfi 1798cdf0c1d5Smjnelson 1799cdf0c1d5Smjnelson# as 1800cdf0c1d5Smjnelsonwhence as | tee -a $build_environ_file >> $LOGFILE 1801cdf0c1d5Smjnelsonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 1802cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1803cdf0c1d5Smjnelson 1804cdf0c1d5Smjnelson# Check that we're running a capable link-editor 1805cdf0c1d5Smjnelsonwhence ld | tee -a $build_environ_file >> $LOGFILE 1806cdf0c1d5SmjnelsonLDVER=`ld -V 2>&1` 1807cdf0c1d5Smjnelsonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 180870087ad3SRichard LoweLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 1809cdf0c1d5Smjnelsonif [ `expr $LDVER \< 422` -eq 1 ]; then 1810cdf0c1d5Smjnelson echo "The link-editor needs to be at version 422 or higher to build" | \ 1811cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1812cdf0c1d5Smjnelson echo "the latest stuff. Hope your build works." | \ 1813cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1814cdf0c1d5Smjnelsonfi 1815cdf0c1d5Smjnelson 18167c478bd9Sstevel@tonic-gate# 18174e5b757fSkupfer# Build and use the workspace's tools if requested 18187c478bd9Sstevel@tonic-gate# 18195110237aSJosef 'Jeff' Sipekif [[ "$t_FLAG" = "y" ]]; then 18204e5b757fSkupfer set_non_debug_build_flags 18217c478bd9Sstevel@tonic-gate 18227c478bd9Sstevel@tonic-gate build_tools ${TOOLS_PROTO} 1823cb4d1691SRichard Lowe if (( $? != 0 )); then 1824cb4d1691SRichard Lowe build_ok=n 1825cb4d1691SRichard Lowe else 18264e5b757fSkupfer use_tools $TOOLS_PROTO 18274e5b757fSkupfer fi 18287c478bd9Sstevel@tonic-gatefi 18297c478bd9Sstevel@tonic-gate 18304e5b757fSkupfer# timestamp the start of the normal build; the findunref tool uses it. 18314e5b757fSkupfertouch $SRC/.build.tstamp 18324e5b757fSkupfer 18337c478bd9Sstevel@tonic-gatenormal_build 18345d715dd7Skupfer 18357c478bd9Sstevel@tonic-gateORIG_SRC=$SRC 18367c478bd9Sstevel@tonic-gateBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 18377c478bd9Sstevel@tonic-gate 18387c478bd9Sstevel@tonic-gate 18394e5b757fSkupfer# 18404e5b757fSkupfer# There are several checks that need to look at the proto area, but 18414e5b757fSkupfer# they only need to look at one, and they don't care whether it's 18424e5b757fSkupfer# DEBUG or non-DEBUG. 18434e5b757fSkupfer# 18444e5b757fSkupferif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 18454e5b757fSkupfer checkroot=$ROOT-nd 18464e5b757fSkupferelse 18474e5b757fSkupfer checkroot=$ROOT 18484e5b757fSkupferfi 18494e5b757fSkupfer 18507c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 18517c478bd9Sstevel@tonic-gate echo "\n==== Creating protolist system file at `date` ====" \ 18527c478bd9Sstevel@tonic-gate >> $LOGFILE 18534e5b757fSkupfer protolist $checkroot > $ATLOG/proto_list_${MACH} 18547c478bd9Sstevel@tonic-gate echo "==== protolist system file created at `date` ====\n" \ 18557c478bd9Sstevel@tonic-gate >> $LOGFILE 18567c478bd9Sstevel@tonic-gate 18577c478bd9Sstevel@tonic-gate if [ "$N_FLAG" != "y" ]; then 18587c478bd9Sstevel@tonic-gate 1859ead1f93eSLiane Praza E1= 1860ead1f93eSLiane Praza f1= 1861ead1f93eSLiane Praza for f in $f1; do 1862ead1f93eSLiane Praza if [ -f "$f" ]; then 1863ead1f93eSLiane Praza E1="$E1 -e $f" 1864ead1f93eSLiane Praza fi 1865ead1f93eSLiane Praza done 1866ead1f93eSLiane Praza 1867ead1f93eSLiane Praza E2= 1868ead1f93eSLiane Praza f2= 1869ead1f93eSLiane Praza if [ -d "$SRC/pkg" ]; then 1870ead1f93eSLiane Praza f2="$f2 exceptions/packaging" 1871ead1f93eSLiane Praza fi 1872ead1f93eSLiane Praza 1873ead1f93eSLiane Praza for f in $f2; do 1874ead1f93eSLiane Praza if [ -f "$f" ]; then 1875ead1f93eSLiane Praza E2="$E2 -e $f" 1876ead1f93eSLiane Praza fi 1877ead1f93eSLiane Praza done 1878ead1f93eSLiane Praza fi 1879ead1f93eSLiane Praza 1880ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 1881ead1f93eSLiane Praza echo "\n==== Validating manifests against proto area ====\n" \ 1882ead1f93eSLiane Praza >> $mail_msg_file 1883cb4d1691SRichard Lowe ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1884cb4d1691SRichard Lowe tee $TMPDIR/protocmp_noise >> $mail_msg_file 1885cb4d1691SRichard Lowe if [[ -s $TMPDIR/protocmp_noise ]]; then 1886cb4d1691SRichard Lowe build_extras_ok=n 1887cb4d1691SRichard Lowe fi 1888ead1f93eSLiane Praza fi 1889ead1f93eSLiane Praza 1890ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 1891ead1f93eSLiane Praza echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 1892ead1f93eSLiane Praza if [ -n "$E2" ]; then 1893ead1f93eSLiane Praza ELIST=$E2 1894ead1f93eSLiane Praza else 1895ead1f93eSLiane Praza ELIST=$E1 1896ead1f93eSLiane Praza fi 18977c478bd9Sstevel@tonic-gate $PROTOCMPTERSE \ 18987c478bd9Sstevel@tonic-gate "Files in yesterday's proto area, but not today's:" \ 18997c478bd9Sstevel@tonic-gate "Files in today's proto area, but not yesterday's:" \ 19007c478bd9Sstevel@tonic-gate "Files that changed between yesterday and today:" \ 19017c478bd9Sstevel@tonic-gate ${ELIST} \ 19027c478bd9Sstevel@tonic-gate -d $REF_PROTO_LIST \ 19037c478bd9Sstevel@tonic-gate $ATLOG/proto_list_${MACH} \ 19047c478bd9Sstevel@tonic-gate >> $mail_msg_file 19057c478bd9Sstevel@tonic-gate fi 19067c478bd9Sstevel@tonic-gatefi 19077c478bd9Sstevel@tonic-gate 1908cb4d1691SRichard Loweif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 1909cb4d1691SRichard Lowe "$build_extras_ok" == "y" ]]; then 19107c478bd9Sstevel@tonic-gate staffer cp $ATLOG/proto_list_${MACH} \ 19117c478bd9Sstevel@tonic-gate $PARENT_WS/usr/src/proto_list_${MACH} 19127c478bd9Sstevel@tonic-gatefi 19137c478bd9Sstevel@tonic-gate 19147c478bd9Sstevel@tonic-gate# Update parent proto area if necessary. This is done now 19157c478bd9Sstevel@tonic-gate# so that the proto area has either DEBUG or non-DEBUG kernels. 19167c478bd9Sstevel@tonic-gate# Note that this clears out the lock file, so we can dispense with 19177c478bd9Sstevel@tonic-gate# the variable now. 19187c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 19197c478bd9Sstevel@tonic-gate echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 19207c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 1921ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT/* 19227c478bd9Sstevel@tonic-gate unset Ulockfile 19237c478bd9Sstevel@tonic-gate mkdir -p $NIGHTLY_PARENT_ROOT 19244e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1925ead1f93eSLiane Praza ( cd $ROOT; tar cf - . | 19264e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 19277c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 19287c478bd9Sstevel@tonic-gate fi 19294e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 1930ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT-nd/* 19314e5b757fSkupfer mkdir -p $NIGHTLY_PARENT_ROOT-nd 19324e5b757fSkupfer cd $ROOT-nd 19334e5b757fSkupfer ( tar cf - . | 19344e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 19354e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 19364e5b757fSkupfer fi 19376798c3f0SMark J. Nelson if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 1938ead1f93eSLiane Praza echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 1939ead1f93eSLiane Praza tee -a $LOGFILE >> $mail_msg_file 1940ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 1941ead1f93eSLiane Praza mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 1942ead1f93eSLiane Praza if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1943ead1f93eSLiane Praza ( cd $TOOLS_PROTO; tar cf - . | 19446798c3f0SMark J. Nelson ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 19456798c3f0SMark J. Nelson umask 0; tar xpf - ) ) 2>&1 | 1946ead1f93eSLiane Praza tee -a $mail_msg_file >> $LOGFILE 1947ead1f93eSLiane Praza fi 19484e5b757fSkupfer fi 19496798c3f0SMark J. Nelsonfi 19507c478bd9Sstevel@tonic-gate 19517c478bd9Sstevel@tonic-gate# 195275ce41a5SAli Bahrami# ELF verification: ABI (-A) and runtime (-r) checks 19537c478bd9Sstevel@tonic-gate# 195475ce41a5SAli Bahramiif [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 195575ce41a5SAli Bahrami # Directory ELF-data.$MACH holds the files produced by these tests. 195675ce41a5SAli Bahrami elf_ddir=$SRC/ELF-data.$MACH 19577c478bd9Sstevel@tonic-gate 195875ce41a5SAli Bahrami # If there is a previous ELF-data backup directory, remove it. Then, 195975ce41a5SAli Bahrami # rotate current ELF-data directory into its place and create a new 196075ce41a5SAli Bahrami # empty directory 196175ce41a5SAli Bahrami rm -rf $elf_ddir.ref 196275ce41a5SAli Bahrami if [[ -d $elf_ddir ]]; then 196375ce41a5SAli Bahrami mv $elf_ddir $elf_ddir.ref 196475ce41a5SAli Bahrami fi 196575ce41a5SAli Bahrami mkdir -p $elf_ddir 196675ce41a5SAli Bahrami 196775ce41a5SAli Bahrami # Call find_elf to produce a list of the ELF objects in the proto area. 196875ce41a5SAli Bahrami # This list is passed to check_rtime and interface_check, preventing 196975ce41a5SAli Bahrami # them from separately calling find_elf to do the same work twice. 197075ce41a5SAli Bahrami find_elf -fr $checkroot > $elf_ddir/object_list 197175ce41a5SAli Bahrami 197275ce41a5SAli Bahrami if [[ $A_FLAG = y ]]; then 19737c478bd9Sstevel@tonic-gate echo "\n==== Check versioning and ABI information ====\n" | \ 19747c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 19757c478bd9Sstevel@tonic-gate 197675ce41a5SAli Bahrami # Produce interface description for the proto. Report errors. 197775ce41a5SAli Bahrami interface_check -o -w $elf_ddir -f object_list \ 197875ce41a5SAli Bahrami -i interface -E interface.err 197975ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.err ]]; then 198075ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/interface.err \ 198175ce41a5SAli Bahrami >> $mail_msg_file 1982cb4d1691SRichard Lowe build_extras_ok=n 19837c478bd9Sstevel@tonic-gate fi 19847c478bd9Sstevel@tonic-gate 19855253169eSAli Bahrami # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 19865253169eSAli Bahrami # description file to that from the baseline gate. Issue a 19875253169eSAli Bahrami # warning if the baseline is not present, and keep going. 19885253169eSAli Bahrami if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 19895253169eSAli Bahrami base_ifile="$ELF_DATA_BASELINE_DIR/interface" 19907c478bd9Sstevel@tonic-gate 19915253169eSAli Bahrami echo "\n==== Compare versioning and ABI information" \ 1992e599109eSAli Bahrami "to baseline ====\n" | \ 19935253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 1994e599109eSAli Bahrami echo "Baseline: $base_ifile\n" >> $LOGFILE 19955253169eSAli Bahrami 19965253169eSAli Bahrami if [[ -f $base_ifile ]]; then 19975253169eSAli Bahrami interface_cmp -d -o $base_ifile \ 199875ce41a5SAli Bahrami $elf_ddir/interface > $elf_ddir/interface.cmp 199975ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.cmp ]]; then 20005253169eSAli Bahrami echo | tee -a $LOGFILE >> $mail_msg_file 20015253169eSAli Bahrami tee -a $LOGFILE < \ 20025253169eSAli Bahrami $elf_ddir/interface.cmp \ 200375ce41a5SAli Bahrami >> $mail_msg_file 2004cb4d1691SRichard Lowe build_extras_ok=n 20057c478bd9Sstevel@tonic-gate fi 20065253169eSAli Bahrami else 20075253169eSAli Bahrami echo "baseline not available. comparison" \ 20085253169eSAli Bahrami "skipped" | \ 20095253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 20105253169eSAli Bahrami fi 20115253169eSAli Bahrami 20125253169eSAli Bahrami fi 20137c478bd9Sstevel@tonic-gate fi 20147c478bd9Sstevel@tonic-gate 201575ce41a5SAli Bahrami if [[ $r_FLAG = y ]]; then 20167c478bd9Sstevel@tonic-gate echo "\n==== Check ELF runtime attributes ====\n" | \ 20177c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 20187c478bd9Sstevel@tonic-gate 2019ead1f93eSLiane Praza # If we're doing a DEBUG build the proto area will be left 202075ce41a5SAli Bahrami # with debuggable objects, thus don't assert -s. 202175ce41a5SAli Bahrami if [[ $D_FLAG = y ]]; then 20227c478bd9Sstevel@tonic-gate rtime_sflag="" 20237c478bd9Sstevel@tonic-gate else 20247c478bd9Sstevel@tonic-gate rtime_sflag="-s" 20257c478bd9Sstevel@tonic-gate fi 202675ce41a5SAli Bahrami check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 202775ce41a5SAli Bahrami -D object_list -f object_list -E runtime.err \ 2028622090e3SAli Bahrami -I runtime.attr.raw 2029cb4d1691SRichard Lowe if (( $? != 0 )); then 2030cb4d1691SRichard Lowe build_extras_ok=n 2031cb4d1691SRichard Lowe fi 2032622090e3SAli Bahrami 2033622090e3SAli Bahrami # check_rtime -I output needs to be sorted in order to 2034622090e3SAli Bahrami # compare it to that from previous builds. 2035622090e3SAli Bahrami sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 2036622090e3SAli Bahrami rm $elf_ddir/runtime.attr.raw 20377c478bd9Sstevel@tonic-gate 203875ce41a5SAli Bahrami # Report errors 203975ce41a5SAli Bahrami if [[ -s $elf_ddir/runtime.err ]]; then 204075ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/runtime.err \ 20417c478bd9Sstevel@tonic-gate >> $mail_msg_file 2042cb4d1691SRichard Lowe build_extras_ok=n 204375ce41a5SAli Bahrami fi 20447c478bd9Sstevel@tonic-gate 204575ce41a5SAli Bahrami # If there is an ELF-data directory from a previous build, 204675ce41a5SAli Bahrami # then diff the attr files. These files contain information 204775ce41a5SAli Bahrami # about dependencies, versioning, and runpaths. There is some 204875ce41a5SAli Bahrami # overlap with the ABI checking done above, but this also 204975ce41a5SAli Bahrami # flushes out non-ABI interface differences along with the 205075ce41a5SAli Bahrami # other information. 205175ce41a5SAli Bahrami echo "\n==== Diff ELF runtime attributes" \ 205275ce41a5SAli Bahrami "(since last build) ====\n" | \ 205375ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 205475ce41a5SAli Bahrami 205575ce41a5SAli Bahrami if [[ -f $elf_ddir.ref/runtime.attr ]]; then 205675ce41a5SAli Bahrami diff $elf_ddir.ref/runtime.attr \ 205775ce41a5SAli Bahrami $elf_ddir/runtime.attr \ 205875ce41a5SAli Bahrami >> $mail_msg_file 205975ce41a5SAli Bahrami fi 206075ce41a5SAli Bahrami fi 20615253169eSAli Bahrami 20625253169eSAli Bahrami # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 20635253169eSAli Bahrami if [[ "$u_FLAG" = "y" ]]; then 20645253169eSAli Bahrami p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 20655253169eSAli Bahrami 20665253169eSAli Bahrami # If parent lacks the ELF-data.$MACH directory, create it 20675253169eSAli Bahrami if [[ ! -d $p_elf_ddir ]]; then 20685253169eSAli Bahrami staffer mkdir -p $p_elf_ddir 20695253169eSAli Bahrami fi 20705253169eSAli Bahrami 20715253169eSAli Bahrami # These files are used asynchronously by other builds for ABI 20725253169eSAli Bahrami # verification, as above for the -A option. As such, we require 20735253169eSAli Bahrami # the file replacement to be atomic. Copy the data to a temp 20745253169eSAli Bahrami # file in the same filesystem and then rename into place. 20755253169eSAli Bahrami ( 20765253169eSAli Bahrami cd $elf_ddir 20775253169eSAli Bahrami for elf_dfile in *; do 20785253169eSAli Bahrami staffer cp $elf_dfile \ 20795253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile}.new 20805253169eSAli Bahrami staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 20815253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile} 20825253169eSAli Bahrami done 20835253169eSAli Bahrami ) 20845253169eSAli Bahrami fi 20857c478bd9Sstevel@tonic-gatefi 20867c478bd9Sstevel@tonic-gate 20877c478bd9Sstevel@tonic-gate# DEBUG lint of kernel begins 20887c478bd9Sstevel@tonic-gate 20897c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 20907c478bd9Sstevel@tonic-gate if [ "$LINTDIRS" = "" ]; then 20917c478bd9Sstevel@tonic-gate # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 20927c478bd9Sstevel@tonic-gate LINTDIRS="$SRC y" 20937c478bd9Sstevel@tonic-gate fi 20947c478bd9Sstevel@tonic-gate set $LINTDIRS 20957c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 20967c478bd9Sstevel@tonic-gate dolint $1 $2; shift; shift 20977c478bd9Sstevel@tonic-gate done 20987c478bd9Sstevel@tonic-gateelse 20997c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 21007c478bd9Sstevel@tonic-gatefi 21017c478bd9Sstevel@tonic-gate 21027c478bd9Sstevel@tonic-gate# "make check" begins 21037c478bd9Sstevel@tonic-gate 21047c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 21057c478bd9Sstevel@tonic-gate # remove old check.out 21067c478bd9Sstevel@tonic-gate rm -f $SRC/check.out 21077c478bd9Sstevel@tonic-gate 21087c478bd9Sstevel@tonic-gate rm -f $SRC/check-${MACH}.out 21097c478bd9Sstevel@tonic-gate cd $SRC 2110170832d3SAlbert Lee $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 2111170832d3SAlbert Lee >> $LOGFILE 21127c478bd9Sstevel@tonic-gate echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 21137c478bd9Sstevel@tonic-gate 21147c478bd9Sstevel@tonic-gate grep ":" $SRC/check-${MACH}.out | 21157c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 2116cb4d1691SRichard Lowe sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 2117cb4d1691SRichard Lowe 2118cb4d1691SRichard Lowe if [[ -s $TMPDIR/check_errors ]]; then 2119cb4d1691SRichard Lowe build_extras_ok=n 2120cb4d1691SRichard Lowe fi 21217c478bd9Sstevel@tonic-gateelse 21227c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 21237c478bd9Sstevel@tonic-gatefi 21247c478bd9Sstevel@tonic-gate 21257c478bd9Sstevel@tonic-gateecho "\n==== Find core files ====\n" | \ 21267c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 21277c478bd9Sstevel@tonic-gate 2128fb23a357Skupferfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 21297c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 21307c478bd9Sstevel@tonic-gate 21317c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21327c478bd9Sstevel@tonic-gate echo "\n==== Diff unreferenced files (since last build) ====\n" \ 21337c478bd9Sstevel@tonic-gate | tee -a $LOGFILE >>$mail_msg_file 21347c478bd9Sstevel@tonic-gate rm -f $SRC/unref-${MACH}.ref 21357c478bd9Sstevel@tonic-gate if [ -f $SRC/unref-${MACH}.out ]; then 21367c478bd9Sstevel@tonic-gate mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 21377c478bd9Sstevel@tonic-gate fi 21387c478bd9Sstevel@tonic-gate 21399730304dSmeem findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 2140cdf0c1d5Smjnelson ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 21419730304dSmeem sort > $SRC/unref-${MACH}.out 21427c478bd9Sstevel@tonic-gate 21437c478bd9Sstevel@tonic-gate if [ ! -f $SRC/unref-${MACH}.ref ]; then 21447c478bd9Sstevel@tonic-gate cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 21457c478bd9Sstevel@tonic-gate fi 21467c478bd9Sstevel@tonic-gate 21477c478bd9Sstevel@tonic-gate diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 21487c478bd9Sstevel@tonic-gatefi 21497c478bd9Sstevel@tonic-gate 21507c478bd9Sstevel@tonic-gate# Verify that the usual lists of files, such as exception lists, 21517c478bd9Sstevel@tonic-gate# contain only valid references to files. If the build has failed, 21527c478bd9Sstevel@tonic-gate# then don't check the proto area. 21537c478bd9Sstevel@tonic-gateCHECK_PATHS=${CHECK_PATHS:-y} 21547c478bd9Sstevel@tonic-gateif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 21557c478bd9Sstevel@tonic-gate echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 21567c478bd9Sstevel@tonic-gate >>$mail_msg_file 21577c478bd9Sstevel@tonic-gate arg=-b 21587c478bd9Sstevel@tonic-gate [ "$build_ok" = y ] && arg= 2159*e2c8add4SRichard PALO checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 2160*e2c8add4SRichard PALO if [[ -s $SRC/check-paths.out ]]; then 2161*e2c8add4SRichard PALO tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 2162cb4d1691SRichard Lowe build_extras_ok=n 2163cb4d1691SRichard Lowe fi 21647c478bd9Sstevel@tonic-gatefi 21657c478bd9Sstevel@tonic-gate 21667c478bd9Sstevel@tonic-gateif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 21677c478bd9Sstevel@tonic-gate echo "\n==== Impact on file permissions ====\n" \ 21687c478bd9Sstevel@tonic-gate >> $mail_msg_file 2169ead1f93eSLiane Praza 2170ead1f93eSLiane Praza abspkg= 2171ead1f93eSLiane Praza for d in $abssrcdirs; do 2172ead1f93eSLiane Praza if [ -d "$d/pkg" ]; then 2173ead1f93eSLiane Praza abspkg="$abspkg $d" 2174ead1f93eSLiane Praza fi 2175ead1f93eSLiane Praza done 2176ead1f93eSLiane Praza 2177ead1f93eSLiane Praza if [ -n "$abspkg" ]; then 2178ead1f93eSLiane Praza for d in "$abspkg"; do 2179ead1f93eSLiane Praza ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 2180ead1f93eSLiane Praza done 2181ead1f93eSLiane Praza fi 21827c478bd9Sstevel@tonic-gatefi 21837c478bd9Sstevel@tonic-gate 218496ccc8cbSesaxeif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 21854e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 21864e5b757fSkupfer do_wsdiff DEBUG $ROOT.prev $ROOT 21874e5b757fSkupfer fi 218896ccc8cbSesaxe 21894e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 21904e5b757fSkupfer do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 219196ccc8cbSesaxe fi 219296ccc8cbSesaxefi 219396ccc8cbSesaxe 21947c478bd9Sstevel@tonic-gateEND_DATE=`date` 21957c478bd9Sstevel@tonic-gateecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 21967c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 21977c478bd9Sstevel@tonic-gate 2198c341b28aSDarren Moffattypeset -i10 hours 21997c478bd9Sstevel@tonic-gatetypeset -Z2 minutes 22007c478bd9Sstevel@tonic-gatetypeset -Z2 seconds 22017c478bd9Sstevel@tonic-gate 22027c478bd9Sstevel@tonic-gateelapsed_time=$SECONDS 22037c478bd9Sstevel@tonic-gate((hours = elapsed_time / 3600 )) 22047c478bd9Sstevel@tonic-gate((minutes = elapsed_time / 60 % 60)) 22057c478bd9Sstevel@tonic-gate((seconds = elapsed_time % 60)) 22067c478bd9Sstevel@tonic-gate 22077c478bd9Sstevel@tonic-gateecho "\n==== Total build time ====" | \ 22087c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 22097c478bd9Sstevel@tonic-gateecho "\nreal ${hours}:${minutes}:${seconds}" | \ 22107c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 22117c478bd9Sstevel@tonic-gate 22127c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 22137c478bd9Sstevel@tonic-gate staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 22147c478bd9Sstevel@tonic-gate 22157c478bd9Sstevel@tonic-gate # 22167c478bd9Sstevel@tonic-gate # Produce a master list of unreferenced files -- ideally, we'd 22177c478bd9Sstevel@tonic-gate # generate the master just once after all of the nightlies 22187c478bd9Sstevel@tonic-gate # have finished, but there's no simple way to know when that 22197c478bd9Sstevel@tonic-gate # will be. Instead, we assume that we're the last nightly to 22207c478bd9Sstevel@tonic-gate # finish and merge all of the unref-${MACH}.out files in 22217c478bd9Sstevel@tonic-gate # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 22227c478bd9Sstevel@tonic-gate # finish, then this file will be the authoritative master 22237c478bd9Sstevel@tonic-gate # list. Otherwise, another ${MACH}'s nightly will eventually 22247c478bd9Sstevel@tonic-gate # overwrite ours with its own master, but in the meantime our 22257c478bd9Sstevel@tonic-gate # temporary "master" will be no worse than any older master 22267c478bd9Sstevel@tonic-gate # which was already on the parent. 22277c478bd9Sstevel@tonic-gate # 22287c478bd9Sstevel@tonic-gate 22297c478bd9Sstevel@tonic-gate set -- $PARENT_WS/usr/src/unref-*.out 22307c478bd9Sstevel@tonic-gate cp "$1" ${TMPDIR}/unref.merge 22317c478bd9Sstevel@tonic-gate shift 22327c478bd9Sstevel@tonic-gate 22337c478bd9Sstevel@tonic-gate for unreffile; do 22347c478bd9Sstevel@tonic-gate comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 22357c478bd9Sstevel@tonic-gate mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 22367c478bd9Sstevel@tonic-gate done 22377c478bd9Sstevel@tonic-gate 22387c478bd9Sstevel@tonic-gate staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 22397c478bd9Sstevel@tonic-gatefi 22407c478bd9Sstevel@tonic-gate 22417c478bd9Sstevel@tonic-gate# 22427c478bd9Sstevel@tonic-gate# All done save for the sweeping up. 22437c478bd9Sstevel@tonic-gate# (whichever exit we hit here will trigger the "cleanup" trap which 22447c478bd9Sstevel@tonic-gate# optionally sends mail on completion). 22457c478bd9Sstevel@tonic-gate# 2246cb4d1691SRichard Loweif [[ "$build_ok" == "y" ]]; then 2247cb4d1691SRichard Lowe if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 22487c478bd9Sstevel@tonic-gate exit 0 22497c478bd9Sstevel@tonic-gate fi 2250cb4d1691SRichard Lowefi 2251cb4d1691SRichard Lowe 22527c478bd9Sstevel@tonic-gateexit 1 2253