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 5257c478bd9Sstevel@tonic-gate if [ "$VERIFY_ELFSIGN" = "y" ]; then 5264e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 5277c478bd9Sstevel@tonic-gate else 5284e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 5297c478bd9Sstevel@tonic-gate fi 5307c478bd9Sstevel@tonic-gate export ELFSIGN 5317c478bd9Sstevel@tonic-gate 532c168ccb7SMark J. Nelson PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 5334e5b757fSkupfer PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 5347c478bd9Sstevel@tonic-gate export PATH 5357c478bd9Sstevel@tonic-gate 536c168ccb7SMark J. Nelson if [ -d "${TOOLSROOT}/opt/onbld" ]; then 537b06f2c55SMark J. Nelson ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 5381d9a8b8dSDan Mick export ONBLD_TOOLS 539c168ccb7SMark J. Nelson fi 5401d9a8b8dSDan Mick 5417c478bd9Sstevel@tonic-gate echo "\n==== New environment settings. ====\n" >> $LOGFILE 5427c478bd9Sstevel@tonic-gate echo "STABS=${STABS}" >> $LOGFILE 5437c478bd9Sstevel@tonic-gate echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 5447c478bd9Sstevel@tonic-gate echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 5457c478bd9Sstevel@tonic-gate echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 5467c478bd9Sstevel@tonic-gate echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 5477c478bd9Sstevel@tonic-gate echo "PATH=${PATH}" >> $LOGFILE 5481d9a8b8dSDan Mick echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 5497c478bd9Sstevel@tonic-gate} 5507c478bd9Sstevel@tonic-gate 551597bd30bSMike Kupferfunction staffer { 5527c478bd9Sstevel@tonic-gate if [ $ISUSER -ne 0 ]; then 5537c478bd9Sstevel@tonic-gate "$@" 5547c478bd9Sstevel@tonic-gate else 5557c478bd9Sstevel@tonic-gate arg="\"$1\"" 5567c478bd9Sstevel@tonic-gate shift 5577c478bd9Sstevel@tonic-gate for i 5587c478bd9Sstevel@tonic-gate do 5597c478bd9Sstevel@tonic-gate arg="$arg \"$i\"" 5607c478bd9Sstevel@tonic-gate done 5617c478bd9Sstevel@tonic-gate eval su $STAFFER -c \'$arg\' 5627c478bd9Sstevel@tonic-gate fi 5637c478bd9Sstevel@tonic-gate} 5647c478bd9Sstevel@tonic-gate 565085d331dSkupfer# 566c3e6cb59SRichard Lowe# Verify that the closed bins are present 567085d331dSkupfer# 568c3e6cb59SRichard Lowefunction check_closed_bins { 569c0e7977aSJosef 'Jeff' Sipek if [[ ! -d "$ON_CLOSED_BINS" ]]; then 570c0e7977aSJosef 'Jeff' Sipek echo "ON_CLOSED_BINS must point to the closed binaries tree." 571cdf0c1d5Smjnelson build_ok=n 572085d331dSkupfer exit 1 573085d331dSkupfer fi 574085d331dSkupfer} 5757c478bd9Sstevel@tonic-gate 5764e5b757fSkupfer# 5774e5b757fSkupfer# wrapper over wsdiff. 5784e5b757fSkupfer# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 5794e5b757fSkupfer# 580597bd30bSMike Kupferfunction do_wsdiff { 5814e5b757fSkupfer label=$1 5824e5b757fSkupfer oldproto=$2 5834e5b757fSkupfer newproto=$3 5844e5b757fSkupfer 5854e5b757fSkupfer wsdiff="wsdiff" 5864e5b757fSkupfer [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 5874e5b757fSkupfer 588598cc7dfSVladimir Kotal echo "\n==== Getting object changes since last build at `date`" \ 589598cc7dfSVladimir Kotal "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 590598cc7dfSVladimir Kotal $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 591598cc7dfSVladimir Kotal tee -a $LOGFILE >> $mail_msg_file 592598cc7dfSVladimir Kotal echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 5934e5b757fSkupfer tee -a $LOGFILE >> $mail_msg_file 5944e5b757fSkupfer} 5954e5b757fSkupfer 5964e5b757fSkupfer# 597ead1f93eSLiane Praza# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 5984e5b757fSkupfer# together. 5994e5b757fSkupfer# 6004e5b757fSkupfer 601597bd30bSMike Kupferfunction set_non_debug_build_flags { 6024e5b757fSkupfer export RELEASE_BUILD ; RELEASE_BUILD= 6034e5b757fSkupfer unset EXTRA_OPTIONS 6044e5b757fSkupfer unset EXTRA_CFLAGS 6054e5b757fSkupfer} 6064e5b757fSkupfer 607597bd30bSMike Kupferfunction set_debug_build_flags { 6084e5b757fSkupfer unset RELEASE_BUILD 6094e5b757fSkupfer unset EXTRA_OPTIONS 6104e5b757fSkupfer unset EXTRA_CFLAGS 6114e5b757fSkupfer} 6124e5b757fSkupfer 613d77e7149Ssommerfe 6147c478bd9Sstevel@tonic-gateMACH=`uname -p` 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gateif [ "$OPTHOME" = "" ]; then 6177c478bd9Sstevel@tonic-gate OPTHOME=/opt 6187c478bd9Sstevel@tonic-gate export OPTHOME 6197c478bd9Sstevel@tonic-gatefi 6207c478bd9Sstevel@tonic-gate 6215110237aSJosef 'Jeff' SipekUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gateWhere: 624d77e7149Ssommerfe -i Fast incremental options (no clobber, lint, check) 6257c478bd9Sstevel@tonic-gate -n Do not do a bringover 6265e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 6277c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 6287c478bd9Sstevel@tonic-gate 6297c478bd9Sstevel@tonic-gate <env_file> file in Bourne shell syntax that sets and exports 6307c478bd9Sstevel@tonic-gate variables that configure the operation of this script and many of 6317c478bd9Sstevel@tonic-gate the scripts this one calls. If <env_file> does not exist, 6327c478bd9Sstevel@tonic-gate it will be looked for in $OPTHOME/onbld/env. 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gatenon-DEBUG is the default build type. Build options can be set in the 6357c478bd9Sstevel@tonic-gateNIGHTLY_OPTIONS variable in the <env_file> as follows: 6367c478bd9Sstevel@tonic-gate 6377c478bd9Sstevel@tonic-gate -A check for ABI differences in .so files 6387c478bd9Sstevel@tonic-gate -C check for cstyle/hdrchk errors 6397c478bd9Sstevel@tonic-gate -D do a build with DEBUG on 6407c478bd9Sstevel@tonic-gate -F do _not_ do a non-DEBUG build 6413c6aa570SMark J. Nelson -G gate keeper default group of options (-au) 6427c478bd9Sstevel@tonic-gate -I integration engineer default group of options (-ampu) 6437c478bd9Sstevel@tonic-gate -M do not run pmodes (safe file permission checker) 6447c478bd9Sstevel@tonic-gate -N do not run protocmp 6457c478bd9Sstevel@tonic-gate -R default group of options for building a release (-mp) 6467c478bd9Sstevel@tonic-gate -U update proto area in the parent 6477c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 6487c478bd9Sstevel@tonic-gate -f find unreferenced files 6497c478bd9Sstevel@tonic-gate -i do an incremental build (no "make clobber") 6507c478bd9Sstevel@tonic-gate -l do "make lint" in $LINTDIRS (default: $SRC y) 6517c478bd9Sstevel@tonic-gate -m send mail to $MAILTO at end of build 6527c478bd9Sstevel@tonic-gate -n do not do a bringover 6537c478bd9Sstevel@tonic-gate -p create packages 6547c478bd9Sstevel@tonic-gate -r check ELF runtime attributes in the proto area 6555e1b109eSPeter Dennis - Sustaining Engineer -t build and use the tools in $SRC/tools (default setting) 6565e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 6577c478bd9Sstevel@tonic-gate -u update proto_list_$MACH and friends in the parent workspace; 6587c478bd9Sstevel@tonic-gate when used with -f, also build an unrefmaster.out in the parent 65996ccc8cbSesaxe -w report on differences between previous and current proto areas 6607c478bd9Sstevel@tonic-gate' 6617c478bd9Sstevel@tonic-gate# 6627c478bd9Sstevel@tonic-gate# A log file will be generated under the name $LOGFILE 6631c79753fSdarrenm# for partially completed build and log.`date '+%F'` 6647c478bd9Sstevel@tonic-gate# in the same directory for fully completed builds. 6657c478bd9Sstevel@tonic-gate# 6667c478bd9Sstevel@tonic-gate 6677c478bd9Sstevel@tonic-gate# default values for low-level FLAGS; G I R are group FLAGS 6687c478bd9Sstevel@tonic-gateA_FLAG=n 6697c478bd9Sstevel@tonic-gateC_FLAG=n 6706c3c9007SstevelD_FLAG=n 6717c478bd9Sstevel@tonic-gateF_FLAG=n 6727c478bd9Sstevel@tonic-gatef_FLAG=n 6737c478bd9Sstevel@tonic-gatei_FLAG=n; i_CMD_LINE_FLAG=n 6747c478bd9Sstevel@tonic-gatel_FLAG=n 6756c3c9007SstevelM_FLAG=n 6767c478bd9Sstevel@tonic-gatem_FLAG=n 6776c3c9007SstevelN_FLAG=n 6786c3c9007Ssteveln_FLAG=n 6797c478bd9Sstevel@tonic-gatep_FLAG=n 6807c478bd9Sstevel@tonic-gater_FLAG=n 681fd7cef36Ssuhat_FLAG=y 6827c478bd9Sstevel@tonic-gateU_FLAG=n 6836c3c9007Sstevelu_FLAG=n 6847c478bd9Sstevel@tonic-gateV_FLAG=n 6856c3c9007Sstevelw_FLAG=n 686cb4d1691SRichard LoweW_FLAG=n 6877c478bd9Sstevel@tonic-gate# 6887c478bd9Sstevel@tonic-gatebuild_ok=y 689cb4d1691SRichard Lowebuild_extras_ok=y 6901fe69678Skupfer 6917c478bd9Sstevel@tonic-gate# 6927c478bd9Sstevel@tonic-gate# examine arguments 6937c478bd9Sstevel@tonic-gate# 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gateOPTIND=1 696cb4d1691SRichard Lowewhile getopts +intV:W FLAG 6977c478bd9Sstevel@tonic-gatedo 6987c478bd9Sstevel@tonic-gate case $FLAG in 6997c478bd9Sstevel@tonic-gate i ) i_FLAG=y; i_CMD_LINE_FLAG=y 7007c478bd9Sstevel@tonic-gate ;; 7017c478bd9Sstevel@tonic-gate n ) n_FLAG=y 7027c478bd9Sstevel@tonic-gate ;; 703fd7cef36Ssuha +t ) t_FLAG=n 7047c478bd9Sstevel@tonic-gate ;; 7056c3c9007Sstevel V ) V_FLAG=y 7066c3c9007Sstevel V_ARG="$OPTARG" 7076c3c9007Sstevel ;; 708cb4d1691SRichard Lowe W ) W_FLAG=y 709cb4d1691SRichard Lowe ;; 7107c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 7117c478bd9Sstevel@tonic-gate exit 1 7127c478bd9Sstevel@tonic-gate ;; 7137c478bd9Sstevel@tonic-gate esac 7147c478bd9Sstevel@tonic-gatedone 7157c478bd9Sstevel@tonic-gate 7167c478bd9Sstevel@tonic-gate# correct argument count after options 7177c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 7187c478bd9Sstevel@tonic-gate 7197c478bd9Sstevel@tonic-gate# test that the path to the environment-setting file was given 7207c478bd9Sstevel@tonic-gateif [ $# -ne 1 ]; then 7217c478bd9Sstevel@tonic-gate echo "$USAGE" 7227c478bd9Sstevel@tonic-gate exit 1 7237c478bd9Sstevel@tonic-gatefi 7247c478bd9Sstevel@tonic-gate 7257c478bd9Sstevel@tonic-gate# check if user is running nightly as root 7267c478bd9Sstevel@tonic-gate# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 7277c478bd9Sstevel@tonic-gate# when root invokes nightly. 7287c478bd9Sstevel@tonic-gate/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 7297c478bd9Sstevel@tonic-gateISUSER=$?; export ISUSER 7307c478bd9Sstevel@tonic-gate 7317c478bd9Sstevel@tonic-gate# 7327c478bd9Sstevel@tonic-gate# force locale to C 73391d74a54SRichard LoweLANG=C; export LANG 73491d74a54SRichard LoweLC_ALL=C; export LC_ALL 7357c478bd9Sstevel@tonic-gateLC_COLLATE=C; export LC_COLLATE 7367c478bd9Sstevel@tonic-gateLC_CTYPE=C; export LC_CTYPE 7377c478bd9Sstevel@tonic-gateLC_MESSAGES=C; export LC_MESSAGES 7387c478bd9Sstevel@tonic-gateLC_MONETARY=C; export LC_MONETARY 7397c478bd9Sstevel@tonic-gateLC_NUMERIC=C; export LC_NUMERIC 7407c478bd9Sstevel@tonic-gateLC_TIME=C; export LC_TIME 7417c478bd9Sstevel@tonic-gate 7427c478bd9Sstevel@tonic-gate# clear environment variables we know to be bad for the build 7437c478bd9Sstevel@tonic-gateunset LD_OPTIONS 7447c478bd9Sstevel@tonic-gateunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 7457c478bd9Sstevel@tonic-gateunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 7467c478bd9Sstevel@tonic-gateunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 7477c478bd9Sstevel@tonic-gateunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 7487c478bd9Sstevel@tonic-gateunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 7497c478bd9Sstevel@tonic-gateunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 7507c478bd9Sstevel@tonic-gateunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 7517c478bd9Sstevel@tonic-gateunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 7527c478bd9Sstevel@tonic-gateunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 7537c478bd9Sstevel@tonic-gateunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 7547c478bd9Sstevel@tonic-gateunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 7557c478bd9Sstevel@tonic-gateunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 7567c478bd9Sstevel@tonic-gateunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 7577c478bd9Sstevel@tonic-gateunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 7587c478bd9Sstevel@tonic-gateunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 7597c478bd9Sstevel@tonic-gateunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 7607c478bd9Sstevel@tonic-gateunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 7617c478bd9Sstevel@tonic-gateunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 7627c478bd9Sstevel@tonic-gateunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 7637c478bd9Sstevel@tonic-gateunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 7647c478bd9Sstevel@tonic-gate 7657c478bd9Sstevel@tonic-gateunset CONFIG 7667c478bd9Sstevel@tonic-gateunset GROUP 7677c478bd9Sstevel@tonic-gateunset OWNER 7687c478bd9Sstevel@tonic-gateunset REMOTE 7697c478bd9Sstevel@tonic-gateunset ENV 7707c478bd9Sstevel@tonic-gateunset ARCH 7717c478bd9Sstevel@tonic-gateunset CLASSPATH 7727c478bd9Sstevel@tonic-gateunset NAME 7737c478bd9Sstevel@tonic-gate 7747c478bd9Sstevel@tonic-gate# 775ead1f93eSLiane Praza# To get ONBLD_TOOLS from the environment, it must come from the env file. 776ead1f93eSLiane Praza# If it comes interactively, it is generally TOOLS_PROTO, which will be 777ead1f93eSLiane Praza# clobbered before the compiler version checks, which will therefore fail. 778ead1f93eSLiane Praza# 779ead1f93eSLiane Prazaunset ONBLD_TOOLS 780ead1f93eSLiane Praza 781ead1f93eSLiane Praza# 7827c478bd9Sstevel@tonic-gate# Setup environmental variables 7837c478bd9Sstevel@tonic-gate# 78447703246Ssommerfeif [ -f /etc/nightly.conf ]; then 78547703246Ssommerfe . /etc/nightly.conf 78647703246Ssommerfefi 78747703246Ssommerfe 7887c478bd9Sstevel@tonic-gateif [ -f $1 ]; then 7897c478bd9Sstevel@tonic-gate if [[ $1 = */* ]]; then 7907c478bd9Sstevel@tonic-gate . $1 7917c478bd9Sstevel@tonic-gate else 7927c478bd9Sstevel@tonic-gate . ./$1 7937c478bd9Sstevel@tonic-gate fi 7947c478bd9Sstevel@tonic-gateelse 7957c478bd9Sstevel@tonic-gate if [ -f $OPTHOME/onbld/env/$1 ]; then 7967c478bd9Sstevel@tonic-gate . $OPTHOME/onbld/env/$1 7977c478bd9Sstevel@tonic-gate else 7987c478bd9Sstevel@tonic-gate echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 7997c478bd9Sstevel@tonic-gate exit 1 8007c478bd9Sstevel@tonic-gate fi 8017c478bd9Sstevel@tonic-gatefi 8027c478bd9Sstevel@tonic-gate 8031fe69678Skupfer# contents of stdenv.sh inserted after next line: 8041fe69678Skupfer# STDENV_START 8051fe69678Skupfer# STDENV_END 8061fe69678Skupfer 807d7693b08SRoland Mainz# Check if we have sufficient data to continue... 808d7693b08SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 809220399b7SRoland Mainzif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 810220399b7SRoland Mainz # Check if the gate data are valid if we don't do a "bringover" below 811220399b7SRoland Mainz [[ -d "${CODEMGR_WS}" ]] || \ 812220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS} is not a directory." 813220399b7SRoland Mainz [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 814220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 815220399b7SRoland Mainzfi 816d7693b08SRoland Mainz 8177c478bd9Sstevel@tonic-gate# 8187c478bd9Sstevel@tonic-gate# place ourselves in a new task, respecting BUILD_PROJECT if set. 8197c478bd9Sstevel@tonic-gate# 8207c478bd9Sstevel@tonic-gateif [ -z "$BUILD_PROJECT" ]; then 8217c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ 8227c478bd9Sstevel@tonic-gateelse 8237c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ -p $BUILD_PROJECT 8247c478bd9Sstevel@tonic-gatefi 8257c478bd9Sstevel@tonic-gate 8267c478bd9Sstevel@tonic-gateps -o taskid= -p $$ | read build_taskid 8277c478bd9Sstevel@tonic-gateps -o project= -p $$ | read build_project 8287c478bd9Sstevel@tonic-gate 8297c478bd9Sstevel@tonic-gate# 8307c478bd9Sstevel@tonic-gate# See if NIGHTLY_OPTIONS is set 8317c478bd9Sstevel@tonic-gate# 8327c478bd9Sstevel@tonic-gateif [ "$NIGHTLY_OPTIONS" = "" ]; then 8337c478bd9Sstevel@tonic-gate NIGHTLY_OPTIONS="-aBm" 8347c478bd9Sstevel@tonic-gatefi 8357c478bd9Sstevel@tonic-gate 8367c478bd9Sstevel@tonic-gate# 8377c478bd9Sstevel@tonic-gate# If BRINGOVER_WS was not specified, let it default to CLONE_WS 8387c478bd9Sstevel@tonic-gate# 8397c478bd9Sstevel@tonic-gateif [ "$BRINGOVER_WS" = "" ]; then 8407c478bd9Sstevel@tonic-gate BRINGOVER_WS=$CLONE_WS 8417c478bd9Sstevel@tonic-gatefi 8427c478bd9Sstevel@tonic-gate 8437c478bd9Sstevel@tonic-gate# 844fb23a357Skupfer# If BRINGOVER_FILES was not specified, default to usr 845a5c06a9eSmike_s# 846a5c06a9eSmike_sif [ "$BRINGOVER_FILES" = "" ]; then 847fb23a357Skupfer BRINGOVER_FILES="usr" 848a5c06a9eSmike_sfi 849a5c06a9eSmike_s 850c3e6cb59SRichard Lowecheck_closed_bins 851fb9f9b97Skupfer 852a5c06a9eSmike_s# 8537c478bd9Sstevel@tonic-gate# Note: changes to the option letters here should also be applied to the 854b84bdc30Smeem# bldenv script. `d' is listed for backward compatibility. 8557c478bd9Sstevel@tonic-gate# 856d77e7149SsommerfeNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 8577c478bd9Sstevel@tonic-gateOPTIND=1 858cb4d1691SRichard Lowewhile getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS 8597c478bd9Sstevel@tonic-gatedo 8607c478bd9Sstevel@tonic-gate case $FLAG in 8617c478bd9Sstevel@tonic-gate A ) A_FLAG=y 8627c478bd9Sstevel@tonic-gate ;; 8637c478bd9Sstevel@tonic-gate B ) D_FLAG=y 8647c478bd9Sstevel@tonic-gate ;; # old version of D 8656c3c9007Sstevel C ) C_FLAG=y 8667c478bd9Sstevel@tonic-gate ;; 8677c478bd9Sstevel@tonic-gate D ) D_FLAG=y 8687c478bd9Sstevel@tonic-gate ;; 8696c3c9007Sstevel F ) F_FLAG=y 8707c478bd9Sstevel@tonic-gate ;; 8716c3c9007Sstevel f ) f_FLAG=y 8727c478bd9Sstevel@tonic-gate ;; 87378add226Sjmcp G ) u_FLAG=y 8747c478bd9Sstevel@tonic-gate ;; 87578add226Sjmcp I ) m_FLAG=y 8767c478bd9Sstevel@tonic-gate p_FLAG=y 8777c478bd9Sstevel@tonic-gate u_FLAG=y 8787c478bd9Sstevel@tonic-gate ;; 8797c478bd9Sstevel@tonic-gate i ) i_FLAG=y 8807c478bd9Sstevel@tonic-gate ;; 8816c3c9007Sstevel l ) l_FLAG=y 8826c3c9007Sstevel ;; 8836c3c9007Sstevel M ) M_FLAG=y 8846c3c9007Sstevel ;; 8856c3c9007Sstevel m ) m_FLAG=y 8866c3c9007Sstevel ;; 8876c3c9007Sstevel N ) N_FLAG=y 8886c3c9007Sstevel ;; 8897c478bd9Sstevel@tonic-gate n ) n_FLAG=y 8907c478bd9Sstevel@tonic-gate ;; 8917c478bd9Sstevel@tonic-gate p ) p_FLAG=y 8927c478bd9Sstevel@tonic-gate ;; 8936c3c9007Sstevel R ) m_FLAG=y 8946c3c9007Sstevel p_FLAG=y 8956c3c9007Sstevel ;; 8967c478bd9Sstevel@tonic-gate r ) r_FLAG=y 8977c478bd9Sstevel@tonic-gate ;; 898fd7cef36Ssuha +t ) t_FLAG=n 8997c478bd9Sstevel@tonic-gate ;; 9006798c3f0SMark J. Nelson U ) if [ -z "${PARENT_ROOT}" ]; then 9017c478bd9Sstevel@tonic-gate echo "PARENT_ROOT must be set if the U flag is" \ 9027c478bd9Sstevel@tonic-gate "present in NIGHTLY_OPTIONS." 9037c478bd9Sstevel@tonic-gate exit 1 9047c478bd9Sstevel@tonic-gate fi 9056798c3f0SMark J. Nelson NIGHTLY_PARENT_ROOT=$PARENT_ROOT 9066798c3f0SMark J. Nelson if [ -n "${PARENT_TOOLS_ROOT}" ]; then 9076798c3f0SMark J. Nelson NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 908ead1f93eSLiane Praza fi 9097c478bd9Sstevel@tonic-gate U_FLAG=y 9107c478bd9Sstevel@tonic-gate ;; 9116c3c9007Sstevel u ) u_FLAG=y 9127c478bd9Sstevel@tonic-gate ;; 9136c3c9007Sstevel w ) w_FLAG=y 9147c478bd9Sstevel@tonic-gate ;; 915cb4d1691SRichard Lowe W ) W_FLAG=y 916cb4d1691SRichard Lowe ;; 9177c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 9187c478bd9Sstevel@tonic-gate exit 1 9197c478bd9Sstevel@tonic-gate ;; 9207c478bd9Sstevel@tonic-gate esac 9217c478bd9Sstevel@tonic-gatedone 9227c478bd9Sstevel@tonic-gate 9237c478bd9Sstevel@tonic-gateif [ $ISUSER -ne 0 ]; then 9247c478bd9Sstevel@tonic-gate # Set default value for STAFFER, if needed. 9257c478bd9Sstevel@tonic-gate if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 9267c478bd9Sstevel@tonic-gate STAFFER=`/usr/xpg4/bin/id -un` 9277c478bd9Sstevel@tonic-gate export STAFFER 9287c478bd9Sstevel@tonic-gate fi 9297c478bd9Sstevel@tonic-gatefi 9307c478bd9Sstevel@tonic-gate 9317c478bd9Sstevel@tonic-gateif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 9327c478bd9Sstevel@tonic-gate MAILTO=$STAFFER 9337c478bd9Sstevel@tonic-gate export MAILTO 9347c478bd9Sstevel@tonic-gatefi 9357c478bd9Sstevel@tonic-gate 936c168ccb7SMark J. NelsonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 937c3e6cb59SRichard LowePATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb" 938c168ccb7SMark J. NelsonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 9397c478bd9Sstevel@tonic-gateexport PATH 9407c478bd9Sstevel@tonic-gate 941fb23a357Skupfer# roots of source trees, both relative to $SRC and absolute. 942fb23a357Skupferrelsrcdirs="." 943c0e7977aSJosef 'Jeff' Sipekabssrcdirs="$SRC" 944fb23a357Skupfer 9457c478bd9Sstevel@tonic-gatePROTOCMPTERSE="protocmp.terse -gu" 9467c478bd9Sstevel@tonic-gatePOUND_SIGN="#" 94748bc00d6Sjmcp# have we set RELEASE_DATE in our env file? 94848bc00d6Sjmcpif [ -z "$RELEASE_DATE" ]; then 94948bc00d6Sjmcp RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 95048bc00d6Sjmcpfi 95148bc00d6SjmcpBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 95248bc00d6SjmcpBASEWSDIR=$(basename $CODEMGR_WS) 95348bc00d6SjmcpDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 9547c478bd9Sstevel@tonic-gate 95548bc00d6Sjmcp# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 956c3e6cb59SRichard Lowe# by avoiding repeated shell invocations to evaluate Makefile.master 957c3e6cb59SRichard Lowe# definitions. 958c3e6cb59SRichard Loweexport POUND_SIGN RELEASE_DATE DEV_CM 9597c478bd9Sstevel@tonic-gate 9607c478bd9Sstevel@tonic-gatemaketype="distributed" 961e119f243SRobert Mustacchiif [[ -z "$MAKE" ]]; then 9627c478bd9Sstevel@tonic-gate MAKE=dmake 963e119f243SRobert Mustacchielif [[ ! -x "$MAKE" ]]; then 964e119f243SRobert Mustacchi echo "\$MAKE is set to garbage in the environment" 965e119f243SRobert Mustacchi exit 1 966e119f243SRobert Mustacchifi 9677c478bd9Sstevel@tonic-gateexport PATH 9687c478bd9Sstevel@tonic-gateexport MAKE 9697c478bd9Sstevel@tonic-gate 9707c478bd9Sstevel@tonic-gateif [ "${SUNWSPRO}" != "" ]; then 9717c478bd9Sstevel@tonic-gate PATH="${SUNWSPRO}/bin:$PATH" 9727c478bd9Sstevel@tonic-gate export PATH 9737c478bd9Sstevel@tonic-gatefi 9747c478bd9Sstevel@tonic-gate 97599e4a37bSWill Fiveashhostname=$(uname -n) 97699e4a37bSWill Fiveashif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 97799e4a37bSWill Fiveashthen 97899e4a37bSWill Fiveash maxjobs= 97999e4a37bSWill Fiveash if [[ -f $HOME/.make.machines ]] 98099e4a37bSWill Fiveash then 98199e4a37bSWill Fiveash # Note: there is a hard tab and space character in the []s 98299e4a37bSWill Fiveash # below. 98399e4a37bSWill Fiveash egrep -i "^[ ]*$hostname[ \.]" \ 98499e4a37bSWill Fiveash $HOME/.make.machines | read host jobs 98599e4a37bSWill Fiveash maxjobs=${jobs##*=} 9867c478bd9Sstevel@tonic-gate fi 98799e4a37bSWill Fiveash 98899e4a37bSWill Fiveash if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 98999e4a37bSWill Fiveash then 99099e4a37bSWill Fiveash # default 99199e4a37bSWill Fiveash maxjobs=4 9927c478bd9Sstevel@tonic-gate fi 99399e4a37bSWill Fiveash 99499e4a37bSWill Fiveash export DMAKE_MAX_JOBS=$maxjobs 99599e4a37bSWill Fiveashfi 99699e4a37bSWill Fiveash 9977c478bd9Sstevel@tonic-gateDMAKE_MODE=parallel; 9987c478bd9Sstevel@tonic-gateexport DMAKE_MODE 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gateif [ -z "${ROOT}" ]; then 10017c478bd9Sstevel@tonic-gate echo "ROOT must be set." 10027c478bd9Sstevel@tonic-gate exit 1 10037c478bd9Sstevel@tonic-gatefi 10047c478bd9Sstevel@tonic-gate 10057c478bd9Sstevel@tonic-gate# 10067c478bd9Sstevel@tonic-gate# if -V flag was given, reset VERSION to V_ARG 10077c478bd9Sstevel@tonic-gate# 10087c478bd9Sstevel@tonic-gateif [ "$V_FLAG" = "y" ]; then 10097c478bd9Sstevel@tonic-gate VERSION=$V_ARG 10107c478bd9Sstevel@tonic-gatefi 10117c478bd9Sstevel@tonic-gate 10127c478bd9Sstevel@tonic-gateTMPDIR="/tmp/nightly.tmpdir.$$" 10137c478bd9Sstevel@tonic-gateexport TMPDIR 10147c478bd9Sstevel@tonic-gaterm -rf ${TMPDIR} 10157c478bd9Sstevel@tonic-gatemkdir -p $TMPDIR || exit 1 101685f46905SMark J. Nelsonchmod 777 $TMPDIR 10177c478bd9Sstevel@tonic-gate 10187c478bd9Sstevel@tonic-gate# 10197c478bd9Sstevel@tonic-gate# Keep elfsign's use of pkcs11_softtoken from looking in the user home 10207c478bd9Sstevel@tonic-gate# directory, which doesn't always work. Needed until all build machines 10217c478bd9Sstevel@tonic-gate# have the fix for 6271754 10227c478bd9Sstevel@tonic-gate# 10237c478bd9Sstevel@tonic-gateSOFTTOKEN_DIR=$TMPDIR 10247c478bd9Sstevel@tonic-gateexport SOFTTOKEN_DIR 10257c478bd9Sstevel@tonic-gate 1026ead1f93eSLiane Praza# 1027ead1f93eSLiane Praza# Tools should only be built non-DEBUG. Keep track of the tools proto 1028ead1f93eSLiane Praza# area path relative to $TOOLS, because the latter changes in an 1029ead1f93eSLiane Praza# export build. 1030ead1f93eSLiane Praza# 1031ead1f93eSLiane Praza# TOOLS_PROTO is included below for builds other than usr/src/tools 1032ead1f93eSLiane Praza# that look for this location. For usr/src/tools, this will be 1033ead1f93eSLiane Praza# overridden on the $MAKE command line in build_tools(). 1034ead1f93eSLiane Praza# 10357c478bd9Sstevel@tonic-gateTOOLS=${SRC}/tools 1036ead1f93eSLiane PrazaTOOLS_PROTO_REL=proto/root_${MACH}-nd 1037ead1f93eSLiane PrazaTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1038ead1f93eSLiane Praza 10397c478bd9Sstevel@tonic-gateunset CFLAGS LD_LIBRARY_PATH LDFLAGS 10407c478bd9Sstevel@tonic-gate 10417c478bd9Sstevel@tonic-gate# create directories that are automatically removed if the nightly script 10427c478bd9Sstevel@tonic-gate# fails to start correctly 1043597bd30bSMike Kupferfunction newdir { 10447c478bd9Sstevel@tonic-gate dir=$1 10457c478bd9Sstevel@tonic-gate toadd= 10467c478bd9Sstevel@tonic-gate while [ ! -d $dir ]; do 10477c478bd9Sstevel@tonic-gate toadd="$dir $toadd" 10487c478bd9Sstevel@tonic-gate dir=`dirname $dir` 10497c478bd9Sstevel@tonic-gate done 10507c478bd9Sstevel@tonic-gate torm= 10517c478bd9Sstevel@tonic-gate newlist= 10527c478bd9Sstevel@tonic-gate for dir in $toadd; do 10537c478bd9Sstevel@tonic-gate if staffer mkdir $dir; then 10547c478bd9Sstevel@tonic-gate newlist="$ISUSER $dir $newlist" 10557c478bd9Sstevel@tonic-gate torm="$dir $torm" 10567c478bd9Sstevel@tonic-gate else 10577c478bd9Sstevel@tonic-gate [ -z "$torm" ] || staffer rmdir $torm 10587c478bd9Sstevel@tonic-gate return 1 10597c478bd9Sstevel@tonic-gate fi 10607c478bd9Sstevel@tonic-gate done 10617c478bd9Sstevel@tonic-gate newdirlist="$newlist $newdirlist" 10627c478bd9Sstevel@tonic-gate return 0 10637c478bd9Sstevel@tonic-gate} 10647c478bd9Sstevel@tonic-gatenewdirlist= 10657c478bd9Sstevel@tonic-gate 10667c478bd9Sstevel@tonic-gate[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 10677c478bd9Sstevel@tonic-gate 10687c478bd9Sstevel@tonic-gate# since this script assumes the build is from full source, it nullifies 10697c478bd9Sstevel@tonic-gate# variables likely to have been set by a "ws" script; nullification 10707c478bd9Sstevel@tonic-gate# confines the search space for headers and libraries to the proto area 10717c478bd9Sstevel@tonic-gate# built from this immediate source. 10727c478bd9Sstevel@tonic-gateENVLDLIBS1= 10737c478bd9Sstevel@tonic-gateENVLDLIBS2= 10747c478bd9Sstevel@tonic-gateENVLDLIBS3= 10757c478bd9Sstevel@tonic-gateENVCPPFLAGS1= 10767c478bd9Sstevel@tonic-gateENVCPPFLAGS2= 10777c478bd9Sstevel@tonic-gateENVCPPFLAGS3= 10787c478bd9Sstevel@tonic-gateENVCPPFLAGS4= 10797c478bd9Sstevel@tonic-gatePARENT_ROOT= 10807c478bd9Sstevel@tonic-gate 10817c478bd9Sstevel@tonic-gateexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1082494f7e12SKeith M Wesolowski ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 10837c478bd9Sstevel@tonic-gate 10847c478bd9Sstevel@tonic-gatePKGARCHIVE_ORIG=$PKGARCHIVE 10857c478bd9Sstevel@tonic-gate 10867c478bd9Sstevel@tonic-gate# 10877c478bd9Sstevel@tonic-gate# Juggle the logs and optionally send mail on completion. 10887c478bd9Sstevel@tonic-gate# 10897c478bd9Sstevel@tonic-gate 1090597bd30bSMike Kupferfunction logshuffle { 1091fd7cef36Ssuha LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 10927c478bd9Sstevel@tonic-gate if [ -f $LLOG -o -d $LLOG ]; then 10937c478bd9Sstevel@tonic-gate LLOG=$LLOG.$$ 10947c478bd9Sstevel@tonic-gate fi 10957c478bd9Sstevel@tonic-gate mkdir $LLOG 10964802ef38Srscott export LLOG 10977c478bd9Sstevel@tonic-gate 10987c478bd9Sstevel@tonic-gate if [ "$build_ok" = "y" ]; then 10997c478bd9Sstevel@tonic-gate mv $ATLOG/proto_list_${MACH} $LLOG 110096ccc8cbSesaxe 11012e02daeeSRainer Orth if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 11022e02daeeSRainer Orth mv $ATLOG/proto_list_tools_${MACH} $LLOG 11032e02daeeSRainer Orth fi 11042e02daeeSRainer Orth 110596ccc8cbSesaxe if [ -f $TMPDIR/wsdiff.results ]; then 110696ccc8cbSesaxe mv $TMPDIR/wsdiff.results $LLOG 110796ccc8cbSesaxe fi 11084e5b757fSkupfer 11094e5b757fSkupfer if [ -f $TMPDIR/wsdiff-nd.results ]; then 11104e5b757fSkupfer mv $TMPDIR/wsdiff-nd.results $LLOG 11114e5b757fSkupfer fi 11127c478bd9Sstevel@tonic-gate fi 11137c478bd9Sstevel@tonic-gate 11147c478bd9Sstevel@tonic-gate # 11157c478bd9Sstevel@tonic-gate # Now that we're about to send mail, it's time to check the noise 11167c478bd9Sstevel@tonic-gate # file. In the event that an error occurs beyond this point, it will 11177c478bd9Sstevel@tonic-gate # be recorded in the nightly.log file, but nowhere else. This would 11187c478bd9Sstevel@tonic-gate # include only errors that cause the copying of the noise log to fail 11197c478bd9Sstevel@tonic-gate # or the mail itself not to be sent. 11207c478bd9Sstevel@tonic-gate # 11217c478bd9Sstevel@tonic-gate 11227c478bd9Sstevel@tonic-gate exec >>$LOGFILE 2>&1 11237c478bd9Sstevel@tonic-gate if [ -s $build_noise_file ]; then 11247c478bd9Sstevel@tonic-gate echo "\n==== Nightly build noise ====\n" | 11257c478bd9Sstevel@tonic-gate tee -a $LOGFILE >>$mail_msg_file 11267c478bd9Sstevel@tonic-gate cat $build_noise_file >>$LOGFILE 11277c478bd9Sstevel@tonic-gate cat $build_noise_file >>$mail_msg_file 11287c478bd9Sstevel@tonic-gate echo | tee -a $LOGFILE >>$mail_msg_file 11297c478bd9Sstevel@tonic-gate fi 11307c478bd9Sstevel@tonic-gate rm -f $build_noise_file 11317c478bd9Sstevel@tonic-gate 11327c478bd9Sstevel@tonic-gate case "$build_ok" in 11337c478bd9Sstevel@tonic-gate y) 11347c478bd9Sstevel@tonic-gate state=Completed 11357c478bd9Sstevel@tonic-gate ;; 11367c478bd9Sstevel@tonic-gate i) 11377c478bd9Sstevel@tonic-gate state=Interrupted 11387c478bd9Sstevel@tonic-gate ;; 11397c478bd9Sstevel@tonic-gate *) 11407c478bd9Sstevel@tonic-gate state=Failed 11417c478bd9Sstevel@tonic-gate ;; 11427c478bd9Sstevel@tonic-gate esac 1143cb4d1691SRichard Lowe 1144cb4d1691SRichard Lowe if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then 1145cb4d1691SRichard Lowe state=Failed 1146cb4d1691SRichard Lowe fi 1147cb4d1691SRichard Lowe 114840bc9153Srscott NIGHTLY_STATUS=$state 114940bc9153Srscott export NIGHTLY_STATUS 11507c478bd9Sstevel@tonic-gate 115147703246Ssommerfe run_hook POST_NIGHTLY $state 115247703246Ssommerfe run_hook SYS_POST_NIGHTLY $state 11534802ef38Srscott 11543cb00cf1SJoshua M. Clulow # 11553cb00cf1SJoshua M. Clulow # mailx(1) sets From: based on the -r flag 11563cb00cf1SJoshua M. Clulow # if it is given. 11573cb00cf1SJoshua M. Clulow # 11583cb00cf1SJoshua M. Clulow mailx_r= 11593cb00cf1SJoshua M. Clulow if [[ -n "${MAILFROM}" ]]; then 11603cb00cf1SJoshua M. Clulow mailx_r="-r ${MAILFROM}" 11613cb00cf1SJoshua M. Clulow fi 11623cb00cf1SJoshua M. Clulow 1163cdf0c1d5Smjnelson cat $build_time_file $build_environ_file $mail_msg_file \ 1164cdf0c1d5Smjnelson > ${LLOG}/mail_msg 11657c478bd9Sstevel@tonic-gate if [ "$m_FLAG" = "y" ]; then 11663cb00cf1SJoshua M. Clulow cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 11677c478bd9Sstevel@tonic-gate "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 11687c478bd9Sstevel@tonic-gate ${MAILTO} 11697c478bd9Sstevel@tonic-gate fi 11707c478bd9Sstevel@tonic-gate 11717c478bd9Sstevel@tonic-gate if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 11727c478bd9Sstevel@tonic-gate staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 11737c478bd9Sstevel@tonic-gate staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 11747c478bd9Sstevel@tonic-gate fi 11757c478bd9Sstevel@tonic-gate 11767c478bd9Sstevel@tonic-gate mv $LOGFILE $LLOG 11777c478bd9Sstevel@tonic-gate} 11787c478bd9Sstevel@tonic-gate 11797c478bd9Sstevel@tonic-gate# 11807c478bd9Sstevel@tonic-gate# Remove the locks and temporary files on any exit 11817c478bd9Sstevel@tonic-gate# 1182597bd30bSMike Kupferfunction cleanup { 11837c478bd9Sstevel@tonic-gate logshuffle 11847c478bd9Sstevel@tonic-gate 11857c478bd9Sstevel@tonic-gate [ -z "$lockfile" ] || staffer rm -f $lockfile 11867c478bd9Sstevel@tonic-gate [ -z "$atloglockfile" ] || rm -f $atloglockfile 11877c478bd9Sstevel@tonic-gate [ -z "$ulockfile" ] || staffer rm -f $ulockfile 11887c478bd9Sstevel@tonic-gate [ -z "$Ulockfile" ] || rm -f $Ulockfile 11897c478bd9Sstevel@tonic-gate 11907c478bd9Sstevel@tonic-gate set -- $newdirlist 11917c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 11927c478bd9Sstevel@tonic-gate ISUSER=$1 staffer rmdir $2 11937c478bd9Sstevel@tonic-gate shift; shift 11947c478bd9Sstevel@tonic-gate done 11957c478bd9Sstevel@tonic-gate rm -rf $TMPDIR 11967c478bd9Sstevel@tonic-gate} 11977c478bd9Sstevel@tonic-gate 1198597bd30bSMike Kupferfunction cleanup_signal { 11997c478bd9Sstevel@tonic-gate build_ok=i 12007c478bd9Sstevel@tonic-gate # this will trigger cleanup(), above. 12017c478bd9Sstevel@tonic-gate exit 1 12027c478bd9Sstevel@tonic-gate} 12037c478bd9Sstevel@tonic-gate 12047c478bd9Sstevel@tonic-gatetrap cleanup 0 12057c478bd9Sstevel@tonic-gatetrap cleanup_signal 1 2 3 15 12067c478bd9Sstevel@tonic-gate 12077c478bd9Sstevel@tonic-gate# 12087c478bd9Sstevel@tonic-gate# Generic lock file processing -- make sure that the lock file doesn't 12097c478bd9Sstevel@tonic-gate# exist. If it does, it should name the build host and PID. If it 12107c478bd9Sstevel@tonic-gate# doesn't, then make sure we can create it. Clean up locks that are 12117c478bd9Sstevel@tonic-gate# known to be stale (assumes host name is unique among build systems 12127c478bd9Sstevel@tonic-gate# for the workspace). 1213cdf0c1d5Smjnelson# 1214597bd30bSMike Kupferfunction create_lock { 12157c478bd9Sstevel@tonic-gate lockf=$1 12167c478bd9Sstevel@tonic-gate lockvar=$2 12178312e758Sdduvall 12187c478bd9Sstevel@tonic-gate ldir=`dirname $lockf` 12197c478bd9Sstevel@tonic-gate [ -d $ldir ] || newdir $ldir || exit 1 12207c478bd9Sstevel@tonic-gate eval $lockvar=$lockf 12218312e758Sdduvall 12228312e758Sdduvall while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 12238312e758Sdduvall basews=`basename $CODEMGR_WS` 12248312e758Sdduvall ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 12258312e758Sdduvall if [ "$host" != "$hostname" ]; then 12268312e758Sdduvall echo "$MACH build of $basews apparently" \ 12278312e758Sdduvall "already started by $user on $host as $pid." 12288312e758Sdduvall exit 1 12298312e758Sdduvall elif kill -s 0 $pid 2>/dev/null; then 12308312e758Sdduvall echo "$MACH build of $basews already started" \ 12318312e758Sdduvall "by $user as $pid." 12328312e758Sdduvall exit 1 12338312e758Sdduvall else 12348312e758Sdduvall # stale lock; clear it out and try again 12358312e758Sdduvall rm -f $lockf 12368312e758Sdduvall fi 12378312e758Sdduvall done 12387c478bd9Sstevel@tonic-gate} 12397c478bd9Sstevel@tonic-gate 12404e5b757fSkupfer# 12414e5b757fSkupfer# Return the list of interesting proto areas, depending on the current 12424e5b757fSkupfer# options. 12434e5b757fSkupfer# 1244597bd30bSMike Kupferfunction allprotos { 1245c7453724SMike Kupfer typeset roots="$ROOT" 1246b83ec4edSjmcp 1247c7453724SMike Kupfer if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1248c7453724SMike Kupfer roots="$roots $ROOT-nd" 12494e5b757fSkupfer fi 12504e5b757fSkupfer 12514e5b757fSkupfer echo $roots 12524e5b757fSkupfer} 12534e5b757fSkupfer 12547c478bd9Sstevel@tonic-gate# Ensure no other instance of this script is running on this host. 12557c478bd9Sstevel@tonic-gate# LOCKNAME can be set in <env_file>, and is by default, but is not 12567c478bd9Sstevel@tonic-gate# required due to the use of $ATLOG below. 12577c478bd9Sstevel@tonic-gateif [ -n "$LOCKNAME" ]; then 12587c478bd9Sstevel@tonic-gate create_lock /tmp/$LOCKNAME "lockfile" 12597c478bd9Sstevel@tonic-gatefi 12607c478bd9Sstevel@tonic-gate# 12617c478bd9Sstevel@tonic-gate# Create from one, two, or three other locks: 12627c478bd9Sstevel@tonic-gate# $ATLOG/nightly.lock 12637c478bd9Sstevel@tonic-gate# - protects against multiple builds in same workspace 12647c478bd9Sstevel@tonic-gate# $PARENT_WS/usr/src/nightly.$MACH.lock 12657c478bd9Sstevel@tonic-gate# - protects against multiple 'u' copy-backs 12667c478bd9Sstevel@tonic-gate# $NIGHTLY_PARENT_ROOT/nightly.lock 12677c478bd9Sstevel@tonic-gate# - protects against multiple 'U' copy-backs 12687c478bd9Sstevel@tonic-gate# 12697c478bd9Sstevel@tonic-gate# Overriding ISUSER to 1 causes the lock to be created as root if the 12707c478bd9Sstevel@tonic-gate# script is run as root. The default is to create it as $STAFFER. 12717c478bd9Sstevel@tonic-gateISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 12727c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" ]; then 12737c478bd9Sstevel@tonic-gate create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 12747c478bd9Sstevel@tonic-gatefi 12757c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" ]; then 12767c478bd9Sstevel@tonic-gate # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 12777c478bd9Sstevel@tonic-gate ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 12787c478bd9Sstevel@tonic-gatefi 12797c478bd9Sstevel@tonic-gate 12807c478bd9Sstevel@tonic-gate# Locks have been taken, so we're doing a build and we're committed to 12817c478bd9Sstevel@tonic-gate# the directories we may have created so far. 12827c478bd9Sstevel@tonic-gatenewdirlist= 12837c478bd9Sstevel@tonic-gate 12847c478bd9Sstevel@tonic-gate# 12857c478bd9Sstevel@tonic-gate# Create mail_msg_file 12867c478bd9Sstevel@tonic-gate# 12877c478bd9Sstevel@tonic-gatemail_msg_file="${TMPDIR}/mail_msg" 12887c478bd9Sstevel@tonic-gatetouch $mail_msg_file 12897c478bd9Sstevel@tonic-gatebuild_time_file="${TMPDIR}/build_time" 1290cdf0c1d5Smjnelsonbuild_environ_file="${TMPDIR}/build_environ" 1291cdf0c1d5Smjnelsontouch $build_environ_file 12927c478bd9Sstevel@tonic-gate# 12937c478bd9Sstevel@tonic-gate# Move old LOGFILE aside 12947c478bd9Sstevel@tonic-gate# ATLOG directory already made by 'create_lock' above 12957c478bd9Sstevel@tonic-gate# 12967c478bd9Sstevel@tonic-gateif [ -f $LOGFILE ]; then 12977c478bd9Sstevel@tonic-gate mv -f $LOGFILE ${LOGFILE}- 12987c478bd9Sstevel@tonic-gatefi 12997c478bd9Sstevel@tonic-gate# 13007c478bd9Sstevel@tonic-gate# Build OsNet source 13017c478bd9Sstevel@tonic-gate# 13027c478bd9Sstevel@tonic-gateSTART_DATE=`date` 13037c478bd9Sstevel@tonic-gateSECONDS=0 13047c478bd9Sstevel@tonic-gateecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 13057c478bd9Sstevel@tonic-gate | tee -a $LOGFILE > $build_time_file 13067c478bd9Sstevel@tonic-gate 1307cdf0c1d5Smjnelsonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1308cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 1309cdf0c1d5Smjnelson 13107c478bd9Sstevel@tonic-gate# make sure we log only to the nightly build file 13117c478bd9Sstevel@tonic-gatebuild_noise_file="${TMPDIR}/build_noise" 13127c478bd9Sstevel@tonic-gateexec </dev/null >$build_noise_file 2>&1 13137c478bd9Sstevel@tonic-gate 131447703246Ssommerferun_hook SYS_PRE_NIGHTLY 131547703246Ssommerferun_hook PRE_NIGHTLY 131647703246Ssommerfe 13177c478bd9Sstevel@tonic-gateecho "\n==== list of environment variables ====\n" >> $LOGFILE 13187c478bd9Sstevel@tonic-gateenv >> $LOGFILE 13197c478bd9Sstevel@tonic-gate 13207c478bd9Sstevel@tonic-gateecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 13217c478bd9Sstevel@tonic-gate 13227c478bd9Sstevel@tonic-gateif [ "$N_FLAG" = "y" ]; then 13237c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" ]; then 13247c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13257c478bd9Sstevel@tonic-gateWARNING: the p option (create packages) is set, but so is the N option (do 13267c478bd9Sstevel@tonic-gate not run protocmp); this is dangerous; you should unset the N option 13277c478bd9Sstevel@tonic-gateEOF 13287c478bd9Sstevel@tonic-gate else 13297c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 13307c478bd9Sstevel@tonic-gateWarning: the N option (do not run protocmp) is set; it probably shouldn't be 13317c478bd9Sstevel@tonic-gateEOF 13327c478bd9Sstevel@tonic-gate fi 13337c478bd9Sstevel@tonic-gate echo "" | tee -a $mail_msg_file >> $LOGFILE 13347c478bd9Sstevel@tonic-gatefi 13357c478bd9Sstevel@tonic-gate 13367c478bd9Sstevel@tonic-gateif [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 13374e5b757fSkupfer # 13384e5b757fSkupfer # In the past we just complained but went ahead with the lint 1339ead1f93eSLiane Praza # pass, even though the proto area was built non-DEBUG. It's 1340ead1f93eSLiane Praza # unlikely that non-DEBUG headers will make a difference, but 13414e5b757fSkupfer # rather than assuming it's a safe combination, force the user 1342ead1f93eSLiane Praza # to specify a DEBUG build. 13434e5b757fSkupfer # 13444e5b757fSkupfer echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 13457c478bd9Sstevel@tonic-gate | tee -a $mail_msg_file >> $LOGFILE 13464e5b757fSkupfer l_FLAG=n 13477c478bd9Sstevel@tonic-gatefi 13487c478bd9Sstevel@tonic-gate 13497c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" ]; then 13507c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "y" ]; then 13517c478bd9Sstevel@tonic-gate echo "WARNING: the -f flag cannot be used during incremental" \ 13527c478bd9Sstevel@tonic-gate "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13537c478bd9Sstevel@tonic-gate f_FLAG=n 13547c478bd9Sstevel@tonic-gate fi 135511a78ea0SMark J. Nelson if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 135611a78ea0SMark J. Nelson echo "WARNING: the -f flag requires -l, and -p;" \ 135711a78ea0SMark J. Nelson "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 13587c478bd9Sstevel@tonic-gate f_FLAG=n 13597c478bd9Sstevel@tonic-gate fi 13607c478bd9Sstevel@tonic-gatefi 13617c478bd9Sstevel@tonic-gate 136296ccc8cbSesaxeif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 13634e5b757fSkupfer echo "WARNING: -w specified, but $ROOT does not exist;" \ 136496ccc8cbSesaxe "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 136596ccc8cbSesaxe w_FLAG=n 136696ccc8cbSesaxefi 136796ccc8cbSesaxe 13687c478bd9Sstevel@tonic-gateif [ "$t_FLAG" = "n" ]; then 13697c478bd9Sstevel@tonic-gate # 13707c478bd9Sstevel@tonic-gate # We're not doing a tools build, so make sure elfsign(1) is 13717c478bd9Sstevel@tonic-gate # new enough to safely sign non-crypto binaries. We test 13727c478bd9Sstevel@tonic-gate # debugging output from elfsign to detect the old version. 13737c478bd9Sstevel@tonic-gate # 13747c478bd9Sstevel@tonic-gate newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 13757c478bd9Sstevel@tonic-gate -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 13767c478bd9Sstevel@tonic-gate | egrep algorithmOID` 13777c478bd9Sstevel@tonic-gate if [ -z "$newelfsigntest" ]; then 13787c478bd9Sstevel@tonic-gate echo "WARNING: /usr/bin/elfsign out of date;" \ 13797c478bd9Sstevel@tonic-gate "will only sign crypto modules\n" | \ 13807c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 13817c478bd9Sstevel@tonic-gate export ELFSIGN_OBJECT=true 13827c478bd9Sstevel@tonic-gate elif [ "$VERIFY_ELFSIGN" = "y" ]; then 13837c478bd9Sstevel@tonic-gate echo "WARNING: VERIFY_ELFSIGN=y requires" \ 13847c478bd9Sstevel@tonic-gate "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 13857c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 13867c478bd9Sstevel@tonic-gate fi 13877c478bd9Sstevel@tonic-gatefi 13887c478bd9Sstevel@tonic-gate 13894e5b757fSkupfercase $MULTI_PROTO in 13904e5b757fSkupferyes|no) ;; 13914e5b757fSkupfer*) 13924e5b757fSkupfer echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 13934e5b757fSkupfer "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 13944e5b757fSkupfer echo "Setting MULTI_PROTO to \"no\".\n" | \ 13954e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 13964e5b757fSkupfer export MULTI_PROTO=no 13974e5b757fSkupfer ;; 13984e5b757fSkupferesac 13994e5b757fSkupfer 14007c478bd9Sstevel@tonic-gateecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 14017c478bd9Sstevel@tonic-gateecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 14027c478bd9Sstevel@tonic-gate 140396ccc8cbSesaxe# Save the current proto area if we're comparing against the last build 140496ccc8cbSesaxeif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 140596ccc8cbSesaxe if [ -d "$ROOT.prev" ]; then 140696ccc8cbSesaxe rm -rf $ROOT.prev 140796ccc8cbSesaxe fi 140896ccc8cbSesaxe mv $ROOT $ROOT.prev 140996ccc8cbSesaxefi 141096ccc8cbSesaxe 14114e5b757fSkupfer# Same for non-DEBUG proto area 14124e5b757fSkupferif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 14134e5b757fSkupfer if [ -d "$ROOT-nd.prev" ]; then 14144e5b757fSkupfer rm -rf $ROOT-nd.prev 14154e5b757fSkupfer fi 14164e5b757fSkupfer mv $ROOT-nd $ROOT-nd.prev 14174e5b757fSkupferfi 14184e5b757fSkupfer 1419445b6314SRichard Lowe# 1420445b6314SRichard Lowe# Echo the SCM type of the parent workspace, this can't just be which_scm 1421445b6314SRichard Lowe# as that does not know how to identify various network repositories. 1422445b6314SRichard Lowe# 1423445b6314SRichard Lowefunction parent_wstype { 1424445b6314SRichard Lowe typeset scm_type junk 142530635de9SJohn.Zolnowsky@Sun.COM 142630635de9SJohn.Zolnowsky@Sun.COM CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1427445b6314SRichard Lowe | read scm_type junk 1428445b6314SRichard Lowe if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 142930635de9SJohn.Zolnowsky@Sun.COM # Probe BRINGOVER_WS to determine its type 1430c3e6cb59SRichard Lowe if [[ $BRINGOVER_WS == ssh://* ]]; then 1431445b6314SRichard Lowe scm_type="mercurial" 143230635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == http://* ]] && \ 1433445b6314SRichard Lowe wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 143430635de9SJohn.Zolnowsky@Sun.COM egrep -s "application/mercurial" 2> /dev/null; then 1435445b6314SRichard Lowe scm_type="mercurial" 143630635de9SJohn.Zolnowsky@Sun.COM else 1437445b6314SRichard Lowe scm_type="none" 143830635de9SJohn.Zolnowsky@Sun.COM fi 143930635de9SJohn.Zolnowsky@Sun.COM fi 144030635de9SJohn.Zolnowsky@Sun.COM 144130635de9SJohn.Zolnowsky@Sun.COM # fold both unsupported and unrecognized results into "none" 1442445b6314SRichard Lowe case "$scm_type" in 1443c3e6cb59SRichard Lowe mercurial) 144430635de9SJohn.Zolnowsky@Sun.COM ;; 1445445b6314SRichard Lowe *) scm_type=none 144630635de9SJohn.Zolnowsky@Sun.COM ;; 144730635de9SJohn.Zolnowsky@Sun.COM esac 144830635de9SJohn.Zolnowsky@Sun.COM 1449445b6314SRichard Lowe echo $scm_type 145030635de9SJohn.Zolnowsky@Sun.COM} 145130635de9SJohn.Zolnowsky@Sun.COM 1452445b6314SRichard Lowe# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1453445b6314SRichard Lowefunction child_wstype { 1454445b6314SRichard Lowe typeset scm_type junk 1455445b6314SRichard Lowe 1456445b6314SRichard Lowe # Probe CODEMGR_WS to determine its type 1457445b6314SRichard Lowe if [[ -d $CODEMGR_WS ]]; then 1458445b6314SRichard Lowe $WHICH_SCM | read scm_type junk || exit 1 1459445b6314SRichard Lowe fi 1460445b6314SRichard Lowe 1461445b6314SRichard Lowe case "$scm_type" in 1462c3e6cb59SRichard Lowe none|git|mercurial) 1463445b6314SRichard Lowe ;; 1464445b6314SRichard Lowe *) scm_type=none 1465445b6314SRichard Lowe ;; 1466445b6314SRichard Lowe esac 1467445b6314SRichard Lowe 1468445b6314SRichard Lowe echo $scm_type 1469445b6314SRichard Lowe} 1470445b6314SRichard Lowe 14715c70f01eSRichard LoweSCM_TYPE=$(child_wstype) 147230635de9SJohn.Zolnowsky@Sun.COM 14737c478bd9Sstevel@tonic-gate# 14747c478bd9Sstevel@tonic-gate# Decide whether to clobber 14757c478bd9Sstevel@tonic-gate# 14767c478bd9Sstevel@tonic-gateif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 14777c478bd9Sstevel@tonic-gate echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 14787c478bd9Sstevel@tonic-gate 14797c478bd9Sstevel@tonic-gate cd $SRC 14807c478bd9Sstevel@tonic-gate # remove old clobber file 14817c478bd9Sstevel@tonic-gate rm -f $SRC/clobber.out 14827c478bd9Sstevel@tonic-gate rm -f $SRC/clobber-${MACH}.out 14837c478bd9Sstevel@tonic-gate 14847c478bd9Sstevel@tonic-gate # Remove all .make.state* files, just in case we are restarting 14857c478bd9Sstevel@tonic-gate # the build after having interrupted a previous 'make clobber'. 14868bcea973SRichard Lowe find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1487cdf0c1d5Smjnelson -o -name 'interfaces.*' \) -prune \ 14887c478bd9Sstevel@tonic-gate -o -name '.make.*' -print | xargs rm -f 14897c478bd9Sstevel@tonic-gate 14907c478bd9Sstevel@tonic-gate $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 14917c478bd9Sstevel@tonic-gate echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 14927c478bd9Sstevel@tonic-gate grep "$MAKE:" $SRC/clobber-${MACH}.out | 1493cb4d1691SRichard Lowe egrep -v "Ignoring unknown host" | \ 1494cb4d1691SRichard Lowe tee $TMPDIR/clobber_errs >> $mail_msg_file 1495cb4d1691SRichard Lowe 1496cb4d1691SRichard Lowe if [[ -s $TMPDIR/clobber_errs ]]; then 1497cb4d1691SRichard Lowe build_extras_ok=n 1498cb4d1691SRichard Lowe fi 14997c478bd9Sstevel@tonic-gate 15005110237aSJosef 'Jeff' Sipek if [[ "$t_FLAG" = "y" ]]; then 15017c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 15027c478bd9Sstevel@tonic-gate cd ${TOOLS} 15037c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/clobber-${MACH}.out 1504ead1f93eSLiane Praza $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 15057c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 15067c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber ERRORS ====\n" \ 15077c478bd9Sstevel@tonic-gate >> $mail_msg_file 15087c478bd9Sstevel@tonic-gate grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 15097c478bd9Sstevel@tonic-gate >> $mail_msg_file 1510cb4d1691SRichard Lowe if (( $? == 0 )); then 1511cb4d1691SRichard Lowe build_extras_ok=n 1512cb4d1691SRichard Lowe fi 15137c478bd9Sstevel@tonic-gate rm -rf ${TOOLS_PROTO} 15147c478bd9Sstevel@tonic-gate mkdir -p ${TOOLS_PROTO} 15157c478bd9Sstevel@tonic-gate fi 151696ccc8cbSesaxe 1517c7453724SMike Kupfer typeset roots=$(allprotos) 1518c7453724SMike Kupfer echo "\n\nClearing $roots" >> "$LOGFILE" 1519c7453724SMike Kupfer rm -rf $roots 15207c478bd9Sstevel@tonic-gate 15217c478bd9Sstevel@tonic-gate # Get back to a clean workspace as much as possible to catch 15227c478bd9Sstevel@tonic-gate # problems that only occur on fresh workspaces. 15237c478bd9Sstevel@tonic-gate # Remove all .make.state* files, libraries, and .o's that may 1524fb23a357Skupfer # have been omitted from clobber. A couple of libraries are 1525cdf0c1d5Smjnelson # under source code control, so leave them alone. 15267c478bd9Sstevel@tonic-gate # We should probably blow away temporary directories too. 15277c478bd9Sstevel@tonic-gate cd $SRC 1528cdf0c1d5Smjnelson find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 15298bcea973SRichard Lowe -o -name .git -o -name 'interfaces.*' \) -prune -o \ 15307c478bd9Sstevel@tonic-gate \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1531fb23a357Skupfer -name '*.o' \) -print | \ 1532fb23a357Skupfer grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 15337c478bd9Sstevel@tonic-gateelse 15347c478bd9Sstevel@tonic-gate echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 15357c478bd9Sstevel@tonic-gatefi 15367c478bd9Sstevel@tonic-gate 1537597bd30bSMike Kupfertype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1538cdf0c1d5Smjnelson typeset -x PATH=$PATH 1539cdf0c1d5Smjnelson 1540cdf0c1d5Smjnelson # If the repository doesn't exist yet, then we want to populate it. 1541cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.hg ]]; then 1542cdf0c1d5Smjnelson staffer hg init $CODEMGR_WS 15438cca05f6SMark J. Nelson staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 15448cca05f6SMark J. Nelson staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1545f457028bSMark J. Nelson touch $TMPDIR/new_repository 1546cdf0c1d5Smjnelson fi 15475c53ea7aSmjnelson 1548cdf0c1d5Smjnelson typeset -x HGMERGE="/bin/false" 1549cdf0c1d5Smjnelson 1550cdf0c1d5Smjnelson # 15515c53ea7aSmjnelson # If the user has changes, regardless of whether those changes are 15525c53ea7aSmjnelson # committed, and regardless of whether those changes conflict, then 15535c53ea7aSmjnelson # we'll attempt to merge them either implicitly (uncommitted) or 15545c53ea7aSmjnelson # explicitly (committed). 1555cdf0c1d5Smjnelson # 15565c53ea7aSmjnelson # These are the messages we'll use to help clarify mercurial output 15575c53ea7aSmjnelson # in those cases. 15585c53ea7aSmjnelson # 15595c53ea7aSmjnelson typeset mergefailmsg="\ 15605c53ea7aSmjnelson***\n\ 15615c53ea7aSmjnelson*** nightly was unable to automatically merge your changes. You should\n\ 15625c53ea7aSmjnelson*** redo the full merge manually, following the steps outlined by mercurial\n\ 15635c53ea7aSmjnelson*** above, then restart nightly.\n\ 15645c53ea7aSmjnelson***\n" 15655c53ea7aSmjnelson typeset mergepassmsg="\ 15665c53ea7aSmjnelson***\n\ 15675c53ea7aSmjnelson*** nightly successfully merged your changes. This means that your working\n\ 15685c53ea7aSmjnelson*** directory has been updated, but those changes are not yet committed.\n\ 15695c53ea7aSmjnelson*** After nightly completes, you should validate the results of the merge,\n\ 15705c53ea7aSmjnelson*** then use hg commit manually.\n\ 15715c53ea7aSmjnelson***\n" 15725c53ea7aSmjnelson 15735c53ea7aSmjnelson # 15745c53ea7aSmjnelson # For each repository in turn: 15755c53ea7aSmjnelson # 15765c53ea7aSmjnelson # 1. Do the pull. If this fails, dump the output and bail out. 15775c53ea7aSmjnelson # 15785c53ea7aSmjnelson # 2. If the pull resulted in an extra head, do an explicit merge. 15795c53ea7aSmjnelson # If this fails, dump the output and bail out. 15805c53ea7aSmjnelson # 15815c53ea7aSmjnelson # Because we can't rely on Mercurial to exit with a failure code 15825c53ea7aSmjnelson # when a merge fails (Mercurial issue #186), we must grep the 15835c53ea7aSmjnelson # output of pull/merge to check for attempted and/or failed merges. 15845c53ea7aSmjnelson # 15855c53ea7aSmjnelson # 3. If a merge failed, set the message and fail the bringover. 15865c53ea7aSmjnelson # 15875c53ea7aSmjnelson # 4. Otherwise, if a merge succeeded, set the message 15885c53ea7aSmjnelson # 15895c53ea7aSmjnelson # 5. Dump the output, and any message from step 3 or 4. 15905c53ea7aSmjnelson # 15915c53ea7aSmjnelson 1592f457028bSMark J. Nelson typeset HG_SOURCE=$BRINGOVER_WS 1593f457028bSMark J. Nelson if [ ! -f $TMPDIR/new_repository ]; then 1594f457028bSMark J. Nelson HG_SOURCE=$TMPDIR/open_bundle.hg 1595f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1596f457028bSMark J. Nelson -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1597f457028bSMark J. Nelson 1598f457028bSMark J. Nelson # 1599f457028bSMark J. Nelson # If there are no incoming changesets, then incoming will 1600f457028bSMark J. Nelson # fail, and there will be no bundle file. Reset the source, 1601f457028bSMark J. Nelson # to allow the remaining logic to complete with no false 1602f457028bSMark J. Nelson # negatives. (Unlike incoming, pull will return success 1603f457028bSMark J. Nelson # for the no-change case.) 1604f457028bSMark J. Nelson # 1605f457028bSMark J. Nelson if (( $? != 0 )); then 1606f457028bSMark J. Nelson HG_SOURCE=$BRINGOVER_WS 1607f457028bSMark J. Nelson fi 1608f457028bSMark J. Nelson fi 1609f457028bSMark J. Nelson 1610f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 16115c53ea7aSmjnelson > $TMPDIR/pull_open.out 2>&1 16125c53ea7aSmjnelson if (( $? != 0 )); then 16135c53ea7aSmjnelson printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 16145c53ea7aSmjnelson cat $TMPDIR/pull_open.out 16155c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16165c53ea7aSmjnelson printf "$mergefailmsg" 16175c53ea7aSmjnelson fi 16185c53ea7aSmjnelson touch $TMPDIR/bringover_failed 16195c53ea7aSmjnelson return 16205c53ea7aSmjnelson fi 16215c53ea7aSmjnelson 1622cdf0c1d5Smjnelson if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 16235c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS merge \ 16245c53ea7aSmjnelson >> $TMPDIR/pull_open.out 2>&1 16255c53ea7aSmjnelson if (( $? != 0 )); then 16265c53ea7aSmjnelson printf "%s: merge failed as follows:\n\n" \ 16275c53ea7aSmjnelson "$CODEMGR_WS" 16285c53ea7aSmjnelson cat $TMPDIR/pull_open.out 16295c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out \ 16305c53ea7aSmjnelson > /dev/null 2>&1; then 16315c53ea7aSmjnelson printf "$mergefailmsg" 16325c53ea7aSmjnelson fi 1633cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 16345c53ea7aSmjnelson return 1635cdf0c1d5Smjnelson fi 1636cdf0c1d5Smjnelson fi 16375c53ea7aSmjnelson 16385c53ea7aSmjnelson printf "updated %s with the following results:\n" "$CODEMGR_WS" 16395c53ea7aSmjnelson cat $TMPDIR/pull_open.out 16405c53ea7aSmjnelson if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 16415c53ea7aSmjnelson printf "$mergepassmsg" 16425c53ea7aSmjnelson fi 16435c53ea7aSmjnelson printf "\n" 16445c53ea7aSmjnelson 16455c53ea7aSmjnelson # 1646f457028bSMark J. Nelson # Per-changeset output is neither useful nor manageable for a 1647f457028bSMark J. Nelson # newly-created repository. 1648f457028bSMark J. Nelson # 1649f457028bSMark J. Nelson if [ -f $TMPDIR/new_repository ]; then 1650f457028bSMark J. Nelson return 1651f457028bSMark J. Nelson fi 1652f457028bSMark J. Nelson 1653f457028bSMark J. Nelson printf "\nadded the following changesets to open repository:\n" 1654f457028bSMark J. Nelson cat $TMPDIR/incoming_open.out 1655cdf0c1d5Smjnelson} 1656cdf0c1d5Smjnelson 1657597bd30bSMike Kupfertype bringover_none > /dev/null 2>&1 || function bringover_none { 1658cdf0c1d5Smjnelson echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1659cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1660cdf0c1d5Smjnelson} 1661cdf0c1d5Smjnelson 1662cdf0c1d5Smjnelson# 1663cdf0c1d5Smjnelson# Decide whether to bringover to the codemgr workspace 1664cdf0c1d5Smjnelson# 1665cdf0c1d5Smjnelsonif [ "$n_FLAG" = "n" ]; then 1666445b6314SRichard Lowe PARENT_SCM_TYPE=$(parent_wstype) 1667ca0ac982Smjnelson 1668ca0ac982Smjnelson if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1669ca0ac982Smjnelson echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1670ca0ac982Smjnelson "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 1671ca0ac982Smjnelson exit 1 1672ca0ac982Smjnelson fi 1673ca0ac982Smjnelson 1674cdf0c1d5Smjnelson run_hook PRE_BRINGOVER 1675cdf0c1d5Smjnelson 1676cdf0c1d5Smjnelson echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1677cdf0c1d5Smjnelson echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1678cdf0c1d5Smjnelson 1679ca0ac982Smjnelson eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 1680cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 168132f1e47bSsommerfe 168232f1e47bSsommerfe if [ -f $TMPDIR/bringover_failed ]; then 168332f1e47bSsommerfe rm -f $TMPDIR/bringover_failed 168432f1e47bSsommerfe build_ok=n 168532f1e47bSsommerfe echo "trouble with bringover, quitting at `date`." | 16867c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 16877c478bd9Sstevel@tonic-gate exit 1 16887c478bd9Sstevel@tonic-gate fi 1689085d331dSkupfer 1690ca0ac982Smjnelson # 1691ca0ac982Smjnelson # It's possible that we used the bringover above to create 1692ca0ac982Smjnelson # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 1693ca0ac982Smjnelson # but should now be the same as $BRINGOVER_WS. 1694ca0ac982Smjnelson # 1695ca0ac982Smjnelson [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 1696ca0ac982Smjnelson 169747703246Ssommerfe run_hook POST_BRINGOVER 169847703246Ssommerfe 1699c3e6cb59SRichard Lowe check_closed_bins 1700b83ec4edSjmcp 17017c478bd9Sstevel@tonic-gateelse 17027c478bd9Sstevel@tonic-gate echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 17037c478bd9Sstevel@tonic-gatefi 17047c478bd9Sstevel@tonic-gate 1705220399b7SRoland Mainz# Safeguards 1706220399b7SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 1707220399b7SRoland Mainz[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 1708220399b7SRoland Mainz[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 1709220399b7SRoland Mainz 1710cdf0c1d5Smjnelsonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 1711cdf0c1d5Smjnelson 1712cdf0c1d5Smjnelson# System 1713cdf0c1d5Smjnelsonwhence uname | tee -a $build_environ_file >> $LOGFILE 1714cdf0c1d5Smjnelsonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 1715cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1716cdf0c1d5Smjnelson 1717cdf0c1d5Smjnelson# make 1718cdf0c1d5Smjnelsonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 1719cdf0c1d5Smjnelson$MAKE -v | tee -a $build_environ_file >> $LOGFILE 1720cdf0c1d5Smjnelsonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1721cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1722cdf0c1d5Smjnelson 1723cdf0c1d5Smjnelson# 1724cdf0c1d5Smjnelson# Report the compiler versions. 1725cdf0c1d5Smjnelson# 1726cdf0c1d5Smjnelson 1727cdf0c1d5Smjnelsonif [[ ! -f $SRC/Makefile ]]; then 1728cdf0c1d5Smjnelson build_ok=n 1729cdf0c1d5Smjnelson echo "\nUnable to find \"Makefile\" in $SRC." | \ 1730cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1731cdf0c1d5Smjnelson exit 1 1732cdf0c1d5Smjnelsonfi 1733cdf0c1d5Smjnelson 1734cdf0c1d5Smjnelson( cd $SRC 1735cdf0c1d5Smjnelson for target in cc-version cc64-version java-version; do 1736cdf0c1d5Smjnelson echo 1737cdf0c1d5Smjnelson # 1738cdf0c1d5Smjnelson # Put statefile somewhere we know we can write to rather than trip 1739cdf0c1d5Smjnelson # over a read-only $srcroot. 1740cdf0c1d5Smjnelson # 1741cdf0c1d5Smjnelson rm -f $TMPDIR/make-state 1742cdf0c1d5Smjnelson export SRC 1743cdf0c1d5Smjnelson if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1744cdf0c1d5Smjnelson continue 1745cdf0c1d5Smjnelson fi 1746cdf0c1d5Smjnelson touch $TMPDIR/nocompiler 1747cdf0c1d5Smjnelson done 1748cdf0c1d5Smjnelson echo 1749cdf0c1d5Smjnelson) | tee -a $build_environ_file >> $LOGFILE 1750cdf0c1d5Smjnelson 1751cdf0c1d5Smjnelsonif [ -f $TMPDIR/nocompiler ]; then 1752cdf0c1d5Smjnelson rm -f $TMPDIR/nocompiler 1753cdf0c1d5Smjnelson build_ok=n 1754cdf0c1d5Smjnelson echo "Aborting due to missing compiler." | 1755cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1756cdf0c1d5Smjnelson exit 1 1757cdf0c1d5Smjnelsonfi 1758cdf0c1d5Smjnelson 1759cdf0c1d5Smjnelson# as 1760cdf0c1d5Smjnelsonwhence as | tee -a $build_environ_file >> $LOGFILE 1761cdf0c1d5Smjnelsonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 1762cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 1763cdf0c1d5Smjnelson 1764cdf0c1d5Smjnelson# Check that we're running a capable link-editor 1765cdf0c1d5Smjnelsonwhence ld | tee -a $build_environ_file >> $LOGFILE 1766cdf0c1d5SmjnelsonLDVER=`ld -V 2>&1` 1767cdf0c1d5Smjnelsonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 176870087ad3SRichard LoweLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 1769cdf0c1d5Smjnelsonif [ `expr $LDVER \< 422` -eq 1 ]; then 1770cdf0c1d5Smjnelson echo "The link-editor needs to be at version 422 or higher to build" | \ 1771cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1772cdf0c1d5Smjnelson echo "the latest stuff. Hope your build works." | \ 1773cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 1774cdf0c1d5Smjnelsonfi 1775cdf0c1d5Smjnelson 17767c478bd9Sstevel@tonic-gate# 17774e5b757fSkupfer# Build and use the workspace's tools if requested 17787c478bd9Sstevel@tonic-gate# 17795110237aSJosef 'Jeff' Sipekif [[ "$t_FLAG" = "y" ]]; then 17804e5b757fSkupfer set_non_debug_build_flags 17817c478bd9Sstevel@tonic-gate 17827c478bd9Sstevel@tonic-gate build_tools ${TOOLS_PROTO} 1783cb4d1691SRichard Lowe if (( $? != 0 )); then 1784cb4d1691SRichard Lowe build_ok=n 1785cb4d1691SRichard Lowe else 17864e5b757fSkupfer use_tools $TOOLS_PROTO 17874e5b757fSkupfer fi 17887c478bd9Sstevel@tonic-gatefi 17897c478bd9Sstevel@tonic-gate 17904e5b757fSkupfer# timestamp the start of the normal build; the findunref tool uses it. 17914e5b757fSkupfertouch $SRC/.build.tstamp 17924e5b757fSkupfer 17937c478bd9Sstevel@tonic-gatenormal_build 17945d715dd7Skupfer 17957c478bd9Sstevel@tonic-gateORIG_SRC=$SRC 17967c478bd9Sstevel@tonic-gateBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 17977c478bd9Sstevel@tonic-gate 17987c478bd9Sstevel@tonic-gate 17994e5b757fSkupfer# 18004e5b757fSkupfer# There are several checks that need to look at the proto area, but 18014e5b757fSkupfer# they only need to look at one, and they don't care whether it's 18024e5b757fSkupfer# DEBUG or non-DEBUG. 18034e5b757fSkupfer# 18044e5b757fSkupferif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 18054e5b757fSkupfer checkroot=$ROOT-nd 18064e5b757fSkupferelse 18074e5b757fSkupfer checkroot=$ROOT 18084e5b757fSkupferfi 18094e5b757fSkupfer 18107c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 18117c478bd9Sstevel@tonic-gate echo "\n==== Creating protolist system file at `date` ====" \ 18127c478bd9Sstevel@tonic-gate >> $LOGFILE 18134e5b757fSkupfer protolist $checkroot > $ATLOG/proto_list_${MACH} 18147c478bd9Sstevel@tonic-gate echo "==== protolist system file created at `date` ====\n" \ 18157c478bd9Sstevel@tonic-gate >> $LOGFILE 18167c478bd9Sstevel@tonic-gate 18177c478bd9Sstevel@tonic-gate if [ "$N_FLAG" != "y" ]; then 18187c478bd9Sstevel@tonic-gate 1819ead1f93eSLiane Praza E1= 1820ead1f93eSLiane Praza f1= 1821ead1f93eSLiane Praza for f in $f1; do 1822ead1f93eSLiane Praza if [ -f "$f" ]; then 1823ead1f93eSLiane Praza E1="$E1 -e $f" 1824ead1f93eSLiane Praza fi 1825ead1f93eSLiane Praza done 1826ead1f93eSLiane Praza 1827ead1f93eSLiane Praza E2= 1828ead1f93eSLiane Praza f2= 1829ead1f93eSLiane Praza if [ -d "$SRC/pkg" ]; then 1830ead1f93eSLiane Praza f2="$f2 exceptions/packaging" 1831ead1f93eSLiane Praza fi 1832ead1f93eSLiane Praza 1833ead1f93eSLiane Praza for f in $f2; do 1834ead1f93eSLiane Praza if [ -f "$f" ]; then 1835ead1f93eSLiane Praza E2="$E2 -e $f" 1836ead1f93eSLiane Praza fi 1837ead1f93eSLiane Praza done 1838ead1f93eSLiane Praza fi 1839ead1f93eSLiane Praza 1840ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 1841ead1f93eSLiane Praza echo "\n==== Validating manifests against proto area ====\n" \ 1842ead1f93eSLiane Praza >> $mail_msg_file 1843cb4d1691SRichard Lowe ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \ 1844cb4d1691SRichard Lowe tee $TMPDIR/protocmp_noise >> $mail_msg_file 1845cb4d1691SRichard Lowe if [[ -s $TMPDIR/protocmp_noise ]]; then 1846cb4d1691SRichard Lowe build_extras_ok=n 1847cb4d1691SRichard Lowe fi 1848ead1f93eSLiane Praza fi 1849ead1f93eSLiane Praza 1850ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 1851ead1f93eSLiane Praza echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 1852ead1f93eSLiane Praza if [ -n "$E2" ]; then 1853ead1f93eSLiane Praza ELIST=$E2 1854ead1f93eSLiane Praza else 1855ead1f93eSLiane Praza ELIST=$E1 1856ead1f93eSLiane Praza fi 18577c478bd9Sstevel@tonic-gate $PROTOCMPTERSE \ 18587c478bd9Sstevel@tonic-gate "Files in yesterday's proto area, but not today's:" \ 18597c478bd9Sstevel@tonic-gate "Files in today's proto area, but not yesterday's:" \ 18607c478bd9Sstevel@tonic-gate "Files that changed between yesterday and today:" \ 18617c478bd9Sstevel@tonic-gate ${ELIST} \ 18627c478bd9Sstevel@tonic-gate -d $REF_PROTO_LIST \ 18637c478bd9Sstevel@tonic-gate $ATLOG/proto_list_${MACH} \ 18647c478bd9Sstevel@tonic-gate >> $mail_msg_file 18657c478bd9Sstevel@tonic-gate fi 18667c478bd9Sstevel@tonic-gatefi 18677c478bd9Sstevel@tonic-gate 1868cb4d1691SRichard Loweif [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \ 1869cb4d1691SRichard Lowe "$build_extras_ok" == "y" ]]; then 18707c478bd9Sstevel@tonic-gate staffer cp $ATLOG/proto_list_${MACH} \ 18717c478bd9Sstevel@tonic-gate $PARENT_WS/usr/src/proto_list_${MACH} 18727c478bd9Sstevel@tonic-gatefi 18737c478bd9Sstevel@tonic-gate 18747c478bd9Sstevel@tonic-gate# Update parent proto area if necessary. This is done now 18757c478bd9Sstevel@tonic-gate# so that the proto area has either DEBUG or non-DEBUG kernels. 18767c478bd9Sstevel@tonic-gate# Note that this clears out the lock file, so we can dispense with 18777c478bd9Sstevel@tonic-gate# the variable now. 18787c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 18797c478bd9Sstevel@tonic-gate echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 18807c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 1881ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT/* 18827c478bd9Sstevel@tonic-gate unset Ulockfile 18837c478bd9Sstevel@tonic-gate mkdir -p $NIGHTLY_PARENT_ROOT 18844e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1885ead1f93eSLiane Praza ( cd $ROOT; tar cf - . | 18864e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 18877c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 18887c478bd9Sstevel@tonic-gate fi 18894e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 1890ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT-nd/* 18914e5b757fSkupfer mkdir -p $NIGHTLY_PARENT_ROOT-nd 18924e5b757fSkupfer cd $ROOT-nd 18934e5b757fSkupfer ( tar cf - . | 18944e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 18954e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 18964e5b757fSkupfer fi 18976798c3f0SMark J. Nelson if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 1898ead1f93eSLiane Praza echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 1899ead1f93eSLiane Praza tee -a $LOGFILE >> $mail_msg_file 1900ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 1901ead1f93eSLiane Praza mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 1902ead1f93eSLiane Praza if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 1903ead1f93eSLiane Praza ( cd $TOOLS_PROTO; tar cf - . | 19046798c3f0SMark J. Nelson ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 19056798c3f0SMark J. Nelson umask 0; tar xpf - ) ) 2>&1 | 1906ead1f93eSLiane Praza tee -a $mail_msg_file >> $LOGFILE 1907ead1f93eSLiane Praza fi 19084e5b757fSkupfer fi 19096798c3f0SMark J. Nelsonfi 19107c478bd9Sstevel@tonic-gate 19117c478bd9Sstevel@tonic-gate# 191275ce41a5SAli Bahrami# ELF verification: ABI (-A) and runtime (-r) checks 19137c478bd9Sstevel@tonic-gate# 191475ce41a5SAli Bahramiif [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then 191575ce41a5SAli Bahrami # Directory ELF-data.$MACH holds the files produced by these tests. 191675ce41a5SAli Bahrami elf_ddir=$SRC/ELF-data.$MACH 19177c478bd9Sstevel@tonic-gate 191875ce41a5SAli Bahrami # If there is a previous ELF-data backup directory, remove it. Then, 191975ce41a5SAli Bahrami # rotate current ELF-data directory into its place and create a new 192075ce41a5SAli Bahrami # empty directory 192175ce41a5SAli Bahrami rm -rf $elf_ddir.ref 192275ce41a5SAli Bahrami if [[ -d $elf_ddir ]]; then 192375ce41a5SAli Bahrami mv $elf_ddir $elf_ddir.ref 192475ce41a5SAli Bahrami fi 192575ce41a5SAli Bahrami mkdir -p $elf_ddir 192675ce41a5SAli Bahrami 192775ce41a5SAli Bahrami # Call find_elf to produce a list of the ELF objects in the proto area. 192875ce41a5SAli Bahrami # This list is passed to check_rtime and interface_check, preventing 192975ce41a5SAli Bahrami # them from separately calling find_elf to do the same work twice. 193075ce41a5SAli Bahrami find_elf -fr $checkroot > $elf_ddir/object_list 193175ce41a5SAli Bahrami 193275ce41a5SAli Bahrami if [[ $A_FLAG = y ]]; then 19337c478bd9Sstevel@tonic-gate echo "\n==== Check versioning and ABI information ====\n" | \ 19347c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 19357c478bd9Sstevel@tonic-gate 193675ce41a5SAli Bahrami # Produce interface description for the proto. Report errors. 193775ce41a5SAli Bahrami interface_check -o -w $elf_ddir -f object_list \ 193875ce41a5SAli Bahrami -i interface -E interface.err 193975ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.err ]]; then 194075ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/interface.err \ 194175ce41a5SAli Bahrami >> $mail_msg_file 1942cb4d1691SRichard Lowe build_extras_ok=n 19437c478bd9Sstevel@tonic-gate fi 19447c478bd9Sstevel@tonic-gate 19455253169eSAli Bahrami # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 19465253169eSAli Bahrami # description file to that from the baseline gate. Issue a 19475253169eSAli Bahrami # warning if the baseline is not present, and keep going. 19485253169eSAli Bahrami if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 19495253169eSAli Bahrami base_ifile="$ELF_DATA_BASELINE_DIR/interface" 19507c478bd9Sstevel@tonic-gate 19515253169eSAli Bahrami echo "\n==== Compare versioning and ABI information" \ 1952e599109eSAli Bahrami "to baseline ====\n" | \ 19535253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 1954e599109eSAli Bahrami echo "Baseline: $base_ifile\n" >> $LOGFILE 19555253169eSAli Bahrami 19565253169eSAli Bahrami if [[ -f $base_ifile ]]; then 19575253169eSAli Bahrami interface_cmp -d -o $base_ifile \ 195875ce41a5SAli Bahrami $elf_ddir/interface > $elf_ddir/interface.cmp 195975ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.cmp ]]; then 19605253169eSAli Bahrami echo | tee -a $LOGFILE >> $mail_msg_file 19615253169eSAli Bahrami tee -a $LOGFILE < \ 19625253169eSAli Bahrami $elf_ddir/interface.cmp \ 196375ce41a5SAli Bahrami >> $mail_msg_file 1964cb4d1691SRichard Lowe build_extras_ok=n 19657c478bd9Sstevel@tonic-gate fi 19665253169eSAli Bahrami else 19675253169eSAli Bahrami echo "baseline not available. comparison" \ 19685253169eSAli Bahrami "skipped" | \ 19695253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 19705253169eSAli Bahrami fi 19715253169eSAli Bahrami 19725253169eSAli Bahrami fi 19737c478bd9Sstevel@tonic-gate fi 19747c478bd9Sstevel@tonic-gate 197575ce41a5SAli Bahrami if [[ $r_FLAG = y ]]; then 19767c478bd9Sstevel@tonic-gate echo "\n==== Check ELF runtime attributes ====\n" | \ 19777c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 19787c478bd9Sstevel@tonic-gate 1979ead1f93eSLiane Praza # If we're doing a DEBUG build the proto area will be left 198075ce41a5SAli Bahrami # with debuggable objects, thus don't assert -s. 198175ce41a5SAli Bahrami if [[ $D_FLAG = y ]]; then 19827c478bd9Sstevel@tonic-gate rtime_sflag="" 19837c478bd9Sstevel@tonic-gate else 19847c478bd9Sstevel@tonic-gate rtime_sflag="-s" 19857c478bd9Sstevel@tonic-gate fi 198675ce41a5SAli Bahrami check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 198775ce41a5SAli Bahrami -D object_list -f object_list -E runtime.err \ 1988622090e3SAli Bahrami -I runtime.attr.raw 1989cb4d1691SRichard Lowe if (( $? != 0 )); then 1990cb4d1691SRichard Lowe build_extras_ok=n 1991cb4d1691SRichard Lowe fi 1992622090e3SAli Bahrami 1993622090e3SAli Bahrami # check_rtime -I output needs to be sorted in order to 1994622090e3SAli Bahrami # compare it to that from previous builds. 1995622090e3SAli Bahrami sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 1996622090e3SAli Bahrami rm $elf_ddir/runtime.attr.raw 19977c478bd9Sstevel@tonic-gate 199875ce41a5SAli Bahrami # Report errors 199975ce41a5SAli Bahrami if [[ -s $elf_ddir/runtime.err ]]; then 200075ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/runtime.err \ 20017c478bd9Sstevel@tonic-gate >> $mail_msg_file 2002cb4d1691SRichard Lowe build_extras_ok=n 200375ce41a5SAli Bahrami fi 20047c478bd9Sstevel@tonic-gate 200575ce41a5SAli Bahrami # If there is an ELF-data directory from a previous build, 200675ce41a5SAli Bahrami # then diff the attr files. These files contain information 200775ce41a5SAli Bahrami # about dependencies, versioning, and runpaths. There is some 200875ce41a5SAli Bahrami # overlap with the ABI checking done above, but this also 200975ce41a5SAli Bahrami # flushes out non-ABI interface differences along with the 201075ce41a5SAli Bahrami # other information. 201175ce41a5SAli Bahrami echo "\n==== Diff ELF runtime attributes" \ 201275ce41a5SAli Bahrami "(since last build) ====\n" | \ 201375ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 201475ce41a5SAli Bahrami 201575ce41a5SAli Bahrami if [[ -f $elf_ddir.ref/runtime.attr ]]; then 201675ce41a5SAli Bahrami diff $elf_ddir.ref/runtime.attr \ 201775ce41a5SAli Bahrami $elf_ddir/runtime.attr \ 201875ce41a5SAli Bahrami >> $mail_msg_file 201975ce41a5SAli Bahrami fi 202075ce41a5SAli Bahrami fi 20215253169eSAli Bahrami 20225253169eSAli Bahrami # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 20235253169eSAli Bahrami if [[ "$u_FLAG" = "y" ]]; then 20245253169eSAli Bahrami p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 20255253169eSAli Bahrami 20265253169eSAli Bahrami # If parent lacks the ELF-data.$MACH directory, create it 20275253169eSAli Bahrami if [[ ! -d $p_elf_ddir ]]; then 20285253169eSAli Bahrami staffer mkdir -p $p_elf_ddir 20295253169eSAli Bahrami fi 20305253169eSAli Bahrami 20315253169eSAli Bahrami # These files are used asynchronously by other builds for ABI 20325253169eSAli Bahrami # verification, as above for the -A option. As such, we require 20335253169eSAli Bahrami # the file replacement to be atomic. Copy the data to a temp 20345253169eSAli Bahrami # file in the same filesystem and then rename into place. 20355253169eSAli Bahrami ( 20365253169eSAli Bahrami cd $elf_ddir 20375253169eSAli Bahrami for elf_dfile in *; do 20385253169eSAli Bahrami staffer cp $elf_dfile \ 20395253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile}.new 20405253169eSAli Bahrami staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 20415253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile} 20425253169eSAli Bahrami done 20435253169eSAli Bahrami ) 20445253169eSAli Bahrami fi 20457c478bd9Sstevel@tonic-gatefi 20467c478bd9Sstevel@tonic-gate 20477c478bd9Sstevel@tonic-gate# DEBUG lint of kernel begins 20487c478bd9Sstevel@tonic-gate 20497c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 20507c478bd9Sstevel@tonic-gate if [ "$LINTDIRS" = "" ]; then 20517c478bd9Sstevel@tonic-gate # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 20527c478bd9Sstevel@tonic-gate LINTDIRS="$SRC y" 20537c478bd9Sstevel@tonic-gate fi 20547c478bd9Sstevel@tonic-gate set $LINTDIRS 20557c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 20567c478bd9Sstevel@tonic-gate dolint $1 $2; shift; shift 20577c478bd9Sstevel@tonic-gate done 20587c478bd9Sstevel@tonic-gateelse 20597c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 20607c478bd9Sstevel@tonic-gatefi 20617c478bd9Sstevel@tonic-gate 20627c478bd9Sstevel@tonic-gate# "make check" begins 20637c478bd9Sstevel@tonic-gate 20647c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 20657c478bd9Sstevel@tonic-gate # remove old check.out 20667c478bd9Sstevel@tonic-gate rm -f $SRC/check.out 20677c478bd9Sstevel@tonic-gate 20687c478bd9Sstevel@tonic-gate rm -f $SRC/check-${MACH}.out 20697c478bd9Sstevel@tonic-gate cd $SRC 2070170832d3SAlbert Lee $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 2071170832d3SAlbert Lee >> $LOGFILE 20727c478bd9Sstevel@tonic-gate echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 20737c478bd9Sstevel@tonic-gate 20747c478bd9Sstevel@tonic-gate grep ":" $SRC/check-${MACH}.out | 20757c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 2076cb4d1691SRichard Lowe sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file 2077cb4d1691SRichard Lowe 2078cb4d1691SRichard Lowe if [[ -s $TMPDIR/check_errors ]]; then 2079cb4d1691SRichard Lowe build_extras_ok=n 2080cb4d1691SRichard Lowe fi 20817c478bd9Sstevel@tonic-gateelse 20827c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 20837c478bd9Sstevel@tonic-gatefi 20847c478bd9Sstevel@tonic-gate 20857c478bd9Sstevel@tonic-gateecho "\n==== Find core files ====\n" | \ 20867c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 20877c478bd9Sstevel@tonic-gate 2088fb23a357Skupferfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 20897c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 20907c478bd9Sstevel@tonic-gate 20917c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 20927c478bd9Sstevel@tonic-gate echo "\n==== Diff unreferenced files (since last build) ====\n" \ 20937c478bd9Sstevel@tonic-gate | tee -a $LOGFILE >>$mail_msg_file 20947c478bd9Sstevel@tonic-gate rm -f $SRC/unref-${MACH}.ref 20957c478bd9Sstevel@tonic-gate if [ -f $SRC/unref-${MACH}.out ]; then 20967c478bd9Sstevel@tonic-gate mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 20977c478bd9Sstevel@tonic-gate fi 20987c478bd9Sstevel@tonic-gate 20999730304dSmeem findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 2100cdf0c1d5Smjnelson ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 21019730304dSmeem sort > $SRC/unref-${MACH}.out 21027c478bd9Sstevel@tonic-gate 21037c478bd9Sstevel@tonic-gate if [ ! -f $SRC/unref-${MACH}.ref ]; then 21047c478bd9Sstevel@tonic-gate cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 21057c478bd9Sstevel@tonic-gate fi 21067c478bd9Sstevel@tonic-gate 21077c478bd9Sstevel@tonic-gate diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 21087c478bd9Sstevel@tonic-gatefi 21097c478bd9Sstevel@tonic-gate 21107c478bd9Sstevel@tonic-gate# Verify that the usual lists of files, such as exception lists, 21117c478bd9Sstevel@tonic-gate# contain only valid references to files. If the build has failed, 21127c478bd9Sstevel@tonic-gate# then don't check the proto area. 21137c478bd9Sstevel@tonic-gateCHECK_PATHS=${CHECK_PATHS:-y} 21147c478bd9Sstevel@tonic-gateif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 21157c478bd9Sstevel@tonic-gate echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 21167c478bd9Sstevel@tonic-gate >>$mail_msg_file 21177c478bd9Sstevel@tonic-gate arg=-b 21187c478bd9Sstevel@tonic-gate [ "$build_ok" = y ] && arg= 2119*e2c8add4SRichard PALO checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1 2120*e2c8add4SRichard PALO if [[ -s $SRC/check-paths.out ]]; then 2121*e2c8add4SRichard PALO tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file 2122cb4d1691SRichard Lowe build_extras_ok=n 2123cb4d1691SRichard Lowe fi 21247c478bd9Sstevel@tonic-gatefi 21257c478bd9Sstevel@tonic-gate 21267c478bd9Sstevel@tonic-gateif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 21277c478bd9Sstevel@tonic-gate echo "\n==== Impact on file permissions ====\n" \ 21287c478bd9Sstevel@tonic-gate >> $mail_msg_file 2129ead1f93eSLiane Praza 2130ead1f93eSLiane Praza abspkg= 2131ead1f93eSLiane Praza for d in $abssrcdirs; do 2132ead1f93eSLiane Praza if [ -d "$d/pkg" ]; then 2133ead1f93eSLiane Praza abspkg="$abspkg $d" 2134ead1f93eSLiane Praza fi 2135ead1f93eSLiane Praza done 2136ead1f93eSLiane Praza 2137ead1f93eSLiane Praza if [ -n "$abspkg" ]; then 2138ead1f93eSLiane Praza for d in "$abspkg"; do 2139ead1f93eSLiane Praza ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 2140ead1f93eSLiane Praza done 2141ead1f93eSLiane Praza fi 21427c478bd9Sstevel@tonic-gatefi 21437c478bd9Sstevel@tonic-gate 214496ccc8cbSesaxeif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 21454e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 21464e5b757fSkupfer do_wsdiff DEBUG $ROOT.prev $ROOT 21474e5b757fSkupfer fi 214896ccc8cbSesaxe 21494e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 21504e5b757fSkupfer do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 215196ccc8cbSesaxe fi 215296ccc8cbSesaxefi 215396ccc8cbSesaxe 21547c478bd9Sstevel@tonic-gateEND_DATE=`date` 21557c478bd9Sstevel@tonic-gateecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 21567c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 21577c478bd9Sstevel@tonic-gate 2158c341b28aSDarren Moffattypeset -i10 hours 21597c478bd9Sstevel@tonic-gatetypeset -Z2 minutes 21607c478bd9Sstevel@tonic-gatetypeset -Z2 seconds 21617c478bd9Sstevel@tonic-gate 21627c478bd9Sstevel@tonic-gateelapsed_time=$SECONDS 21637c478bd9Sstevel@tonic-gate((hours = elapsed_time / 3600 )) 21647c478bd9Sstevel@tonic-gate((minutes = elapsed_time / 60 % 60)) 21657c478bd9Sstevel@tonic-gate((seconds = elapsed_time % 60)) 21667c478bd9Sstevel@tonic-gate 21677c478bd9Sstevel@tonic-gateecho "\n==== Total build time ====" | \ 21687c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 21697c478bd9Sstevel@tonic-gateecho "\nreal ${hours}:${minutes}:${seconds}" | \ 21707c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 21717c478bd9Sstevel@tonic-gate 21727c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 21737c478bd9Sstevel@tonic-gate staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 21747c478bd9Sstevel@tonic-gate 21757c478bd9Sstevel@tonic-gate # 21767c478bd9Sstevel@tonic-gate # Produce a master list of unreferenced files -- ideally, we'd 21777c478bd9Sstevel@tonic-gate # generate the master just once after all of the nightlies 21787c478bd9Sstevel@tonic-gate # have finished, but there's no simple way to know when that 21797c478bd9Sstevel@tonic-gate # will be. Instead, we assume that we're the last nightly to 21807c478bd9Sstevel@tonic-gate # finish and merge all of the unref-${MACH}.out files in 21817c478bd9Sstevel@tonic-gate # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 21827c478bd9Sstevel@tonic-gate # finish, then this file will be the authoritative master 21837c478bd9Sstevel@tonic-gate # list. Otherwise, another ${MACH}'s nightly will eventually 21847c478bd9Sstevel@tonic-gate # overwrite ours with its own master, but in the meantime our 21857c478bd9Sstevel@tonic-gate # temporary "master" will be no worse than any older master 21867c478bd9Sstevel@tonic-gate # which was already on the parent. 21877c478bd9Sstevel@tonic-gate # 21887c478bd9Sstevel@tonic-gate 21897c478bd9Sstevel@tonic-gate set -- $PARENT_WS/usr/src/unref-*.out 21907c478bd9Sstevel@tonic-gate cp "$1" ${TMPDIR}/unref.merge 21917c478bd9Sstevel@tonic-gate shift 21927c478bd9Sstevel@tonic-gate 21937c478bd9Sstevel@tonic-gate for unreffile; do 21947c478bd9Sstevel@tonic-gate comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 21957c478bd9Sstevel@tonic-gate mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 21967c478bd9Sstevel@tonic-gate done 21977c478bd9Sstevel@tonic-gate 21987c478bd9Sstevel@tonic-gate staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 21997c478bd9Sstevel@tonic-gatefi 22007c478bd9Sstevel@tonic-gate 22017c478bd9Sstevel@tonic-gate# 22027c478bd9Sstevel@tonic-gate# All done save for the sweeping up. 22037c478bd9Sstevel@tonic-gate# (whichever exit we hit here will trigger the "cleanup" trap which 22047c478bd9Sstevel@tonic-gate# optionally sends mail on completion). 22057c478bd9Sstevel@tonic-gate# 2206cb4d1691SRichard Loweif [[ "$build_ok" == "y" ]]; then 2207cb4d1691SRichard Lowe if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then 22087c478bd9Sstevel@tonic-gate exit 0 22097c478bd9Sstevel@tonic-gate fi 2210cb4d1691SRichard Lowefi 2211cb4d1691SRichard Lowe 22127c478bd9Sstevel@tonic-gateexit 1 2213