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# 497c478bd9Sstevel@tonic-gate# OPTHOME and TEAMWARE may be set in the environment to override /opt 507c478bd9Sstevel@tonic-gate# and /opt/teamware defaults. 517c478bd9Sstevel@tonic-gate# 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate# 547c478bd9Sstevel@tonic-gate# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 557c478bd9Sstevel@tonic-gate# under certain circumstances, which can really screw things up; unset it. 567c478bd9Sstevel@tonic-gate# 577c478bd9Sstevel@tonic-gateunset CDPATH 587c478bd9Sstevel@tonic-gate 59cdf0c1d5Smjnelson# Get the absolute path of the nightly script that the user invoked. This 60cdf0c1d5Smjnelson# may be a relative path, and we need to do this before changing directory. 61cdf0c1d5Smjnelsonnightly_path=`whence $0` 62cdf0c1d5Smjnelson 63cdf0c1d5Smjnelson# 64cdf0c1d5Smjnelson# Keep track of where we found nightly so we can invoke the matching 65cdf0c1d5Smjnelson# which_scm script. If that doesn't work, don't go guessing, just rely 66cdf0c1d5Smjnelson# on the $PATH settings, which will generally give us either /opt/onbld 67cdf0c1d5Smjnelson# or the user's workspace. 68cdf0c1d5Smjnelson# 69cdf0c1d5SmjnelsonWHICH_SCM=$(dirname $nightly_path)/which_scm 70cdf0c1d5Smjnelsonif [[ ! -x $WHICH_SCM ]]; then 71cdf0c1d5Smjnelson WHICH_SCM=which_scm 72cdf0c1d5Smjnelsonfi 73cdf0c1d5Smjnelson 74d7693b08SRoland Mainzfunction fatal_error 75d7693b08SRoland Mainz{ 76d7693b08SRoland Mainz print -u2 "nightly: $*" 77d7693b08SRoland Mainz exit 1 78d7693b08SRoland Mainz} 79d7693b08SRoland Mainz 804e5b757fSkupfer# 814e5b757fSkupfer# Function to do a DEBUG and non-DEBUG build. Needed because we might 827c478bd9Sstevel@tonic-gate# need to do another for the source build, and since we only deliver DEBUG or 837c478bd9Sstevel@tonic-gate# non-DEBUG packages. 844e5b757fSkupfer# 85b83ec4edSjmcp# usage: normal_build 86ead1f93eSLiane Praza# 87597bd30bSMike Kupferfunction normal_build { 887c478bd9Sstevel@tonic-gate 8952a52aebSkupfer typeset orig_p_FLAG="$p_FLAG" 90597bd30bSMike Kupfer typeset crypto_signer="$CODESIGN_USER" 914e5b757fSkupfer 924e5b757fSkupfer suffix="" 93ead1f93eSLiane Praza 947c478bd9Sstevel@tonic-gate # non-DEBUG build begins 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate if [ "$F_FLAG" = "n" ]; then 974e5b757fSkupfer set_non_debug_build_flags 98597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 996ea3c060SGarrett D'Amore build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" 1004e5b757fSkupfer if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \ 1014e5b757fSkupfer "$p_FLAG" = "y" ]; then 1027c478bd9Sstevel@tonic-gate copy_ihv_pkgs non-DEBUG -nd 1037c478bd9Sstevel@tonic-gate fi 1047c478bd9Sstevel@tonic-gate else 10552a52aebSkupfer echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 1067c478bd9Sstevel@tonic-gate fi 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate # non-DEBUG build ends 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate # DEBUG build begins 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate if [ "$D_FLAG" = "y" ]; then 1134e5b757fSkupfer set_debug_build_flags 114597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 1156ea3c060SGarrett D'Amore build "DEBUG" "$suffix" "" "$MULTI_PROTO" 1164e5b757fSkupfer if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \ 1174e5b757fSkupfer "$p_FLAG" = "y" ]; then 1187c478bd9Sstevel@tonic-gate copy_ihv_pkgs DEBUG "" 1197c478bd9Sstevel@tonic-gate fi 1207c478bd9Sstevel@tonic-gate else 12152a52aebSkupfer echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 1227c478bd9Sstevel@tonic-gate fi 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate # DEBUG build ends 1254e5b757fSkupfer 12652a52aebSkupfer p_FLAG="$orig_p_FLAG" 1277c478bd9Sstevel@tonic-gate} 1287c478bd9Sstevel@tonic-gate 1291fe69678Skupfer# 13047703246Ssommerfe# usage: run_hook HOOKNAME ARGS... 13147703246Ssommerfe# 13247703246Ssommerfe# If variable "$HOOKNAME" is defined, insert a section header into 13347703246Ssommerfe# our logs and then run the command with ARGS 13447703246Ssommerfe# 135597bd30bSMike Kupferfunction run_hook { 13647703246Ssommerfe HOOKNAME=$1 13747703246Ssommerfe eval HOOKCMD=\$$HOOKNAME 13847703246Ssommerfe shift 13947703246Ssommerfe 14047703246Ssommerfe if [ -n "$HOOKCMD" ]; then 14147703246Ssommerfe ( 14247703246Ssommerfe echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 14347703246Ssommerfe ( $HOOKCMD "$@" 2>&1 ) 14447703246Ssommerfe if [ "$?" -ne 0 ]; then 14547703246Ssommerfe # Let exit status propagate up 14647703246Ssommerfe touch $TMPDIR/abort 14747703246Ssommerfe fi 14847703246Ssommerfe ) | tee -a $mail_msg_file >> $LOGFILE 14947703246Ssommerfe 15047703246Ssommerfe if [ -f $TMPDIR/abort ]; then 15147703246Ssommerfe build_ok=n 15247703246Ssommerfe echo "\nAborting at request of $HOOKNAME" | 15347703246Ssommerfe tee -a $mail_msg_file >> $LOGFILE 15447703246Ssommerfe exit 1 15547703246Ssommerfe fi 15647703246Ssommerfe fi 15747703246Ssommerfe} 15847703246Ssommerfe 15947703246Ssommerfe# 1601fe69678Skupfer# usage: filelist DESTDIR PATTERN 1611fe69678Skupfer# 162597bd30bSMike Kupferfunction filelist { 1637c478bd9Sstevel@tonic-gate DEST=$1 1647c478bd9Sstevel@tonic-gate PATTERN=$2 1657c478bd9Sstevel@tonic-gate cd ${DEST} 1667c478bd9Sstevel@tonic-gate} 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate# function to save off binaries after a full build for later 1697c478bd9Sstevel@tonic-gate# restoration 170597bd30bSMike Kupferfunction save_binaries { 1717c478bd9Sstevel@tonic-gate # save off list of binaries 1727c478bd9Sstevel@tonic-gate echo "\n==== Saving binaries from build at `date` ====\n" | \ 1737c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 1747c478bd9Sstevel@tonic-gate rm -f ${BINARCHIVE} 1757c478bd9Sstevel@tonic-gate cd ${CODEMGR_WS} 1767c478bd9Sstevel@tonic-gate filelist ${CODEMGR_WS} '^preserve:' >> $LOGFILE 1777c478bd9Sstevel@tonic-gate filelist ${CODEMGR_WS} '^preserve:' | \ 1787c478bd9Sstevel@tonic-gate cpio -ocB 2>/dev/null | compress \ 1797c478bd9Sstevel@tonic-gate > ${BINARCHIVE} 1807c478bd9Sstevel@tonic-gate} 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate# delete files 1831fe69678Skupfer# usage: hybridize_files DESTDIR MAKE_TARGET 184597bd30bSMike Kupferfunction hybridize_files { 1857c478bd9Sstevel@tonic-gate DEST=$1 1867c478bd9Sstevel@tonic-gate MAKETARG=$2 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate echo "\n==== Hybridizing files at `date` ====\n" | \ 1897c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 1907c478bd9Sstevel@tonic-gate for i in `filelist ${DEST} '^delete:'` 1917c478bd9Sstevel@tonic-gate do 1927c478bd9Sstevel@tonic-gate echo "removing ${i}." | tee -a $mail_msg_file >> $LOGFILE 1937c478bd9Sstevel@tonic-gate rm -rf "${i}" 1947c478bd9Sstevel@tonic-gate done 1957c478bd9Sstevel@tonic-gate for i in `filelist ${DEST} '^hybridize:' ` 1967c478bd9Sstevel@tonic-gate do 1977c478bd9Sstevel@tonic-gate echo "hybridizing ${i}." | tee -a $mail_msg_file >> $LOGFILE 1987c478bd9Sstevel@tonic-gate rm -f ${i}+ 1997c478bd9Sstevel@tonic-gate sed -e "/^# HYBRID DELETE START/,/^# HYBRID DELETE END/d" \ 2007c478bd9Sstevel@tonic-gate < ${i} > ${i}+ 2017c478bd9Sstevel@tonic-gate mv ${i}+ ${i} 2027c478bd9Sstevel@tonic-gate done 2037c478bd9Sstevel@tonic-gate} 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate# restore binaries into the proper source tree. 2061fe69678Skupfer# usage: restore_binaries DESTDIR MAKE_TARGET 207597bd30bSMike Kupferfunction restore_binaries { 2087c478bd9Sstevel@tonic-gate DEST=$1 2097c478bd9Sstevel@tonic-gate MAKETARG=$2 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate echo "\n==== Restoring binaries to ${MAKETARG} at `date` ====\n" | \ 2127c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 2137c478bd9Sstevel@tonic-gate cd ${DEST} 2147c478bd9Sstevel@tonic-gate zcat ${BINARCHIVE} | \ 2157c478bd9Sstevel@tonic-gate cpio -idmucvB 2>/dev/null | tee -a $mail_msg_file >> ${LOGFILE} 2167c478bd9Sstevel@tonic-gate} 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate# rename files we save binaries of 2191fe69678Skupfer# usage: rename_files DESTDIR MAKE_TARGET 220597bd30bSMike Kupferfunction rename_files { 2217c478bd9Sstevel@tonic-gate DEST=$1 2227c478bd9Sstevel@tonic-gate MAKETARG=$2 2237c478bd9Sstevel@tonic-gate echo "\n==== Renaming source files in ${MAKETARG} at `date` ====\n" | \ 2247c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 2257c478bd9Sstevel@tonic-gate for i in `filelist ${DEST} '^rename:'` 2267c478bd9Sstevel@tonic-gate do 2277c478bd9Sstevel@tonic-gate echo ${i} | tee -a $mail_msg_file >> ${LOGFILE} 2287c478bd9Sstevel@tonic-gate rm -f ${i}.export 2297c478bd9Sstevel@tonic-gate mv ${i} ${i}.export 2307c478bd9Sstevel@tonic-gate done 2317c478bd9Sstevel@tonic-gate} 2327c478bd9Sstevel@tonic-gate 2334e5b757fSkupfer# Return library search directive as function of given root. 234597bd30bSMike Kupferfunction myldlibs { 2354e5b757fSkupfer echo "-L$1/lib -L$1/usr/lib" 2364e5b757fSkupfer} 2377c478bd9Sstevel@tonic-gate 2384e5b757fSkupfer# Return header search directive as function of given root. 239597bd30bSMike Kupferfunction myheaders { 2404e5b757fSkupfer echo "-I$1/usr/include" 2414e5b757fSkupfer} 2424e5b757fSkupfer 2434e5b757fSkupfer# 24478add226Sjmcp# Function to do the build, including package generation. 2456ea3c060SGarrett D'Amore# usage: build LABEL SUFFIX ND MULTIPROTO 2464e5b757fSkupfer# - LABEL is used to tag build output. 247ead1f93eSLiane Praza# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 248597bd30bSMike Kupfer# open-only vs full tree). 249ead1f93eSLiane Praza# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 2504e5b757fSkupfer# - If MULTIPROTO is "yes", it means to name the proto area according to 2514e5b757fSkupfer# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 2524e5b757fSkupfer# 253597bd30bSMike Kupferfunction build { 2547c478bd9Sstevel@tonic-gate LABEL=$1 2557c478bd9Sstevel@tonic-gate SUFFIX=$2 256597bd30bSMike Kupfer ND=$3 257597bd30bSMike Kupfer MULTIPROTO=$4 2587c478bd9Sstevel@tonic-gate INSTALLOG=install${SUFFIX}-${MACH} 2597c478bd9Sstevel@tonic-gate NOISE=noise${SUFFIX}-${MACH} 2607c478bd9Sstevel@tonic-gate PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 2617c478bd9Sstevel@tonic-gate 2624e5b757fSkupfer ORIGROOT=$ROOT 2634e5b757fSkupfer [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 2644e5b757fSkupfer 2654e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 2664e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 2674e5b757fSkupfer 2687c478bd9Sstevel@tonic-gate this_build_ok=y 2697c478bd9Sstevel@tonic-gate # 2707c478bd9Sstevel@tonic-gate # Build OS-Networking source 2717c478bd9Sstevel@tonic-gate # 2727c478bd9Sstevel@tonic-gate echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 2737c478bd9Sstevel@tonic-gate >> $LOGFILE 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate rm -f $SRC/${INSTALLOG}.out 2767c478bd9Sstevel@tonic-gate cd $SRC 2777c478bd9Sstevel@tonic-gate /bin/time $MAKE -e install 2>&1 | \ 2787c478bd9Sstevel@tonic-gate tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 27932f1e47bSsommerfe 280cdf0c1d5Smjnelson if [[ "$SCM_TYPE" = teamware ]]; then 28132f1e47bSsommerfe echo "\n==== SCCS Noise ($LABEL) ====\n" >> $mail_msg_file 282cdf0c1d5Smjnelson egrep 'sccs(check:| *get)' $SRC/${INSTALLOG}.out >> \ 283cdf0c1d5Smjnelson $mail_msg_file 284cdf0c1d5Smjnelson fi 28532f1e47bSsommerfe 2867c478bd9Sstevel@tonic-gate echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 2877c478bd9Sstevel@tonic-gate egrep ":" $SRC/${INSTALLOG}.out | 2887c478bd9Sstevel@tonic-gate egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 2897c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 2907c478bd9Sstevel@tonic-gate egrep -v "cc .* -o error " | \ 2917c478bd9Sstevel@tonic-gate egrep -v "warning" >> $mail_msg_file 2927c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 2937c478bd9Sstevel@tonic-gate build_ok=n 2947c478bd9Sstevel@tonic-gate this_build_ok=n 2957c478bd9Sstevel@tonic-gate fi 2967c478bd9Sstevel@tonic-gate grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 2977c478bd9Sstevel@tonic-gate >> $mail_msg_file 2987c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 2997c478bd9Sstevel@tonic-gate build_ok=n 3007c478bd9Sstevel@tonic-gate this_build_ok=n 3017c478bd9Sstevel@tonic-gate fi 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate if [ "$W_FLAG" = "n" ]; then 3047c478bd9Sstevel@tonic-gate echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 3057c478bd9Sstevel@tonic-gate egrep -i warning: $SRC/${INSTALLOG}.out \ 3067c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 30720272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 3087c478bd9Sstevel@tonic-gate | egrep -v "parameter <PSTAMP> set to" \ 3097c478bd9Sstevel@tonic-gate | egrep -v "Ignoring unknown host" \ 3107c478bd9Sstevel@tonic-gate | egrep -v "redefining segment flags attribute for" \ 3117c478bd9Sstevel@tonic-gate >> $mail_msg_file 3127c478bd9Sstevel@tonic-gate fi 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 3157c478bd9Sstevel@tonic-gate >> $LOGFILE 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 3187c478bd9Sstevel@tonic-gate tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "n" -a "$W_FLAG" = "n" ]; then 3217c478bd9Sstevel@tonic-gate rm -f $SRC/${NOISE}.ref 3227c478bd9Sstevel@tonic-gate if [ -f $SRC/${NOISE}.out ]; then 3237c478bd9Sstevel@tonic-gate mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 3247c478bd9Sstevel@tonic-gate fi 3257c478bd9Sstevel@tonic-gate grep : $SRC/${INSTALLOG}.out \ 3267c478bd9Sstevel@tonic-gate | egrep -v '^/' \ 3277c478bd9Sstevel@tonic-gate | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 3287c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 3297c478bd9Sstevel@tonic-gate | egrep -v '^mcs' \ 3307c478bd9Sstevel@tonic-gate | egrep -v '^LD_LIBRARY_PATH=' \ 3317c478bd9Sstevel@tonic-gate | egrep -v 'ar: creating' \ 3327c478bd9Sstevel@tonic-gate | egrep -v 'ar: writing' \ 3337c478bd9Sstevel@tonic-gate | egrep -v 'conflicts:' \ 3347c478bd9Sstevel@tonic-gate | egrep -v ':saved created' \ 3357c478bd9Sstevel@tonic-gate | egrep -v '^stty.*c:' \ 3367c478bd9Sstevel@tonic-gate | egrep -v '^mfgname.c:' \ 3377c478bd9Sstevel@tonic-gate | egrep -v '^uname-i.c:' \ 3387c478bd9Sstevel@tonic-gate | egrep -v '^volumes.c:' \ 3397c478bd9Sstevel@tonic-gate | egrep -v '^lint library construction:' \ 3407c478bd9Sstevel@tonic-gate | egrep -v 'tsort: INFORM:' \ 3417c478bd9Sstevel@tonic-gate | egrep -v 'stripalign:' \ 3427c478bd9Sstevel@tonic-gate | egrep -v 'chars, width' \ 34320272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 3447c478bd9Sstevel@tonic-gate | egrep -v 'PSTAMP' \ 3457c478bd9Sstevel@tonic-gate | egrep -v '|%WHOANDWHERE%|' \ 3467c478bd9Sstevel@tonic-gate | egrep -v '^Manifying' \ 3477c478bd9Sstevel@tonic-gate | egrep -v 'Ignoring unknown host' \ 3487c478bd9Sstevel@tonic-gate | egrep -v 'Processing method:' \ 3497c478bd9Sstevel@tonic-gate | egrep -v '^Writing' \ 3507c478bd9Sstevel@tonic-gate | egrep -v 'spellin1:' \ 3517c478bd9Sstevel@tonic-gate | egrep -v '^adding:' \ 3527c478bd9Sstevel@tonic-gate | egrep -v "^echo 'msgid" \ 3537c478bd9Sstevel@tonic-gate | egrep -v '^echo ' \ 3547c478bd9Sstevel@tonic-gate | egrep -v '\.c:$' \ 3557c478bd9Sstevel@tonic-gate | egrep -v '^Adding file:' \ 3567c478bd9Sstevel@tonic-gate | egrep -v 'CLASSPATH=' \ 3577c478bd9Sstevel@tonic-gate | egrep -v '\/var\/mail\/:saved' \ 3587c478bd9Sstevel@tonic-gate | egrep -v -- '-DUTS_VERSION=' \ 3597c478bd9Sstevel@tonic-gate | egrep -v '^Running Mkbootstrap' \ 3607c478bd9Sstevel@tonic-gate | egrep -v '^Applet length read:' \ 3617c478bd9Sstevel@tonic-gate | egrep -v 'bytes written:' \ 3627c478bd9Sstevel@tonic-gate | egrep -v '^File:SolarisAuthApplet.bin' \ 3637c478bd9Sstevel@tonic-gate | egrep -v -i 'jibversion' \ 3647c478bd9Sstevel@tonic-gate | egrep -v '^Output size:' \ 3657c478bd9Sstevel@tonic-gate | egrep -v '^Solo size statistics:' \ 3667c478bd9Sstevel@tonic-gate | egrep -v '^Using ROM API Version' \ 3677c478bd9Sstevel@tonic-gate | egrep -v '^Zero Signature length:' \ 3687c478bd9Sstevel@tonic-gate | egrep -v '^Note \(probably harmless\):' \ 3697c478bd9Sstevel@tonic-gate | egrep -v '::' \ 3707c478bd9Sstevel@tonic-gate | egrep -v -- '-xcache' \ 371010b217aSwesolows | egrep -v '^\+' \ 37203eb5f54Swesolows | egrep -v '^cc1: note: -fwritable-strings' \ 373c817a439Sjohnz | egrep -v 'svccfg-native -s svc:/' \ 3747c478bd9Sstevel@tonic-gate | sort | uniq >$SRC/${NOISE}.out 3757c478bd9Sstevel@tonic-gate if [ ! -f $SRC/${NOISE}.ref ]; then 3767c478bd9Sstevel@tonic-gate cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 3777c478bd9Sstevel@tonic-gate fi 3787c478bd9Sstevel@tonic-gate echo "\n==== Build noise differences ($LABEL) ====\n" \ 3797c478bd9Sstevel@tonic-gate >>$mail_msg_file 3807c478bd9Sstevel@tonic-gate diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 3817c478bd9Sstevel@tonic-gate fi 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate # 38423259b79Srotondo # Re-sign selected binaries using signing server 38523259b79Srotondo # (gatekeeper builds only) 38623259b79Srotondo # 3872210853dSjohnz if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 38823259b79Srotondo echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 38923259b79Srotondo signing_file="${TMPDIR}/signing" 39023259b79Srotondo rm -f ${signing_file} 39123259b79Srotondo export CODESIGN_USER 39223259b79Srotondo signproto $SRC/tools/codesign/creds 2>&1 | \ 39323259b79Srotondo tee -a ${signing_file} >> $LOGFILE 39423259b79Srotondo echo "\n==== Finished signing proto area at `date` ====\n" \ 39523259b79Srotondo >> $LOGFILE 39623259b79Srotondo echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 39723259b79Srotondo >> $mail_msg_file 39823259b79Srotondo egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 399cdf0c1d5Smjnelson if (( $? == 0 )) ; then 4002210853dSjohnz build_ok=n 4012210853dSjohnz this_build_ok=n 4022210853dSjohnz fi 40323259b79Srotondo fi 40423259b79Srotondo 40523259b79Srotondo # 4067c478bd9Sstevel@tonic-gate # Building Packages 4077c478bd9Sstevel@tonic-gate # 4087c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 409ead1f93eSLiane Praza if [ -d $SRC/pkg -o -d $SRC/pkgdefs ]; then 4107c478bd9Sstevel@tonic-gate echo "\n==== Creating $LABEL packages at `date` ====\n" \ 4117c478bd9Sstevel@tonic-gate >> $LOGFILE 412ead1f93eSLiane Praza echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 4136798c3f0SMark J. Nelson rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 4146798c3f0SMark J. Nelson mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 415d8fd4470Sjg 416ead1f93eSLiane Praza for d in pkg pkgdefs; do 4176798c3f0SMark J. Nelson if [ ! -f "$SRC/$d/Makefile" ]; then 418ead1f93eSLiane Praza continue 419ead1f93eSLiane Praza fi 420ead1f93eSLiane Praza rm -f $SRC/$d/${INSTALLOG}.out 421ead1f93eSLiane Praza cd $SRC/$d 422ead1f93eSLiane Praza /bin/time $MAKE -e install 2>&1 | \ 423ead1f93eSLiane Praza tee -a $SRC/$d/${INSTALLOG}.out >> $LOGFILE 424ead1f93eSLiane Praza done 425ead1f93eSLiane Praza 426ead1f93eSLiane Praza echo "\n==== package build errors ($LABEL) ====\n" \ 427ead1f93eSLiane Praza >> $mail_msg_file 428ead1f93eSLiane Praza 429ead1f93eSLiane Praza for d in pkg pkgdefs; do 4306798c3f0SMark J. Nelson if [ ! -f "$SRC/$d/Makefile" ]; then 431ead1f93eSLiane Praza continue 432d8fd4470Sjg fi 433d8fd4470Sjg 434ead1f93eSLiane Praza egrep "${MAKE}|ERROR|WARNING" $SRC/$d/${INSTALLOG}.out | \ 4357c478bd9Sstevel@tonic-gate grep ':' | \ 4367c478bd9Sstevel@tonic-gate grep -v PSTAMP | \ 4377c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" \ 4387c478bd9Sstevel@tonic-gate >> $mail_msg_file 439ead1f93eSLiane Praza done 440ead1f93eSLiane Praza else 441ead1f93eSLiane Praza # 442ead1f93eSLiane Praza # Handle it gracefully if -p was set but there are 443ead1f93eSLiane Praza # neither pkg nor pkgdefs directories. 444ead1f93eSLiane Praza # 445ead1f93eSLiane Praza echo "\n==== No $LABEL packages to build ====\n" \ 446ead1f93eSLiane Praza >> $LOGFILE 447ead1f93eSLiane Praza fi 4487c478bd9Sstevel@tonic-gate else 4497c478bd9Sstevel@tonic-gate echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 4507c478bd9Sstevel@tonic-gate fi 4514e5b757fSkupfer 4524e5b757fSkupfer ROOT=$ORIGROOT 4537c478bd9Sstevel@tonic-gate} 4547c478bd9Sstevel@tonic-gate 4551fe69678Skupfer# Usage: dolint /dir y|n 4567c478bd9Sstevel@tonic-gate# Arg. 2 is a flag to turn on/off the lint diff output 457597bd30bSMike Kupferfunction dolint { 4587c478bd9Sstevel@tonic-gate if [ ! -d "$1" ]; then 4591fe69678Skupfer echo "dolint error: $1 is not a directory" 4607c478bd9Sstevel@tonic-gate exit 1 4617c478bd9Sstevel@tonic-gate fi 4627c478bd9Sstevel@tonic-gate 4637c478bd9Sstevel@tonic-gate if [ "$2" != "y" -a "$2" != "n" ]; then 4641fe69678Skupfer echo "dolint internal error: $2 should be 'y' or 'n'" 4657c478bd9Sstevel@tonic-gate exit 1 4667c478bd9Sstevel@tonic-gate fi 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate lintdir=$1 4697c478bd9Sstevel@tonic-gate dodiff=$2 4707c478bd9Sstevel@tonic-gate base=`basename $lintdir` 4717c478bd9Sstevel@tonic-gate LINTOUT=$lintdir/lint-${MACH}.out 4727c478bd9Sstevel@tonic-gate LINTNOISE=$lintdir/lint-noise-${MACH} 4734e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 4744e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 4757c478bd9Sstevel@tonic-gate 4764e5b757fSkupfer set_debug_build_flags 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate # 4797c478bd9Sstevel@tonic-gate # '$MAKE lint' in $lintdir 4807c478bd9Sstevel@tonic-gate # 4817c478bd9Sstevel@tonic-gate echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 4827c478bd9Sstevel@tonic-gate 4837c478bd9Sstevel@tonic-gate # remove old lint.out 4847c478bd9Sstevel@tonic-gate rm -f $lintdir/lint.out $lintdir/lint-noise.out 4857c478bd9Sstevel@tonic-gate if [ -f $lintdir/lint-noise.ref ]; then 4867c478bd9Sstevel@tonic-gate mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 4877c478bd9Sstevel@tonic-gate fi 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate rm -f $LINTOUT 4907c478bd9Sstevel@tonic-gate cd $lintdir 4917c478bd9Sstevel@tonic-gate # 4927c478bd9Sstevel@tonic-gate # Remove all .ln files to ensure a full reference file 4937c478bd9Sstevel@tonic-gate # 4947c478bd9Sstevel@tonic-gate rm -f Nothing_to_remove \ 4958bcea973SRichard Lowe `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \ 496cdf0c1d5Smjnelson -prune -o -type f -name '*.ln' -print ` 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate /bin/time $MAKE -ek lint 2>&1 | \ 4997c478bd9Sstevel@tonic-gate tee -a $LINTOUT >> $LOGFILE 5007c478bd9Sstevel@tonic-gate echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 5017c478bd9Sstevel@tonic-gate grep "$MAKE:" $LINTOUT | 5027c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" \ 5037c478bd9Sstevel@tonic-gate >> $mail_msg_file 5047c478bd9Sstevel@tonic-gate 5057c478bd9Sstevel@tonic-gate echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 5087c478bd9Sstevel@tonic-gate >>$mail_msg_file 5097c478bd9Sstevel@tonic-gate tail -3 $LINTOUT >>$mail_msg_file 5107c478bd9Sstevel@tonic-gate 5117c478bd9Sstevel@tonic-gate rm -f ${LINTNOISE}.ref 5127c478bd9Sstevel@tonic-gate if [ -f ${LINTNOISE}.out ]; then 5137c478bd9Sstevel@tonic-gate mv ${LINTNOISE}.out ${LINTNOISE}.ref 5147c478bd9Sstevel@tonic-gate fi 5157c478bd9Sstevel@tonic-gate grep : $LINTOUT | \ 5167c478bd9Sstevel@tonic-gate egrep -v '^(real|user|sys)' | 5177c478bd9Sstevel@tonic-gate egrep -v '(library construction)' | \ 5187c478bd9Sstevel@tonic-gate egrep -v ': global crosschecks' | \ 5197c478bd9Sstevel@tonic-gate egrep -v 'Ignoring unknown host' | \ 5207c478bd9Sstevel@tonic-gate egrep -v '\.c:$' | \ 5217c478bd9Sstevel@tonic-gate sort | uniq > ${LINTNOISE}.out 5227c478bd9Sstevel@tonic-gate if [ ! -f ${LINTNOISE}.ref ]; then 5237c478bd9Sstevel@tonic-gate cp ${LINTNOISE}.out ${LINTNOISE}.ref 5247c478bd9Sstevel@tonic-gate fi 5257c478bd9Sstevel@tonic-gate if [ "$dodiff" != "n" ]; then 5267c478bd9Sstevel@tonic-gate echo "\n==== lint warnings $base ====\n" \ 5277c478bd9Sstevel@tonic-gate >>$mail_msg_file 5287c478bd9Sstevel@tonic-gate # should be none, though there are a few that were filtered out 5297c478bd9Sstevel@tonic-gate # above 5307c478bd9Sstevel@tonic-gate egrep -i '(warning|lint):' ${LINTNOISE}.out \ 5317c478bd9Sstevel@tonic-gate | sort | uniq >> $mail_msg_file 5327c478bd9Sstevel@tonic-gate echo "\n==== lint noise differences $base ====\n" \ 5337c478bd9Sstevel@tonic-gate >> $mail_msg_file 5347c478bd9Sstevel@tonic-gate diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 5357c478bd9Sstevel@tonic-gate >> $mail_msg_file 5367c478bd9Sstevel@tonic-gate fi 5377c478bd9Sstevel@tonic-gate} 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate# Install proto area from IHV build 5407c478bd9Sstevel@tonic-gate 541597bd30bSMike Kupferfunction copy_ihv_proto { 5427c478bd9Sstevel@tonic-gate 5436fec3625Sdduvall echo "\n==== Installing IHV proto area ====\n" \ 5447c478bd9Sstevel@tonic-gate >> $LOGFILE 5457c478bd9Sstevel@tonic-gate if [ -d "$IA32_IHV_ROOT" ]; then 5467c478bd9Sstevel@tonic-gate if [ ! -d "$ROOT" ]; then 5477c478bd9Sstevel@tonic-gate echo "mkdir -p $ROOT" >> $LOGFILE 5487c478bd9Sstevel@tonic-gate mkdir -p $ROOT 5497c478bd9Sstevel@tonic-gate fi 5506fec3625Sdduvall echo "copying $IA32_IHV_ROOT to $ROOT\n" >> $LOGFILE 5517c478bd9Sstevel@tonic-gate cd $IA32_IHV_ROOT 552b83ec4edSjmcp tar cf - . | (cd $ROOT; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 5537c478bd9Sstevel@tonic-gate else 5547c478bd9Sstevel@tonic-gate echo "$IA32_IHV_ROOT: not found" >> $LOGFILE 5557c478bd9Sstevel@tonic-gate fi 5564e5b757fSkupfer 5574e5b757fSkupfer if [ "$MULTI_PROTO" = yes ]; then 5584e5b757fSkupfer if [ ! -d "$ROOT-nd" ]; then 5594e5b757fSkupfer echo "mkdir -p $ROOT-nd" >> $LOGFILE 5604e5b757fSkupfer mkdir -p $ROOT-nd 5614e5b757fSkupfer fi 562ead1f93eSLiane Praza # If there's a non-DEBUG version of the IHV proto area, 5634e5b757fSkupfer # copy it, but copy something if there's not. 5644e5b757fSkupfer if [ -d "$IA32_IHV_ROOT-nd" ]; then 5654e5b757fSkupfer echo "copying $IA32_IHV_ROOT-nd to $ROOT-nd\n" >> $LOGFILE 5664e5b757fSkupfer cd $IA32_IHV_ROOT-nd 5674e5b757fSkupfer elif [ -d "$IA32_IHV_ROOT" ]; then 5684e5b757fSkupfer echo "copying $IA32_IHV_ROOT to $ROOT-nd\n" >> $LOGFILE 5694e5b757fSkupfer cd $IA32_IHV_ROOT 5704e5b757fSkupfer else 5714e5b757fSkupfer echo "$IA32_IHV_ROOT{-nd,}: not found" >> $LOGFILE 5724e5b757fSkupfer return 5734e5b757fSkupfer fi 574b83ec4edSjmcp tar cf - . | (cd $ROOT-nd; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 5754e5b757fSkupfer fi 5767c478bd9Sstevel@tonic-gate} 5777c478bd9Sstevel@tonic-gate 5787c478bd9Sstevel@tonic-gate# Install IHV packages in PKGARCHIVE 5791fe69678Skupfer# usage: copy_ihv_pkgs LABEL SUFFIX 580597bd30bSMike Kupferfunction copy_ihv_pkgs { 5817c478bd9Sstevel@tonic-gate LABEL=$1 5827c478bd9Sstevel@tonic-gate SUFFIX=$2 5837c478bd9Sstevel@tonic-gate # always use non-DEBUG IHV packages 5847c478bd9Sstevel@tonic-gate IA32_IHV_PKGS=${IA32_IHV_PKGS_ORIG}-nd 5857c478bd9Sstevel@tonic-gate PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate echo "\n==== Installing IHV packages from $IA32_IHV_PKGS ($LABEL) ====\n" \ 5887c478bd9Sstevel@tonic-gate >> $LOGFILE 5897c478bd9Sstevel@tonic-gate if [ -d "$IA32_IHV_PKGS" ]; then 5907c478bd9Sstevel@tonic-gate cd $IA32_IHV_PKGS 591b83ec4edSjmcp tar cf - * | \ 5927c478bd9Sstevel@tonic-gate (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 5937c478bd9Sstevel@tonic-gate else 5947c478bd9Sstevel@tonic-gate echo "$IA32_IHV_PKGS: not found" >> $LOGFILE 5957c478bd9Sstevel@tonic-gate fi 5967c478bd9Sstevel@tonic-gate 5977c478bd9Sstevel@tonic-gate echo "\n==== Installing IHV packages from $IA32_IHV_BINARY_PKGS ($LABEL) ====\n" \ 5987c478bd9Sstevel@tonic-gate >> $LOGFILE 5997c478bd9Sstevel@tonic-gate if [ -d "$IA32_IHV_BINARY_PKGS" ]; then 6007c478bd9Sstevel@tonic-gate cd $IA32_IHV_BINARY_PKGS 601b83ec4edSjmcp tar cf - * | \ 6027c478bd9Sstevel@tonic-gate (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 6037c478bd9Sstevel@tonic-gate else 6047c478bd9Sstevel@tonic-gate echo "$IA32_IHV_BINARY_PKGS: not found" >> $LOGFILE 6057c478bd9Sstevel@tonic-gate fi 6067c478bd9Sstevel@tonic-gate} 6077c478bd9Sstevel@tonic-gate 6084e5b757fSkupfer# 6094e5b757fSkupfer# Build and install the onbld tools. 6104e5b757fSkupfer# 6111fe69678Skupfer# usage: build_tools DESTROOT 6124e5b757fSkupfer# 6134e5b757fSkupfer# returns non-zero status if the build was successful. 6144e5b757fSkupfer# 615597bd30bSMike Kupferfunction build_tools { 6167c478bd9Sstevel@tonic-gate DESTROOT=$1 6177c478bd9Sstevel@tonic-gate 6187c478bd9Sstevel@tonic-gate INSTALLOG=install-${MACH} 6197c478bd9Sstevel@tonic-gate 6207c478bd9Sstevel@tonic-gate echo "\n==== Building tools at `date` ====\n" \ 6217c478bd9Sstevel@tonic-gate >> $LOGFILE 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/${INSTALLOG}.out 6247c478bd9Sstevel@tonic-gate cd ${TOOLS} 625ead1f93eSLiane Praza /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 6267c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 6277c478bd9Sstevel@tonic-gate 6287c478bd9Sstevel@tonic-gate echo "\n==== Tools build errors ====\n" >> $mail_msg_file 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate egrep ":" ${TOOLS}/${INSTALLOG}.out | 6317c478bd9Sstevel@tonic-gate egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 6327c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 6337c478bd9Sstevel@tonic-gate egrep -v warning >> $mail_msg_file 6344e5b757fSkupfer return $? 6354e5b757fSkupfer} 6364e5b757fSkupfer 6374e5b757fSkupfer# 6384e5b757fSkupfer# Set up to use locally installed tools. 6394e5b757fSkupfer# 6404e5b757fSkupfer# usage: use_tools TOOLSROOT 6414e5b757fSkupfer# 642597bd30bSMike Kupferfunction use_tools { 6434e5b757fSkupfer TOOLSROOT=$1 6444e5b757fSkupfer 645c168ccb7SMark J. Nelson # 646c168ccb7SMark J. Nelson # If we're not building ON workspace, then the TOOLSROOT 647c168ccb7SMark J. Nelson # settings here are clearly ignored by the workspace 648c168ccb7SMark J. Nelson # makefiles, prepending nonexistent directories to PATH is 649c168ccb7SMark J. Nelson # harmless, and we clearly do not wish to override 650c168ccb7SMark J. Nelson # ONBLD_TOOLS. 651c168ccb7SMark J. Nelson # 652c168ccb7SMark J. Nelson # If we're building an ON workspace, then the prepended PATH 653c168ccb7SMark J. Nelson # elements should supercede the preexisting ONBLD_TOOLS paths, 654c168ccb7SMark J. Nelson # and we want to override ONBLD_TOOLS to catch the tools that 655c168ccb7SMark J. Nelson # don't have specific path env vars here. 656c168ccb7SMark J. Nelson # 657c168ccb7SMark J. Nelson # So the only conditional behavior is overriding ONBLD_TOOLS, 658c168ccb7SMark J. Nelson # and we check for "an ON workspace" by looking for 659c168ccb7SMark J. Nelson # ${TOOLSROOT}/opt/onbld. 660c168ccb7SMark J. Nelson # 661c168ccb7SMark J. Nelson 6624e5b757fSkupfer STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs 6637c478bd9Sstevel@tonic-gate export STABS 6644e5b757fSkupfer CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs 6657c478bd9Sstevel@tonic-gate export CTFSTABS 6664e5b757fSkupfer GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets 6677c478bd9Sstevel@tonic-gate export GENOFFSETS 6687c478bd9Sstevel@tonic-gate 6694e5b757fSkupfer CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert 6707c478bd9Sstevel@tonic-gate export CTFCONVERT 6714e5b757fSkupfer CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge 6727c478bd9Sstevel@tonic-gate export CTFMERGE 6737c478bd9Sstevel@tonic-gate 6744e5b757fSkupfer CTFCVTPTBL=${TOOLSROOT}/opt/onbld/bin/ctfcvtptbl 6757c478bd9Sstevel@tonic-gate export CTFCVTPTBL 6764e5b757fSkupfer CTFFINDMOD=${TOOLSROOT}/opt/onbld/bin/ctffindmod 6777c478bd9Sstevel@tonic-gate export CTFFINDMOD 6787c478bd9Sstevel@tonic-gate 6797c478bd9Sstevel@tonic-gate if [ "$VERIFY_ELFSIGN" = "y" ]; then 6804e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 6817c478bd9Sstevel@tonic-gate else 6824e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 6837c478bd9Sstevel@tonic-gate fi 6847c478bd9Sstevel@tonic-gate export ELFSIGN 6857c478bd9Sstevel@tonic-gate 686c168ccb7SMark J. Nelson PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 6874e5b757fSkupfer PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 6887c478bd9Sstevel@tonic-gate export PATH 6897c478bd9Sstevel@tonic-gate 690c168ccb7SMark J. Nelson if [ -d "${TOOLSROOT}/opt/onbld" ]; then 691b06f2c55SMark J. Nelson ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 6921d9a8b8dSDan Mick export ONBLD_TOOLS 693c168ccb7SMark J. Nelson fi 6941d9a8b8dSDan Mick 6957c478bd9Sstevel@tonic-gate echo "\n==== New environment settings. ====\n" >> $LOGFILE 6967c478bd9Sstevel@tonic-gate echo "STABS=${STABS}" >> $LOGFILE 6977c478bd9Sstevel@tonic-gate echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 6987c478bd9Sstevel@tonic-gate echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 6997c478bd9Sstevel@tonic-gate echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 7007c478bd9Sstevel@tonic-gate echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE 7017c478bd9Sstevel@tonic-gate echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE 7027c478bd9Sstevel@tonic-gate echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 7037c478bd9Sstevel@tonic-gate echo "PATH=${PATH}" >> $LOGFILE 7041d9a8b8dSDan Mick echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 7057c478bd9Sstevel@tonic-gate} 7067c478bd9Sstevel@tonic-gate 707597bd30bSMike Kupferfunction staffer { 7087c478bd9Sstevel@tonic-gate if [ $ISUSER -ne 0 ]; then 7097c478bd9Sstevel@tonic-gate "$@" 7107c478bd9Sstevel@tonic-gate else 7117c478bd9Sstevel@tonic-gate arg="\"$1\"" 7127c478bd9Sstevel@tonic-gate shift 7137c478bd9Sstevel@tonic-gate for i 7147c478bd9Sstevel@tonic-gate do 7157c478bd9Sstevel@tonic-gate arg="$arg \"$i\"" 7167c478bd9Sstevel@tonic-gate done 7177c478bd9Sstevel@tonic-gate eval su $STAFFER -c \'$arg\' 7187c478bd9Sstevel@tonic-gate fi 7197c478bd9Sstevel@tonic-gate} 7207c478bd9Sstevel@tonic-gate 721085d331dSkupfer# 722085d331dSkupfer# Verify that the closed tree is present if it needs to be. 723085d331dSkupfer# 724597bd30bSMike Kupferfunction check_closed_tree { 725c0e7977aSJosef 'Jeff' Sipek if [[ ! -d "$ON_CLOSED_BINS" ]]; then 726c0e7977aSJosef 'Jeff' Sipek echo "ON_CLOSED_BINS must point to the closed binaries tree." 727cdf0c1d5Smjnelson build_ok=n 728085d331dSkupfer exit 1 729085d331dSkupfer fi 730085d331dSkupfer} 7317c478bd9Sstevel@tonic-gate 732597bd30bSMike Kupferfunction obsolete_build { 733d77e7149Ssommerfe echo "WARNING: Obsolete $1 build requested; request will be ignored" 734d77e7149Ssommerfe} 735d77e7149Ssommerfe 7364e5b757fSkupfer# 7374e5b757fSkupfer# wrapper over wsdiff. 7384e5b757fSkupfer# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 7394e5b757fSkupfer# 740597bd30bSMike Kupferfunction do_wsdiff { 7414e5b757fSkupfer label=$1 7424e5b757fSkupfer oldproto=$2 7434e5b757fSkupfer newproto=$3 7444e5b757fSkupfer 7454e5b757fSkupfer wsdiff="wsdiff" 7464e5b757fSkupfer [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 7474e5b757fSkupfer 748598cc7dfSVladimir Kotal echo "\n==== Getting object changes since last build at `date`" \ 749598cc7dfSVladimir Kotal "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 750598cc7dfSVladimir Kotal $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 751598cc7dfSVladimir Kotal tee -a $LOGFILE >> $mail_msg_file 752598cc7dfSVladimir Kotal echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 7534e5b757fSkupfer tee -a $LOGFILE >> $mail_msg_file 7544e5b757fSkupfer} 7554e5b757fSkupfer 7564e5b757fSkupfer# 757ead1f93eSLiane Praza# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 7584e5b757fSkupfer# together. 7594e5b757fSkupfer# 7604e5b757fSkupfer 761597bd30bSMike Kupferfunction set_non_debug_build_flags { 7624e5b757fSkupfer export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 7634e5b757fSkupfer export RELEASE_BUILD ; RELEASE_BUILD= 7644e5b757fSkupfer unset EXTRA_OPTIONS 7654e5b757fSkupfer unset EXTRA_CFLAGS 7664e5b757fSkupfer} 7674e5b757fSkupfer 768597bd30bSMike Kupferfunction set_debug_build_flags { 7694e5b757fSkupfer export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 7704e5b757fSkupfer unset RELEASE_BUILD 7714e5b757fSkupfer unset EXTRA_OPTIONS 7724e5b757fSkupfer unset EXTRA_CFLAGS 7734e5b757fSkupfer} 7744e5b757fSkupfer 775d77e7149Ssommerfe 7767c478bd9Sstevel@tonic-gateMACH=`uname -p` 7777c478bd9Sstevel@tonic-gate 7787c478bd9Sstevel@tonic-gateif [ "$OPTHOME" = "" ]; then 7797c478bd9Sstevel@tonic-gate OPTHOME=/opt 7807c478bd9Sstevel@tonic-gate export OPTHOME 7817c478bd9Sstevel@tonic-gatefi 7827c478bd9Sstevel@tonic-gateif [ "$TEAMWARE" = "" ]; then 7837c478bd9Sstevel@tonic-gate TEAMWARE=$OPTHOME/teamware 7847c478bd9Sstevel@tonic-gate export TEAMWARE 7857c478bd9Sstevel@tonic-gatefi 7867c478bd9Sstevel@tonic-gate 787*5110237aSJosef 'Jeff' SipekUSAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file> 7887c478bd9Sstevel@tonic-gate 7897c478bd9Sstevel@tonic-gateWhere: 790d77e7149Ssommerfe -i Fast incremental options (no clobber, lint, check) 7917c478bd9Sstevel@tonic-gate -n Do not do a bringover 7925e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 7937c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 7947c478bd9Sstevel@tonic-gate 7957c478bd9Sstevel@tonic-gate <env_file> file in Bourne shell syntax that sets and exports 7967c478bd9Sstevel@tonic-gate variables that configure the operation of this script and many of 7977c478bd9Sstevel@tonic-gate the scripts this one calls. If <env_file> does not exist, 7987c478bd9Sstevel@tonic-gate it will be looked for in $OPTHOME/onbld/env. 7997c478bd9Sstevel@tonic-gate 8007c478bd9Sstevel@tonic-gatenon-DEBUG is the default build type. Build options can be set in the 8017c478bd9Sstevel@tonic-gateNIGHTLY_OPTIONS variable in the <env_file> as follows: 8027c478bd9Sstevel@tonic-gate 8037c478bd9Sstevel@tonic-gate -A check for ABI differences in .so files 8047c478bd9Sstevel@tonic-gate -C check for cstyle/hdrchk errors 8057c478bd9Sstevel@tonic-gate -D do a build with DEBUG on 8067c478bd9Sstevel@tonic-gate -F do _not_ do a non-DEBUG build 8073c6aa570SMark J. Nelson -G gate keeper default group of options (-au) 8087c478bd9Sstevel@tonic-gate -I integration engineer default group of options (-ampu) 8097c478bd9Sstevel@tonic-gate -M do not run pmodes (safe file permission checker) 8107c478bd9Sstevel@tonic-gate -N do not run protocmp 8117c478bd9Sstevel@tonic-gate -R default group of options for building a release (-mp) 8127c478bd9Sstevel@tonic-gate -U update proto area in the parent 8137c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 81404a42e3eSszhou -X copy x86 IHV proto area 8157c478bd9Sstevel@tonic-gate -f find unreferenced files 8167c478bd9Sstevel@tonic-gate -i do an incremental build (no "make clobber") 8177c478bd9Sstevel@tonic-gate -l do "make lint" in $LINTDIRS (default: $SRC y) 8187c478bd9Sstevel@tonic-gate -m send mail to $MAILTO at end of build 8197c478bd9Sstevel@tonic-gate -n do not do a bringover 8207c478bd9Sstevel@tonic-gate -o build using root privileges to set OWNER/GROUP (old style) 8217c478bd9Sstevel@tonic-gate -p create packages 8227c478bd9Sstevel@tonic-gate -r check ELF runtime attributes in the proto area 8235e1b109eSPeter Dennis - Sustaining Engineer -t build and use the tools in $SRC/tools (default setting) 8245e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 8257c478bd9Sstevel@tonic-gate -u update proto_list_$MACH and friends in the parent workspace; 8267c478bd9Sstevel@tonic-gate when used with -f, also build an unrefmaster.out in the parent 82796ccc8cbSesaxe -w report on differences between previous and current proto areas 8287c478bd9Sstevel@tonic-gate -z compress cpio archives with gzip 8297c478bd9Sstevel@tonic-gate -W Do not report warnings (freeware gate ONLY) 8307c478bd9Sstevel@tonic-gate' 8317c478bd9Sstevel@tonic-gate# 8327c478bd9Sstevel@tonic-gate# A log file will be generated under the name $LOGFILE 8331c79753fSdarrenm# for partially completed build and log.`date '+%F'` 8347c478bd9Sstevel@tonic-gate# in the same directory for fully completed builds. 8357c478bd9Sstevel@tonic-gate# 8367c478bd9Sstevel@tonic-gate 8377c478bd9Sstevel@tonic-gate# default values for low-level FLAGS; G I R are group FLAGS 8387c478bd9Sstevel@tonic-gateA_FLAG=n 8397c478bd9Sstevel@tonic-gateC_FLAG=n 8406c3c9007SstevelD_FLAG=n 8417c478bd9Sstevel@tonic-gateF_FLAG=n 8427c478bd9Sstevel@tonic-gatef_FLAG=n 8437c478bd9Sstevel@tonic-gatei_FLAG=n; i_CMD_LINE_FLAG=n 8447c478bd9Sstevel@tonic-gatel_FLAG=n 8456c3c9007SstevelM_FLAG=n 8467c478bd9Sstevel@tonic-gatem_FLAG=n 8476c3c9007SstevelN_FLAG=n 8486c3c9007Ssteveln_FLAG=n 8496c3c9007Sstevelo_FLAG=n 8506c3c9007SstevelP_FLAG=n 8517c478bd9Sstevel@tonic-gatep_FLAG=n 8527c478bd9Sstevel@tonic-gater_FLAG=n 8536c3c9007SstevelT_FLAG=n 854fd7cef36Ssuhat_FLAG=y 8557c478bd9Sstevel@tonic-gateU_FLAG=n 8566c3c9007Sstevelu_FLAG=n 8577c478bd9Sstevel@tonic-gateV_FLAG=n 8587c478bd9Sstevel@tonic-gateW_FLAG=n 8596c3c9007Sstevelw_FLAG=n 8606c3c9007SstevelX_FLAG=n 8617c478bd9Sstevel@tonic-gate# 8627c478bd9Sstevel@tonic-gateXMOD_OPT= 8637c478bd9Sstevel@tonic-gate# 8647c478bd9Sstevel@tonic-gatebuild_ok=y 8651fe69678Skupfer 8667c478bd9Sstevel@tonic-gate# 8677c478bd9Sstevel@tonic-gate# examine arguments 8687c478bd9Sstevel@tonic-gate# 8697c478bd9Sstevel@tonic-gate 8707c478bd9Sstevel@tonic-gateOPTIND=1 871*5110237aSJosef 'Jeff' Sipekwhile getopts +intV: FLAG 8727c478bd9Sstevel@tonic-gatedo 8737c478bd9Sstevel@tonic-gate case $FLAG in 8747c478bd9Sstevel@tonic-gate i ) i_FLAG=y; i_CMD_LINE_FLAG=y 8757c478bd9Sstevel@tonic-gate ;; 8767c478bd9Sstevel@tonic-gate n ) n_FLAG=y 8777c478bd9Sstevel@tonic-gate ;; 878fd7cef36Ssuha +t ) t_FLAG=n 8797c478bd9Sstevel@tonic-gate ;; 8806c3c9007Sstevel V ) V_FLAG=y 8816c3c9007Sstevel V_ARG="$OPTARG" 8826c3c9007Sstevel ;; 8837c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 8847c478bd9Sstevel@tonic-gate exit 1 8857c478bd9Sstevel@tonic-gate ;; 8867c478bd9Sstevel@tonic-gate esac 8877c478bd9Sstevel@tonic-gatedone 8887c478bd9Sstevel@tonic-gate 8897c478bd9Sstevel@tonic-gate# correct argument count after options 8907c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 8917c478bd9Sstevel@tonic-gate 8927c478bd9Sstevel@tonic-gate# test that the path to the environment-setting file was given 8937c478bd9Sstevel@tonic-gateif [ $# -ne 1 ]; then 8947c478bd9Sstevel@tonic-gate echo "$USAGE" 8957c478bd9Sstevel@tonic-gate exit 1 8967c478bd9Sstevel@tonic-gatefi 8977c478bd9Sstevel@tonic-gate 8987c478bd9Sstevel@tonic-gate# check if user is running nightly as root 8997c478bd9Sstevel@tonic-gate# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 9007c478bd9Sstevel@tonic-gate# when root invokes nightly. 9017c478bd9Sstevel@tonic-gate/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 9027c478bd9Sstevel@tonic-gateISUSER=$?; export ISUSER 9037c478bd9Sstevel@tonic-gate 9047c478bd9Sstevel@tonic-gate# 9057c478bd9Sstevel@tonic-gate# force locale to C 9067c478bd9Sstevel@tonic-gateLC_COLLATE=C; export LC_COLLATE 9077c478bd9Sstevel@tonic-gateLC_CTYPE=C; export LC_CTYPE 9087c478bd9Sstevel@tonic-gateLC_MESSAGES=C; export LC_MESSAGES 9097c478bd9Sstevel@tonic-gateLC_MONETARY=C; export LC_MONETARY 9107c478bd9Sstevel@tonic-gateLC_NUMERIC=C; export LC_NUMERIC 9117c478bd9Sstevel@tonic-gateLC_TIME=C; export LC_TIME 9127c478bd9Sstevel@tonic-gate 9137c478bd9Sstevel@tonic-gate# clear environment variables we know to be bad for the build 9147c478bd9Sstevel@tonic-gateunset LD_OPTIONS 9157c478bd9Sstevel@tonic-gateunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 9167c478bd9Sstevel@tonic-gateunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 9177c478bd9Sstevel@tonic-gateunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 9187c478bd9Sstevel@tonic-gateunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 9197c478bd9Sstevel@tonic-gateunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 9207c478bd9Sstevel@tonic-gateunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 9217c478bd9Sstevel@tonic-gateunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 9227c478bd9Sstevel@tonic-gateunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 9237c478bd9Sstevel@tonic-gateunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 9247c478bd9Sstevel@tonic-gateunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 9257c478bd9Sstevel@tonic-gateunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 9267c478bd9Sstevel@tonic-gateunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 9277c478bd9Sstevel@tonic-gateunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 9287c478bd9Sstevel@tonic-gateunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 9297c478bd9Sstevel@tonic-gateunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 9307c478bd9Sstevel@tonic-gateunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 9317c478bd9Sstevel@tonic-gateunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 9327c478bd9Sstevel@tonic-gateunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 9337c478bd9Sstevel@tonic-gateunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 9347c478bd9Sstevel@tonic-gateunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 9357c478bd9Sstevel@tonic-gate 9367c478bd9Sstevel@tonic-gateunset CONFIG 9377c478bd9Sstevel@tonic-gateunset GROUP 9387c478bd9Sstevel@tonic-gateunset OWNER 9397c478bd9Sstevel@tonic-gateunset REMOTE 9407c478bd9Sstevel@tonic-gateunset ENV 9417c478bd9Sstevel@tonic-gateunset ARCH 9427c478bd9Sstevel@tonic-gateunset CLASSPATH 9437c478bd9Sstevel@tonic-gateunset NAME 9447c478bd9Sstevel@tonic-gate 9457c478bd9Sstevel@tonic-gate# 946ead1f93eSLiane Praza# To get ONBLD_TOOLS from the environment, it must come from the env file. 947ead1f93eSLiane Praza# If it comes interactively, it is generally TOOLS_PROTO, which will be 948ead1f93eSLiane Praza# clobbered before the compiler version checks, which will therefore fail. 949ead1f93eSLiane Praza# 950ead1f93eSLiane Prazaunset ONBLD_TOOLS 951ead1f93eSLiane Praza 952ead1f93eSLiane Praza# 9537c478bd9Sstevel@tonic-gate# Setup environmental variables 9547c478bd9Sstevel@tonic-gate# 95547703246Ssommerfeif [ -f /etc/nightly.conf ]; then 95647703246Ssommerfe . /etc/nightly.conf 95747703246Ssommerfefi 95847703246Ssommerfe 9597c478bd9Sstevel@tonic-gateif [ -f $1 ]; then 9607c478bd9Sstevel@tonic-gate if [[ $1 = */* ]]; then 9617c478bd9Sstevel@tonic-gate . $1 9627c478bd9Sstevel@tonic-gate else 9637c478bd9Sstevel@tonic-gate . ./$1 9647c478bd9Sstevel@tonic-gate fi 9657c478bd9Sstevel@tonic-gateelse 9667c478bd9Sstevel@tonic-gate if [ -f $OPTHOME/onbld/env/$1 ]; then 9677c478bd9Sstevel@tonic-gate . $OPTHOME/onbld/env/$1 9687c478bd9Sstevel@tonic-gate else 9697c478bd9Sstevel@tonic-gate echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 9707c478bd9Sstevel@tonic-gate exit 1 9717c478bd9Sstevel@tonic-gate fi 9727c478bd9Sstevel@tonic-gatefi 9737c478bd9Sstevel@tonic-gate 9741fe69678Skupfer# contents of stdenv.sh inserted after next line: 9751fe69678Skupfer# STDENV_START 9761fe69678Skupfer# STDENV_END 9771fe69678Skupfer 978d7693b08SRoland Mainz# Check if we have sufficient data to continue... 979d7693b08SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 980220399b7SRoland Mainzif [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then 981220399b7SRoland Mainz # Check if the gate data are valid if we don't do a "bringover" below 982220399b7SRoland Mainz [[ -d "${CODEMGR_WS}" ]] || \ 983220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS} is not a directory." 984220399b7SRoland Mainz [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \ 985220399b7SRoland Mainz fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 986220399b7SRoland Mainzfi 987d7693b08SRoland Mainz 9887c478bd9Sstevel@tonic-gate# 9897c478bd9Sstevel@tonic-gate# place ourselves in a new task, respecting BUILD_PROJECT if set. 9907c478bd9Sstevel@tonic-gate# 9917c478bd9Sstevel@tonic-gateif [ -z "$BUILD_PROJECT" ]; then 9927c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ 9937c478bd9Sstevel@tonic-gateelse 9947c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ -p $BUILD_PROJECT 9957c478bd9Sstevel@tonic-gatefi 9967c478bd9Sstevel@tonic-gate 9977c478bd9Sstevel@tonic-gateps -o taskid= -p $$ | read build_taskid 9987c478bd9Sstevel@tonic-gateps -o project= -p $$ | read build_project 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gate# 10017c478bd9Sstevel@tonic-gate# See if NIGHTLY_OPTIONS is set 10027c478bd9Sstevel@tonic-gate# 10037c478bd9Sstevel@tonic-gateif [ "$NIGHTLY_OPTIONS" = "" ]; then 10047c478bd9Sstevel@tonic-gate NIGHTLY_OPTIONS="-aBm" 10057c478bd9Sstevel@tonic-gatefi 10067c478bd9Sstevel@tonic-gate 10077c478bd9Sstevel@tonic-gate# 10087c478bd9Sstevel@tonic-gate# If BRINGOVER_WS was not specified, let it default to CLONE_WS 10097c478bd9Sstevel@tonic-gate# 10107c478bd9Sstevel@tonic-gateif [ "$BRINGOVER_WS" = "" ]; then 10117c478bd9Sstevel@tonic-gate BRINGOVER_WS=$CLONE_WS 10127c478bd9Sstevel@tonic-gatefi 10137c478bd9Sstevel@tonic-gate 10147c478bd9Sstevel@tonic-gate# 1015cdf0c1d5Smjnelson# If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS 1016cdf0c1d5Smjnelson# 1017cdf0c1d5Smjnelsonif [ "$CLOSED_BRINGOVER_WS" = "" ]; then 1018cdf0c1d5Smjnelson CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS 1019cdf0c1d5Smjnelsonfi 1020cdf0c1d5Smjnelson 1021cdf0c1d5Smjnelson# 1022fb23a357Skupfer# If BRINGOVER_FILES was not specified, default to usr 1023a5c06a9eSmike_s# 1024a5c06a9eSmike_sif [ "$BRINGOVER_FILES" = "" ]; then 1025fb23a357Skupfer BRINGOVER_FILES="usr" 1026a5c06a9eSmike_sfi 1027a5c06a9eSmike_s 1028085d331dSkupfercheck_closed_tree 1029fb9f9b97Skupfer 1030a5c06a9eSmike_s# 10317c478bd9Sstevel@tonic-gate# Note: changes to the option letters here should also be applied to the 1032b84bdc30Smeem# bldenv script. `d' is listed for backward compatibility. 10337c478bd9Sstevel@tonic-gate# 1034d77e7149SsommerfeNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 10357c478bd9Sstevel@tonic-gateOPTIND=1 1036*5110237aSJosef 'Jeff' Sipekwhile getopts +ABCDdFfGIilMmNnoPpRrTtUuWwXxz FLAG $NIGHTLY_OPTIONS 10377c478bd9Sstevel@tonic-gatedo 10387c478bd9Sstevel@tonic-gate case $FLAG in 10397c478bd9Sstevel@tonic-gate A ) A_FLAG=y 10407c478bd9Sstevel@tonic-gate ;; 10417c478bd9Sstevel@tonic-gate B ) D_FLAG=y 10427c478bd9Sstevel@tonic-gate ;; # old version of D 10436c3c9007Sstevel C ) C_FLAG=y 10447c478bd9Sstevel@tonic-gate ;; 10457c478bd9Sstevel@tonic-gate D ) D_FLAG=y 10467c478bd9Sstevel@tonic-gate ;; 10476c3c9007Sstevel F ) F_FLAG=y 10487c478bd9Sstevel@tonic-gate ;; 10496c3c9007Sstevel f ) f_FLAG=y 10507c478bd9Sstevel@tonic-gate ;; 105178add226Sjmcp G ) u_FLAG=y 10527c478bd9Sstevel@tonic-gate ;; 105378add226Sjmcp I ) m_FLAG=y 10547c478bd9Sstevel@tonic-gate p_FLAG=y 10557c478bd9Sstevel@tonic-gate u_FLAG=y 10567c478bd9Sstevel@tonic-gate ;; 10577c478bd9Sstevel@tonic-gate i ) i_FLAG=y 10587c478bd9Sstevel@tonic-gate ;; 10596c3c9007Sstevel l ) l_FLAG=y 10606c3c9007Sstevel ;; 10616c3c9007Sstevel M ) M_FLAG=y 10626c3c9007Sstevel ;; 10636c3c9007Sstevel m ) m_FLAG=y 10646c3c9007Sstevel ;; 10656c3c9007Sstevel N ) N_FLAG=y 10666c3c9007Sstevel ;; 10677c478bd9Sstevel@tonic-gate n ) n_FLAG=y 10687c478bd9Sstevel@tonic-gate ;; 10697c478bd9Sstevel@tonic-gate o ) o_FLAG=y 10707c478bd9Sstevel@tonic-gate ;; 10716c3c9007Sstevel P ) P_FLAG=y 10726c3c9007Sstevel ;; # obsolete 10737c478bd9Sstevel@tonic-gate p ) p_FLAG=y 10747c478bd9Sstevel@tonic-gate ;; 10756c3c9007Sstevel R ) m_FLAG=y 10766c3c9007Sstevel p_FLAG=y 10776c3c9007Sstevel ;; 10787c478bd9Sstevel@tonic-gate r ) r_FLAG=y 10797c478bd9Sstevel@tonic-gate ;; 10806c3c9007Sstevel T ) T_FLAG=y 10816c3c9007Sstevel ;; # obsolete 1082fd7cef36Ssuha +t ) t_FLAG=n 10837c478bd9Sstevel@tonic-gate ;; 10846798c3f0SMark J. Nelson U ) if [ -z "${PARENT_ROOT}" ]; then 10857c478bd9Sstevel@tonic-gate echo "PARENT_ROOT must be set if the U flag is" \ 10867c478bd9Sstevel@tonic-gate "present in NIGHTLY_OPTIONS." 10877c478bd9Sstevel@tonic-gate exit 1 10887c478bd9Sstevel@tonic-gate fi 10896798c3f0SMark J. Nelson NIGHTLY_PARENT_ROOT=$PARENT_ROOT 10906798c3f0SMark J. Nelson if [ -n "${PARENT_TOOLS_ROOT}" ]; then 10916798c3f0SMark J. Nelson NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 1092ead1f93eSLiane Praza fi 10937c478bd9Sstevel@tonic-gate U_FLAG=y 10947c478bd9Sstevel@tonic-gate ;; 10956c3c9007Sstevel u ) u_FLAG=y 10967c478bd9Sstevel@tonic-gate ;; 10977c478bd9Sstevel@tonic-gate W ) W_FLAG=y 10987c478bd9Sstevel@tonic-gate ;; 10996c3c9007Sstevel 11006c3c9007Sstevel w ) w_FLAG=y 11017c478bd9Sstevel@tonic-gate ;; 11027c478bd9Sstevel@tonic-gate X ) # now that we no longer need realmode builds, just 11037c478bd9Sstevel@tonic-gate # copy IHV packages. only meaningful on x86. 11047c478bd9Sstevel@tonic-gate if [ "$MACH" = "i386" ]; then 11057c478bd9Sstevel@tonic-gate X_FLAG=y 11067c478bd9Sstevel@tonic-gate fi 11077c478bd9Sstevel@tonic-gate ;; 11086c3c9007Sstevel x ) XMOD_OPT="-x" 11096c3c9007Sstevel ;; 11107c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 11117c478bd9Sstevel@tonic-gate exit 1 11127c478bd9Sstevel@tonic-gate ;; 11137c478bd9Sstevel@tonic-gate esac 11147c478bd9Sstevel@tonic-gatedone 11157c478bd9Sstevel@tonic-gate 11167c478bd9Sstevel@tonic-gateif [ $ISUSER -ne 0 ]; then 11177c478bd9Sstevel@tonic-gate if [ "$o_FLAG" = "y" ]; then 11187c478bd9Sstevel@tonic-gate echo "Old-style build requires root permission." 11197c478bd9Sstevel@tonic-gate exit 1 11207c478bd9Sstevel@tonic-gate fi 11217c478bd9Sstevel@tonic-gate 11227c478bd9Sstevel@tonic-gate # Set default value for STAFFER, if needed. 11237c478bd9Sstevel@tonic-gate if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 11247c478bd9Sstevel@tonic-gate STAFFER=`/usr/xpg4/bin/id -un` 11257c478bd9Sstevel@tonic-gate export STAFFER 11267c478bd9Sstevel@tonic-gate fi 11277c478bd9Sstevel@tonic-gatefi 11287c478bd9Sstevel@tonic-gate 11297c478bd9Sstevel@tonic-gateif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 11307c478bd9Sstevel@tonic-gate MAILTO=$STAFFER 11317c478bd9Sstevel@tonic-gate export MAILTO 11327c478bd9Sstevel@tonic-gatefi 11337c478bd9Sstevel@tonic-gate 1134c168ccb7SMark J. NelsonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 1135c168ccb7SMark J. NelsonPATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb" 1136c168ccb7SMark J. NelsonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 11377c478bd9Sstevel@tonic-gateexport PATH 11387c478bd9Sstevel@tonic-gate 1139fb23a357Skupfer# roots of source trees, both relative to $SRC and absolute. 1140fb23a357Skupferrelsrcdirs="." 1141c0e7977aSJosef 'Jeff' Sipekabssrcdirs="$SRC" 1142fb23a357Skupfer 11437c478bd9Sstevel@tonic-gateunset CH 11447c478bd9Sstevel@tonic-gateif [ "$o_FLAG" = "y" ]; then 11457c478bd9Sstevel@tonic-gate# root invoked old-style build -- make sure it works as it always has 11467c478bd9Sstevel@tonic-gate# by exporting 'CH'. The current Makefile.master doesn't use this, but 11477c478bd9Sstevel@tonic-gate# the old ones still do. 11487c478bd9Sstevel@tonic-gate PROTOCMPTERSE="protocmp.terse" 11497c478bd9Sstevel@tonic-gate CH= 11507c478bd9Sstevel@tonic-gate export CH 11517c478bd9Sstevel@tonic-gateelse 11527c478bd9Sstevel@tonic-gate PROTOCMPTERSE="protocmp.terse -gu" 11537c478bd9Sstevel@tonic-gatefi 11547c478bd9Sstevel@tonic-gatePOUND_SIGN="#" 115548bc00d6Sjmcp# have we set RELEASE_DATE in our env file? 115648bc00d6Sjmcpif [ -z "$RELEASE_DATE" ]; then 115748bc00d6Sjmcp RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 115848bc00d6Sjmcpfi 115948bc00d6SjmcpBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 116048bc00d6SjmcpBASEWSDIR=$(basename $CODEMGR_WS) 116148bc00d6SjmcpDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 11627c478bd9Sstevel@tonic-gate 116348bc00d6Sjmcp# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 116448bc00d6Sjmcp# by avoiding repeated shell invocations to evaluate Makefile.master definitions. 11653c6aa570SMark J. Nelson# we export o_FLAG and X_FLAG for use by makebfu, and by usr/src/pkg/Makefile 116648bc00d6Sjmcpexport o_FLAG X_FLAG POUND_SIGN RELEASE_DATE DEV_CM 11677c478bd9Sstevel@tonic-gate 11687c478bd9Sstevel@tonic-gatemaketype="distributed" 11697c478bd9Sstevel@tonic-gateMAKE=dmake 11707c478bd9Sstevel@tonic-gate# get the dmake version string alone 11717c478bd9Sstevel@tonic-gateDMAKE_VERSION=$( $MAKE -v ) 11727c478bd9Sstevel@tonic-gateDMAKE_VERSION=${DMAKE_VERSION#*: } 11737c478bd9Sstevel@tonic-gate# focus in on just the dotted version number alone 11747c478bd9Sstevel@tonic-gateDMAKE_MAJOR=$( echo $DMAKE_VERSION | \ 11757c478bd9Sstevel@tonic-gate sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' ) 11767c478bd9Sstevel@tonic-gate# extract the second (or final) integer 11777c478bd9Sstevel@tonic-gateDMAKE_MINOR=${DMAKE_MAJOR#*.} 11787c478bd9Sstevel@tonic-gateDMAKE_MINOR=${DMAKE_MINOR%%.*} 11797c478bd9Sstevel@tonic-gate# extract the first integer 11807c478bd9Sstevel@tonic-gateDMAKE_MAJOR=${DMAKE_MAJOR%%.*} 11817c478bd9Sstevel@tonic-gateCHECK_DMAKE=${CHECK_DMAKE:-y} 11827c478bd9Sstevel@tonic-gate# x86 was built on the 12th, sparc on the 13th. 11837c478bd9Sstevel@tonic-gateif [ "$CHECK_DMAKE" = "y" -a \ 11847c478bd9Sstevel@tonic-gate "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \ 11857c478bd9Sstevel@tonic-gate "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \ 11867c478bd9Sstevel@tonic-gate "$DMAKE_MAJOR" -lt 7 -o \ 11877c478bd9Sstevel@tonic-gate "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then 11887c478bd9Sstevel@tonic-gate if [ -z "$DMAKE_VERSION" ]; then 11897c478bd9Sstevel@tonic-gate echo "$MAKE is missing." 11907c478bd9Sstevel@tonic-gate exit 1 11917c478bd9Sstevel@tonic-gate fi 11927c478bd9Sstevel@tonic-gate echo `whence $MAKE`" version is:" 11937c478bd9Sstevel@tonic-gate echo " ${DMAKE_VERSION}" 11947c478bd9Sstevel@tonic-gate cat <<EOF 11957c478bd9Sstevel@tonic-gate 11967c478bd9Sstevel@tonic-gateThis version may not be safe for use. Either set TEAMWARE to a better 11977c478bd9Sstevel@tonic-gatepath or (if you really want to use this version of dmake anyway), add 11987c478bd9Sstevel@tonic-gatethe following to your environment to disable this check: 11997c478bd9Sstevel@tonic-gate 12007c478bd9Sstevel@tonic-gate CHECK_DMAKE=n 12017c478bd9Sstevel@tonic-gateEOF 12027c478bd9Sstevel@tonic-gate exit 1 12037c478bd9Sstevel@tonic-gatefi 12047c478bd9Sstevel@tonic-gateexport PATH 12057c478bd9Sstevel@tonic-gateexport MAKE 12067c478bd9Sstevel@tonic-gate 12077c478bd9Sstevel@tonic-gateif [ "${SUNWSPRO}" != "" ]; then 12087c478bd9Sstevel@tonic-gate PATH="${SUNWSPRO}/bin:$PATH" 12097c478bd9Sstevel@tonic-gate export PATH 12107c478bd9Sstevel@tonic-gatefi 12117c478bd9Sstevel@tonic-gate 121299e4a37bSWill Fiveashhostname=$(uname -n) 121399e4a37bSWill Fiveashif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 121499e4a37bSWill Fiveashthen 121599e4a37bSWill Fiveash maxjobs= 121699e4a37bSWill Fiveash if [[ -f $HOME/.make.machines ]] 121799e4a37bSWill Fiveash then 121899e4a37bSWill Fiveash # Note: there is a hard tab and space character in the []s 121999e4a37bSWill Fiveash # below. 122099e4a37bSWill Fiveash egrep -i "^[ ]*$hostname[ \.]" \ 122199e4a37bSWill Fiveash $HOME/.make.machines | read host jobs 122299e4a37bSWill Fiveash maxjobs=${jobs##*=} 12237c478bd9Sstevel@tonic-gate fi 122499e4a37bSWill Fiveash 122599e4a37bSWill Fiveash if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 122699e4a37bSWill Fiveash then 122799e4a37bSWill Fiveash # default 122899e4a37bSWill Fiveash maxjobs=4 12297c478bd9Sstevel@tonic-gate fi 123099e4a37bSWill Fiveash 123199e4a37bSWill Fiveash export DMAKE_MAX_JOBS=$maxjobs 123299e4a37bSWill Fiveashfi 123399e4a37bSWill Fiveash 12347c478bd9Sstevel@tonic-gateDMAKE_MODE=parallel; 12357c478bd9Sstevel@tonic-gateexport DMAKE_MODE 12367c478bd9Sstevel@tonic-gate 12377c478bd9Sstevel@tonic-gateif [ -z "${ROOT}" ]; then 12387c478bd9Sstevel@tonic-gate echo "ROOT must be set." 12397c478bd9Sstevel@tonic-gate exit 1 12407c478bd9Sstevel@tonic-gatefi 12417c478bd9Sstevel@tonic-gate 12427c478bd9Sstevel@tonic-gate# 12437c478bd9Sstevel@tonic-gate# if -V flag was given, reset VERSION to V_ARG 12447c478bd9Sstevel@tonic-gate# 12457c478bd9Sstevel@tonic-gateif [ "$V_FLAG" = "y" ]; then 12467c478bd9Sstevel@tonic-gate VERSION=$V_ARG 12477c478bd9Sstevel@tonic-gatefi 12487c478bd9Sstevel@tonic-gate 124904a42e3eSszhou# 125004a42e3eSszhou# Check for IHV root for copying ihv proto area 125104a42e3eSszhou# 125204a42e3eSszhouif [ "$X_FLAG" = "y" ]; then 125304a42e3eSszhou if [ "$IA32_IHV_ROOT" = "" ]; then 125404a42e3eSszhou echo "IA32_IHV_ROOT: must be set for copying ihv proto" 125504a42e3eSszhou args_ok=n 125604a42e3eSszhou fi 125704a42e3eSszhou if [ ! -d "$IA32_IHV_ROOT" ]; then 125804a42e3eSszhou echo "$IA32_IHV_ROOT: not found" 125904a42e3eSszhou args_ok=n 126004a42e3eSszhou fi 12616fec3625Sdduvall if [ "$IA32_IHV_WS" = "" ]; then 12626fec3625Sdduvall echo "IA32_IHV_WS: must be set for copying ihv proto" 12636fec3625Sdduvall args_ok=n 12646fec3625Sdduvall fi 12656fec3625Sdduvall if [ ! -d "$IA32_IHV_WS" ]; then 12666fec3625Sdduvall echo "$IA32_IHV_WS: not found" 12676fec3625Sdduvall args_ok=n 12686fec3625Sdduvall fi 126904a42e3eSszhoufi 127004a42e3eSszhou 12717c478bd9Sstevel@tonic-gateTMPDIR="/tmp/nightly.tmpdir.$$" 12727c478bd9Sstevel@tonic-gateexport TMPDIR 12737c478bd9Sstevel@tonic-gaterm -rf ${TMPDIR} 12747c478bd9Sstevel@tonic-gatemkdir -p $TMPDIR || exit 1 127585f46905SMark J. Nelsonchmod 777 $TMPDIR 12767c478bd9Sstevel@tonic-gate 12777c478bd9Sstevel@tonic-gate# 12787c478bd9Sstevel@tonic-gate# Keep elfsign's use of pkcs11_softtoken from looking in the user home 12797c478bd9Sstevel@tonic-gate# directory, which doesn't always work. Needed until all build machines 12807c478bd9Sstevel@tonic-gate# have the fix for 6271754 12817c478bd9Sstevel@tonic-gate# 12827c478bd9Sstevel@tonic-gateSOFTTOKEN_DIR=$TMPDIR 12837c478bd9Sstevel@tonic-gateexport SOFTTOKEN_DIR 12847c478bd9Sstevel@tonic-gate 1285ead1f93eSLiane Praza# 1286ead1f93eSLiane Praza# Tools should only be built non-DEBUG. Keep track of the tools proto 1287ead1f93eSLiane Praza# area path relative to $TOOLS, because the latter changes in an 1288ead1f93eSLiane Praza# export build. 1289ead1f93eSLiane Praza# 1290ead1f93eSLiane Praza# TOOLS_PROTO is included below for builds other than usr/src/tools 1291ead1f93eSLiane Praza# that look for this location. For usr/src/tools, this will be 1292ead1f93eSLiane Praza# overridden on the $MAKE command line in build_tools(). 1293ead1f93eSLiane Praza# 12947c478bd9Sstevel@tonic-gateTOOLS=${SRC}/tools 1295ead1f93eSLiane PrazaTOOLS_PROTO_REL=proto/root_${MACH}-nd 1296ead1f93eSLiane PrazaTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1297ead1f93eSLiane Praza 12987c478bd9Sstevel@tonic-gateunset CFLAGS LD_LIBRARY_PATH LDFLAGS 12997c478bd9Sstevel@tonic-gate 13007c478bd9Sstevel@tonic-gate# create directories that are automatically removed if the nightly script 13017c478bd9Sstevel@tonic-gate# fails to start correctly 1302597bd30bSMike Kupferfunction newdir { 13037c478bd9Sstevel@tonic-gate dir=$1 13047c478bd9Sstevel@tonic-gate toadd= 13057c478bd9Sstevel@tonic-gate while [ ! -d $dir ]; do 13067c478bd9Sstevel@tonic-gate toadd="$dir $toadd" 13077c478bd9Sstevel@tonic-gate dir=`dirname $dir` 13087c478bd9Sstevel@tonic-gate done 13097c478bd9Sstevel@tonic-gate torm= 13107c478bd9Sstevel@tonic-gate newlist= 13117c478bd9Sstevel@tonic-gate for dir in $toadd; do 13127c478bd9Sstevel@tonic-gate if staffer mkdir $dir; then 13137c478bd9Sstevel@tonic-gate newlist="$ISUSER $dir $newlist" 13147c478bd9Sstevel@tonic-gate torm="$dir $torm" 13157c478bd9Sstevel@tonic-gate else 13167c478bd9Sstevel@tonic-gate [ -z "$torm" ] || staffer rmdir $torm 13177c478bd9Sstevel@tonic-gate return 1 13187c478bd9Sstevel@tonic-gate fi 13197c478bd9Sstevel@tonic-gate done 13207c478bd9Sstevel@tonic-gate newdirlist="$newlist $newdirlist" 13217c478bd9Sstevel@tonic-gate return 0 13227c478bd9Sstevel@tonic-gate} 13237c478bd9Sstevel@tonic-gatenewdirlist= 13247c478bd9Sstevel@tonic-gate 13257c478bd9Sstevel@tonic-gate[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 13267c478bd9Sstevel@tonic-gate 13277c478bd9Sstevel@tonic-gate# since this script assumes the build is from full source, it nullifies 13287c478bd9Sstevel@tonic-gate# variables likely to have been set by a "ws" script; nullification 13297c478bd9Sstevel@tonic-gate# confines the search space for headers and libraries to the proto area 13307c478bd9Sstevel@tonic-gate# built from this immediate source. 13317c478bd9Sstevel@tonic-gateENVLDLIBS1= 13327c478bd9Sstevel@tonic-gateENVLDLIBS2= 13337c478bd9Sstevel@tonic-gateENVLDLIBS3= 13347c478bd9Sstevel@tonic-gateENVCPPFLAGS1= 13357c478bd9Sstevel@tonic-gateENVCPPFLAGS2= 13367c478bd9Sstevel@tonic-gateENVCPPFLAGS3= 13377c478bd9Sstevel@tonic-gateENVCPPFLAGS4= 13387c478bd9Sstevel@tonic-gatePARENT_ROOT= 13397c478bd9Sstevel@tonic-gate 13407c478bd9Sstevel@tonic-gateexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1341494f7e12SKeith M Wesolowski ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT 13427c478bd9Sstevel@tonic-gate 13437c478bd9Sstevel@tonic-gatePKGARCHIVE_ORIG=$PKGARCHIVE 13447c478bd9Sstevel@tonic-gateIA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS 13457c478bd9Sstevel@tonic-gate 13467c478bd9Sstevel@tonic-gate# 13477c478bd9Sstevel@tonic-gate# Juggle the logs and optionally send mail on completion. 13487c478bd9Sstevel@tonic-gate# 13497c478bd9Sstevel@tonic-gate 1350597bd30bSMike Kupferfunction logshuffle { 1351fd7cef36Ssuha LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 13527c478bd9Sstevel@tonic-gate if [ -f $LLOG -o -d $LLOG ]; then 13537c478bd9Sstevel@tonic-gate LLOG=$LLOG.$$ 13547c478bd9Sstevel@tonic-gate fi 13557c478bd9Sstevel@tonic-gate mkdir $LLOG 13564802ef38Srscott export LLOG 13577c478bd9Sstevel@tonic-gate 13587c478bd9Sstevel@tonic-gate if [ "$build_ok" = "y" ]; then 13597c478bd9Sstevel@tonic-gate mv $ATLOG/proto_list_${MACH} $LLOG 136096ccc8cbSesaxe 13612e02daeeSRainer Orth if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 13622e02daeeSRainer Orth mv $ATLOG/proto_list_tools_${MACH} $LLOG 13632e02daeeSRainer Orth fi 13642e02daeeSRainer Orth 136596ccc8cbSesaxe if [ -f $TMPDIR/wsdiff.results ]; then 136696ccc8cbSesaxe mv $TMPDIR/wsdiff.results $LLOG 136796ccc8cbSesaxe fi 13684e5b757fSkupfer 13694e5b757fSkupfer if [ -f $TMPDIR/wsdiff-nd.results ]; then 13704e5b757fSkupfer mv $TMPDIR/wsdiff-nd.results $LLOG 13714e5b757fSkupfer fi 13727c478bd9Sstevel@tonic-gate fi 13737c478bd9Sstevel@tonic-gate 13747c478bd9Sstevel@tonic-gate # 13757c478bd9Sstevel@tonic-gate # Now that we're about to send mail, it's time to check the noise 13767c478bd9Sstevel@tonic-gate # file. In the event that an error occurs beyond this point, it will 13777c478bd9Sstevel@tonic-gate # be recorded in the nightly.log file, but nowhere else. This would 13787c478bd9Sstevel@tonic-gate # include only errors that cause the copying of the noise log to fail 13797c478bd9Sstevel@tonic-gate # or the mail itself not to be sent. 13807c478bd9Sstevel@tonic-gate # 13817c478bd9Sstevel@tonic-gate 13827c478bd9Sstevel@tonic-gate exec >>$LOGFILE 2>&1 13837c478bd9Sstevel@tonic-gate if [ -s $build_noise_file ]; then 13847c478bd9Sstevel@tonic-gate echo "\n==== Nightly build noise ====\n" | 13857c478bd9Sstevel@tonic-gate tee -a $LOGFILE >>$mail_msg_file 13867c478bd9Sstevel@tonic-gate cat $build_noise_file >>$LOGFILE 13877c478bd9Sstevel@tonic-gate cat $build_noise_file >>$mail_msg_file 13887c478bd9Sstevel@tonic-gate echo | tee -a $LOGFILE >>$mail_msg_file 13897c478bd9Sstevel@tonic-gate fi 13907c478bd9Sstevel@tonic-gate rm -f $build_noise_file 13917c478bd9Sstevel@tonic-gate 13927c478bd9Sstevel@tonic-gate case "$build_ok" in 13937c478bd9Sstevel@tonic-gate y) 13947c478bd9Sstevel@tonic-gate state=Completed 13957c478bd9Sstevel@tonic-gate ;; 13967c478bd9Sstevel@tonic-gate i) 13977c478bd9Sstevel@tonic-gate state=Interrupted 13987c478bd9Sstevel@tonic-gate ;; 13997c478bd9Sstevel@tonic-gate *) 14007c478bd9Sstevel@tonic-gate state=Failed 14017c478bd9Sstevel@tonic-gate ;; 14027c478bd9Sstevel@tonic-gate esac 140340bc9153Srscott NIGHTLY_STATUS=$state 140440bc9153Srscott export NIGHTLY_STATUS 14057c478bd9Sstevel@tonic-gate 140647703246Ssommerfe run_hook POST_NIGHTLY $state 140747703246Ssommerfe run_hook SYS_POST_NIGHTLY $state 14084802ef38Srscott 14093cb00cf1SJoshua M. Clulow # 14103cb00cf1SJoshua M. Clulow # mailx(1) sets From: based on the -r flag 14113cb00cf1SJoshua M. Clulow # if it is given. 14123cb00cf1SJoshua M. Clulow # 14133cb00cf1SJoshua M. Clulow mailx_r= 14143cb00cf1SJoshua M. Clulow if [[ -n "${MAILFROM}" ]]; then 14153cb00cf1SJoshua M. Clulow mailx_r="-r ${MAILFROM}" 14163cb00cf1SJoshua M. Clulow fi 14173cb00cf1SJoshua M. Clulow 1418cdf0c1d5Smjnelson cat $build_time_file $build_environ_file $mail_msg_file \ 1419cdf0c1d5Smjnelson > ${LLOG}/mail_msg 14207c478bd9Sstevel@tonic-gate if [ "$m_FLAG" = "y" ]; then 14213cb00cf1SJoshua M. Clulow cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \ 14227c478bd9Sstevel@tonic-gate "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 14237c478bd9Sstevel@tonic-gate ${MAILTO} 14247c478bd9Sstevel@tonic-gate fi 14257c478bd9Sstevel@tonic-gate 14267c478bd9Sstevel@tonic-gate if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 14277c478bd9Sstevel@tonic-gate staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 14287c478bd9Sstevel@tonic-gate staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 14297c478bd9Sstevel@tonic-gate fi 14307c478bd9Sstevel@tonic-gate 14317c478bd9Sstevel@tonic-gate mv $LOGFILE $LLOG 14327c478bd9Sstevel@tonic-gate} 14337c478bd9Sstevel@tonic-gate 14347c478bd9Sstevel@tonic-gate# 14357c478bd9Sstevel@tonic-gate# Remove the locks and temporary files on any exit 14367c478bd9Sstevel@tonic-gate# 1437597bd30bSMike Kupferfunction cleanup { 14387c478bd9Sstevel@tonic-gate logshuffle 14397c478bd9Sstevel@tonic-gate 14407c478bd9Sstevel@tonic-gate [ -z "$lockfile" ] || staffer rm -f $lockfile 14417c478bd9Sstevel@tonic-gate [ -z "$atloglockfile" ] || rm -f $atloglockfile 14427c478bd9Sstevel@tonic-gate [ -z "$ulockfile" ] || staffer rm -f $ulockfile 14437c478bd9Sstevel@tonic-gate [ -z "$Ulockfile" ] || rm -f $Ulockfile 14447c478bd9Sstevel@tonic-gate 14457c478bd9Sstevel@tonic-gate set -- $newdirlist 14467c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 14477c478bd9Sstevel@tonic-gate ISUSER=$1 staffer rmdir $2 14487c478bd9Sstevel@tonic-gate shift; shift 14497c478bd9Sstevel@tonic-gate done 14507c478bd9Sstevel@tonic-gate rm -rf $TMPDIR 14517c478bd9Sstevel@tonic-gate} 14527c478bd9Sstevel@tonic-gate 1453597bd30bSMike Kupferfunction cleanup_signal { 14547c478bd9Sstevel@tonic-gate build_ok=i 14557c478bd9Sstevel@tonic-gate # this will trigger cleanup(), above. 14567c478bd9Sstevel@tonic-gate exit 1 14577c478bd9Sstevel@tonic-gate} 14587c478bd9Sstevel@tonic-gate 14597c478bd9Sstevel@tonic-gatetrap cleanup 0 14607c478bd9Sstevel@tonic-gatetrap cleanup_signal 1 2 3 15 14617c478bd9Sstevel@tonic-gate 14627c478bd9Sstevel@tonic-gate# 14637c478bd9Sstevel@tonic-gate# Generic lock file processing -- make sure that the lock file doesn't 14647c478bd9Sstevel@tonic-gate# exist. If it does, it should name the build host and PID. If it 14657c478bd9Sstevel@tonic-gate# doesn't, then make sure we can create it. Clean up locks that are 14667c478bd9Sstevel@tonic-gate# known to be stale (assumes host name is unique among build systems 14677c478bd9Sstevel@tonic-gate# for the workspace). 1468cdf0c1d5Smjnelson# 1469597bd30bSMike Kupferfunction create_lock { 14707c478bd9Sstevel@tonic-gate lockf=$1 14717c478bd9Sstevel@tonic-gate lockvar=$2 14728312e758Sdduvall 14737c478bd9Sstevel@tonic-gate ldir=`dirname $lockf` 14747c478bd9Sstevel@tonic-gate [ -d $ldir ] || newdir $ldir || exit 1 14757c478bd9Sstevel@tonic-gate eval $lockvar=$lockf 14768312e758Sdduvall 14778312e758Sdduvall while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 14788312e758Sdduvall basews=`basename $CODEMGR_WS` 14798312e758Sdduvall ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 14808312e758Sdduvall if [ "$host" != "$hostname" ]; then 14818312e758Sdduvall echo "$MACH build of $basews apparently" \ 14828312e758Sdduvall "already started by $user on $host as $pid." 14838312e758Sdduvall exit 1 14848312e758Sdduvall elif kill -s 0 $pid 2>/dev/null; then 14858312e758Sdduvall echo "$MACH build of $basews already started" \ 14868312e758Sdduvall "by $user as $pid." 14878312e758Sdduvall exit 1 14888312e758Sdduvall else 14898312e758Sdduvall # stale lock; clear it out and try again 14908312e758Sdduvall rm -f $lockf 14918312e758Sdduvall fi 14928312e758Sdduvall done 14937c478bd9Sstevel@tonic-gate} 14947c478bd9Sstevel@tonic-gate 14954e5b757fSkupfer# 14964e5b757fSkupfer# Return the list of interesting proto areas, depending on the current 14974e5b757fSkupfer# options. 14984e5b757fSkupfer# 1499597bd30bSMike Kupferfunction allprotos { 1500c7453724SMike Kupfer typeset roots="$ROOT" 1501b83ec4edSjmcp 1502c7453724SMike Kupfer if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 1503c7453724SMike Kupfer roots="$roots $ROOT-nd" 15044e5b757fSkupfer fi 15054e5b757fSkupfer 15064e5b757fSkupfer echo $roots 15074e5b757fSkupfer} 15084e5b757fSkupfer 15097c478bd9Sstevel@tonic-gate# Ensure no other instance of this script is running on this host. 15107c478bd9Sstevel@tonic-gate# LOCKNAME can be set in <env_file>, and is by default, but is not 15117c478bd9Sstevel@tonic-gate# required due to the use of $ATLOG below. 15127c478bd9Sstevel@tonic-gateif [ -n "$LOCKNAME" ]; then 15137c478bd9Sstevel@tonic-gate create_lock /tmp/$LOCKNAME "lockfile" 15147c478bd9Sstevel@tonic-gatefi 15157c478bd9Sstevel@tonic-gate# 15167c478bd9Sstevel@tonic-gate# Create from one, two, or three other locks: 15177c478bd9Sstevel@tonic-gate# $ATLOG/nightly.lock 15187c478bd9Sstevel@tonic-gate# - protects against multiple builds in same workspace 15197c478bd9Sstevel@tonic-gate# $PARENT_WS/usr/src/nightly.$MACH.lock 15207c478bd9Sstevel@tonic-gate# - protects against multiple 'u' copy-backs 15217c478bd9Sstevel@tonic-gate# $NIGHTLY_PARENT_ROOT/nightly.lock 15227c478bd9Sstevel@tonic-gate# - protects against multiple 'U' copy-backs 15237c478bd9Sstevel@tonic-gate# 15247c478bd9Sstevel@tonic-gate# Overriding ISUSER to 1 causes the lock to be created as root if the 15257c478bd9Sstevel@tonic-gate# script is run as root. The default is to create it as $STAFFER. 15267c478bd9Sstevel@tonic-gateISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 15277c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" ]; then 15287c478bd9Sstevel@tonic-gate create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 15297c478bd9Sstevel@tonic-gatefi 15307c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" ]; then 15317c478bd9Sstevel@tonic-gate # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 15327c478bd9Sstevel@tonic-gate ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 15337c478bd9Sstevel@tonic-gatefi 15347c478bd9Sstevel@tonic-gate 15357c478bd9Sstevel@tonic-gate# Locks have been taken, so we're doing a build and we're committed to 15367c478bd9Sstevel@tonic-gate# the directories we may have created so far. 15377c478bd9Sstevel@tonic-gatenewdirlist= 15387c478bd9Sstevel@tonic-gate 15397c478bd9Sstevel@tonic-gate# 15407c478bd9Sstevel@tonic-gate# Create mail_msg_file 15417c478bd9Sstevel@tonic-gate# 15427c478bd9Sstevel@tonic-gatemail_msg_file="${TMPDIR}/mail_msg" 15437c478bd9Sstevel@tonic-gatetouch $mail_msg_file 15447c478bd9Sstevel@tonic-gatebuild_time_file="${TMPDIR}/build_time" 1545cdf0c1d5Smjnelsonbuild_environ_file="${TMPDIR}/build_environ" 1546cdf0c1d5Smjnelsontouch $build_environ_file 15477c478bd9Sstevel@tonic-gate# 15487c478bd9Sstevel@tonic-gate# Move old LOGFILE aside 15497c478bd9Sstevel@tonic-gate# ATLOG directory already made by 'create_lock' above 15507c478bd9Sstevel@tonic-gate# 15517c478bd9Sstevel@tonic-gateif [ -f $LOGFILE ]; then 15527c478bd9Sstevel@tonic-gate mv -f $LOGFILE ${LOGFILE}- 15537c478bd9Sstevel@tonic-gatefi 15547c478bd9Sstevel@tonic-gate# 15557c478bd9Sstevel@tonic-gate# Build OsNet source 15567c478bd9Sstevel@tonic-gate# 15577c478bd9Sstevel@tonic-gateSTART_DATE=`date` 15587c478bd9Sstevel@tonic-gateSECONDS=0 15597c478bd9Sstevel@tonic-gateecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 15607c478bd9Sstevel@tonic-gate | tee -a $LOGFILE > $build_time_file 15617c478bd9Sstevel@tonic-gate 1562cdf0c1d5Smjnelsonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1563cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 1564cdf0c1d5Smjnelson 15657c478bd9Sstevel@tonic-gate# make sure we log only to the nightly build file 15667c478bd9Sstevel@tonic-gatebuild_noise_file="${TMPDIR}/build_noise" 15677c478bd9Sstevel@tonic-gateexec </dev/null >$build_noise_file 2>&1 15687c478bd9Sstevel@tonic-gate 156947703246Ssommerferun_hook SYS_PRE_NIGHTLY 157047703246Ssommerferun_hook PRE_NIGHTLY 157147703246Ssommerfe 15727c478bd9Sstevel@tonic-gateecho "\n==== list of environment variables ====\n" >> $LOGFILE 15737c478bd9Sstevel@tonic-gateenv >> $LOGFILE 15747c478bd9Sstevel@tonic-gate 15757c478bd9Sstevel@tonic-gateecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 15767c478bd9Sstevel@tonic-gate 1577d77e7149Ssommerfeif [ "$P_FLAG" = "y" ]; then 1578d77e7149Ssommerfe obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE 1579d77e7149Ssommerfefi 1580d77e7149Ssommerfe 1581d77e7149Ssommerfeif [ "$T_FLAG" = "y" ]; then 1582d77e7149Ssommerfe obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE 1583d77e7149Ssommerfefi 1584d77e7149Ssommerfe 15857c478bd9Sstevel@tonic-gateif [ "$N_FLAG" = "y" ]; then 15867c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" ]; then 15877c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 15887c478bd9Sstevel@tonic-gateWARNING: the p option (create packages) is set, but so is the N option (do 15897c478bd9Sstevel@tonic-gate not run protocmp); this is dangerous; you should unset the N option 15907c478bd9Sstevel@tonic-gateEOF 15917c478bd9Sstevel@tonic-gate else 15927c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 15937c478bd9Sstevel@tonic-gateWarning: the N option (do not run protocmp) is set; it probably shouldn't be 15947c478bd9Sstevel@tonic-gateEOF 15957c478bd9Sstevel@tonic-gate fi 15967c478bd9Sstevel@tonic-gate echo "" | tee -a $mail_msg_file >> $LOGFILE 15977c478bd9Sstevel@tonic-gatefi 15987c478bd9Sstevel@tonic-gate 15997c478bd9Sstevel@tonic-gateif [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 16004e5b757fSkupfer # 16014e5b757fSkupfer # In the past we just complained but went ahead with the lint 1602ead1f93eSLiane Praza # pass, even though the proto area was built non-DEBUG. It's 1603ead1f93eSLiane Praza # unlikely that non-DEBUG headers will make a difference, but 16044e5b757fSkupfer # rather than assuming it's a safe combination, force the user 1605ead1f93eSLiane Praza # to specify a DEBUG build. 16064e5b757fSkupfer # 16074e5b757fSkupfer echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 16087c478bd9Sstevel@tonic-gate | tee -a $mail_msg_file >> $LOGFILE 16094e5b757fSkupfer l_FLAG=n 16107c478bd9Sstevel@tonic-gatefi 16117c478bd9Sstevel@tonic-gate 16127c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" ]; then 16137c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "y" ]; then 16147c478bd9Sstevel@tonic-gate echo "WARNING: the -f flag cannot be used during incremental" \ 16157c478bd9Sstevel@tonic-gate "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 16167c478bd9Sstevel@tonic-gate f_FLAG=n 16177c478bd9Sstevel@tonic-gate fi 161811a78ea0SMark J. Nelson if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 161911a78ea0SMark J. Nelson echo "WARNING: the -f flag requires -l, and -p;" \ 162011a78ea0SMark J. Nelson "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 16217c478bd9Sstevel@tonic-gate f_FLAG=n 16227c478bd9Sstevel@tonic-gate fi 16237c478bd9Sstevel@tonic-gatefi 16247c478bd9Sstevel@tonic-gate 162596ccc8cbSesaxeif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 16264e5b757fSkupfer echo "WARNING: -w specified, but $ROOT does not exist;" \ 162796ccc8cbSesaxe "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 162896ccc8cbSesaxe w_FLAG=n 162996ccc8cbSesaxefi 163096ccc8cbSesaxe 16317c478bd9Sstevel@tonic-gateif [ "$t_FLAG" = "n" ]; then 16327c478bd9Sstevel@tonic-gate # 16337c478bd9Sstevel@tonic-gate # We're not doing a tools build, so make sure elfsign(1) is 16347c478bd9Sstevel@tonic-gate # new enough to safely sign non-crypto binaries. We test 16357c478bd9Sstevel@tonic-gate # debugging output from elfsign to detect the old version. 16367c478bd9Sstevel@tonic-gate # 16377c478bd9Sstevel@tonic-gate newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 16387c478bd9Sstevel@tonic-gate -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 16397c478bd9Sstevel@tonic-gate | egrep algorithmOID` 16407c478bd9Sstevel@tonic-gate if [ -z "$newelfsigntest" ]; then 16417c478bd9Sstevel@tonic-gate echo "WARNING: /usr/bin/elfsign out of date;" \ 16427c478bd9Sstevel@tonic-gate "will only sign crypto modules\n" | \ 16437c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 16447c478bd9Sstevel@tonic-gate export ELFSIGN_OBJECT=true 16457c478bd9Sstevel@tonic-gate elif [ "$VERIFY_ELFSIGN" = "y" ]; then 16467c478bd9Sstevel@tonic-gate echo "WARNING: VERIFY_ELFSIGN=y requires" \ 16477c478bd9Sstevel@tonic-gate "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 16487c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 16497c478bd9Sstevel@tonic-gate fi 16507c478bd9Sstevel@tonic-gatefi 16517c478bd9Sstevel@tonic-gate 16524e5b757fSkupfercase $MULTI_PROTO in 16534e5b757fSkupferyes|no) ;; 16544e5b757fSkupfer*) 16554e5b757fSkupfer echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 16564e5b757fSkupfer "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 16574e5b757fSkupfer echo "Setting MULTI_PROTO to \"no\".\n" | \ 16584e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 16594e5b757fSkupfer export MULTI_PROTO=no 16604e5b757fSkupfer ;; 16614e5b757fSkupferesac 16624e5b757fSkupfer 16637c478bd9Sstevel@tonic-gateecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 16647c478bd9Sstevel@tonic-gateecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 16657c478bd9Sstevel@tonic-gate 166696ccc8cbSesaxe# Save the current proto area if we're comparing against the last build 166796ccc8cbSesaxeif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 166896ccc8cbSesaxe if [ -d "$ROOT.prev" ]; then 166996ccc8cbSesaxe rm -rf $ROOT.prev 167096ccc8cbSesaxe fi 167196ccc8cbSesaxe mv $ROOT $ROOT.prev 167296ccc8cbSesaxefi 167396ccc8cbSesaxe 16744e5b757fSkupfer# Same for non-DEBUG proto area 16754e5b757fSkupferif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 16764e5b757fSkupfer if [ -d "$ROOT-nd.prev" ]; then 16774e5b757fSkupfer rm -rf $ROOT-nd.prev 16784e5b757fSkupfer fi 16794e5b757fSkupfer mv $ROOT-nd $ROOT-nd.prev 16804e5b757fSkupferfi 16814e5b757fSkupfer 1682445b6314SRichard Lowe# 1683445b6314SRichard Lowe# Echo the SCM type of the parent workspace, this can't just be which_scm 1684445b6314SRichard Lowe# as that does not know how to identify various network repositories. 1685445b6314SRichard Lowe# 1686445b6314SRichard Lowefunction parent_wstype { 1687445b6314SRichard Lowe typeset scm_type junk 168830635de9SJohn.Zolnowsky@Sun.COM 168930635de9SJohn.Zolnowsky@Sun.COM CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 1690445b6314SRichard Lowe | read scm_type junk 1691445b6314SRichard Lowe if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 169230635de9SJohn.Zolnowsky@Sun.COM # Probe BRINGOVER_WS to determine its type 169330635de9SJohn.Zolnowsky@Sun.COM if [[ $BRINGOVER_WS == svn*://* ]]; then 1694445b6314SRichard Lowe scm_type="subversion" 169530635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == file://* ]] && 169630635de9SJohn.Zolnowsky@Sun.COM egrep -s "This is a Subversion repository" \ 169730635de9SJohn.Zolnowsky@Sun.COM ${BRINGOVER_WS#file://}/README.txt 2> /dev/null; then 1698445b6314SRichard Lowe scm_type="subversion" 169930635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == ssh://* ]]; then 1700445b6314SRichard Lowe scm_type="mercurial" 170130635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == http://* ]] && \ 1702445b6314SRichard Lowe wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 170330635de9SJohn.Zolnowsky@Sun.COM egrep -s "application/mercurial" 2> /dev/null; then 1704445b6314SRichard Lowe scm_type="mercurial" 1705445b6314SRichard Lowe elif svn info $BRINGOVER_WS > /dev/null 2>&1; then 1706445b6314SRichard Lowe scm_type="subversion" 170730635de9SJohn.Zolnowsky@Sun.COM else 1708445b6314SRichard Lowe scm_type="none" 170930635de9SJohn.Zolnowsky@Sun.COM fi 171030635de9SJohn.Zolnowsky@Sun.COM fi 171130635de9SJohn.Zolnowsky@Sun.COM 171230635de9SJohn.Zolnowsky@Sun.COM # fold both unsupported and unrecognized results into "none" 1713445b6314SRichard Lowe case "$scm_type" in 171430635de9SJohn.Zolnowsky@Sun.COM none|subversion|teamware|mercurial) 171530635de9SJohn.Zolnowsky@Sun.COM ;; 1716445b6314SRichard Lowe *) scm_type=none 171730635de9SJohn.Zolnowsky@Sun.COM ;; 171830635de9SJohn.Zolnowsky@Sun.COM esac 171930635de9SJohn.Zolnowsky@Sun.COM 1720445b6314SRichard Lowe echo $scm_type 172130635de9SJohn.Zolnowsky@Sun.COM} 172230635de9SJohn.Zolnowsky@Sun.COM 1723445b6314SRichard Lowe# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 1724445b6314SRichard Lowefunction child_wstype { 1725445b6314SRichard Lowe typeset scm_type junk 1726445b6314SRichard Lowe 1727445b6314SRichard Lowe # Probe CODEMGR_WS to determine its type 1728445b6314SRichard Lowe if [[ -d $CODEMGR_WS ]]; then 1729445b6314SRichard Lowe $WHICH_SCM | read scm_type junk || exit 1 1730445b6314SRichard Lowe fi 1731445b6314SRichard Lowe 1732445b6314SRichard Lowe case "$scm_type" in 17331b1e41ddSRichard Lowe none|subversion|git|teamware|mercurial) 1734445b6314SRichard Lowe ;; 1735445b6314SRichard Lowe *) scm_type=none 1736445b6314SRichard Lowe ;; 1737445b6314SRichard Lowe esac 1738445b6314SRichard Lowe 1739445b6314SRichard Lowe echo $scm_type 1740445b6314SRichard Lowe} 1741445b6314SRichard Lowe 17425c70f01eSRichard LoweSCM_TYPE=$(child_wstype) 174330635de9SJohn.Zolnowsky@Sun.COM 17447c478bd9Sstevel@tonic-gate# 17457c478bd9Sstevel@tonic-gate# Decide whether to clobber 17467c478bd9Sstevel@tonic-gate# 17477c478bd9Sstevel@tonic-gateif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 17487c478bd9Sstevel@tonic-gate echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 17497c478bd9Sstevel@tonic-gate 17507c478bd9Sstevel@tonic-gate cd $SRC 17517c478bd9Sstevel@tonic-gate # remove old clobber file 17527c478bd9Sstevel@tonic-gate rm -f $SRC/clobber.out 17537c478bd9Sstevel@tonic-gate rm -f $SRC/clobber-${MACH}.out 17547c478bd9Sstevel@tonic-gate 17557c478bd9Sstevel@tonic-gate # Remove all .make.state* files, just in case we are restarting 17567c478bd9Sstevel@tonic-gate # the build after having interrupted a previous 'make clobber'. 17578bcea973SRichard Lowe find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \ 1758cdf0c1d5Smjnelson -o -name 'interfaces.*' \) -prune \ 17597c478bd9Sstevel@tonic-gate -o -name '.make.*' -print | xargs rm -f 17607c478bd9Sstevel@tonic-gate 17617c478bd9Sstevel@tonic-gate $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 17627c478bd9Sstevel@tonic-gate echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 17637c478bd9Sstevel@tonic-gate grep "$MAKE:" $SRC/clobber-${MACH}.out | 17647c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" \ 17657c478bd9Sstevel@tonic-gate >> $mail_msg_file 17667c478bd9Sstevel@tonic-gate 1767*5110237aSJosef 'Jeff' Sipek if [[ "$t_FLAG" = "y" ]]; then 17687c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 17697c478bd9Sstevel@tonic-gate cd ${TOOLS} 17707c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/clobber-${MACH}.out 1771ead1f93eSLiane Praza $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 17727c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 17737c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber ERRORS ====\n" \ 17747c478bd9Sstevel@tonic-gate >> $mail_msg_file 17757c478bd9Sstevel@tonic-gate grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 17767c478bd9Sstevel@tonic-gate >> $mail_msg_file 17777c478bd9Sstevel@tonic-gate rm -rf ${TOOLS_PROTO} 17787c478bd9Sstevel@tonic-gate mkdir -p ${TOOLS_PROTO} 17797c478bd9Sstevel@tonic-gate fi 178096ccc8cbSesaxe 1781c7453724SMike Kupfer typeset roots=$(allprotos) 1782c7453724SMike Kupfer echo "\n\nClearing $roots" >> "$LOGFILE" 1783c7453724SMike Kupfer rm -rf $roots 17847c478bd9Sstevel@tonic-gate 17857c478bd9Sstevel@tonic-gate # Get back to a clean workspace as much as possible to catch 17867c478bd9Sstevel@tonic-gate # problems that only occur on fresh workspaces. 17877c478bd9Sstevel@tonic-gate # Remove all .make.state* files, libraries, and .o's that may 1788fb23a357Skupfer # have been omitted from clobber. A couple of libraries are 1789cdf0c1d5Smjnelson # under source code control, so leave them alone. 17907c478bd9Sstevel@tonic-gate # We should probably blow away temporary directories too. 17917c478bd9Sstevel@tonic-gate cd $SRC 1792cdf0c1d5Smjnelson find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 17938bcea973SRichard Lowe -o -name .git -o -name 'interfaces.*' \) -prune -o \ 17947c478bd9Sstevel@tonic-gate \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1795fb23a357Skupfer -name '*.o' \) -print | \ 1796fb23a357Skupfer grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 17977c478bd9Sstevel@tonic-gateelse 17987c478bd9Sstevel@tonic-gate echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 17997c478bd9Sstevel@tonic-gatefi 18007c478bd9Sstevel@tonic-gate 1801597bd30bSMike Kupfertype bringover_teamware > /dev/null 2>&1 || function bringover_teamware { 18027c478bd9Sstevel@tonic-gate # sleep on the parent workspace's lock 18037c478bd9Sstevel@tonic-gate while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks 18047c478bd9Sstevel@tonic-gate do 18057c478bd9Sstevel@tonic-gate sleep 120 18067c478bd9Sstevel@tonic-gate done 18077c478bd9Sstevel@tonic-gate 1808fd7cef36Ssuha if [[ -z $BRINGOVER ]]; then 1809fd7cef36Ssuha BRINGOVER=$TEAMWARE/bin/bringover 1810fd7cef36Ssuha fi 181132f1e47bSsommerfe 1812cdf0c1d5Smjnelson staffer $BRINGOVER -c "nightly update" -p $BRINGOVER_WS \ 181332f1e47bSsommerfe -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 || 181432f1e47bSsommerfe touch $TMPDIR/bringover_failed 181532f1e47bSsommerfe 1816d77e7149Ssommerfe staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1 1817d77e7149Ssommerfe if [ -s $TMPDIR/bringovercheck.out ]; then 1818d77e7149Ssommerfe echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n" 1819d77e7149Ssommerfe cat $TMPDIR/bringovercheck.out 1820d77e7149Ssommerfe fi 1821cdf0c1d5Smjnelson} 182232f1e47bSsommerfe 1823597bd30bSMike Kupfertype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 1824cdf0c1d5Smjnelson typeset -x PATH=$PATH 1825cdf0c1d5Smjnelson 1826cdf0c1d5Smjnelson # If the repository doesn't exist yet, then we want to populate it. 1827cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.hg ]]; then 1828cdf0c1d5Smjnelson staffer hg init $CODEMGR_WS 18298cca05f6SMark J. Nelson staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 18308cca05f6SMark J. Nelson staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 1831f457028bSMark J. Nelson touch $TMPDIR/new_repository 1832cdf0c1d5Smjnelson fi 18335c53ea7aSmjnelson 1834cdf0c1d5Smjnelson typeset -x HGMERGE="/bin/false" 1835cdf0c1d5Smjnelson 1836cdf0c1d5Smjnelson # 18375c53ea7aSmjnelson # If the user has changes, regardless of whether those changes are 18385c53ea7aSmjnelson # committed, and regardless of whether those changes conflict, then 18395c53ea7aSmjnelson # we'll attempt to merge them either implicitly (uncommitted) or 18405c53ea7aSmjnelson # explicitly (committed). 1841cdf0c1d5Smjnelson # 18425c53ea7aSmjnelson # These are the messages we'll use to help clarify mercurial output 18435c53ea7aSmjnelson # in those cases. 18445c53ea7aSmjnelson # 18455c53ea7aSmjnelson typeset mergefailmsg="\ 18465c53ea7aSmjnelson***\n\ 18475c53ea7aSmjnelson*** nightly was unable to automatically merge your changes. You should\n\ 18485c53ea7aSmjnelson*** redo the full merge manually, following the steps outlined by mercurial\n\ 18495c53ea7aSmjnelson*** above, then restart nightly.\n\ 18505c53ea7aSmjnelson***\n" 18515c53ea7aSmjnelson typeset mergepassmsg="\ 18525c53ea7aSmjnelson***\n\ 18535c53ea7aSmjnelson*** nightly successfully merged your changes. This means that your working\n\ 18545c53ea7aSmjnelson*** directory has been updated, but those changes are not yet committed.\n\ 18555c53ea7aSmjnelson*** After nightly completes, you should validate the results of the merge,\n\ 18565c53ea7aSmjnelson*** then use hg commit manually.\n\ 18575c53ea7aSmjnelson***\n" 18585c53ea7aSmjnelson 18595c53ea7aSmjnelson # 18605c53ea7aSmjnelson # For each repository in turn: 18615c53ea7aSmjnelson # 18625c53ea7aSmjnelson # 1. Do the pull. If this fails, dump the output and bail out. 18635c53ea7aSmjnelson # 18645c53ea7aSmjnelson # 2. If the pull resulted in an extra head, do an explicit merge. 18655c53ea7aSmjnelson # If this fails, dump the output and bail out. 18665c53ea7aSmjnelson # 18675c53ea7aSmjnelson # Because we can't rely on Mercurial to exit with a failure code 18685c53ea7aSmjnelson # when a merge fails (Mercurial issue #186), we must grep the 18695c53ea7aSmjnelson # output of pull/merge to check for attempted and/or failed merges. 18705c53ea7aSmjnelson # 18715c53ea7aSmjnelson # 3. If a merge failed, set the message and fail the bringover. 18725c53ea7aSmjnelson # 18735c53ea7aSmjnelson # 4. Otherwise, if a merge succeeded, set the message 18745c53ea7aSmjnelson # 18755c53ea7aSmjnelson # 5. Dump the output, and any message from step 3 or 4. 18765c53ea7aSmjnelson # 18775c53ea7aSmjnelson 1878f457028bSMark J. Nelson typeset HG_SOURCE=$BRINGOVER_WS 1879f457028bSMark J. Nelson if [ ! -f $TMPDIR/new_repository ]; then 1880f457028bSMark J. Nelson HG_SOURCE=$TMPDIR/open_bundle.hg 1881f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 1882f457028bSMark J. Nelson -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 1883f457028bSMark J. Nelson 1884f457028bSMark J. Nelson # 1885f457028bSMark J. Nelson # If there are no incoming changesets, then incoming will 1886f457028bSMark J. Nelson # fail, and there will be no bundle file. Reset the source, 1887f457028bSMark J. Nelson # to allow the remaining logic to complete with no false 1888f457028bSMark J. Nelson # negatives. (Unlike incoming, pull will return success 1889f457028bSMark J. Nelson # for the no-change case.) 1890f457028bSMark J. Nelson # 1891f457028bSMark J. Nelson if (( $? != 0 )); then 1892f457028bSMark J. Nelson HG_SOURCE=$BRINGOVER_WS 1893f457028bSMark J. Nelson fi 1894f457028bSMark J. Nelson fi 1895f457028bSMark J. Nelson 1896f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 18975c53ea7aSmjnelson > $TMPDIR/pull_open.out 2>&1 18985c53ea7aSmjnelson if (( $? != 0 )); then 18995c53ea7aSmjnelson printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 19005c53ea7aSmjnelson cat $TMPDIR/pull_open.out 19015c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 19025c53ea7aSmjnelson printf "$mergefailmsg" 19035c53ea7aSmjnelson fi 19045c53ea7aSmjnelson touch $TMPDIR/bringover_failed 19055c53ea7aSmjnelson return 19065c53ea7aSmjnelson fi 19075c53ea7aSmjnelson 1908cdf0c1d5Smjnelson if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 19095c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS merge \ 19105c53ea7aSmjnelson >> $TMPDIR/pull_open.out 2>&1 19115c53ea7aSmjnelson if (( $? != 0 )); then 19125c53ea7aSmjnelson printf "%s: merge failed as follows:\n\n" \ 19135c53ea7aSmjnelson "$CODEMGR_WS" 19145c53ea7aSmjnelson cat $TMPDIR/pull_open.out 19155c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out \ 19165c53ea7aSmjnelson > /dev/null 2>&1; then 19175c53ea7aSmjnelson printf "$mergefailmsg" 19185c53ea7aSmjnelson fi 1919cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 19205c53ea7aSmjnelson return 1921cdf0c1d5Smjnelson fi 1922cdf0c1d5Smjnelson fi 19235c53ea7aSmjnelson 19245c53ea7aSmjnelson printf "updated %s with the following results:\n" "$CODEMGR_WS" 19255c53ea7aSmjnelson cat $TMPDIR/pull_open.out 19265c53ea7aSmjnelson if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 19275c53ea7aSmjnelson printf "$mergepassmsg" 19285c53ea7aSmjnelson fi 19295c53ea7aSmjnelson printf "\n" 19305c53ea7aSmjnelson 19315c53ea7aSmjnelson # 1932f457028bSMark J. Nelson # Per-changeset output is neither useful nor manageable for a 1933f457028bSMark J. Nelson # newly-created repository. 1934f457028bSMark J. Nelson # 1935f457028bSMark J. Nelson if [ -f $TMPDIR/new_repository ]; then 1936f457028bSMark J. Nelson return 1937f457028bSMark J. Nelson fi 1938f457028bSMark J. Nelson 1939f457028bSMark J. Nelson printf "\nadded the following changesets to open repository:\n" 1940f457028bSMark J. Nelson cat $TMPDIR/incoming_open.out 1941f457028bSMark J. Nelson 1942f457028bSMark J. Nelson # 1943f457028bSMark J. Nelson # The closed repository could have been newly created, even though 1944f457028bSMark J. Nelson # the open one previously existed... 1945f457028bSMark J. Nelson # 1946f457028bSMark J. Nelson if [ -f $TMPDIR/new_closed ]; then 1947f457028bSMark J. Nelson return 1948f457028bSMark J. Nelson fi 1949f457028bSMark J. Nelson 1950f457028bSMark J. Nelson if [ -f $TMPDIR/incoming_closed.out ]; then 1951f457028bSMark J. Nelson printf "\nadded the following changesets to closed repository:\n" 1952f457028bSMark J. Nelson cat $TMPDIR/incoming_closed.out 1953f457028bSMark J. Nelson fi 1954cdf0c1d5Smjnelson} 1955cdf0c1d5Smjnelson 1956597bd30bSMike Kupfertype bringover_subversion > /dev/null 2>&1 || function bringover_subversion { 1957cdf0c1d5Smjnelson typeset -x PATH=$PATH 1958cdf0c1d5Smjnelson 1959cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.svn ]]; then 1960cdf0c1d5Smjnelson staffer svn checkout $BRINGOVER_WS $CODEMGR_WS || 1961cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1962cdf0c1d5Smjnelson else 1963cdf0c1d5Smjnelson typeset root 1964cdf0c1d5Smjnelson root=$(staffer svn info $CODEMGR_WS | 1965cdf0c1d5Smjnelson nawk '/^Repository Root:/ {print $NF}') 1966cdf0c1d5Smjnelson if [[ $root != $BRINGOVER_WS ]]; then 1967cdf0c1d5Smjnelson # We fail here because there's no way to update 1968cdf0c1d5Smjnelson # from a named repo. 1969cdf0c1d5Smjnelson cat <<-EOF 1970cdf0c1d5Smjnelson \$BRINGOVER_WS doesn't match repository root: 1971cdf0c1d5Smjnelson \$BRINGOVER_WS: $BRINGOVER_WS 1972cdf0c1d5Smjnelson Repository root: $root 1973cdf0c1d5Smjnelson EOF 1974cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1975cdf0c1d5Smjnelson else 1976cdf0c1d5Smjnelson # If a conflict happens, svn still exits 0. 1977cdf0c1d5Smjnelson staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out || 1978cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1979cdf0c1d5Smjnelson if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then 1980cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1981cdf0c1d5Smjnelson fi 1982cdf0c1d5Smjnelson fi 1983cdf0c1d5Smjnelson fi 1984cdf0c1d5Smjnelson} 1985cdf0c1d5Smjnelson 1986597bd30bSMike Kupfertype bringover_none > /dev/null 2>&1 || function bringover_none { 1987cdf0c1d5Smjnelson echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 1988cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 1989cdf0c1d5Smjnelson} 1990cdf0c1d5Smjnelson 1991cdf0c1d5Smjnelson# 1992cdf0c1d5Smjnelson# Decide whether to bringover to the codemgr workspace 1993cdf0c1d5Smjnelson# 1994cdf0c1d5Smjnelsonif [ "$n_FLAG" = "n" ]; then 1995445b6314SRichard Lowe PARENT_SCM_TYPE=$(parent_wstype) 1996ca0ac982Smjnelson 1997ca0ac982Smjnelson if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 1998ca0ac982Smjnelson echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 1999ca0ac982Smjnelson "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 2000ca0ac982Smjnelson exit 1 2001ca0ac982Smjnelson fi 2002ca0ac982Smjnelson 2003cdf0c1d5Smjnelson run_hook PRE_BRINGOVER 2004cdf0c1d5Smjnelson 2005cdf0c1d5Smjnelson echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 2006cdf0c1d5Smjnelson echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 2007cdf0c1d5Smjnelson 2008ca0ac982Smjnelson eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 2009cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 201032f1e47bSsommerfe 201132f1e47bSsommerfe if [ -f $TMPDIR/bringover_failed ]; then 201232f1e47bSsommerfe rm -f $TMPDIR/bringover_failed 201332f1e47bSsommerfe build_ok=n 201432f1e47bSsommerfe echo "trouble with bringover, quitting at `date`." | 20157c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 20167c478bd9Sstevel@tonic-gate exit 1 20177c478bd9Sstevel@tonic-gate fi 2018085d331dSkupfer 2019ca0ac982Smjnelson # 2020ca0ac982Smjnelson # It's possible that we used the bringover above to create 2021ca0ac982Smjnelson # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 2022ca0ac982Smjnelson # but should now be the same as $BRINGOVER_WS. 2023ca0ac982Smjnelson # 2024ca0ac982Smjnelson [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 2025ca0ac982Smjnelson 202647703246Ssommerfe run_hook POST_BRINGOVER 202747703246Ssommerfe 2028085d331dSkupfer check_closed_tree 2029b83ec4edSjmcp 20307c478bd9Sstevel@tonic-gateelse 20317c478bd9Sstevel@tonic-gate echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 20327c478bd9Sstevel@tonic-gatefi 20337c478bd9Sstevel@tonic-gate 2034220399b7SRoland Mainz# Safeguards 2035220399b7SRoland Mainz[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 2036220399b7SRoland Mainz[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 2037220399b7SRoland Mainz[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 2038220399b7SRoland Mainz 2039cdf0c1d5Smjnelsonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 2040cdf0c1d5Smjnelson 2041cdf0c1d5Smjnelson# System 2042cdf0c1d5Smjnelsonwhence uname | tee -a $build_environ_file >> $LOGFILE 2043cdf0c1d5Smjnelsonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 2044cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 2045cdf0c1d5Smjnelson 2046cdf0c1d5Smjnelson# make 2047cdf0c1d5Smjnelsonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 2048cdf0c1d5Smjnelson$MAKE -v | tee -a $build_environ_file >> $LOGFILE 2049cdf0c1d5Smjnelsonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 2050cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2051cdf0c1d5Smjnelson 2052cdf0c1d5Smjnelson# 2053cdf0c1d5Smjnelson# Report the compiler versions. 2054cdf0c1d5Smjnelson# 2055cdf0c1d5Smjnelson 2056cdf0c1d5Smjnelsonif [[ ! -f $SRC/Makefile ]]; then 2057cdf0c1d5Smjnelson build_ok=n 2058cdf0c1d5Smjnelson echo "\nUnable to find \"Makefile\" in $SRC." | \ 2059cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2060cdf0c1d5Smjnelson exit 1 2061cdf0c1d5Smjnelsonfi 2062cdf0c1d5Smjnelson 2063cdf0c1d5Smjnelson( cd $SRC 2064cdf0c1d5Smjnelson for target in cc-version cc64-version java-version; do 2065cdf0c1d5Smjnelson echo 2066cdf0c1d5Smjnelson # 2067cdf0c1d5Smjnelson # Put statefile somewhere we know we can write to rather than trip 2068cdf0c1d5Smjnelson # over a read-only $srcroot. 2069cdf0c1d5Smjnelson # 2070cdf0c1d5Smjnelson rm -f $TMPDIR/make-state 2071cdf0c1d5Smjnelson export SRC 2072cdf0c1d5Smjnelson if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 2073cdf0c1d5Smjnelson continue 2074cdf0c1d5Smjnelson fi 2075cdf0c1d5Smjnelson touch $TMPDIR/nocompiler 2076cdf0c1d5Smjnelson done 2077cdf0c1d5Smjnelson echo 2078cdf0c1d5Smjnelson) | tee -a $build_environ_file >> $LOGFILE 2079cdf0c1d5Smjnelson 2080cdf0c1d5Smjnelsonif [ -f $TMPDIR/nocompiler ]; then 2081cdf0c1d5Smjnelson rm -f $TMPDIR/nocompiler 2082cdf0c1d5Smjnelson build_ok=n 2083cdf0c1d5Smjnelson echo "Aborting due to missing compiler." | 2084cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2085cdf0c1d5Smjnelson exit 1 2086cdf0c1d5Smjnelsonfi 2087cdf0c1d5Smjnelson 2088cdf0c1d5Smjnelson# as 2089cdf0c1d5Smjnelsonwhence as | tee -a $build_environ_file >> $LOGFILE 2090cdf0c1d5Smjnelsonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 2091cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 2092cdf0c1d5Smjnelson 2093cdf0c1d5Smjnelson# Check that we're running a capable link-editor 2094cdf0c1d5Smjnelsonwhence ld | tee -a $build_environ_file >> $LOGFILE 2095cdf0c1d5SmjnelsonLDVER=`ld -V 2>&1` 2096cdf0c1d5Smjnelsonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 209770087ad3SRichard LoweLDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"` 2098cdf0c1d5Smjnelsonif [ `expr $LDVER \< 422` -eq 1 ]; then 2099cdf0c1d5Smjnelson echo "The link-editor needs to be at version 422 or higher to build" | \ 2100cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2101cdf0c1d5Smjnelson echo "the latest stuff. Hope your build works." | \ 2102cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2103cdf0c1d5Smjnelsonfi 2104cdf0c1d5Smjnelson 21057c478bd9Sstevel@tonic-gate# 21064e5b757fSkupfer# Build and use the workspace's tools if requested 21077c478bd9Sstevel@tonic-gate# 2108*5110237aSJosef 'Jeff' Sipekif [[ "$t_FLAG" = "y" ]]; then 21094e5b757fSkupfer set_non_debug_build_flags 21107c478bd9Sstevel@tonic-gate 21117c478bd9Sstevel@tonic-gate build_tools ${TOOLS_PROTO} 2112ead1f93eSLiane Praza if [[ $? != 0 && "$t_FLAG" = y ]]; then 21134e5b757fSkupfer use_tools $TOOLS_PROTO 21144e5b757fSkupfer fi 21157c478bd9Sstevel@tonic-gatefi 21167c478bd9Sstevel@tonic-gate 21176fec3625Sdduvall# 21186fec3625Sdduvall# copy ihv proto area in addition to the build itself 21196fec3625Sdduvall# 21206fec3625Sdduvallif [ "$X_FLAG" = "y" ]; then 21216fec3625Sdduvall copy_ihv_proto 21226fec3625Sdduvallfi 21236fec3625Sdduvall 21244e5b757fSkupfer# timestamp the start of the normal build; the findunref tool uses it. 21254e5b757fSkupfertouch $SRC/.build.tstamp 21264e5b757fSkupfer 21277c478bd9Sstevel@tonic-gatenormal_build 21285d715dd7Skupfer 21297c478bd9Sstevel@tonic-gateORIG_SRC=$SRC 21307c478bd9Sstevel@tonic-gateBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 21317c478bd9Sstevel@tonic-gate 21327c478bd9Sstevel@tonic-gate 21334e5b757fSkupfer# 21344e5b757fSkupfer# There are several checks that need to look at the proto area, but 21354e5b757fSkupfer# they only need to look at one, and they don't care whether it's 21364e5b757fSkupfer# DEBUG or non-DEBUG. 21374e5b757fSkupfer# 21384e5b757fSkupferif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 21394e5b757fSkupfer checkroot=$ROOT-nd 21404e5b757fSkupferelse 21414e5b757fSkupfer checkroot=$ROOT 21424e5b757fSkupferfi 21434e5b757fSkupfer 21447c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 21457c478bd9Sstevel@tonic-gate echo "\n==== Creating protolist system file at `date` ====" \ 21467c478bd9Sstevel@tonic-gate >> $LOGFILE 21474e5b757fSkupfer protolist $checkroot > $ATLOG/proto_list_${MACH} 21487c478bd9Sstevel@tonic-gate echo "==== protolist system file created at `date` ====\n" \ 21497c478bd9Sstevel@tonic-gate >> $LOGFILE 21507c478bd9Sstevel@tonic-gate 21517c478bd9Sstevel@tonic-gate if [ "$N_FLAG" != "y" ]; then 21527c478bd9Sstevel@tonic-gate 2153ead1f93eSLiane Praza E1= 2154ead1f93eSLiane Praza f1= 2155ead1f93eSLiane Praza if [ -d "$SRC/pkgdefs" ]; then 2156ead1f93eSLiane Praza f1="$SRC/pkgdefs/etc/exception_list_$MACH" 2157ead1f93eSLiane Praza if [ "$X_FLAG" = "y" ]; then 2158ead1f93eSLiane Praza f1="$f1 $IA32_IHV_WS/usr/src/pkgdefs/etc/exception_list_$MACH" 21597c478bd9Sstevel@tonic-gate fi 21606fec3625Sdduvall fi 21617c478bd9Sstevel@tonic-gate 2162ead1f93eSLiane Praza for f in $f1; do 2163ead1f93eSLiane Praza if [ -f "$f" ]; then 2164ead1f93eSLiane Praza E1="$E1 -e $f" 2165ead1f93eSLiane Praza fi 2166ead1f93eSLiane Praza done 2167ead1f93eSLiane Praza 2168ead1f93eSLiane Praza E2= 2169ead1f93eSLiane Praza f2= 2170ead1f93eSLiane Praza if [ -d "$SRC/pkg" ]; then 2171ead1f93eSLiane Praza f2="$f2 exceptions/packaging" 2172ead1f93eSLiane Praza fi 2173ead1f93eSLiane Praza 2174ead1f93eSLiane Praza for f in $f2; do 2175ead1f93eSLiane Praza if [ -f "$f" ]; then 2176ead1f93eSLiane Praza E2="$E2 -e $f" 2177ead1f93eSLiane Praza fi 2178ead1f93eSLiane Praza done 2179ead1f93eSLiane Praza 21807c478bd9Sstevel@tonic-gate if [ -f "$REF_PROTO_LIST" ]; then 2181ead1f93eSLiane Praza # 2182b4add148Sdduvall # For builds that copy the IHV proto area (-X), add the 2183b4add148Sdduvall # IHV proto list to the reference list if the reference 2184b4add148Sdduvall # was built without -X. 2185b4add148Sdduvall # 2186b4add148Sdduvall # For builds that don't copy the IHV proto area, add the 2187b4add148Sdduvall # IHV proto list to the build's proto list if the 2188b4add148Sdduvall # reference was built with -X. 2189b4add148Sdduvall # 2190b4add148Sdduvall # Use the presence of the first file entry of the cached 2191b4add148Sdduvall # IHV proto list in the reference list to determine 2192ead1f93eSLiane Praza # whether it was built with -X or not. 2193ead1f93eSLiane Praza # 2194a51a9b36SMark J. Nelson IHV_REF_PROTO_LIST=$SRC/pkg/proto_list_ihv_$MACH 2195b4add148Sdduvall grepfor=$(nawk '$1 == "f" { print $2; exit }' \ 2196b4add148Sdduvall $IHV_REF_PROTO_LIST 2> /dev/null) 2197b4add148Sdduvall if [ $? = 0 -a -n "$grepfor" ]; then 2198b4add148Sdduvall if [ "$X_FLAG" = "y" ]; then 2199b4add148Sdduvall grep -w "$grepfor" \ 2200b4add148Sdduvall $REF_PROTO_LIST > /dev/null 2201b4add148Sdduvall if [ ! "$?" = "0" ]; then 2202b4add148Sdduvall REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST" 2203b4add148Sdduvall fi 2204b4add148Sdduvall else 2205b4add148Sdduvall grep -w "$grepfor" \ 2206b4add148Sdduvall $REF_PROTO_LIST > /dev/null 2207b4add148Sdduvall if [ "$?" = "0" ]; then 2208b4add148Sdduvall IHV_PROTO_LIST="$IHV_REF_PROTO_LIST" 2209b4add148Sdduvall fi 2210b4add148Sdduvall fi 2211b4add148Sdduvall fi 2212ead1f93eSLiane Praza fi 2213ead1f93eSLiane Praza fi 2214b4add148Sdduvall 221587916a32SMark J. Nelson if [ "$N_FLAG" != "y" -a -f $SRC/pkgdefs/Makefile ]; then 2216ead1f93eSLiane Praza echo "\n==== Impact on SVr4 packages ====\n" >> $mail_msg_file 2217ead1f93eSLiane Praza # 2218ead1f93eSLiane Praza # Compare the build's proto list with current package 2219ead1f93eSLiane Praza # definitions to audit the quality of package 2220ead1f93eSLiane Praza # definitions and makefile install targets. Use the 2221ead1f93eSLiane Praza # current exception list. 2222ead1f93eSLiane Praza # 2223ead1f93eSLiane Praza PKGDEFS_LIST="" 2224ead1f93eSLiane Praza for d in $abssrcdirs; do 2225ead1f93eSLiane Praza if [ -d $d/pkgdefs ]; then 2226ead1f93eSLiane Praza PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs" 2227ead1f93eSLiane Praza fi 2228ead1f93eSLiane Praza done 2229ead1f93eSLiane Praza if [ "$X_FLAG" = "y" -a \ 2230ead1f93eSLiane Praza -d $IA32_IHV_WS/usr/src/pkgdefs ]; then 2231ead1f93eSLiane Praza PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs" 2232ead1f93eSLiane Praza fi 2233ead1f93eSLiane Praza $PROTOCMPTERSE \ 2234ead1f93eSLiane Praza "Files missing from the proto area:" \ 2235ead1f93eSLiane Praza "Files missing from packages:" \ 2236ead1f93eSLiane Praza "Inconsistencies between pkgdefs and proto area:" \ 2237ead1f93eSLiane Praza ${E1} \ 2238ead1f93eSLiane Praza ${PKGDEFS_LIST} \ 2239ead1f93eSLiane Praza $ATLOG/proto_list_${MACH} \ 2240ead1f93eSLiane Praza >> $mail_msg_file 2241ead1f93eSLiane Praza fi 2242ead1f93eSLiane Praza 2243ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 2244ead1f93eSLiane Praza echo "\n==== Validating manifests against proto area ====\n" \ 2245ead1f93eSLiane Praza >> $mail_msg_file 2246ead1f93eSLiane Praza ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) \ 2247ead1f93eSLiane Praza >> $mail_msg_file 2248ead1f93eSLiane Praza 2249ead1f93eSLiane Praza fi 2250ead1f93eSLiane Praza 2251ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 2252ead1f93eSLiane Praza echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 2253ead1f93eSLiane Praza if [ -n "$E2" ]; then 2254ead1f93eSLiane Praza ELIST=$E2 2255ead1f93eSLiane Praza else 2256ead1f93eSLiane Praza ELIST=$E1 2257ead1f93eSLiane Praza fi 22587c478bd9Sstevel@tonic-gate $PROTOCMPTERSE \ 22597c478bd9Sstevel@tonic-gate "Files in yesterday's proto area, but not today's:" \ 22607c478bd9Sstevel@tonic-gate "Files in today's proto area, but not yesterday's:" \ 22617c478bd9Sstevel@tonic-gate "Files that changed between yesterday and today:" \ 22627c478bd9Sstevel@tonic-gate ${ELIST} \ 22637c478bd9Sstevel@tonic-gate -d $REF_PROTO_LIST \ 2264b4add148Sdduvall $REF_IHV_PROTO \ 22657c478bd9Sstevel@tonic-gate $ATLOG/proto_list_${MACH} \ 2266b4add148Sdduvall $IHV_PROTO_LIST \ 22677c478bd9Sstevel@tonic-gate >> $mail_msg_file 22687c478bd9Sstevel@tonic-gate fi 22697c478bd9Sstevel@tonic-gatefi 22707c478bd9Sstevel@tonic-gate 22717c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 22727c478bd9Sstevel@tonic-gate staffer cp $ATLOG/proto_list_${MACH} \ 22737c478bd9Sstevel@tonic-gate $PARENT_WS/usr/src/proto_list_${MACH} 22747c478bd9Sstevel@tonic-gatefi 22757c478bd9Sstevel@tonic-gate 22767c478bd9Sstevel@tonic-gate# Update parent proto area if necessary. This is done now 22777c478bd9Sstevel@tonic-gate# so that the proto area has either DEBUG or non-DEBUG kernels. 22787c478bd9Sstevel@tonic-gate# Note that this clears out the lock file, so we can dispense with 22797c478bd9Sstevel@tonic-gate# the variable now. 22807c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 22817c478bd9Sstevel@tonic-gate echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 22827c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 2283ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT/* 22847c478bd9Sstevel@tonic-gate unset Ulockfile 22857c478bd9Sstevel@tonic-gate mkdir -p $NIGHTLY_PARENT_ROOT 22864e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 2287ead1f93eSLiane Praza ( cd $ROOT; tar cf - . | 22884e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 22897c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 22907c478bd9Sstevel@tonic-gate fi 22914e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 2292ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT-nd/* 22934e5b757fSkupfer mkdir -p $NIGHTLY_PARENT_ROOT-nd 22944e5b757fSkupfer cd $ROOT-nd 22954e5b757fSkupfer ( tar cf - . | 22964e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 22974e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 22984e5b757fSkupfer fi 22996798c3f0SMark J. Nelson if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 2300ead1f93eSLiane Praza echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 2301ead1f93eSLiane Praza tee -a $LOGFILE >> $mail_msg_file 2302ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 2303ead1f93eSLiane Praza mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 2304ead1f93eSLiane Praza if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 2305ead1f93eSLiane Praza ( cd $TOOLS_PROTO; tar cf - . | 23066798c3f0SMark J. Nelson ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 23076798c3f0SMark J. Nelson umask 0; tar xpf - ) ) 2>&1 | 2308ead1f93eSLiane Praza tee -a $mail_msg_file >> $LOGFILE 2309ead1f93eSLiane Praza fi 23104e5b757fSkupfer fi 23116798c3f0SMark J. Nelsonfi 23127c478bd9Sstevel@tonic-gate 23137c478bd9Sstevel@tonic-gate# 231475ce41a5SAli Bahrami# ELF verification: ABI (-A) and runtime (-r) checks 23157c478bd9Sstevel@tonic-gate# 231675ce41a5SAli Bahramiif [[ ($build_ok = y) && ( ($A_FLAG = y) || ($r_FLAG = y) ) ]]; then 231775ce41a5SAli Bahrami # Directory ELF-data.$MACH holds the files produced by these tests. 231875ce41a5SAli Bahrami elf_ddir=$SRC/ELF-data.$MACH 23197c478bd9Sstevel@tonic-gate 232075ce41a5SAli Bahrami # If there is a previous ELF-data backup directory, remove it. Then, 232175ce41a5SAli Bahrami # rotate current ELF-data directory into its place and create a new 232275ce41a5SAli Bahrami # empty directory 232375ce41a5SAli Bahrami rm -rf $elf_ddir.ref 232475ce41a5SAli Bahrami if [[ -d $elf_ddir ]]; then 232575ce41a5SAli Bahrami mv $elf_ddir $elf_ddir.ref 232675ce41a5SAli Bahrami fi 232775ce41a5SAli Bahrami mkdir -p $elf_ddir 232875ce41a5SAli Bahrami 232975ce41a5SAli Bahrami # Call find_elf to produce a list of the ELF objects in the proto area. 233075ce41a5SAli Bahrami # This list is passed to check_rtime and interface_check, preventing 233175ce41a5SAli Bahrami # them from separately calling find_elf to do the same work twice. 233275ce41a5SAli Bahrami find_elf -fr $checkroot > $elf_ddir/object_list 233375ce41a5SAli Bahrami 233475ce41a5SAli Bahrami if [[ $A_FLAG = y ]]; then 23357c478bd9Sstevel@tonic-gate echo "\n==== Check versioning and ABI information ====\n" | \ 23367c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 23377c478bd9Sstevel@tonic-gate 233875ce41a5SAli Bahrami # Produce interface description for the proto. Report errors. 233975ce41a5SAli Bahrami interface_check -o -w $elf_ddir -f object_list \ 234075ce41a5SAli Bahrami -i interface -E interface.err 234175ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.err ]]; then 234275ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/interface.err \ 234375ce41a5SAli Bahrami >> $mail_msg_file 23447c478bd9Sstevel@tonic-gate fi 23457c478bd9Sstevel@tonic-gate 23465253169eSAli Bahrami # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 23475253169eSAli Bahrami # description file to that from the baseline gate. Issue a 23485253169eSAli Bahrami # warning if the baseline is not present, and keep going. 23495253169eSAli Bahrami if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 23505253169eSAli Bahrami base_ifile="$ELF_DATA_BASELINE_DIR/interface" 23517c478bd9Sstevel@tonic-gate 23525253169eSAli Bahrami echo "\n==== Compare versioning and ABI information" \ 2353e599109eSAli Bahrami "to baseline ====\n" | \ 23545253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 2355e599109eSAli Bahrami echo "Baseline: $base_ifile\n" >> $LOGFILE 23565253169eSAli Bahrami 23575253169eSAli Bahrami if [[ -f $base_ifile ]]; then 23585253169eSAli Bahrami interface_cmp -d -o $base_ifile \ 235975ce41a5SAli Bahrami $elf_ddir/interface > $elf_ddir/interface.cmp 236075ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.cmp ]]; then 23615253169eSAli Bahrami echo | tee -a $LOGFILE >> $mail_msg_file 23625253169eSAli Bahrami tee -a $LOGFILE < \ 23635253169eSAli Bahrami $elf_ddir/interface.cmp \ 236475ce41a5SAli Bahrami >> $mail_msg_file 23657c478bd9Sstevel@tonic-gate fi 23665253169eSAli Bahrami else 23675253169eSAli Bahrami echo "baseline not available. comparison" \ 23685253169eSAli Bahrami "skipped" | \ 23695253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 23705253169eSAli Bahrami fi 23715253169eSAli Bahrami 23725253169eSAli Bahrami fi 23737c478bd9Sstevel@tonic-gate fi 23747c478bd9Sstevel@tonic-gate 237575ce41a5SAli Bahrami if [[ $r_FLAG = y ]]; then 23767c478bd9Sstevel@tonic-gate echo "\n==== Check ELF runtime attributes ====\n" | \ 23777c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 23787c478bd9Sstevel@tonic-gate 2379ead1f93eSLiane Praza # If we're doing a DEBUG build the proto area will be left 238075ce41a5SAli Bahrami # with debuggable objects, thus don't assert -s. 238175ce41a5SAli Bahrami if [[ $D_FLAG = y ]]; then 23827c478bd9Sstevel@tonic-gate rtime_sflag="" 23837c478bd9Sstevel@tonic-gate else 23847c478bd9Sstevel@tonic-gate rtime_sflag="-s" 23857c478bd9Sstevel@tonic-gate fi 238675ce41a5SAli Bahrami check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 238775ce41a5SAli Bahrami -D object_list -f object_list -E runtime.err \ 2388622090e3SAli Bahrami -I runtime.attr.raw 2389622090e3SAli Bahrami 2390622090e3SAli Bahrami # check_rtime -I output needs to be sorted in order to 2391622090e3SAli Bahrami # compare it to that from previous builds. 2392622090e3SAli Bahrami sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 2393622090e3SAli Bahrami rm $elf_ddir/runtime.attr.raw 23947c478bd9Sstevel@tonic-gate 239575ce41a5SAli Bahrami # Report errors 239675ce41a5SAli Bahrami if [[ -s $elf_ddir/runtime.err ]]; then 239775ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/runtime.err \ 23987c478bd9Sstevel@tonic-gate >> $mail_msg_file 239975ce41a5SAli Bahrami fi 24007c478bd9Sstevel@tonic-gate 240175ce41a5SAli Bahrami # If there is an ELF-data directory from a previous build, 240275ce41a5SAli Bahrami # then diff the attr files. These files contain information 240375ce41a5SAli Bahrami # about dependencies, versioning, and runpaths. There is some 240475ce41a5SAli Bahrami # overlap with the ABI checking done above, but this also 240575ce41a5SAli Bahrami # flushes out non-ABI interface differences along with the 240675ce41a5SAli Bahrami # other information. 240775ce41a5SAli Bahrami echo "\n==== Diff ELF runtime attributes" \ 240875ce41a5SAli Bahrami "(since last build) ====\n" | \ 240975ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 241075ce41a5SAli Bahrami 241175ce41a5SAli Bahrami if [[ -f $elf_ddir.ref/runtime.attr ]]; then 241275ce41a5SAli Bahrami diff $elf_ddir.ref/runtime.attr \ 241375ce41a5SAli Bahrami $elf_ddir/runtime.attr \ 241475ce41a5SAli Bahrami >> $mail_msg_file 241575ce41a5SAli Bahrami fi 241675ce41a5SAli Bahrami fi 24175253169eSAli Bahrami 24185253169eSAli Bahrami # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 24195253169eSAli Bahrami if [[ "$u_FLAG" = "y" ]]; then 24205253169eSAli Bahrami p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 24215253169eSAli Bahrami 24225253169eSAli Bahrami # If parent lacks the ELF-data.$MACH directory, create it 24235253169eSAli Bahrami if [[ ! -d $p_elf_ddir ]]; then 24245253169eSAli Bahrami staffer mkdir -p $p_elf_ddir 24255253169eSAli Bahrami fi 24265253169eSAli Bahrami 24275253169eSAli Bahrami # These files are used asynchronously by other builds for ABI 24285253169eSAli Bahrami # verification, as above for the -A option. As such, we require 24295253169eSAli Bahrami # the file replacement to be atomic. Copy the data to a temp 24305253169eSAli Bahrami # file in the same filesystem and then rename into place. 24315253169eSAli Bahrami ( 24325253169eSAli Bahrami cd $elf_ddir 24335253169eSAli Bahrami for elf_dfile in *; do 24345253169eSAli Bahrami staffer cp $elf_dfile \ 24355253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile}.new 24365253169eSAli Bahrami staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 24375253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile} 24385253169eSAli Bahrami done 24395253169eSAli Bahrami ) 24405253169eSAli Bahrami fi 24417c478bd9Sstevel@tonic-gatefi 24427c478bd9Sstevel@tonic-gate 24437c478bd9Sstevel@tonic-gate# DEBUG lint of kernel begins 24447c478bd9Sstevel@tonic-gate 24457c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 24467c478bd9Sstevel@tonic-gate if [ "$LINTDIRS" = "" ]; then 24477c478bd9Sstevel@tonic-gate # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 24487c478bd9Sstevel@tonic-gate LINTDIRS="$SRC y" 24497c478bd9Sstevel@tonic-gate fi 24507c478bd9Sstevel@tonic-gate set $LINTDIRS 24517c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 24527c478bd9Sstevel@tonic-gate dolint $1 $2; shift; shift 24537c478bd9Sstevel@tonic-gate done 24547c478bd9Sstevel@tonic-gateelse 24557c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 24567c478bd9Sstevel@tonic-gatefi 24577c478bd9Sstevel@tonic-gate 24587c478bd9Sstevel@tonic-gate# "make check" begins 24597c478bd9Sstevel@tonic-gate 24607c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 24617c478bd9Sstevel@tonic-gate # remove old check.out 24627c478bd9Sstevel@tonic-gate rm -f $SRC/check.out 24637c478bd9Sstevel@tonic-gate 24647c478bd9Sstevel@tonic-gate rm -f $SRC/check-${MACH}.out 24657c478bd9Sstevel@tonic-gate cd $SRC 2466170832d3SAlbert Lee $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \ 2467170832d3SAlbert Lee >> $LOGFILE 24687c478bd9Sstevel@tonic-gate echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 24697c478bd9Sstevel@tonic-gate 24707c478bd9Sstevel@tonic-gate grep ":" $SRC/check-${MACH}.out | 24717c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 24727c478bd9Sstevel@tonic-gate sort | uniq >> $mail_msg_file 24737c478bd9Sstevel@tonic-gateelse 24747c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 24757c478bd9Sstevel@tonic-gatefi 24767c478bd9Sstevel@tonic-gate 24777c478bd9Sstevel@tonic-gateecho "\n==== Find core files ====\n" | \ 24787c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 24797c478bd9Sstevel@tonic-gate 2480fb23a357Skupferfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 24817c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 24827c478bd9Sstevel@tonic-gate 24837c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 24847c478bd9Sstevel@tonic-gate echo "\n==== Diff unreferenced files (since last build) ====\n" \ 24857c478bd9Sstevel@tonic-gate | tee -a $LOGFILE >>$mail_msg_file 24867c478bd9Sstevel@tonic-gate rm -f $SRC/unref-${MACH}.ref 24877c478bd9Sstevel@tonic-gate if [ -f $SRC/unref-${MACH}.out ]; then 24887c478bd9Sstevel@tonic-gate mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 24897c478bd9Sstevel@tonic-gate fi 24907c478bd9Sstevel@tonic-gate 24919730304dSmeem findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 2492cdf0c1d5Smjnelson ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 24939730304dSmeem sort > $SRC/unref-${MACH}.out 24947c478bd9Sstevel@tonic-gate 24957c478bd9Sstevel@tonic-gate if [ ! -f $SRC/unref-${MACH}.ref ]; then 24967c478bd9Sstevel@tonic-gate cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 24977c478bd9Sstevel@tonic-gate fi 24987c478bd9Sstevel@tonic-gate 24997c478bd9Sstevel@tonic-gate diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 25007c478bd9Sstevel@tonic-gatefi 25017c478bd9Sstevel@tonic-gate 25025d715dd7Skupfer# 25035d715dd7Skupfer# Generate the OpenSolaris deliverables if requested. Some of these 25045d715dd7Skupfer# steps need to come after findunref and are commented below. 25055d715dd7Skupfer# 2506597bd30bSMike Kupfer 25077c478bd9Sstevel@tonic-gate# Verify that the usual lists of files, such as exception lists, 25087c478bd9Sstevel@tonic-gate# contain only valid references to files. If the build has failed, 25097c478bd9Sstevel@tonic-gate# then don't check the proto area. 25107c478bd9Sstevel@tonic-gateCHECK_PATHS=${CHECK_PATHS:-y} 25117c478bd9Sstevel@tonic-gateif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 25127c478bd9Sstevel@tonic-gate echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 25137c478bd9Sstevel@tonic-gate >>$mail_msg_file 25147c478bd9Sstevel@tonic-gate arg=-b 25157c478bd9Sstevel@tonic-gate [ "$build_ok" = y ] && arg= 25164e5b757fSkupfer checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file 25177c478bd9Sstevel@tonic-gatefi 25187c478bd9Sstevel@tonic-gate 25197c478bd9Sstevel@tonic-gateif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 25207c478bd9Sstevel@tonic-gate echo "\n==== Impact on file permissions ====\n" \ 25217c478bd9Sstevel@tonic-gate >> $mail_msg_file 2522ead1f93eSLiane Praza 2523ead1f93eSLiane Praza abspkgdefs= 2524ead1f93eSLiane Praza abspkg= 2525ead1f93eSLiane Praza for d in $abssrcdirs; do 2526ead1f93eSLiane Praza if [ -d "$d/pkgdefs" ]; then 2527ead1f93eSLiane Praza abspkgdefs="$abspkgdefs $d" 25287c478bd9Sstevel@tonic-gate fi 2529ead1f93eSLiane Praza if [ -d "$d/pkg" ]; then 2530ead1f93eSLiane Praza abspkg="$abspkg $d" 2531ead1f93eSLiane Praza fi 2532ead1f93eSLiane Praza done 2533ead1f93eSLiane Praza 2534ead1f93eSLiane Praza if [ -n "$abspkgdefs" ]; then 2535ead1f93eSLiane Praza pmodes -qvdP \ 2536ead1f93eSLiane Praza `find $abspkgdefs -name pkginfo.tmpl -print -o \ 2537ead1f93eSLiane Praza -name .del\* -prune | sed -e 's:/pkginfo.tmpl$::' | \ 2538ead1f93eSLiane Praza sort -u` >> $mail_msg_file 2539ead1f93eSLiane Praza fi 2540ead1f93eSLiane Praza 2541ead1f93eSLiane Praza if [ -n "$abspkg" ]; then 2542ead1f93eSLiane Praza for d in "$abspkg"; do 2543ead1f93eSLiane Praza ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 2544ead1f93eSLiane Praza done 2545ead1f93eSLiane Praza fi 25467c478bd9Sstevel@tonic-gatefi 25477c478bd9Sstevel@tonic-gate 254896ccc8cbSesaxeif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 25494e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 25504e5b757fSkupfer do_wsdiff DEBUG $ROOT.prev $ROOT 25514e5b757fSkupfer fi 255296ccc8cbSesaxe 25534e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 25544e5b757fSkupfer do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 255596ccc8cbSesaxe fi 255696ccc8cbSesaxefi 255796ccc8cbSesaxe 25587c478bd9Sstevel@tonic-gateEND_DATE=`date` 25597c478bd9Sstevel@tonic-gateecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 25607c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 25617c478bd9Sstevel@tonic-gate 2562c341b28aSDarren Moffattypeset -i10 hours 25637c478bd9Sstevel@tonic-gatetypeset -Z2 minutes 25647c478bd9Sstevel@tonic-gatetypeset -Z2 seconds 25657c478bd9Sstevel@tonic-gate 25667c478bd9Sstevel@tonic-gateelapsed_time=$SECONDS 25677c478bd9Sstevel@tonic-gate((hours = elapsed_time / 3600 )) 25687c478bd9Sstevel@tonic-gate((minutes = elapsed_time / 60 % 60)) 25697c478bd9Sstevel@tonic-gate((seconds = elapsed_time % 60)) 25707c478bd9Sstevel@tonic-gate 25717c478bd9Sstevel@tonic-gateecho "\n==== Total build time ====" | \ 25727c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 25737c478bd9Sstevel@tonic-gateecho "\nreal ${hours}:${minutes}:${seconds}" | \ 25747c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 25757c478bd9Sstevel@tonic-gate 25767c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 25777c478bd9Sstevel@tonic-gate staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 25787c478bd9Sstevel@tonic-gate 25797c478bd9Sstevel@tonic-gate # 25807c478bd9Sstevel@tonic-gate # Produce a master list of unreferenced files -- ideally, we'd 25817c478bd9Sstevel@tonic-gate # generate the master just once after all of the nightlies 25827c478bd9Sstevel@tonic-gate # have finished, but there's no simple way to know when that 25837c478bd9Sstevel@tonic-gate # will be. Instead, we assume that we're the last nightly to 25847c478bd9Sstevel@tonic-gate # finish and merge all of the unref-${MACH}.out files in 25857c478bd9Sstevel@tonic-gate # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 25867c478bd9Sstevel@tonic-gate # finish, then this file will be the authoritative master 25877c478bd9Sstevel@tonic-gate # list. Otherwise, another ${MACH}'s nightly will eventually 25887c478bd9Sstevel@tonic-gate # overwrite ours with its own master, but in the meantime our 25897c478bd9Sstevel@tonic-gate # temporary "master" will be no worse than any older master 25907c478bd9Sstevel@tonic-gate # which was already on the parent. 25917c478bd9Sstevel@tonic-gate # 25927c478bd9Sstevel@tonic-gate 25937c478bd9Sstevel@tonic-gate set -- $PARENT_WS/usr/src/unref-*.out 25947c478bd9Sstevel@tonic-gate cp "$1" ${TMPDIR}/unref.merge 25957c478bd9Sstevel@tonic-gate shift 25967c478bd9Sstevel@tonic-gate 25977c478bd9Sstevel@tonic-gate for unreffile; do 25987c478bd9Sstevel@tonic-gate comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 25997c478bd9Sstevel@tonic-gate mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 26007c478bd9Sstevel@tonic-gate done 26017c478bd9Sstevel@tonic-gate 26027c478bd9Sstevel@tonic-gate staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 26037c478bd9Sstevel@tonic-gatefi 26047c478bd9Sstevel@tonic-gate 26057c478bd9Sstevel@tonic-gate# 26067c478bd9Sstevel@tonic-gate# All done save for the sweeping up. 26077c478bd9Sstevel@tonic-gate# (whichever exit we hit here will trigger the "cleanup" trap which 26087c478bd9Sstevel@tonic-gate# optionally sends mail on completion). 26097c478bd9Sstevel@tonic-gate# 26107c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 26117c478bd9Sstevel@tonic-gate exit 0 26127c478bd9Sstevel@tonic-gatefi 26137c478bd9Sstevel@tonic-gateexit 1 2614