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. 25*445b6314SRichard Lowe# Copyright 2008, 2010, Richard Lowe 267c478bd9Sstevel@tonic-gate# 277c478bd9Sstevel@tonic-gate# Based on the nightly script from the integration folks, 287c478bd9Sstevel@tonic-gate# Mostly modified and owned by mike_s. 297c478bd9Sstevel@tonic-gate# Changes also by kjc, dmk. 307c478bd9Sstevel@tonic-gate# 317c478bd9Sstevel@tonic-gate# BRINGOVER_WS may be specified in the env file. 327c478bd9Sstevel@tonic-gate# The default is the old behavior of CLONE_WS 337c478bd9Sstevel@tonic-gate# 347c478bd9Sstevel@tonic-gate# -i on the command line, means fast options, so when it's on the 35d77e7149Ssommerfe# command line (only), lint and check builds are skipped no matter what 36d77e7149Ssommerfe# the setting of their individual flags are in NIGHTLY_OPTIONS. 377c478bd9Sstevel@tonic-gate# 387c478bd9Sstevel@tonic-gate# LINTDIRS can be set in the env file, format is a list of: 397c478bd9Sstevel@tonic-gate# 407c478bd9Sstevel@tonic-gate# /dirname-to-run-lint-on flag 417c478bd9Sstevel@tonic-gate# 427c478bd9Sstevel@tonic-gate# Where flag is: y - enable lint noise diff output 437c478bd9Sstevel@tonic-gate# n - disable lint noise diff output 447c478bd9Sstevel@tonic-gate# 457c478bd9Sstevel@tonic-gate# For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y" 467c478bd9Sstevel@tonic-gate# 477c478bd9Sstevel@tonic-gate# OPTHOME and TEAMWARE may be set in the environment to override /opt 487c478bd9Sstevel@tonic-gate# and /opt/teamware defaults. 497c478bd9Sstevel@tonic-gate# 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate# 527c478bd9Sstevel@tonic-gate# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 537c478bd9Sstevel@tonic-gate# under certain circumstances, which can really screw things up; unset it. 547c478bd9Sstevel@tonic-gate# 557c478bd9Sstevel@tonic-gateunset CDPATH 567c478bd9Sstevel@tonic-gate 57cdf0c1d5Smjnelson# Get the absolute path of the nightly script that the user invoked. This 58cdf0c1d5Smjnelson# may be a relative path, and we need to do this before changing directory. 59cdf0c1d5Smjnelsonnightly_path=`whence $0` 6030635de9SJohn.Zolnowsky@Sun.COMnightly_ls="`ls -l $nightly_path`" 61cdf0c1d5Smjnelson 62cdf0c1d5Smjnelson# 63cdf0c1d5Smjnelson# Keep track of where we found nightly so we can invoke the matching 64cdf0c1d5Smjnelson# which_scm script. If that doesn't work, don't go guessing, just rely 65cdf0c1d5Smjnelson# on the $PATH settings, which will generally give us either /opt/onbld 66cdf0c1d5Smjnelson# or the user's workspace. 67cdf0c1d5Smjnelson# 68cdf0c1d5SmjnelsonWHICH_SCM=$(dirname $nightly_path)/which_scm 69cdf0c1d5Smjnelsonif [[ ! -x $WHICH_SCM ]]; then 70cdf0c1d5Smjnelson WHICH_SCM=which_scm 71cdf0c1d5Smjnelsonfi 72cdf0c1d5Smjnelson 734e5b757fSkupfer# 74597bd30bSMike Kupfer# Datestamp for crypto tarballs. We don't use BUILD_DATE because it 75597bd30bSMike Kupfer# doesn't sort right and it uses English abbreviations for the month. 76597bd30bSMike Kupfer# We want to guarantee a consistent string, so just invoke date(1) 77597bd30bSMike Kupfer# once and save the result in a global variable. YYYY-MM-DD is easier 78597bd30bSMike Kupfer# to parse visually than YYYYMMDD. 79597bd30bSMike Kupfer# 80597bd30bSMike Kupfercryptostamp=$(date +%Y-%m-%d) 81597bd30bSMike Kupfer 82597bd30bSMike Kupfer# 83597bd30bSMike Kupfer# Echo the path for depositing a crypto tarball, creating the target 84597bd30bSMike Kupfer# directory if it doesn't already exist. 85597bd30bSMike Kupfer# usage: cryptodest suffix 86597bd30bSMike Kupfer# where "suffix" is "" or "-nd". 87597bd30bSMike Kupfer# 88597bd30bSMike Kupferfunction cryptodest { 89597bd30bSMike Kupfer typeset suffix=$1 90597bd30bSMike Kupfer # 91597bd30bSMike Kupfer # $PKGARCHIVE gets wiped out with each build, so put the 92597bd30bSMike Kupfer # tarball one level up. 93597bd30bSMike Kupfer # 94597bd30bSMike Kupfer typeset dir=$(dirname "$PKGARCHIVE") 95597bd30bSMike Kupfer [ -d "$dir" ] || mkdir -p "$dir" >> "$LOGFILE" 2>&1 96597bd30bSMike Kupfer # 97597bd30bSMike Kupfer # Put the suffix after the datestamp to make it easier for 98597bd30bSMike Kupfer # gatelings to use crypto from a specific date (no need to 99597bd30bSMike Kupfer # copy and rename the gate tarball). 100597bd30bSMike Kupfer # 101597bd30bSMike Kupfer echo "$dir/on-crypto-$cryptostamp$suffix.$MACH.tar" 102597bd30bSMike Kupfer} 103597bd30bSMike Kupfer 104597bd30bSMike Kupfer# 105597bd30bSMike Kupfer# Create a non-stamped symlink to the given crypto tarball. 106597bd30bSMike Kupfer# Return 0 on success, non-zero on failure. 107597bd30bSMike Kupfer# 108597bd30bSMike Kupferfunction cryptolink { 109597bd30bSMike Kupfer typeset targpath=$1 110597bd30bSMike Kupfer typeset suffix=$2 111597bd30bSMike Kupfer if [ ! -f "$targpath" ]; then 112597bd30bSMike Kupfer echo "no crypto at $targpath" 113597bd30bSMike Kupfer return 1 114597bd30bSMike Kupfer fi 115597bd30bSMike Kupfer typeset dir=$(dirname "$targpath") 116597bd30bSMike Kupfer typeset targfile=$(basename "$targpath") 117597bd30bSMike Kupfer typeset link=on-crypto$suffix.$MACH.tar.bz2 118597bd30bSMike Kupfer (cd "$dir"; rm -f "$link") 119597bd30bSMike Kupfer (cd "$dir"; ln -s "$targfile" "$link") 120597bd30bSMike Kupfer return $? 121597bd30bSMike Kupfer} 122597bd30bSMike Kupfer 123597bd30bSMike Kupfer# 124597bd30bSMike Kupfer# Generate a crypto tarball from the proto area and put it in the 125597bd30bSMike Kupfer# canonical location, along with the datestamp-free symlink. 126597bd30bSMike Kupfer# Sets build_ok to "n" if there is a problem. 127597bd30bSMike Kupfer# 128597bd30bSMike Kupferfunction crypto_from_proto { 129597bd30bSMike Kupfer typeset label=$1 130597bd30bSMike Kupfer typeset suffix=$2 131597bd30bSMike Kupfer typeset -i stat 132597bd30bSMike Kupfer typeset to 133597bd30bSMike Kupfer 134597bd30bSMike Kupfer echo "Creating $label crypto tarball..." >> "$LOGFILE" 135597bd30bSMike Kupfer 136597bd30bSMike Kupfer # 137597bd30bSMike Kupfer # Generate the crypto THIRDPARTYLICENSE file. This needs to 138597bd30bSMike Kupfer # be done after the build has finished and before we run 139597bd30bSMike Kupfer # cryptodrop. We'll generate the file twice if we're building 140ead1f93eSLiane Praza # both DEBUG and non-DEBUG, but it's a cheap operation and not 141597bd30bSMike Kupfer # worth the complexity to only do once. 142597bd30bSMike Kupfer # 1435b40bb4eSMark J. Nelson if [ -d ${ROOT}${suffix}/licenses/usr ]; then 1445b40bb4eSMark J. Nelson ( cd ${ROOT}${suffix}/licenses ; \ 1455084e753SMark J. Nelson mktpl -c $SRC/pkg/license-list ) >> "$LOGFILE" 2>&1 146597bd30bSMike Kupfer if (( $? != 0 )) ; then 1475084e753SMark J. Nelson echo "Couldn't create crypto THIRDPARTYLICENSE files" | 148597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 149597bd30bSMike Kupfer build_ok=n 150597bd30bSMike Kupfer return 151597bd30bSMike Kupfer fi 1525084e753SMark J. Nelson else 1535b40bb4eSMark J. Nelson echo "No licenses found under ${ROOT}${suffix}/licenses" | 1545084e753SMark J. Nelson tee -a "$mail_msg_file" >> "$LOGFILE" 1555084e753SMark J. Nelson fi 156597bd30bSMike Kupfer 157597bd30bSMike Kupfer to=$(cryptodest "$suffix") 158597bd30bSMike Kupfer if [ "$suffix" = "-nd" ]; then 159597bd30bSMike Kupfer cryptodrop -n "$to" >> "$LOGFILE" 2>&1 160597bd30bSMike Kupfer else 161597bd30bSMike Kupfer cryptodrop "$to" >> "$LOGFILE" 2>&1 162597bd30bSMike Kupfer fi 163597bd30bSMike Kupfer if (( $? != 0 )) ; then 164597bd30bSMike Kupfer echo "\nCould not create $label crypto tarball." | 165597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 166597bd30bSMike Kupfer build_ok=n 167597bd30bSMike Kupfer else 168597bd30bSMike Kupfer cryptolink "$to.bz2" "$suffix" >> "$LOGFILE" 2>&1 169597bd30bSMike Kupfer if (( $? != 0 )) ; then 170597bd30bSMike Kupfer build_ok=n 171597bd30bSMike Kupfer fi 172597bd30bSMike Kupfer fi 173597bd30bSMike Kupfer} 174597bd30bSMike Kupfer 175597bd30bSMike Kupfer# 1764e5b757fSkupfer# Function to do a DEBUG and non-DEBUG build. Needed because we might 1777c478bd9Sstevel@tonic-gate# need to do another for the source build, and since we only deliver DEBUG or 1787c478bd9Sstevel@tonic-gate# non-DEBUG packages. 1794e5b757fSkupfer# 180b83ec4edSjmcp# usage: normal_build 181ead1f93eSLiane Praza# 182597bd30bSMike Kupferfunction normal_build { 1837c478bd9Sstevel@tonic-gate 18452a52aebSkupfer typeset orig_p_FLAG="$p_FLAG" 185597bd30bSMike Kupfer typeset crypto_in="$ON_CRYPTO_BINS" 186597bd30bSMike Kupfer typeset crypto_signer="$CODESIGN_USER" 187597bd30bSMike Kupfer typeset gencrypto=no 1884e5b757fSkupfer 1894e5b757fSkupfer suffix="" 190597bd30bSMike Kupfer [ -n "$CODESIGN_USER" ] && gencrypto=yes 191ead1f93eSLiane Praza 1927c478bd9Sstevel@tonic-gate # non-DEBUG build begins 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate if [ "$F_FLAG" = "n" ]; then 1954e5b757fSkupfer set_non_debug_build_flags 196597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 197b83ec4edSjmcp build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO" \ 198597bd30bSMike Kupfer $(ndcrypto "$crypto_in") 1994e5b757fSkupfer if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \ 2004e5b757fSkupfer "$p_FLAG" = "y" ]; then 2017c478bd9Sstevel@tonic-gate copy_ihv_pkgs non-DEBUG -nd 2027c478bd9Sstevel@tonic-gate fi 203597bd30bSMike Kupfer 204597bd30bSMike Kupfer if [[ "$gencrypto" = yes && "$build_ok" = y ]]; then 205597bd30bSMike Kupfer crypto_from_proto non-DEBUG -nd 206597bd30bSMike Kupfer fi 2077c478bd9Sstevel@tonic-gate else 20852a52aebSkupfer echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE" 2097c478bd9Sstevel@tonic-gate fi 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate # non-DEBUG build ends 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate # DEBUG build begins 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate if [ "$D_FLAG" = "y" ]; then 2164e5b757fSkupfer set_debug_build_flags 217597bd30bSMike Kupfer CODESIGN_USER="$crypto_signer" \ 218b83ec4edSjmcp build "DEBUG" "$suffix" "" "$MULTI_PROTO" "$crypto_in" 2194e5b757fSkupfer if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \ 2204e5b757fSkupfer "$p_FLAG" = "y" ]; then 2217c478bd9Sstevel@tonic-gate copy_ihv_pkgs DEBUG "" 2227c478bd9Sstevel@tonic-gate fi 2237c478bd9Sstevel@tonic-gate 224597bd30bSMike Kupfer if [[ "$gencrypto" = yes && "$build_ok" = y ]]; then 225597bd30bSMike Kupfer crypto_from_proto DEBUG "" 226597bd30bSMike Kupfer fi 2277c478bd9Sstevel@tonic-gate else 22852a52aebSkupfer echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE" 2297c478bd9Sstevel@tonic-gate fi 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate # DEBUG build ends 2324e5b757fSkupfer 23352a52aebSkupfer p_FLAG="$orig_p_FLAG" 2347c478bd9Sstevel@tonic-gate} 2357c478bd9Sstevel@tonic-gate 2361fe69678Skupfer# 23747703246Ssommerfe# usage: run_hook HOOKNAME ARGS... 23847703246Ssommerfe# 23947703246Ssommerfe# If variable "$HOOKNAME" is defined, insert a section header into 24047703246Ssommerfe# our logs and then run the command with ARGS 24147703246Ssommerfe# 242597bd30bSMike Kupferfunction run_hook { 24347703246Ssommerfe HOOKNAME=$1 24447703246Ssommerfe eval HOOKCMD=\$$HOOKNAME 24547703246Ssommerfe shift 24647703246Ssommerfe 24747703246Ssommerfe if [ -n "$HOOKCMD" ]; then 24847703246Ssommerfe ( 24947703246Ssommerfe echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" 25047703246Ssommerfe ( $HOOKCMD "$@" 2>&1 ) 25147703246Ssommerfe if [ "$?" -ne 0 ]; then 25247703246Ssommerfe # Let exit status propagate up 25347703246Ssommerfe touch $TMPDIR/abort 25447703246Ssommerfe fi 25547703246Ssommerfe ) | tee -a $mail_msg_file >> $LOGFILE 25647703246Ssommerfe 25747703246Ssommerfe if [ -f $TMPDIR/abort ]; then 25847703246Ssommerfe build_ok=n 25947703246Ssommerfe echo "\nAborting at request of $HOOKNAME" | 26047703246Ssommerfe tee -a $mail_msg_file >> $LOGFILE 26147703246Ssommerfe exit 1 26247703246Ssommerfe fi 26347703246Ssommerfe fi 26447703246Ssommerfe} 26547703246Ssommerfe 26647703246Ssommerfe# 2671fe69678Skupfer# usage: filelist DESTDIR PATTERN 2681fe69678Skupfer# 269597bd30bSMike Kupferfunction filelist { 2707c478bd9Sstevel@tonic-gate DEST=$1 2717c478bd9Sstevel@tonic-gate PATTERN=$2 2727c478bd9Sstevel@tonic-gate cd ${DEST} 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate OBJFILES=${ORIG_SRC}/xmod/obj_files 2757c478bd9Sstevel@tonic-gate if [ ! -f ${OBJFILES} ]; then 2767c478bd9Sstevel@tonic-gate return; 2777c478bd9Sstevel@tonic-gate fi 2781fe69678Skupfer for i in `grep -v '^#' ${OBJFILES} | \ 2797c478bd9Sstevel@tonic-gate grep ${PATTERN} | cut -d: -f2 | tr -d ' \t'` 2807c478bd9Sstevel@tonic-gate do 2817c478bd9Sstevel@tonic-gate # wildcard expansion 2827c478bd9Sstevel@tonic-gate for j in $i 2837c478bd9Sstevel@tonic-gate do 2847c478bd9Sstevel@tonic-gate if [ -f "$j" ]; then 2857c478bd9Sstevel@tonic-gate echo $j 2867c478bd9Sstevel@tonic-gate fi 2877c478bd9Sstevel@tonic-gate if [ -d "$j" ]; then 2887c478bd9Sstevel@tonic-gate echo $j 2897c478bd9Sstevel@tonic-gate fi 2907c478bd9Sstevel@tonic-gate done 2917c478bd9Sstevel@tonic-gate done | sort | uniq 2927c478bd9Sstevel@tonic-gate} 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate# function to save off binaries after a full build for later 2957c478bd9Sstevel@tonic-gate# restoration 296597bd30bSMike Kupferfunction save_binaries { 2977c478bd9Sstevel@tonic-gate # save off list of binaries 2987c478bd9Sstevel@tonic-gate echo "\n==== Saving binaries from build at `date` ====\n" | \ 2997c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 3007c478bd9Sstevel@tonic-gate rm -f ${BINARCHIVE} 3017c478bd9Sstevel@tonic-gate cd ${CODEMGR_WS} 3027c478bd9Sstevel@tonic-gate filelist ${CODEMGR_WS} '^preserve:' >> $LOGFILE 3037c478bd9Sstevel@tonic-gate filelist ${CODEMGR_WS} '^preserve:' | \ 3047c478bd9Sstevel@tonic-gate cpio -ocB 2>/dev/null | compress \ 3057c478bd9Sstevel@tonic-gate > ${BINARCHIVE} 3067c478bd9Sstevel@tonic-gate} 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate# delete files 3091fe69678Skupfer# usage: hybridize_files DESTDIR MAKE_TARGET 310597bd30bSMike Kupferfunction hybridize_files { 3117c478bd9Sstevel@tonic-gate DEST=$1 3127c478bd9Sstevel@tonic-gate MAKETARG=$2 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate echo "\n==== Hybridizing files at `date` ====\n" | \ 3157c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 3167c478bd9Sstevel@tonic-gate for i in `filelist ${DEST} '^delete:'` 3177c478bd9Sstevel@tonic-gate do 3187c478bd9Sstevel@tonic-gate echo "removing ${i}." | tee -a $mail_msg_file >> $LOGFILE 3197c478bd9Sstevel@tonic-gate rm -rf "${i}" 3207c478bd9Sstevel@tonic-gate done 3217c478bd9Sstevel@tonic-gate for i in `filelist ${DEST} '^hybridize:' ` 3227c478bd9Sstevel@tonic-gate do 3237c478bd9Sstevel@tonic-gate echo "hybridizing ${i}." | tee -a $mail_msg_file >> $LOGFILE 3247c478bd9Sstevel@tonic-gate rm -f ${i}+ 3257c478bd9Sstevel@tonic-gate sed -e "/^# HYBRID DELETE START/,/^# HYBRID DELETE END/d" \ 3267c478bd9Sstevel@tonic-gate < ${i} > ${i}+ 3277c478bd9Sstevel@tonic-gate mv ${i}+ ${i} 3287c478bd9Sstevel@tonic-gate done 3297c478bd9Sstevel@tonic-gate} 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate# restore binaries into the proper source tree. 3321fe69678Skupfer# usage: restore_binaries DESTDIR MAKE_TARGET 333597bd30bSMike Kupferfunction restore_binaries { 3347c478bd9Sstevel@tonic-gate DEST=$1 3357c478bd9Sstevel@tonic-gate MAKETARG=$2 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate echo "\n==== Restoring binaries to ${MAKETARG} at `date` ====\n" | \ 3387c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 3397c478bd9Sstevel@tonic-gate cd ${DEST} 3407c478bd9Sstevel@tonic-gate zcat ${BINARCHIVE} | \ 3417c478bd9Sstevel@tonic-gate cpio -idmucvB 2>/dev/null | tee -a $mail_msg_file >> ${LOGFILE} 3427c478bd9Sstevel@tonic-gate} 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate# rename files we save binaries of 3451fe69678Skupfer# usage: rename_files DESTDIR MAKE_TARGET 346597bd30bSMike Kupferfunction rename_files { 3477c478bd9Sstevel@tonic-gate DEST=$1 3487c478bd9Sstevel@tonic-gate MAKETARG=$2 3497c478bd9Sstevel@tonic-gate echo "\n==== Renaming source files in ${MAKETARG} at `date` ====\n" | \ 3507c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 3517c478bd9Sstevel@tonic-gate for i in `filelist ${DEST} '^rename:'` 3527c478bd9Sstevel@tonic-gate do 3537c478bd9Sstevel@tonic-gate echo ${i} | tee -a $mail_msg_file >> ${LOGFILE} 3547c478bd9Sstevel@tonic-gate rm -f ${i}.export 3557c478bd9Sstevel@tonic-gate mv ${i} ${i}.export 3567c478bd9Sstevel@tonic-gate done 3577c478bd9Sstevel@tonic-gate} 3587c478bd9Sstevel@tonic-gate 3591fe69678Skupfer# 3601fe69678Skupfer# Copy some or all of the source tree. 361cdf0c1d5Smjnelson# 362cdf0c1d5Smjnelson# Returns 0 for success, non-zero for failure. 363cdf0c1d5Smjnelson# 3641fe69678Skupfer# usage: copy_source CODEMGR_WS DESTDIR LABEL SRCROOT 3651fe69678Skupfer# 366597bd30bSMike Kupferfunction copy_source { 3677c478bd9Sstevel@tonic-gate WS=$1 3687c478bd9Sstevel@tonic-gate DEST=$2 3691fe69678Skupfer label=$3 3701fe69678Skupfer srcroot=$4 3717c478bd9Sstevel@tonic-gate 372cdf0c1d5Smjnelson printf "\n==== Creating %s source from %s (%s) ====\n\n" \ 373cdf0c1d5Smjnelson "$DEST" "$WS" "$label" | tee -a $mail_msg_file >> $LOGFILE 374cdf0c1d5Smjnelson 375cdf0c1d5Smjnelson printf "cleaning out %s\n" "$DEST." >> $LOGFILE 376cdf0c1d5Smjnelson rm -rf "$DEST" >> $LOGFILE 2>&1 377cdf0c1d5Smjnelson 378cdf0c1d5Smjnelson printf "creating %s\n" "$DEST." >> $LOGFILE 379cdf0c1d5Smjnelson mkdir -p "$DEST" 2>> $LOGFILE 380cdf0c1d5Smjnelson 381cdf0c1d5Smjnelson if (( $? != 0 )) ; then 382cdf0c1d5Smjnelson printf "failed to create %s\n" "$DEST" | 3837c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 384cdf0c1d5Smjnelson build_ok=n 385cdf0c1d5Smjnelson return 1 386cdf0c1d5Smjnelson fi 387cdf0c1d5Smjnelson cd "$WS" 3887c478bd9Sstevel@tonic-gate 389cdf0c1d5Smjnelson printf "populating %s\n" "$DEST." >> $LOGFILE 3907c478bd9Sstevel@tonic-gate 391cdf0c1d5Smjnelson case "$SCM_TYPE" in 392cdf0c1d5Smjnelson teamware) 3931fe69678Skupfer find $srcroot -name 's\.*' -a -type f -print | \ 3947c478bd9Sstevel@tonic-gate sed -e 's,SCCS\/s.,,' | \ 3957c478bd9Sstevel@tonic-gate grep -v '/\.del-*' | \ 396cdf0c1d5Smjnelson cpio -pd $DEST >>$LOGFILE 2>&1 397cdf0c1d5Smjnelson if (( $? != 0 )) ; then 398cdf0c1d5Smjnelson printf "cpio failed for %s\n" "$DEST" | 399cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 400cdf0c1d5Smjnelson build_ok=n 401cdf0c1d5Smjnelson return 1 402cdf0c1d5Smjnelson fi 403cdf0c1d5Smjnelson ;; 404cdf0c1d5Smjnelson mercurial) 405cdf0c1d5Smjnelson copy_source_mercurial $DEST $srcroot 406cdf0c1d5Smjnelson if (( $? != 0 )) ; then 407cdf0c1d5Smjnelson build_ok=n 408cdf0c1d5Smjnelson return 1 409cdf0c1d5Smjnelson fi 410cdf0c1d5Smjnelson ;; 411cdf0c1d5Smjnelson *) 412cdf0c1d5Smjnelson build_ok=n 413cdf0c1d5Smjnelson echo "Tree copy is not supported for workspace type" \ 414cdf0c1d5Smjnelson "$SCM_TYPE" | tee -a $mail_msg_file >> $LOGFILE 415cdf0c1d5Smjnelson return 1 416cdf0c1d5Smjnelson ;; 417cdf0c1d5Smjnelson esac 418cdf0c1d5Smjnelson 419cdf0c1d5Smjnelson return 0 420cdf0c1d5Smjnelson} 421cdf0c1d5Smjnelson 422cdf0c1d5Smjnelson# 423cdf0c1d5Smjnelson# Mercurial-specific copy code for copy_source(). Handles the 424cdf0c1d5Smjnelson# combined open and closed trees. 425cdf0c1d5Smjnelson# 426cdf0c1d5Smjnelson# Returns 0 for success, non-zero for failure. 427cdf0c1d5Smjnelson# 428cdf0c1d5Smjnelson# usage: copy_source_mercurial destdir srcroot 429cdf0c1d5Smjnelson# 430cdf0c1d5Smjnelsonfunction copy_source_mercurial { 431cdf0c1d5Smjnelson typeset dest=$1 432cdf0c1d5Smjnelson typeset srcroot=$2 433cdf0c1d5Smjnelson typeset open_top closed_top 434cdf0c1d5Smjnelson 435cdf0c1d5Smjnelson case $srcroot in 436cdf0c1d5Smjnelson usr) 437cdf0c1d5Smjnelson open_top=usr 438cdf0c1d5Smjnelson if [[ "$CLOSED_IS_PRESENT" = yes ]]; then 439cdf0c1d5Smjnelson closed_top=usr/closed 440cdf0c1d5Smjnelson fi 441cdf0c1d5Smjnelson ;; 442cdf0c1d5Smjnelson usr/closed*) 443cdf0c1d5Smjnelson if [[ "$CLOSED_IS_PRESENT" = no ]]; then 444cdf0c1d5Smjnelson printf "can't copy %s: closed tree not present.\n" \ 445cdf0c1d5Smjnelson "$srcroot" | tee -a $mail_msg_file >> $LOGFILE 446cdf0c1d5Smjnelson return 1 447cdf0c1d5Smjnelson fi 448cdf0c1d5Smjnelson closed_top="$srcroot" 449cdf0c1d5Smjnelson ;; 450cdf0c1d5Smjnelson *) 451cdf0c1d5Smjnelson open_top="$srcroot" 452cdf0c1d5Smjnelson ;; 453cdf0c1d5Smjnelson esac 454cdf0c1d5Smjnelson 455cdf0c1d5Smjnelson if [[ -n "$open_top" ]]; then 456cdf0c1d5Smjnelson hg locate -I "$open_top" | cpio -pd "$dest" >>$LOGFILE 2>&1 457cdf0c1d5Smjnelson if (( $? != 0 )) ; then 458cdf0c1d5Smjnelson printf "cpio failed for %s\n" "$dest" | 459cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 460cdf0c1d5Smjnelson return 1 461cdf0c1d5Smjnelson fi 462cdf0c1d5Smjnelson fi 463cdf0c1d5Smjnelson 464cdf0c1d5Smjnelson if [[ -n "$closed_top" ]]; then 465cdf0c1d5Smjnelson mkdir -p "$dest/usr/closed" || return 1 466cdf0c1d5Smjnelson if [[ "$closed_top" = usr/closed ]]; then 467cdf0c1d5Smjnelson (cd usr/closed; hg locate | 468cdf0c1d5Smjnelson cpio -pd "$dest/usr/closed") >>$LOGFILE 2>&1 469cdf0c1d5Smjnelson if (( $? != 0 )) ; then 470cdf0c1d5Smjnelson printf "cpio failed for %s/usr/closed\n" \ 471cdf0c1d5Smjnelson "$dest" | tee -a $mail_msg_file >> $LOGFILE 472cdf0c1d5Smjnelson return 1 473cdf0c1d5Smjnelson fi 474cdf0c1d5Smjnelson else 475cdf0c1d5Smjnelson # copy subtree of usr/closed 476cdf0c1d5Smjnelson closed_top=${closed_top#usr/closed/} 477cdf0c1d5Smjnelson (cd usr/closed; hg locate -I "$closed_top" | 478cdf0c1d5Smjnelson cpio -pd "$dest/usr/closed") >>$LOGFILE 2>&1 479cdf0c1d5Smjnelson if (( $? != 0 )) ; then 480cdf0c1d5Smjnelson printf "cpio failed for %s/usr/closed/%s\n" \ 481cdf0c1d5Smjnelson "$dest" "$closed_top" | 482cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 483cdf0c1d5Smjnelson return 1 484cdf0c1d5Smjnelson fi 485cdf0c1d5Smjnelson fi 486cdf0c1d5Smjnelson fi 487cdf0c1d5Smjnelson 488cdf0c1d5Smjnelson return 0 4891fe69678Skupfer} 4907c478bd9Sstevel@tonic-gate 4911fe69678Skupfer# 4921fe69678Skupfer# function to create (but not build) the export/crypt source tree. 4931fe69678Skupfer# usage: set_up_source_build CODEMGR_WS DESTDIR MAKE_TARGET 4941fe69678Skupfer# Sets SRC to the modified source tree, for use by the caller when it 4951fe69678Skupfer# builds the tree. 4961fe69678Skupfer# 497597bd30bSMike Kupferfunction set_up_source_build { 4981fe69678Skupfer WS=$1 4991fe69678Skupfer DEST=$2 5001fe69678Skupfer MAKETARG=$3 5011fe69678Skupfer 5021fe69678Skupfer copy_source $WS $DEST $MAKETARG usr 503cdf0c1d5Smjnelson if (( $? != 0 )); then 504cdf0c1d5Smjnelson echo "\nCould not copy source tree for source build." | 505cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 506cdf0c1d5Smjnelson build_ok=n 507cdf0c1d5Smjnelson return 508cdf0c1d5Smjnelson fi 509cdf0c1d5Smjnelson 5107c478bd9Sstevel@tonic-gate SRC=${DEST}/usr/src 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate cd $SRC 5137c478bd9Sstevel@tonic-gate rm -f ${MAKETARG}.out 5147c478bd9Sstevel@tonic-gate echo "making ${MAKETARG} in ${SRC}." >> $LOGFILE 5157c478bd9Sstevel@tonic-gate /bin/time $MAKE -e ${MAKETARG} 2>&1 | \ 5167c478bd9Sstevel@tonic-gate tee -a $SRC/${MAKETARG}.out >> $LOGFILE 5177c478bd9Sstevel@tonic-gate echo "\n==== ${MAKETARG} build errors ====\n" >> $mail_msg_file 5187c478bd9Sstevel@tonic-gate egrep ":" $SRC/${MAKETARG}.out | \ 5197c478bd9Sstevel@tonic-gate egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 5207c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 5217c478bd9Sstevel@tonic-gate egrep -v "warning" >> $mail_msg_file 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate echo "clearing state files." >> $LOGFILE 5247c478bd9Sstevel@tonic-gate find . -name '.make*' -exec rm -f {} \; 5257c478bd9Sstevel@tonic-gate 5267c478bd9Sstevel@tonic-gate cd ${DEST} 5277c478bd9Sstevel@tonic-gate if [ "${MAKETARG}" = "CRYPT_SRC" ]; then 5287c478bd9Sstevel@tonic-gate rm -f ${CODEMGR_WS}/crypt_files.cpio.Z 5297c478bd9Sstevel@tonic-gate echo "\n==== xmod/cry_files that don't exist ====\n" | \ 5307c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 5317c478bd9Sstevel@tonic-gate CRYPT_FILES=${WS}/usr/src/xmod/cry_files 5327c478bd9Sstevel@tonic-gate for i in `cat ${CRYPT_FILES}` 5337c478bd9Sstevel@tonic-gate do 5347c478bd9Sstevel@tonic-gate # make sure the files exist 5357c478bd9Sstevel@tonic-gate if [ -f "$i" ]; then 5367c478bd9Sstevel@tonic-gate continue 5377c478bd9Sstevel@tonic-gate fi 5387c478bd9Sstevel@tonic-gate if [ -d "$i" ]; then 5397c478bd9Sstevel@tonic-gate continue 5407c478bd9Sstevel@tonic-gate fi 5417c478bd9Sstevel@tonic-gate echo "$i" | tee -a $mail_msg_file >> $LOGFILE 5427c478bd9Sstevel@tonic-gate done 5437c478bd9Sstevel@tonic-gate find `cat ${CRYPT_FILES}` -print 2>/dev/null | \ 5447c478bd9Sstevel@tonic-gate cpio -ocB 2>/dev/null | \ 5457c478bd9Sstevel@tonic-gate compress > ${CODEMGR_WS}/crypt_files.cpio.Z 5467c478bd9Sstevel@tonic-gate fi 5477c478bd9Sstevel@tonic-gate 5487c478bd9Sstevel@tonic-gate if [ "${MAKETARG}" = "EXPORT_SRC" ]; then 5497c478bd9Sstevel@tonic-gate # rename first, since we might restore a file 5507c478bd9Sstevel@tonic-gate # of the same name (mapfiles) 5517c478bd9Sstevel@tonic-gate rename_files ${EXPORT_SRC} EXPORT_SRC 5527c478bd9Sstevel@tonic-gate if [ "$SH_FLAG" = "y" ]; then 5537c478bd9Sstevel@tonic-gate hybridize_files ${EXPORT_SRC} EXPORT_SRC 5547c478bd9Sstevel@tonic-gate fi 5557c478bd9Sstevel@tonic-gate fi 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate # save the cleartext 5587c478bd9Sstevel@tonic-gate echo "\n==== Creating ${MAKETARG}.cpio.Z ====\n" | \ 5597c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 5607c478bd9Sstevel@tonic-gate cd ${DEST} 5617c478bd9Sstevel@tonic-gate rm -f ${MAKETARG}.cpio.Z 562fb23a357Skupfer find usr -depth -print | \ 5637c478bd9Sstevel@tonic-gate grep -v usr/src/${MAKETARG}.out | \ 5647c478bd9Sstevel@tonic-gate cpio -ocB 2>/dev/null | \ 5657c478bd9Sstevel@tonic-gate compress > ${CODEMGR_WS}/${MAKETARG}.cpio.Z 5667c478bd9Sstevel@tonic-gate if [ "${MAKETARG}" = "EXPORT_SRC" ]; then 5677c478bd9Sstevel@tonic-gate restore_binaries ${EXPORT_SRC} EXPORT_SRC 5687c478bd9Sstevel@tonic-gate fi 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate if [ "${MAKETARG}" = "CRYPT_SRC" ]; then 5717c478bd9Sstevel@tonic-gate restore_binaries ${CRYPT_SRC} CRYPT_SRC 5727c478bd9Sstevel@tonic-gate fi 5737c478bd9Sstevel@tonic-gate 5747c478bd9Sstevel@tonic-gate} 5757c478bd9Sstevel@tonic-gate 5764e5b757fSkupfer# Return library search directive as function of given root. 577597bd30bSMike Kupferfunction myldlibs { 5784e5b757fSkupfer echo "-L$1/lib -L$1/usr/lib" 5794e5b757fSkupfer} 5807c478bd9Sstevel@tonic-gate 5814e5b757fSkupfer# Return header search directive as function of given root. 582597bd30bSMike Kupferfunction myheaders { 5834e5b757fSkupfer echo "-I$1/usr/include" 5844e5b757fSkupfer} 5854e5b757fSkupfer 5864e5b757fSkupfer# 587597bd30bSMike Kupfer# Unpack the crypto tarball into the proto area. We first extract the 588ead1f93eSLiane Praza# tarball into a temp directory so that we can handle the non-DEBUG 589597bd30bSMike Kupfer# tarball correctly with MULTI_PROTO=no. 590597bd30bSMike Kupfer# Return 0 on success, non-zero on failure. 591597bd30bSMike Kupfer# 592597bd30bSMike Kupferfunction unpack_crypto { 593597bd30bSMike Kupfer typeset tarfile=$1 594597bd30bSMike Kupfer typeset suffix=$2 595597bd30bSMike Kupfer typeset ctop=$(mktemp -d /tmp/crypto.XXXXXX) 596597bd30bSMike Kupfer [ -n "$ctop" ] || return 1 597597bd30bSMike Kupfer typeset croot=$ctop/proto/root_$MACH$suffix 598597bd30bSMike Kupfer echo "Unpacking crypto ($tarfile)..." 599597bd30bSMike Kupfer bzcat "$tarfile" | (cd "$ctop"; tar xfBp -) 600597bd30bSMike Kupfer if [[ $? -ne 0 || ! -d "$croot" ]]; then 601597bd30bSMike Kupfer return 1 602597bd30bSMike Kupfer fi 603597bd30bSMike Kupfer # 604597bd30bSMike Kupfer # We extract with -p so that we maintain permissions on directories. 605597bd30bSMike Kupfer # 606597bd30bSMike Kupfer (cd "$croot"; tar cf - *) | (cd "$ROOT"; tar xfBp -) 607597bd30bSMike Kupfer typeset -i stat=$? 608597bd30bSMike Kupfer rm -rf "$ctop" 609597bd30bSMike Kupfer return $stat 610597bd30bSMike Kupfer} 611597bd30bSMike Kupfer 612597bd30bSMike Kupfer# 61378add226Sjmcp# Function to do the build, including package generation. 614597bd30bSMike Kupfer# usage: build LABEL SUFFIX ND MULTIPROTO CRYPTO 6154e5b757fSkupfer# - LABEL is used to tag build output. 616ead1f93eSLiane Praza# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG, 617597bd30bSMike Kupfer# open-only vs full tree). 618ead1f93eSLiane Praza# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds). 6194e5b757fSkupfer# - If MULTIPROTO is "yes", it means to name the proto area according to 6204e5b757fSkupfer# SUFFIX. Otherwise ("no"), (re)use the standard proto area. 621597bd30bSMike Kupfer# - CRYPTO is the path to the crypto tarball, or null. 6224e5b757fSkupfer# 623597bd30bSMike Kupferfunction build { 6247c478bd9Sstevel@tonic-gate LABEL=$1 6257c478bd9Sstevel@tonic-gate SUFFIX=$2 626597bd30bSMike Kupfer ND=$3 627597bd30bSMike Kupfer MULTIPROTO=$4 628597bd30bSMike Kupfer CRYPTOPATH=$5 6297c478bd9Sstevel@tonic-gate INSTALLOG=install${SUFFIX}-${MACH} 6307c478bd9Sstevel@tonic-gate NOISE=noise${SUFFIX}-${MACH} 6317c478bd9Sstevel@tonic-gate PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 6327c478bd9Sstevel@tonic-gate 6334e5b757fSkupfer ORIGROOT=$ROOT 6344e5b757fSkupfer [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX 6354e5b757fSkupfer 636b83ec4edSjmcp if [[ "$O_FLAG" = y ]]; then 637b83ec4edSjmcp echo "\nSetting CLOSEDROOT= ${ROOT}-closed\n" >> $LOGFILE 638b83ec4edSjmcp export CLOSEDROOT=${ROOT}-closed 639b83ec4edSjmcp fi 640b83ec4edSjmcp 6414e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 6424e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 6434e5b757fSkupfer 6447c478bd9Sstevel@tonic-gate this_build_ok=y 6457c478bd9Sstevel@tonic-gate # 6467c478bd9Sstevel@tonic-gate # Build OS-Networking source 6477c478bd9Sstevel@tonic-gate # 6487c478bd9Sstevel@tonic-gate echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 6497c478bd9Sstevel@tonic-gate >> $LOGFILE 6507c478bd9Sstevel@tonic-gate 6517c478bd9Sstevel@tonic-gate rm -f $SRC/${INSTALLOG}.out 6527c478bd9Sstevel@tonic-gate cd $SRC 6537c478bd9Sstevel@tonic-gate /bin/time $MAKE -e install 2>&1 | \ 6547c478bd9Sstevel@tonic-gate tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 65532f1e47bSsommerfe 656cdf0c1d5Smjnelson if [[ "$SCM_TYPE" = teamware ]]; then 65732f1e47bSsommerfe echo "\n==== SCCS Noise ($LABEL) ====\n" >> $mail_msg_file 658cdf0c1d5Smjnelson egrep 'sccs(check:| *get)' $SRC/${INSTALLOG}.out >> \ 659cdf0c1d5Smjnelson $mail_msg_file 660cdf0c1d5Smjnelson fi 66132f1e47bSsommerfe 6627c478bd9Sstevel@tonic-gate echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 6637c478bd9Sstevel@tonic-gate egrep ":" $SRC/${INSTALLOG}.out | 6647c478bd9Sstevel@tonic-gate egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 6657c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 6667c478bd9Sstevel@tonic-gate egrep -v "cc .* -o error " | \ 6677c478bd9Sstevel@tonic-gate egrep -v "warning" >> $mail_msg_file 6687c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 6697c478bd9Sstevel@tonic-gate build_ok=n 6707c478bd9Sstevel@tonic-gate this_build_ok=n 6717c478bd9Sstevel@tonic-gate fi 6727c478bd9Sstevel@tonic-gate grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 6737c478bd9Sstevel@tonic-gate >> $mail_msg_file 6747c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 6757c478bd9Sstevel@tonic-gate build_ok=n 6767c478bd9Sstevel@tonic-gate this_build_ok=n 6777c478bd9Sstevel@tonic-gate fi 6787c478bd9Sstevel@tonic-gate 679597bd30bSMike Kupfer if [ -n "$CRYPTOPATH" ]; then 680597bd30bSMike Kupfer unpack_crypto "$CRYPTOPATH" "$ND" >> "$LOGFILE" 2>&1 681597bd30bSMike Kupfer if (( $? != 0 )) ; then 682597bd30bSMike Kupfer echo "Could not unpack crypto ($CRYPTOPATH)" | 683597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 684597bd30bSMike Kupfer build_ok=n 685597bd30bSMike Kupfer this_build_ok=n 686597bd30bSMike Kupfer fi 687597bd30bSMike Kupfer fi 688597bd30bSMike Kupfer 6897c478bd9Sstevel@tonic-gate if [ "$W_FLAG" = "n" ]; then 6907c478bd9Sstevel@tonic-gate echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 6917c478bd9Sstevel@tonic-gate egrep -i warning: $SRC/${INSTALLOG}.out \ 6927c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 69320272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 6947c478bd9Sstevel@tonic-gate | egrep -v "parameter <PSTAMP> set to" \ 6957c478bd9Sstevel@tonic-gate | egrep -v "Ignoring unknown host" \ 6967c478bd9Sstevel@tonic-gate | egrep -v "redefining segment flags attribute for" \ 6977c478bd9Sstevel@tonic-gate >> $mail_msg_file 6987c478bd9Sstevel@tonic-gate fi 6997c478bd9Sstevel@tonic-gate 7007c478bd9Sstevel@tonic-gate echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 7017c478bd9Sstevel@tonic-gate >> $LOGFILE 7027c478bd9Sstevel@tonic-gate 7037c478bd9Sstevel@tonic-gate echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 7047c478bd9Sstevel@tonic-gate tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 7057c478bd9Sstevel@tonic-gate 7067c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "n" -a "$W_FLAG" = "n" ]; then 7077c478bd9Sstevel@tonic-gate rm -f $SRC/${NOISE}.ref 7087c478bd9Sstevel@tonic-gate if [ -f $SRC/${NOISE}.out ]; then 7097c478bd9Sstevel@tonic-gate mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 7107c478bd9Sstevel@tonic-gate fi 7117c478bd9Sstevel@tonic-gate grep : $SRC/${INSTALLOG}.out \ 7127c478bd9Sstevel@tonic-gate | egrep -v '^/' \ 7137c478bd9Sstevel@tonic-gate | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 7147c478bd9Sstevel@tonic-gate | egrep -v '^tic:' \ 7157c478bd9Sstevel@tonic-gate | egrep -v '^mcs' \ 7167c478bd9Sstevel@tonic-gate | egrep -v '^LD_LIBRARY_PATH=' \ 7177c478bd9Sstevel@tonic-gate | egrep -v 'ar: creating' \ 7187c478bd9Sstevel@tonic-gate | egrep -v 'ar: writing' \ 7197c478bd9Sstevel@tonic-gate | egrep -v 'conflicts:' \ 7207c478bd9Sstevel@tonic-gate | egrep -v ':saved created' \ 7217c478bd9Sstevel@tonic-gate | egrep -v '^stty.*c:' \ 7227c478bd9Sstevel@tonic-gate | egrep -v '^mfgname.c:' \ 7237c478bd9Sstevel@tonic-gate | egrep -v '^uname-i.c:' \ 7247c478bd9Sstevel@tonic-gate | egrep -v '^volumes.c:' \ 7257c478bd9Sstevel@tonic-gate | egrep -v '^lint library construction:' \ 7267c478bd9Sstevel@tonic-gate | egrep -v 'tsort: INFORM:' \ 7277c478bd9Sstevel@tonic-gate | egrep -v 'stripalign:' \ 7287c478bd9Sstevel@tonic-gate | egrep -v 'chars, width' \ 72920272c2eSAli Bahrami | egrep -v "symbol (\`|')timezone' has differing types:" \ 7307c478bd9Sstevel@tonic-gate | egrep -v 'PSTAMP' \ 7317c478bd9Sstevel@tonic-gate | egrep -v '|%WHOANDWHERE%|' \ 7327c478bd9Sstevel@tonic-gate | egrep -v '^Manifying' \ 7337c478bd9Sstevel@tonic-gate | egrep -v 'Ignoring unknown host' \ 7347c478bd9Sstevel@tonic-gate | egrep -v 'Processing method:' \ 7357c478bd9Sstevel@tonic-gate | egrep -v '^Writing' \ 7367c478bd9Sstevel@tonic-gate | egrep -v 'spellin1:' \ 7377c478bd9Sstevel@tonic-gate | egrep -v '^adding:' \ 7387c478bd9Sstevel@tonic-gate | egrep -v "^echo 'msgid" \ 7397c478bd9Sstevel@tonic-gate | egrep -v '^echo ' \ 7407c478bd9Sstevel@tonic-gate | egrep -v '\.c:$' \ 7417c478bd9Sstevel@tonic-gate | egrep -v '^Adding file:' \ 7427c478bd9Sstevel@tonic-gate | egrep -v 'CLASSPATH=' \ 7437c478bd9Sstevel@tonic-gate | egrep -v '\/var\/mail\/:saved' \ 7447c478bd9Sstevel@tonic-gate | egrep -v -- '-DUTS_VERSION=' \ 7457c478bd9Sstevel@tonic-gate | egrep -v '^Running Mkbootstrap' \ 7467c478bd9Sstevel@tonic-gate | egrep -v '^Applet length read:' \ 7477c478bd9Sstevel@tonic-gate | egrep -v 'bytes written:' \ 7487c478bd9Sstevel@tonic-gate | egrep -v '^File:SolarisAuthApplet.bin' \ 7497c478bd9Sstevel@tonic-gate | egrep -v -i 'jibversion' \ 7507c478bd9Sstevel@tonic-gate | egrep -v '^Output size:' \ 7517c478bd9Sstevel@tonic-gate | egrep -v '^Solo size statistics:' \ 7527c478bd9Sstevel@tonic-gate | egrep -v '^Using ROM API Version' \ 7537c478bd9Sstevel@tonic-gate | egrep -v '^Zero Signature length:' \ 7547c478bd9Sstevel@tonic-gate | egrep -v '^Note \(probably harmless\):' \ 7557c478bd9Sstevel@tonic-gate | egrep -v '::' \ 7567c478bd9Sstevel@tonic-gate | egrep -v -- '-xcache' \ 757010b217aSwesolows | egrep -v '^\+' \ 75803eb5f54Swesolows | egrep -v '^cc1: note: -fwritable-strings' \ 759c817a439Sjohnz | egrep -v 'svccfg-native -s svc:/' \ 7607c478bd9Sstevel@tonic-gate | sort | uniq >$SRC/${NOISE}.out 7617c478bd9Sstevel@tonic-gate if [ ! -f $SRC/${NOISE}.ref ]; then 7627c478bd9Sstevel@tonic-gate cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 7637c478bd9Sstevel@tonic-gate fi 7647c478bd9Sstevel@tonic-gate echo "\n==== Build noise differences ($LABEL) ====\n" \ 7657c478bd9Sstevel@tonic-gate >>$mail_msg_file 7667c478bd9Sstevel@tonic-gate diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 7677c478bd9Sstevel@tonic-gate fi 7687c478bd9Sstevel@tonic-gate 7697c478bd9Sstevel@tonic-gate # 77023259b79Srotondo # Re-sign selected binaries using signing server 77123259b79Srotondo # (gatekeeper builds only) 77223259b79Srotondo # 7732210853dSjohnz if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then 77423259b79Srotondo echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE 77523259b79Srotondo signing_file="${TMPDIR}/signing" 77623259b79Srotondo rm -f ${signing_file} 77723259b79Srotondo export CODESIGN_USER 77823259b79Srotondo signproto $SRC/tools/codesign/creds 2>&1 | \ 77923259b79Srotondo tee -a ${signing_file} >> $LOGFILE 78023259b79Srotondo echo "\n==== Finished signing proto area at `date` ====\n" \ 78123259b79Srotondo >> $LOGFILE 78223259b79Srotondo echo "\n==== Crypto module signing errors ($LABEL) ====\n" \ 78323259b79Srotondo >> $mail_msg_file 78423259b79Srotondo egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file 785cdf0c1d5Smjnelson if (( $? == 0 )) ; then 7862210853dSjohnz build_ok=n 7872210853dSjohnz this_build_ok=n 7882210853dSjohnz fi 78923259b79Srotondo fi 79023259b79Srotondo 79123259b79Srotondo # 7927c478bd9Sstevel@tonic-gate # Building Packages 7937c478bd9Sstevel@tonic-gate # 7947c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 795ead1f93eSLiane Praza if [ -d $SRC/pkg -o -d $SRC/pkgdefs ]; then 7967c478bd9Sstevel@tonic-gate echo "\n==== Creating $LABEL packages at `date` ====\n" \ 7977c478bd9Sstevel@tonic-gate >> $LOGFILE 798ead1f93eSLiane Praza echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 7996798c3f0SMark J. Nelson rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1 8006798c3f0SMark J. Nelson mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1 801d8fd4470Sjg 802ead1f93eSLiane Praza for d in pkg pkgdefs; do 8036798c3f0SMark J. Nelson if [ ! -f "$SRC/$d/Makefile" ]; then 804ead1f93eSLiane Praza continue 805ead1f93eSLiane Praza fi 806ead1f93eSLiane Praza rm -f $SRC/$d/${INSTALLOG}.out 807ead1f93eSLiane Praza cd $SRC/$d 808ead1f93eSLiane Praza /bin/time $MAKE -e install 2>&1 | \ 809ead1f93eSLiane Praza tee -a $SRC/$d/${INSTALLOG}.out >> $LOGFILE 810ead1f93eSLiane Praza done 811ead1f93eSLiane Praza 812ead1f93eSLiane Praza echo "\n==== package build errors ($LABEL) ====\n" \ 813ead1f93eSLiane Praza >> $mail_msg_file 814ead1f93eSLiane Praza 815ead1f93eSLiane Praza for d in pkg pkgdefs; do 8166798c3f0SMark J. Nelson if [ ! -f "$SRC/$d/Makefile" ]; then 817ead1f93eSLiane Praza continue 818d8fd4470Sjg fi 819d8fd4470Sjg 820ead1f93eSLiane Praza egrep "${MAKE}|ERROR|WARNING" $SRC/$d/${INSTALLOG}.out | \ 8217c478bd9Sstevel@tonic-gate grep ':' | \ 8227c478bd9Sstevel@tonic-gate grep -v PSTAMP | \ 8237c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" \ 8247c478bd9Sstevel@tonic-gate >> $mail_msg_file 825ead1f93eSLiane Praza done 826ead1f93eSLiane Praza else 827ead1f93eSLiane Praza # 828ead1f93eSLiane Praza # Handle it gracefully if -p was set but there are 829ead1f93eSLiane Praza # neither pkg nor pkgdefs directories. 830ead1f93eSLiane Praza # 831ead1f93eSLiane Praza echo "\n==== No $LABEL packages to build ====\n" \ 832ead1f93eSLiane Praza >> $LOGFILE 833ead1f93eSLiane Praza fi 8347c478bd9Sstevel@tonic-gate else 8357c478bd9Sstevel@tonic-gate echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 8367c478bd9Sstevel@tonic-gate fi 8374e5b757fSkupfer 8384e5b757fSkupfer ROOT=$ORIGROOT 8397c478bd9Sstevel@tonic-gate} 8407c478bd9Sstevel@tonic-gate 8411fe69678Skupfer# Usage: dolint /dir y|n 8427c478bd9Sstevel@tonic-gate# Arg. 2 is a flag to turn on/off the lint diff output 843597bd30bSMike Kupferfunction dolint { 8447c478bd9Sstevel@tonic-gate if [ ! -d "$1" ]; then 8451fe69678Skupfer echo "dolint error: $1 is not a directory" 8467c478bd9Sstevel@tonic-gate exit 1 8477c478bd9Sstevel@tonic-gate fi 8487c478bd9Sstevel@tonic-gate 8497c478bd9Sstevel@tonic-gate if [ "$2" != "y" -a "$2" != "n" ]; then 8501fe69678Skupfer echo "dolint internal error: $2 should be 'y' or 'n'" 8517c478bd9Sstevel@tonic-gate exit 1 8527c478bd9Sstevel@tonic-gate fi 8537c478bd9Sstevel@tonic-gate 8547c478bd9Sstevel@tonic-gate lintdir=$1 8557c478bd9Sstevel@tonic-gate dodiff=$2 8567c478bd9Sstevel@tonic-gate base=`basename $lintdir` 8577c478bd9Sstevel@tonic-gate LINTOUT=$lintdir/lint-${MACH}.out 8587c478bd9Sstevel@tonic-gate LINTNOISE=$lintdir/lint-noise-${MACH} 8594e5b757fSkupfer export ENVLDLIBS1=`myldlibs $ROOT` 8604e5b757fSkupfer export ENVCPPFLAGS1=`myheaders $ROOT` 8617c478bd9Sstevel@tonic-gate 8624e5b757fSkupfer set_debug_build_flags 8637c478bd9Sstevel@tonic-gate 8647c478bd9Sstevel@tonic-gate # 8657c478bd9Sstevel@tonic-gate # '$MAKE lint' in $lintdir 8667c478bd9Sstevel@tonic-gate # 8677c478bd9Sstevel@tonic-gate echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 8687c478bd9Sstevel@tonic-gate 8697c478bd9Sstevel@tonic-gate # remove old lint.out 8707c478bd9Sstevel@tonic-gate rm -f $lintdir/lint.out $lintdir/lint-noise.out 8717c478bd9Sstevel@tonic-gate if [ -f $lintdir/lint-noise.ref ]; then 8727c478bd9Sstevel@tonic-gate mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 8737c478bd9Sstevel@tonic-gate fi 8747c478bd9Sstevel@tonic-gate 8757c478bd9Sstevel@tonic-gate rm -f $LINTOUT 8767c478bd9Sstevel@tonic-gate cd $lintdir 8777c478bd9Sstevel@tonic-gate # 8787c478bd9Sstevel@tonic-gate # Remove all .ln files to ensure a full reference file 8797c478bd9Sstevel@tonic-gate # 8807c478bd9Sstevel@tonic-gate rm -f Nothing_to_remove \ 881cdf0c1d5Smjnelson `find . \( -name SCCS -o -name .hg -o -name .svn \) \ 882cdf0c1d5Smjnelson -prune -o -type f -name '*.ln' -print ` 8837c478bd9Sstevel@tonic-gate 8847c478bd9Sstevel@tonic-gate /bin/time $MAKE -ek lint 2>&1 | \ 8857c478bd9Sstevel@tonic-gate tee -a $LINTOUT >> $LOGFILE 8867c478bd9Sstevel@tonic-gate echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 8877c478bd9Sstevel@tonic-gate grep "$MAKE:" $LINTOUT | 8887c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" \ 8897c478bd9Sstevel@tonic-gate >> $mail_msg_file 8907c478bd9Sstevel@tonic-gate 8917c478bd9Sstevel@tonic-gate echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 8927c478bd9Sstevel@tonic-gate 8937c478bd9Sstevel@tonic-gate echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 8947c478bd9Sstevel@tonic-gate >>$mail_msg_file 8957c478bd9Sstevel@tonic-gate tail -3 $LINTOUT >>$mail_msg_file 8967c478bd9Sstevel@tonic-gate 8977c478bd9Sstevel@tonic-gate rm -f ${LINTNOISE}.ref 8987c478bd9Sstevel@tonic-gate if [ -f ${LINTNOISE}.out ]; then 8997c478bd9Sstevel@tonic-gate mv ${LINTNOISE}.out ${LINTNOISE}.ref 9007c478bd9Sstevel@tonic-gate fi 9017c478bd9Sstevel@tonic-gate grep : $LINTOUT | \ 9027c478bd9Sstevel@tonic-gate egrep -v '^(real|user|sys)' | 9037c478bd9Sstevel@tonic-gate egrep -v '(library construction)' | \ 9047c478bd9Sstevel@tonic-gate egrep -v ': global crosschecks' | \ 9057c478bd9Sstevel@tonic-gate egrep -v 'Ignoring unknown host' | \ 9067c478bd9Sstevel@tonic-gate egrep -v '\.c:$' | \ 9077c478bd9Sstevel@tonic-gate sort | uniq > ${LINTNOISE}.out 9087c478bd9Sstevel@tonic-gate if [ ! -f ${LINTNOISE}.ref ]; then 9097c478bd9Sstevel@tonic-gate cp ${LINTNOISE}.out ${LINTNOISE}.ref 9107c478bd9Sstevel@tonic-gate fi 9117c478bd9Sstevel@tonic-gate if [ "$dodiff" != "n" ]; then 9127c478bd9Sstevel@tonic-gate echo "\n==== lint warnings $base ====\n" \ 9137c478bd9Sstevel@tonic-gate >>$mail_msg_file 9147c478bd9Sstevel@tonic-gate # should be none, though there are a few that were filtered out 9157c478bd9Sstevel@tonic-gate # above 9167c478bd9Sstevel@tonic-gate egrep -i '(warning|lint):' ${LINTNOISE}.out \ 9177c478bd9Sstevel@tonic-gate | sort | uniq >> $mail_msg_file 9187c478bd9Sstevel@tonic-gate echo "\n==== lint noise differences $base ====\n" \ 9197c478bd9Sstevel@tonic-gate >> $mail_msg_file 9207c478bd9Sstevel@tonic-gate diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 9217c478bd9Sstevel@tonic-gate >> $mail_msg_file 9227c478bd9Sstevel@tonic-gate fi 9237c478bd9Sstevel@tonic-gate} 9247c478bd9Sstevel@tonic-gate 9257c478bd9Sstevel@tonic-gate# Install proto area from IHV build 9267c478bd9Sstevel@tonic-gate 927597bd30bSMike Kupferfunction copy_ihv_proto { 9287c478bd9Sstevel@tonic-gate 9296fec3625Sdduvall echo "\n==== Installing IHV proto area ====\n" \ 9307c478bd9Sstevel@tonic-gate >> $LOGFILE 9317c478bd9Sstevel@tonic-gate if [ -d "$IA32_IHV_ROOT" ]; then 9327c478bd9Sstevel@tonic-gate if [ ! -d "$ROOT" ]; then 9337c478bd9Sstevel@tonic-gate echo "mkdir -p $ROOT" >> $LOGFILE 9347c478bd9Sstevel@tonic-gate mkdir -p $ROOT 9357c478bd9Sstevel@tonic-gate fi 9366fec3625Sdduvall echo "copying $IA32_IHV_ROOT to $ROOT\n" >> $LOGFILE 9377c478bd9Sstevel@tonic-gate cd $IA32_IHV_ROOT 938b83ec4edSjmcp tar cf - . | (cd $ROOT; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 9397c478bd9Sstevel@tonic-gate else 9407c478bd9Sstevel@tonic-gate echo "$IA32_IHV_ROOT: not found" >> $LOGFILE 9417c478bd9Sstevel@tonic-gate fi 9424e5b757fSkupfer 9434e5b757fSkupfer if [ "$MULTI_PROTO" = yes ]; then 9444e5b757fSkupfer if [ ! -d "$ROOT-nd" ]; then 9454e5b757fSkupfer echo "mkdir -p $ROOT-nd" >> $LOGFILE 9464e5b757fSkupfer mkdir -p $ROOT-nd 9474e5b757fSkupfer fi 948ead1f93eSLiane Praza # If there's a non-DEBUG version of the IHV proto area, 9494e5b757fSkupfer # copy it, but copy something if there's not. 9504e5b757fSkupfer if [ -d "$IA32_IHV_ROOT-nd" ]; then 9514e5b757fSkupfer echo "copying $IA32_IHV_ROOT-nd to $ROOT-nd\n" >> $LOGFILE 9524e5b757fSkupfer cd $IA32_IHV_ROOT-nd 9534e5b757fSkupfer elif [ -d "$IA32_IHV_ROOT" ]; then 9544e5b757fSkupfer echo "copying $IA32_IHV_ROOT to $ROOT-nd\n" >> $LOGFILE 9554e5b757fSkupfer cd $IA32_IHV_ROOT 9564e5b757fSkupfer else 9574e5b757fSkupfer echo "$IA32_IHV_ROOT{-nd,}: not found" >> $LOGFILE 9584e5b757fSkupfer return 9594e5b757fSkupfer fi 960b83ec4edSjmcp tar cf - . | (cd $ROOT-nd; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 9614e5b757fSkupfer fi 9627c478bd9Sstevel@tonic-gate} 9637c478bd9Sstevel@tonic-gate 9647c478bd9Sstevel@tonic-gate# Install IHV packages in PKGARCHIVE 9651fe69678Skupfer# usage: copy_ihv_pkgs LABEL SUFFIX 966597bd30bSMike Kupferfunction copy_ihv_pkgs { 9677c478bd9Sstevel@tonic-gate LABEL=$1 9687c478bd9Sstevel@tonic-gate SUFFIX=$2 9697c478bd9Sstevel@tonic-gate # always use non-DEBUG IHV packages 9707c478bd9Sstevel@tonic-gate IA32_IHV_PKGS=${IA32_IHV_PKGS_ORIG}-nd 9717c478bd9Sstevel@tonic-gate PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 9727c478bd9Sstevel@tonic-gate 9737c478bd9Sstevel@tonic-gate echo "\n==== Installing IHV packages from $IA32_IHV_PKGS ($LABEL) ====\n" \ 9747c478bd9Sstevel@tonic-gate >> $LOGFILE 9757c478bd9Sstevel@tonic-gate if [ -d "$IA32_IHV_PKGS" ]; then 9767c478bd9Sstevel@tonic-gate cd $IA32_IHV_PKGS 977b83ec4edSjmcp tar cf - * | \ 9787c478bd9Sstevel@tonic-gate (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 9797c478bd9Sstevel@tonic-gate else 9807c478bd9Sstevel@tonic-gate echo "$IA32_IHV_PKGS: not found" >> $LOGFILE 9817c478bd9Sstevel@tonic-gate fi 9827c478bd9Sstevel@tonic-gate 9837c478bd9Sstevel@tonic-gate echo "\n==== Installing IHV packages from $IA32_IHV_BINARY_PKGS ($LABEL) ====\n" \ 9847c478bd9Sstevel@tonic-gate >> $LOGFILE 9857c478bd9Sstevel@tonic-gate if [ -d "$IA32_IHV_BINARY_PKGS" ]; then 9867c478bd9Sstevel@tonic-gate cd $IA32_IHV_BINARY_PKGS 987b83ec4edSjmcp tar cf - * | \ 9887c478bd9Sstevel@tonic-gate (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 9897c478bd9Sstevel@tonic-gate else 9907c478bd9Sstevel@tonic-gate echo "$IA32_IHV_BINARY_PKGS: not found" >> $LOGFILE 9917c478bd9Sstevel@tonic-gate fi 9927c478bd9Sstevel@tonic-gate} 9937c478bd9Sstevel@tonic-gate 9944e5b757fSkupfer# 9954e5b757fSkupfer# Build and install the onbld tools. 9964e5b757fSkupfer# 9971fe69678Skupfer# usage: build_tools DESTROOT 9984e5b757fSkupfer# 9994e5b757fSkupfer# returns non-zero status if the build was successful. 10004e5b757fSkupfer# 1001597bd30bSMike Kupferfunction build_tools { 10027c478bd9Sstevel@tonic-gate DESTROOT=$1 10037c478bd9Sstevel@tonic-gate 10047c478bd9Sstevel@tonic-gate INSTALLOG=install-${MACH} 10057c478bd9Sstevel@tonic-gate 10067c478bd9Sstevel@tonic-gate echo "\n==== Building tools at `date` ====\n" \ 10077c478bd9Sstevel@tonic-gate >> $LOGFILE 10087c478bd9Sstevel@tonic-gate 10097c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/${INSTALLOG}.out 10107c478bd9Sstevel@tonic-gate cd ${TOOLS} 1011ead1f93eSLiane Praza /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \ 10127c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 10137c478bd9Sstevel@tonic-gate 10147c478bd9Sstevel@tonic-gate echo "\n==== Tools build errors ====\n" >> $mail_msg_file 10157c478bd9Sstevel@tonic-gate 10167c478bd9Sstevel@tonic-gate egrep ":" ${TOOLS}/${INSTALLOG}.out | 10177c478bd9Sstevel@tonic-gate egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 10187c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 10197c478bd9Sstevel@tonic-gate egrep -v warning >> $mail_msg_file 10204e5b757fSkupfer return $? 10214e5b757fSkupfer} 10224e5b757fSkupfer 10234e5b757fSkupfer# 10244e5b757fSkupfer# Set up to use locally installed tools. 10254e5b757fSkupfer# 10264e5b757fSkupfer# usage: use_tools TOOLSROOT 10274e5b757fSkupfer# 1028597bd30bSMike Kupferfunction use_tools { 10294e5b757fSkupfer TOOLSROOT=$1 10304e5b757fSkupfer 1031c168ccb7SMark J. Nelson # 1032c168ccb7SMark J. Nelson # If we're not building ON workspace, then the TOOLSROOT 1033c168ccb7SMark J. Nelson # settings here are clearly ignored by the workspace 1034c168ccb7SMark J. Nelson # makefiles, prepending nonexistent directories to PATH is 1035c168ccb7SMark J. Nelson # harmless, and we clearly do not wish to override 1036c168ccb7SMark J. Nelson # ONBLD_TOOLS. 1037c168ccb7SMark J. Nelson # 1038c168ccb7SMark J. Nelson # If we're building an ON workspace, then the prepended PATH 1039c168ccb7SMark J. Nelson # elements should supercede the preexisting ONBLD_TOOLS paths, 1040c168ccb7SMark J. Nelson # and we want to override ONBLD_TOOLS to catch the tools that 1041c168ccb7SMark J. Nelson # don't have specific path env vars here. 1042c168ccb7SMark J. Nelson # 1043c168ccb7SMark J. Nelson # So the only conditional behavior is overriding ONBLD_TOOLS, 1044c168ccb7SMark J. Nelson # and we check for "an ON workspace" by looking for 1045c168ccb7SMark J. Nelson # ${TOOLSROOT}/opt/onbld. 1046c168ccb7SMark J. Nelson # 1047c168ccb7SMark J. Nelson 10484e5b757fSkupfer STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs 10497c478bd9Sstevel@tonic-gate export STABS 10504e5b757fSkupfer CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs 10517c478bd9Sstevel@tonic-gate export CTFSTABS 10524e5b757fSkupfer GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets 10537c478bd9Sstevel@tonic-gate export GENOFFSETS 10547c478bd9Sstevel@tonic-gate 10554e5b757fSkupfer CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert 10567c478bd9Sstevel@tonic-gate export CTFCONVERT 10574e5b757fSkupfer CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge 10587c478bd9Sstevel@tonic-gate export CTFMERGE 10597c478bd9Sstevel@tonic-gate 10604e5b757fSkupfer CTFCVTPTBL=${TOOLSROOT}/opt/onbld/bin/ctfcvtptbl 10617c478bd9Sstevel@tonic-gate export CTFCVTPTBL 10624e5b757fSkupfer CTFFINDMOD=${TOOLSROOT}/opt/onbld/bin/ctffindmod 10637c478bd9Sstevel@tonic-gate export CTFFINDMOD 10647c478bd9Sstevel@tonic-gate 10657c478bd9Sstevel@tonic-gate if [ "$VERIFY_ELFSIGN" = "y" ]; then 10664e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp 10677c478bd9Sstevel@tonic-gate else 10684e5b757fSkupfer ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign 10697c478bd9Sstevel@tonic-gate fi 10707c478bd9Sstevel@tonic-gate export ELFSIGN 10717c478bd9Sstevel@tonic-gate 1072c168ccb7SMark J. Nelson PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" 10734e5b757fSkupfer PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" 10747c478bd9Sstevel@tonic-gate export PATH 10757c478bd9Sstevel@tonic-gate 1076c168ccb7SMark J. Nelson if [ -d "${TOOLSROOT}/opt/onbld" ]; then 1077b06f2c55SMark J. Nelson ONBLD_TOOLS=${TOOLSROOT}/opt/onbld 10781d9a8b8dSDan Mick export ONBLD_TOOLS 1079c168ccb7SMark J. Nelson fi 10801d9a8b8dSDan Mick 10817c478bd9Sstevel@tonic-gate echo "\n==== New environment settings. ====\n" >> $LOGFILE 10827c478bd9Sstevel@tonic-gate echo "STABS=${STABS}" >> $LOGFILE 10837c478bd9Sstevel@tonic-gate echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 10847c478bd9Sstevel@tonic-gate echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 10857c478bd9Sstevel@tonic-gate echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 10867c478bd9Sstevel@tonic-gate echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE 10877c478bd9Sstevel@tonic-gate echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE 10887c478bd9Sstevel@tonic-gate echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 10897c478bd9Sstevel@tonic-gate echo "PATH=${PATH}" >> $LOGFILE 10901d9a8b8dSDan Mick echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE 10917c478bd9Sstevel@tonic-gate} 10927c478bd9Sstevel@tonic-gate 1093597bd30bSMike Kupferfunction staffer { 10947c478bd9Sstevel@tonic-gate if [ $ISUSER -ne 0 ]; then 10957c478bd9Sstevel@tonic-gate "$@" 10967c478bd9Sstevel@tonic-gate else 10977c478bd9Sstevel@tonic-gate arg="\"$1\"" 10987c478bd9Sstevel@tonic-gate shift 10997c478bd9Sstevel@tonic-gate for i 11007c478bd9Sstevel@tonic-gate do 11017c478bd9Sstevel@tonic-gate arg="$arg \"$i\"" 11027c478bd9Sstevel@tonic-gate done 11037c478bd9Sstevel@tonic-gate eval su $STAFFER -c \'$arg\' 11047c478bd9Sstevel@tonic-gate fi 11057c478bd9Sstevel@tonic-gate} 11067c478bd9Sstevel@tonic-gate 1107085d331dSkupfer# 1108085d331dSkupfer# Verify that the closed tree is present if it needs to be. 1109085d331dSkupfer# Sets CLOSED_IS_PRESENT for future use. 1110085d331dSkupfer# 1111597bd30bSMike Kupferfunction check_closed_tree { 1112085d331dSkupfer if [ -z "$CLOSED_IS_PRESENT" ]; then 11135c53ea7aSmjnelson if [ -d $CODEMGR_WS/usr/closed ]; then 1114085d331dSkupfer CLOSED_IS_PRESENT="yes" 1115085d331dSkupfer else 1116085d331dSkupfer CLOSED_IS_PRESENT="no" 1117085d331dSkupfer fi 1118085d331dSkupfer export CLOSED_IS_PRESENT 1119085d331dSkupfer fi 1120085d331dSkupfer if [[ "$CLOSED_IS_PRESENT" = no && ! -d "$ON_CLOSED_BINS" ]]; then 1121085d331dSkupfer # 1122085d331dSkupfer # If it's an old (pre-split) tree or an empty 1123085d331dSkupfer # workspace, don't complain. 1124085d331dSkupfer # 1125085d331dSkupfer if grep -s CLOSED_BUILD $SRC/Makefile.master > /dev/null; then 1126085d331dSkupfer echo "If the closed sources are not present," \ 1127085d331dSkupfer "ON_CLOSED_BINS" 1128085d331dSkupfer echo "must point to the closed binaries tree." 1129cdf0c1d5Smjnelson build_ok=n 1130085d331dSkupfer exit 1 1131085d331dSkupfer fi 1132085d331dSkupfer fi 1133085d331dSkupfer} 11347c478bd9Sstevel@tonic-gate 1135597bd30bSMike Kupferfunction obsolete_build { 1136d77e7149Ssommerfe echo "WARNING: Obsolete $1 build requested; request will be ignored" 1137d77e7149Ssommerfe} 1138d77e7149Ssommerfe 11394e5b757fSkupfer# 11404e5b757fSkupfer# wrapper over wsdiff. 11414e5b757fSkupfer# usage: do_wsdiff LABEL OLDPROTO NEWPROTO 11424e5b757fSkupfer# 1143597bd30bSMike Kupferfunction do_wsdiff { 11444e5b757fSkupfer label=$1 11454e5b757fSkupfer oldproto=$2 11464e5b757fSkupfer newproto=$3 11474e5b757fSkupfer 11484e5b757fSkupfer wsdiff="wsdiff" 11494e5b757fSkupfer [ "$t_FLAG" = y ] && wsdiff="wsdiff -t" 11504e5b757fSkupfer 1151598cc7dfSVladimir Kotal echo "\n==== Getting object changes since last build at `date`" \ 1152598cc7dfSVladimir Kotal "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file 1153598cc7dfSVladimir Kotal $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \ 1154598cc7dfSVladimir Kotal tee -a $LOGFILE >> $mail_msg_file 1155598cc7dfSVladimir Kotal echo "\n==== Object changes determined at `date` ($label) ====\n" | \ 11564e5b757fSkupfer tee -a $LOGFILE >> $mail_msg_file 11574e5b757fSkupfer} 11584e5b757fSkupfer 11594e5b757fSkupfer# 1160ead1f93eSLiane Praza# Functions for setting build flags (DEBUG/non-DEBUG). Keep them 11614e5b757fSkupfer# together. 11624e5b757fSkupfer# 11634e5b757fSkupfer 1164597bd30bSMike Kupferfunction set_non_debug_build_flags { 11654e5b757fSkupfer export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 11664e5b757fSkupfer export RELEASE_BUILD ; RELEASE_BUILD= 11674e5b757fSkupfer unset EXTRA_OPTIONS 11684e5b757fSkupfer unset EXTRA_CFLAGS 11694e5b757fSkupfer} 11704e5b757fSkupfer 1171597bd30bSMike Kupferfunction set_debug_build_flags { 11724e5b757fSkupfer export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 11734e5b757fSkupfer unset RELEASE_BUILD 11744e5b757fSkupfer unset EXTRA_OPTIONS 11754e5b757fSkupfer unset EXTRA_CFLAGS 11764e5b757fSkupfer} 11774e5b757fSkupfer 1178d77e7149Ssommerfe 11797c478bd9Sstevel@tonic-gateMACH=`uname -p` 11807c478bd9Sstevel@tonic-gate 11817c478bd9Sstevel@tonic-gateif [ "$OPTHOME" = "" ]; then 11827c478bd9Sstevel@tonic-gate OPTHOME=/opt 11837c478bd9Sstevel@tonic-gate export OPTHOME 11847c478bd9Sstevel@tonic-gatefi 11857c478bd9Sstevel@tonic-gateif [ "$TEAMWARE" = "" ]; then 11867c478bd9Sstevel@tonic-gate TEAMWARE=$OPTHOME/teamware 11877c478bd9Sstevel@tonic-gate export TEAMWARE 11887c478bd9Sstevel@tonic-gatefi 11897c478bd9Sstevel@tonic-gate 11905e1b109eSPeter Dennis - Sustaining EngineerUSAGE='Usage: nightly [-in] [+t] [-V VERS ] [ -S E|D|H|O ] <env_file> 11917c478bd9Sstevel@tonic-gate 11927c478bd9Sstevel@tonic-gateWhere: 1193d77e7149Ssommerfe -i Fast incremental options (no clobber, lint, check) 11947c478bd9Sstevel@tonic-gate -n Do not do a bringover 11955e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 11967c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 11977c478bd9Sstevel@tonic-gate -S Build a variant of the source product 11987c478bd9Sstevel@tonic-gate E - build exportable source 11997c478bd9Sstevel@tonic-gate D - build domestic source (exportable + crypt) 12007c478bd9Sstevel@tonic-gate H - build hybrid source (binaries + deleted source) 12011fe69678Skupfer O - build (only) open source 12027c478bd9Sstevel@tonic-gate 12037c478bd9Sstevel@tonic-gate <env_file> file in Bourne shell syntax that sets and exports 12047c478bd9Sstevel@tonic-gate variables that configure the operation of this script and many of 12057c478bd9Sstevel@tonic-gate the scripts this one calls. If <env_file> does not exist, 12067c478bd9Sstevel@tonic-gate it will be looked for in $OPTHOME/onbld/env. 12077c478bd9Sstevel@tonic-gate 12087c478bd9Sstevel@tonic-gatenon-DEBUG is the default build type. Build options can be set in the 12097c478bd9Sstevel@tonic-gateNIGHTLY_OPTIONS variable in the <env_file> as follows: 12107c478bd9Sstevel@tonic-gate 12117c478bd9Sstevel@tonic-gate -A check for ABI differences in .so files 12127c478bd9Sstevel@tonic-gate -C check for cstyle/hdrchk errors 12137c478bd9Sstevel@tonic-gate -D do a build with DEBUG on 12147c478bd9Sstevel@tonic-gate -F do _not_ do a non-DEBUG build 12153c6aa570SMark J. Nelson -G gate keeper default group of options (-au) 12167c478bd9Sstevel@tonic-gate -I integration engineer default group of options (-ampu) 12177c478bd9Sstevel@tonic-gate -M do not run pmodes (safe file permission checker) 12187c478bd9Sstevel@tonic-gate -N do not run protocmp 12194e5b757fSkupfer -O generate OpenSolaris deliverables 12207c478bd9Sstevel@tonic-gate -R default group of options for building a release (-mp) 12217c478bd9Sstevel@tonic-gate -U update proto area in the parent 12227c478bd9Sstevel@tonic-gate -V VERS set the build version string to VERS 122304a42e3eSszhou -X copy x86 IHV proto area 12247c478bd9Sstevel@tonic-gate -f find unreferenced files 12257c478bd9Sstevel@tonic-gate -i do an incremental build (no "make clobber") 12267c478bd9Sstevel@tonic-gate -l do "make lint" in $LINTDIRS (default: $SRC y) 12277c478bd9Sstevel@tonic-gate -m send mail to $MAILTO at end of build 12287c478bd9Sstevel@tonic-gate -n do not do a bringover 12297c478bd9Sstevel@tonic-gate -o build using root privileges to set OWNER/GROUP (old style) 12307c478bd9Sstevel@tonic-gate -p create packages 12317c478bd9Sstevel@tonic-gate -r check ELF runtime attributes in the proto area 12325e1b109eSPeter Dennis - Sustaining Engineer -t build and use the tools in $SRC/tools (default setting) 12335e1b109eSPeter Dennis - Sustaining Engineer +t Use the build tools in $ONBLD_TOOLS/bin 12347c478bd9Sstevel@tonic-gate -u update proto_list_$MACH and friends in the parent workspace; 12357c478bd9Sstevel@tonic-gate when used with -f, also build an unrefmaster.out in the parent 123696ccc8cbSesaxe -w report on differences between previous and current proto areas 12377c478bd9Sstevel@tonic-gate -z compress cpio archives with gzip 12387c478bd9Sstevel@tonic-gate -W Do not report warnings (freeware gate ONLY) 12397c478bd9Sstevel@tonic-gate -S Build a variant of the source product 12407c478bd9Sstevel@tonic-gate E - build exportable source 12417c478bd9Sstevel@tonic-gate D - build domestic source (exportable + crypt) 12427c478bd9Sstevel@tonic-gate H - build hybrid source (binaries + deleted source) 12431fe69678Skupfer O - build (only) open source 12447c478bd9Sstevel@tonic-gate' 12457c478bd9Sstevel@tonic-gate# 12467c478bd9Sstevel@tonic-gate# -x less public handling of xmod source for the source product 12477c478bd9Sstevel@tonic-gate# 12487c478bd9Sstevel@tonic-gate# A log file will be generated under the name $LOGFILE 12491c79753fSdarrenm# for partially completed build and log.`date '+%F'` 12507c478bd9Sstevel@tonic-gate# in the same directory for fully completed builds. 12517c478bd9Sstevel@tonic-gate# 12527c478bd9Sstevel@tonic-gate 12537c478bd9Sstevel@tonic-gate# default values for low-level FLAGS; G I R are group FLAGS 12547c478bd9Sstevel@tonic-gateA_FLAG=n 12557c478bd9Sstevel@tonic-gateC_FLAG=n 12566c3c9007SstevelD_FLAG=n 12577c478bd9Sstevel@tonic-gateF_FLAG=n 12587c478bd9Sstevel@tonic-gatef_FLAG=n 12597c478bd9Sstevel@tonic-gatei_FLAG=n; i_CMD_LINE_FLAG=n 12607c478bd9Sstevel@tonic-gatel_FLAG=n 12616c3c9007SstevelM_FLAG=n 12627c478bd9Sstevel@tonic-gatem_FLAG=n 12636c3c9007SstevelN_FLAG=n 12646c3c9007Ssteveln_FLAG=n 12654e5b757fSkupferO_FLAG=n 12666c3c9007Sstevelo_FLAG=n 12676c3c9007SstevelP_FLAG=n 12687c478bd9Sstevel@tonic-gatep_FLAG=n 12697c478bd9Sstevel@tonic-gater_FLAG=n 12706c3c9007SstevelT_FLAG=n 1271fd7cef36Ssuhat_FLAG=y 12727c478bd9Sstevel@tonic-gateU_FLAG=n 12736c3c9007Sstevelu_FLAG=n 12747c478bd9Sstevel@tonic-gateV_FLAG=n 12757c478bd9Sstevel@tonic-gateW_FLAG=n 12766c3c9007Sstevelw_FLAG=n 12776c3c9007SstevelX_FLAG=n 12787c478bd9Sstevel@tonic-gateSD_FLAG=n 12796c3c9007SstevelSE_FLAG=n 12807c478bd9Sstevel@tonic-gateSH_FLAG=n 12811fe69678SkupferSO_FLAG=n 12827c478bd9Sstevel@tonic-gate# 12837c478bd9Sstevel@tonic-gateXMOD_OPT= 12847c478bd9Sstevel@tonic-gate# 12857c478bd9Sstevel@tonic-gatebuild_ok=y 12861fe69678Skupfer 1287597bd30bSMike Kupferfunction is_source_build { 12881fe69678Skupfer [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o \ 12891fe69678Skupfer "$SH_FLAG" = "y" -o "$SO_FLAG" = "y" ] 12901fe69678Skupfer return $? 12911fe69678Skupfer} 12921fe69678Skupfer 12937c478bd9Sstevel@tonic-gate# 12947c478bd9Sstevel@tonic-gate# examine arguments 12957c478bd9Sstevel@tonic-gate# 12967c478bd9Sstevel@tonic-gate 12971fe69678Skupfer# 12981fe69678Skupfer# single function for setting -S flag and doing error checking. 12991fe69678Skupfer# usage: set_S_flag <type> 13001fe69678Skupfer# where <type> is the source build type ("E", "D", ...). 13011fe69678Skupfer# 1302597bd30bSMike Kupferfunction set_S_flag { 13031fe69678Skupfer if is_source_build; then 13041fe69678Skupfer echo "Can only build one source variant at a time." 13051fe69678Skupfer exit 1 13061fe69678Skupfer fi 13071fe69678Skupfer if [ "$1" = "E" ]; then 13081fe69678Skupfer SE_FLAG=y 13091fe69678Skupfer elif [ "$1" = "D" ]; then 13101fe69678Skupfer SD_FLAG=y 13111fe69678Skupfer elif [ "$1" = "H" ]; then 13121fe69678Skupfer SH_FLAG=y 13131fe69678Skupfer elif [ "$1" = "O" ]; then 13141fe69678Skupfer SO_FLAG=y 13151fe69678Skupfer else 13161fe69678Skupfer echo "$USAGE" 13171fe69678Skupfer exit 1 13181fe69678Skupfer fi 13191fe69678Skupfer} 13201fe69678Skupfer 13217c478bd9Sstevel@tonic-gateOPTIND=1 13225e1b109eSPeter Dennis - Sustaining Engineerwhile getopts +inS:tV: FLAG 13237c478bd9Sstevel@tonic-gatedo 13247c478bd9Sstevel@tonic-gate case $FLAG in 13257c478bd9Sstevel@tonic-gate i ) i_FLAG=y; i_CMD_LINE_FLAG=y 13267c478bd9Sstevel@tonic-gate ;; 13277c478bd9Sstevel@tonic-gate n ) n_FLAG=y 13287c478bd9Sstevel@tonic-gate ;; 13297c478bd9Sstevel@tonic-gate S ) 13301fe69678Skupfer set_S_flag $OPTARG 13317c478bd9Sstevel@tonic-gate ;; 1332fd7cef36Ssuha +t ) t_FLAG=n 13337c478bd9Sstevel@tonic-gate ;; 13346c3c9007Sstevel V ) V_FLAG=y 13356c3c9007Sstevel V_ARG="$OPTARG" 13366c3c9007Sstevel ;; 13377c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 13387c478bd9Sstevel@tonic-gate exit 1 13397c478bd9Sstevel@tonic-gate ;; 13407c478bd9Sstevel@tonic-gate esac 13417c478bd9Sstevel@tonic-gatedone 13427c478bd9Sstevel@tonic-gate 13437c478bd9Sstevel@tonic-gate# correct argument count after options 13447c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 13457c478bd9Sstevel@tonic-gate 13467c478bd9Sstevel@tonic-gate# test that the path to the environment-setting file was given 13477c478bd9Sstevel@tonic-gateif [ $# -ne 1 ]; then 13487c478bd9Sstevel@tonic-gate echo "$USAGE" 13497c478bd9Sstevel@tonic-gate exit 1 13507c478bd9Sstevel@tonic-gatefi 13517c478bd9Sstevel@tonic-gate 13527c478bd9Sstevel@tonic-gate# check if user is running nightly as root 13537c478bd9Sstevel@tonic-gate# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 13547c478bd9Sstevel@tonic-gate# when root invokes nightly. 13557c478bd9Sstevel@tonic-gate/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 13567c478bd9Sstevel@tonic-gateISUSER=$?; export ISUSER 13577c478bd9Sstevel@tonic-gate 13587c478bd9Sstevel@tonic-gate# 13597c478bd9Sstevel@tonic-gate# force locale to C 13607c478bd9Sstevel@tonic-gateLC_COLLATE=C; export LC_COLLATE 13617c478bd9Sstevel@tonic-gateLC_CTYPE=C; export LC_CTYPE 13627c478bd9Sstevel@tonic-gateLC_MESSAGES=C; export LC_MESSAGES 13637c478bd9Sstevel@tonic-gateLC_MONETARY=C; export LC_MONETARY 13647c478bd9Sstevel@tonic-gateLC_NUMERIC=C; export LC_NUMERIC 13657c478bd9Sstevel@tonic-gateLC_TIME=C; export LC_TIME 13667c478bd9Sstevel@tonic-gate 13677c478bd9Sstevel@tonic-gate# clear environment variables we know to be bad for the build 13687c478bd9Sstevel@tonic-gateunset LD_OPTIONS 13697c478bd9Sstevel@tonic-gateunset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 13707c478bd9Sstevel@tonic-gateunset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 13717c478bd9Sstevel@tonic-gateunset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 13727c478bd9Sstevel@tonic-gateunset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 13737c478bd9Sstevel@tonic-gateunset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 13747c478bd9Sstevel@tonic-gateunset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 13757c478bd9Sstevel@tonic-gateunset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 13767c478bd9Sstevel@tonic-gateunset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 13777c478bd9Sstevel@tonic-gateunset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 13787c478bd9Sstevel@tonic-gateunset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 13797c478bd9Sstevel@tonic-gateunset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 13807c478bd9Sstevel@tonic-gateunset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 13817c478bd9Sstevel@tonic-gateunset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 13827c478bd9Sstevel@tonic-gateunset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 13837c478bd9Sstevel@tonic-gateunset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 13847c478bd9Sstevel@tonic-gateunset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 13857c478bd9Sstevel@tonic-gateunset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 13867c478bd9Sstevel@tonic-gateunset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 13877c478bd9Sstevel@tonic-gateunset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 13887c478bd9Sstevel@tonic-gateunset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 13897c478bd9Sstevel@tonic-gate 13907c478bd9Sstevel@tonic-gateunset CONFIG 13917c478bd9Sstevel@tonic-gateunset GROUP 13927c478bd9Sstevel@tonic-gateunset OWNER 13937c478bd9Sstevel@tonic-gateunset REMOTE 13947c478bd9Sstevel@tonic-gateunset ENV 13957c478bd9Sstevel@tonic-gateunset ARCH 13967c478bd9Sstevel@tonic-gateunset CLASSPATH 13977c478bd9Sstevel@tonic-gateunset NAME 13987c478bd9Sstevel@tonic-gate 13997c478bd9Sstevel@tonic-gate# 1400ead1f93eSLiane Praza# To get ONBLD_TOOLS from the environment, it must come from the env file. 1401ead1f93eSLiane Praza# If it comes interactively, it is generally TOOLS_PROTO, which will be 1402ead1f93eSLiane Praza# clobbered before the compiler version checks, which will therefore fail. 1403ead1f93eSLiane Praza# 1404ead1f93eSLiane Prazaunset ONBLD_TOOLS 1405ead1f93eSLiane Praza 1406ead1f93eSLiane Praza# 14077c478bd9Sstevel@tonic-gate# Setup environmental variables 14087c478bd9Sstevel@tonic-gate# 140947703246Ssommerfeif [ -f /etc/nightly.conf ]; then 141047703246Ssommerfe . /etc/nightly.conf 141147703246Ssommerfefi 141247703246Ssommerfe 14137c478bd9Sstevel@tonic-gateif [ -f $1 ]; then 14147c478bd9Sstevel@tonic-gate if [[ $1 = */* ]]; then 14157c478bd9Sstevel@tonic-gate . $1 14167c478bd9Sstevel@tonic-gate else 14177c478bd9Sstevel@tonic-gate . ./$1 14187c478bd9Sstevel@tonic-gate fi 14197c478bd9Sstevel@tonic-gateelse 14207c478bd9Sstevel@tonic-gate if [ -f $OPTHOME/onbld/env/$1 ]; then 14217c478bd9Sstevel@tonic-gate . $OPTHOME/onbld/env/$1 14227c478bd9Sstevel@tonic-gate else 14237c478bd9Sstevel@tonic-gate echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 14247c478bd9Sstevel@tonic-gate exit 1 14257c478bd9Sstevel@tonic-gate fi 14267c478bd9Sstevel@tonic-gatefi 14277c478bd9Sstevel@tonic-gate 14281fe69678Skupfer# contents of stdenv.sh inserted after next line: 14291fe69678Skupfer# STDENV_START 14301fe69678Skupfer# STDENV_END 14311fe69678Skupfer 14327c478bd9Sstevel@tonic-gate# 14337c478bd9Sstevel@tonic-gate# place ourselves in a new task, respecting BUILD_PROJECT if set. 14347c478bd9Sstevel@tonic-gate# 14357c478bd9Sstevel@tonic-gateif [ -z "$BUILD_PROJECT" ]; then 14367c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ 14377c478bd9Sstevel@tonic-gateelse 14387c478bd9Sstevel@tonic-gate /usr/bin/newtask -c $$ -p $BUILD_PROJECT 14397c478bd9Sstevel@tonic-gatefi 14407c478bd9Sstevel@tonic-gate 14417c478bd9Sstevel@tonic-gateps -o taskid= -p $$ | read build_taskid 14427c478bd9Sstevel@tonic-gateps -o project= -p $$ | read build_project 14437c478bd9Sstevel@tonic-gate 14447c478bd9Sstevel@tonic-gate# 14457c478bd9Sstevel@tonic-gate# See if NIGHTLY_OPTIONS is set 14467c478bd9Sstevel@tonic-gate# 14477c478bd9Sstevel@tonic-gateif [ "$NIGHTLY_OPTIONS" = "" ]; then 14487c478bd9Sstevel@tonic-gate NIGHTLY_OPTIONS="-aBm" 14497c478bd9Sstevel@tonic-gatefi 14507c478bd9Sstevel@tonic-gate 14517c478bd9Sstevel@tonic-gate# 14527c478bd9Sstevel@tonic-gate# If BRINGOVER_WS was not specified, let it default to CLONE_WS 14537c478bd9Sstevel@tonic-gate# 14547c478bd9Sstevel@tonic-gateif [ "$BRINGOVER_WS" = "" ]; then 14557c478bd9Sstevel@tonic-gate BRINGOVER_WS=$CLONE_WS 14567c478bd9Sstevel@tonic-gatefi 14577c478bd9Sstevel@tonic-gate 14587c478bd9Sstevel@tonic-gate# 1459cdf0c1d5Smjnelson# If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS 1460cdf0c1d5Smjnelson# 1461cdf0c1d5Smjnelsonif [ "$CLOSED_BRINGOVER_WS" = "" ]; then 1462cdf0c1d5Smjnelson CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS 1463cdf0c1d5Smjnelsonfi 1464cdf0c1d5Smjnelson 1465cdf0c1d5Smjnelson# 1466fb23a357Skupfer# If BRINGOVER_FILES was not specified, default to usr 1467a5c06a9eSmike_s# 1468a5c06a9eSmike_sif [ "$BRINGOVER_FILES" = "" ]; then 1469fb23a357Skupfer BRINGOVER_FILES="usr" 1470a5c06a9eSmike_sfi 1471a5c06a9eSmike_s 1472fb9f9b97Skupfer# 1473fb9f9b97Skupfer# If the closed sources are not present, the closed binaries must be 1474fb9f9b97Skupfer# present for the build to succeed. If there's no pointer to the 1475fb9f9b97Skupfer# closed binaries, flag that now, rather than forcing the user to wait 1476fb9f9b97Skupfer# a couple hours (or more) to find out. 1477fb9f9b97Skupfer# 1478085d331dSkupferorig_closed_is_present="$CLOSED_IS_PRESENT" 1479085d331dSkupfercheck_closed_tree 1480fb9f9b97Skupfer 1481a5c06a9eSmike_s# 14827c478bd9Sstevel@tonic-gate# Note: changes to the option letters here should also be applied to the 1483b84bdc30Smeem# bldenv script. `d' is listed for backward compatibility. 14847c478bd9Sstevel@tonic-gate# 1485d77e7149SsommerfeNIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 14867c478bd9Sstevel@tonic-gateOPTIND=1 148778add226Sjmcpwhile getopts +ABCDdFfGIilMmNnOoPpRrS:TtUuWwXxz FLAG $NIGHTLY_OPTIONS 14887c478bd9Sstevel@tonic-gatedo 14897c478bd9Sstevel@tonic-gate case $FLAG in 14907c478bd9Sstevel@tonic-gate A ) A_FLAG=y 14915253169eSAli Bahrami # 14925253169eSAli Bahrami # If ELF_DATA_BASELINE_DIR is not defined, and we are on SWAN 14935253169eSAli Bahrami # (based on CLOSED_IS_PRESENT), then refuse to run. The value 14945253169eSAli Bahrami # of ELF version checking is greatly enhanced by including 14955253169eSAli Bahrami # the baseline gate comparison. 14965253169eSAli Bahrami if [ "$CLOSED_IS_PRESENT" = 'yes' -a \ 14975253169eSAli Bahrami "$ELF_DATA_BASELINE_DIR" = '' ]; then 14985253169eSAli Bahrami echo "ELF_DATA_BASELINE_DIR must be set if the A" \ 14995253169eSAli Bahrami "flag is present in\nNIGHTLY_OPTIONS and closed" \ 15005253169eSAli Bahrami "sources are present. Update environment file." 15015253169eSAli Bahrami exit 1; 15025253169eSAli Bahrami fi 15037c478bd9Sstevel@tonic-gate ;; 15047c478bd9Sstevel@tonic-gate B ) D_FLAG=y 15057c478bd9Sstevel@tonic-gate ;; # old version of D 15066c3c9007Sstevel C ) C_FLAG=y 15077c478bd9Sstevel@tonic-gate ;; 15087c478bd9Sstevel@tonic-gate D ) D_FLAG=y 15097c478bd9Sstevel@tonic-gate ;; 15106c3c9007Sstevel F ) F_FLAG=y 15117c478bd9Sstevel@tonic-gate ;; 15126c3c9007Sstevel f ) f_FLAG=y 15137c478bd9Sstevel@tonic-gate ;; 151478add226Sjmcp G ) u_FLAG=y 15157c478bd9Sstevel@tonic-gate ;; 151678add226Sjmcp I ) m_FLAG=y 15177c478bd9Sstevel@tonic-gate p_FLAG=y 15187c478bd9Sstevel@tonic-gate u_FLAG=y 15197c478bd9Sstevel@tonic-gate ;; 15207c478bd9Sstevel@tonic-gate i ) i_FLAG=y 15217c478bd9Sstevel@tonic-gate ;; 15226c3c9007Sstevel l ) l_FLAG=y 15236c3c9007Sstevel ;; 15246c3c9007Sstevel M ) M_FLAG=y 15256c3c9007Sstevel ;; 15266c3c9007Sstevel m ) m_FLAG=y 15276c3c9007Sstevel ;; 15286c3c9007Sstevel N ) N_FLAG=y 15296c3c9007Sstevel ;; 15307c478bd9Sstevel@tonic-gate n ) n_FLAG=y 15317c478bd9Sstevel@tonic-gate ;; 15324e5b757fSkupfer O ) O_FLAG=y 15334e5b757fSkupfer ;; 15347c478bd9Sstevel@tonic-gate o ) o_FLAG=y 15357c478bd9Sstevel@tonic-gate ;; 15366c3c9007Sstevel P ) P_FLAG=y 15376c3c9007Sstevel ;; # obsolete 15387c478bd9Sstevel@tonic-gate p ) p_FLAG=y 15397c478bd9Sstevel@tonic-gate ;; 15406c3c9007Sstevel R ) m_FLAG=y 15416c3c9007Sstevel p_FLAG=y 15426c3c9007Sstevel ;; 15437c478bd9Sstevel@tonic-gate r ) r_FLAG=y 15447c478bd9Sstevel@tonic-gate ;; 15456c3c9007Sstevel S ) 15466c3c9007Sstevel set_S_flag $OPTARG 15476c3c9007Sstevel ;; 15486c3c9007Sstevel T ) T_FLAG=y 15496c3c9007Sstevel ;; # obsolete 1550fd7cef36Ssuha +t ) t_FLAG=n 15517c478bd9Sstevel@tonic-gate ;; 15526798c3f0SMark J. Nelson U ) if [ -z "${PARENT_ROOT}" ]; then 15537c478bd9Sstevel@tonic-gate echo "PARENT_ROOT must be set if the U flag is" \ 15547c478bd9Sstevel@tonic-gate "present in NIGHTLY_OPTIONS." 15557c478bd9Sstevel@tonic-gate exit 1 15567c478bd9Sstevel@tonic-gate fi 15576798c3f0SMark J. Nelson NIGHTLY_PARENT_ROOT=$PARENT_ROOT 15586798c3f0SMark J. Nelson if [ -n "${PARENT_TOOLS_ROOT}" ]; then 15596798c3f0SMark J. Nelson NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT 1560ead1f93eSLiane Praza fi 15617c478bd9Sstevel@tonic-gate U_FLAG=y 15627c478bd9Sstevel@tonic-gate ;; 15636c3c9007Sstevel u ) u_FLAG=y 15647c478bd9Sstevel@tonic-gate ;; 15657c478bd9Sstevel@tonic-gate W ) W_FLAG=y 15667c478bd9Sstevel@tonic-gate ;; 15676c3c9007Sstevel 15686c3c9007Sstevel w ) w_FLAG=y 15697c478bd9Sstevel@tonic-gate ;; 15707c478bd9Sstevel@tonic-gate X ) # now that we no longer need realmode builds, just 15717c478bd9Sstevel@tonic-gate # copy IHV packages. only meaningful on x86. 15727c478bd9Sstevel@tonic-gate if [ "$MACH" = "i386" ]; then 15737c478bd9Sstevel@tonic-gate X_FLAG=y 15747c478bd9Sstevel@tonic-gate fi 15757c478bd9Sstevel@tonic-gate ;; 15766c3c9007Sstevel x ) XMOD_OPT="-x" 15776c3c9007Sstevel ;; 15787c478bd9Sstevel@tonic-gate \? ) echo "$USAGE" 15797c478bd9Sstevel@tonic-gate exit 1 15807c478bd9Sstevel@tonic-gate ;; 15817c478bd9Sstevel@tonic-gate esac 15827c478bd9Sstevel@tonic-gatedone 15837c478bd9Sstevel@tonic-gate 15847c478bd9Sstevel@tonic-gateif [ $ISUSER -ne 0 ]; then 15857c478bd9Sstevel@tonic-gate if [ "$o_FLAG" = "y" ]; then 15867c478bd9Sstevel@tonic-gate echo "Old-style build requires root permission." 15877c478bd9Sstevel@tonic-gate exit 1 15887c478bd9Sstevel@tonic-gate fi 15897c478bd9Sstevel@tonic-gate 15907c478bd9Sstevel@tonic-gate # Set default value for STAFFER, if needed. 15917c478bd9Sstevel@tonic-gate if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 15927c478bd9Sstevel@tonic-gate STAFFER=`/usr/xpg4/bin/id -un` 15937c478bd9Sstevel@tonic-gate export STAFFER 15947c478bd9Sstevel@tonic-gate fi 15957c478bd9Sstevel@tonic-gatefi 15967c478bd9Sstevel@tonic-gate 15977c478bd9Sstevel@tonic-gateif [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 15987c478bd9Sstevel@tonic-gate MAILTO=$STAFFER 15997c478bd9Sstevel@tonic-gate export MAILTO 16007c478bd9Sstevel@tonic-gatefi 16017c478bd9Sstevel@tonic-gate 1602c168ccb7SMark J. NelsonPATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 1603c168ccb7SMark J. NelsonPATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb" 1604c168ccb7SMark J. NelsonPATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 16057c478bd9Sstevel@tonic-gateexport PATH 16067c478bd9Sstevel@tonic-gate 1607fb23a357Skupfer# roots of source trees, both relative to $SRC and absolute. 1608fb23a357Skupferrelsrcdirs="." 16095c53ea7aSmjnelsonif [[ -d $CODEMGR_WS/usr/closed && "$CLOSED_IS_PRESENT" != no ]]; then 1610fb9f9b97Skupfer relsrcdirs="$relsrcdirs ../closed" 1611fb9f9b97Skupferfi 1612fb23a357Skupferabssrcdirs="" 1613fb23a357Skupferfor d in $relsrcdirs; do 1614fb23a357Skupfer abssrcdirs="$abssrcdirs $SRC/$d" 1615fb23a357Skupferdone 1616fb23a357Skupfer 16177c478bd9Sstevel@tonic-gateunset CH 16187c478bd9Sstevel@tonic-gateif [ "$o_FLAG" = "y" ]; then 16197c478bd9Sstevel@tonic-gate# root invoked old-style build -- make sure it works as it always has 16207c478bd9Sstevel@tonic-gate# by exporting 'CH'. The current Makefile.master doesn't use this, but 16217c478bd9Sstevel@tonic-gate# the old ones still do. 16227c478bd9Sstevel@tonic-gate PROTOCMPTERSE="protocmp.terse" 16237c478bd9Sstevel@tonic-gate CH= 16247c478bd9Sstevel@tonic-gate export CH 16257c478bd9Sstevel@tonic-gateelse 16267c478bd9Sstevel@tonic-gate PROTOCMPTERSE="protocmp.terse -gu" 16277c478bd9Sstevel@tonic-gatefi 16287c478bd9Sstevel@tonic-gatePOUND_SIGN="#" 162948bc00d6Sjmcp# have we set RELEASE_DATE in our env file? 163048bc00d6Sjmcpif [ -z "$RELEASE_DATE" ]; then 163148bc00d6Sjmcp RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 163248bc00d6Sjmcpfi 163348bc00d6SjmcpBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d) 163448bc00d6SjmcpBASEWSDIR=$(basename $CODEMGR_WS) 163548bc00d6SjmcpDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\"" 16367c478bd9Sstevel@tonic-gate 163748bc00d6Sjmcp# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process 163848bc00d6Sjmcp# by avoiding repeated shell invocations to evaluate Makefile.master definitions. 16393c6aa570SMark J. Nelson# we export o_FLAG and X_FLAG for use by makebfu, and by usr/src/pkg/Makefile 164048bc00d6Sjmcpexport o_FLAG X_FLAG POUND_SIGN RELEASE_DATE DEV_CM 16417c478bd9Sstevel@tonic-gate 16427c478bd9Sstevel@tonic-gatemaketype="distributed" 16437c478bd9Sstevel@tonic-gateMAKE=dmake 16447c478bd9Sstevel@tonic-gate# get the dmake version string alone 16457c478bd9Sstevel@tonic-gateDMAKE_VERSION=$( $MAKE -v ) 16467c478bd9Sstevel@tonic-gateDMAKE_VERSION=${DMAKE_VERSION#*: } 16477c478bd9Sstevel@tonic-gate# focus in on just the dotted version number alone 16487c478bd9Sstevel@tonic-gateDMAKE_MAJOR=$( echo $DMAKE_VERSION | \ 16497c478bd9Sstevel@tonic-gate sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' ) 16507c478bd9Sstevel@tonic-gate# extract the second (or final) integer 16517c478bd9Sstevel@tonic-gateDMAKE_MINOR=${DMAKE_MAJOR#*.} 16527c478bd9Sstevel@tonic-gateDMAKE_MINOR=${DMAKE_MINOR%%.*} 16537c478bd9Sstevel@tonic-gate# extract the first integer 16547c478bd9Sstevel@tonic-gateDMAKE_MAJOR=${DMAKE_MAJOR%%.*} 16557c478bd9Sstevel@tonic-gateCHECK_DMAKE=${CHECK_DMAKE:-y} 16567c478bd9Sstevel@tonic-gate# x86 was built on the 12th, sparc on the 13th. 16577c478bd9Sstevel@tonic-gateif [ "$CHECK_DMAKE" = "y" -a \ 16587c478bd9Sstevel@tonic-gate "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \ 16597c478bd9Sstevel@tonic-gate "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \ 16607c478bd9Sstevel@tonic-gate "$DMAKE_MAJOR" -lt 7 -o \ 16617c478bd9Sstevel@tonic-gate "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then 16627c478bd9Sstevel@tonic-gate if [ -z "$DMAKE_VERSION" ]; then 16637c478bd9Sstevel@tonic-gate echo "$MAKE is missing." 16647c478bd9Sstevel@tonic-gate exit 1 16657c478bd9Sstevel@tonic-gate fi 16667c478bd9Sstevel@tonic-gate echo `whence $MAKE`" version is:" 16677c478bd9Sstevel@tonic-gate echo " ${DMAKE_VERSION}" 16687c478bd9Sstevel@tonic-gate cat <<EOF 16697c478bd9Sstevel@tonic-gate 16707c478bd9Sstevel@tonic-gateThis version may not be safe for use. Either set TEAMWARE to a better 16717c478bd9Sstevel@tonic-gatepath or (if you really want to use this version of dmake anyway), add 16727c478bd9Sstevel@tonic-gatethe following to your environment to disable this check: 16737c478bd9Sstevel@tonic-gate 16747c478bd9Sstevel@tonic-gate CHECK_DMAKE=n 16757c478bd9Sstevel@tonic-gateEOF 16767c478bd9Sstevel@tonic-gate exit 1 16777c478bd9Sstevel@tonic-gatefi 16787c478bd9Sstevel@tonic-gateexport PATH 16797c478bd9Sstevel@tonic-gateexport MAKE 16807c478bd9Sstevel@tonic-gate 1681597bd30bSMike Kupfer# 1682597bd30bSMike Kupfer# Make sure the crypto tarball is available if it's needed. 1683597bd30bSMike Kupfer# 1684597bd30bSMike Kupfer 1685ead1f93eSLiane Praza# Echo the non-DEBUG name corresponding to the given crypto tarball path. 1686597bd30bSMike Kupferfunction ndcrypto { 1687597bd30bSMike Kupfer typeset dir file 1688597bd30bSMike Kupfer 1689597bd30bSMike Kupfer if [ -z "$1" ]; then 1690597bd30bSMike Kupfer echo "" 1691597bd30bSMike Kupfer return 1692597bd30bSMike Kupfer fi 1693597bd30bSMike Kupfer 1694597bd30bSMike Kupfer dir=$(dirname "$1") 1695597bd30bSMike Kupfer file=$(basename "$1" ".$MACH.tar.bz2") 1696597bd30bSMike Kupfer 1697597bd30bSMike Kupfer echo "$dir/$file-nd.$MACH.tar.bz2" 1698597bd30bSMike Kupfer} 1699597bd30bSMike Kupfer 1700597bd30bSMike Kupfer# Return 0 (success) if the required crypto tarball(s) are present. 1701597bd30bSMike Kupferfunction crypto_is_present { 1702597bd30bSMike Kupfer if [ -z "$ON_CRYPTO_BINS" ]; then 1703597bd30bSMike Kupfer echo "ON_CRYPTO_BINS is null or not set." 1704597bd30bSMike Kupfer return 1 1705597bd30bSMike Kupfer fi 1706597bd30bSMike Kupfer if [ "$D_FLAG" = y ]; then 1707597bd30bSMike Kupfer if [ ! -f "$ON_CRYPTO_BINS" ]; then 1708597bd30bSMike Kupfer echo "DEBUG crypto tarball is unavailable." 1709597bd30bSMike Kupfer return 1 1710597bd30bSMike Kupfer fi 1711597bd30bSMike Kupfer fi 1712597bd30bSMike Kupfer if [ "$F_FLAG" = n ]; then 1713597bd30bSMike Kupfer if [ ! -f $(ndcrypto "$ON_CRYPTO_BINS") ]; then 1714597bd30bSMike Kupfer echo "Non-DEBUG crypto tarball is unavailable." 1715597bd30bSMike Kupfer return 1 1716597bd30bSMike Kupfer fi 1717597bd30bSMike Kupfer fi 1718597bd30bSMike Kupfer 1719597bd30bSMike Kupfer return 0 1720597bd30bSMike Kupfer} 1721597bd30bSMike Kupfer 1722597bd30bSMike Kupfer# 1723597bd30bSMike Kupfer# Canonicalize ON_CRYPTO_BINS, just in case it was set to the -nd 1724597bd30bSMike Kupfer# tarball. 1725597bd30bSMike Kupfer# 1726597bd30bSMike Kupferif [ -n "$ON_CRYPTO_BINS" ]; then 1727597bd30bSMike Kupfer export ON_CRYPTO_BINS=$(echo "$ON_CRYPTO_BINS" | 1728597bd30bSMike Kupfer sed -e s/-nd.$MACH.tar/.$MACH.tar/) 1729597bd30bSMike Kupferfi 1730597bd30bSMike Kupfer 1731597bd30bSMike Kupferif [[ "$O_FLAG" = y && -z "$CODESIGN_USER" ]]; then 1732597bd30bSMike Kupfer if ! crypto_is_present; then 1733597bd30bSMike Kupfer echo "OpenSolaris deliveries need signed crypto." 1734597bd30bSMike Kupfer exit 1 1735597bd30bSMike Kupfer fi 1736597bd30bSMike Kupferfi 1737597bd30bSMike Kupfer 1738b83ec4edSjmcpif [[ "$O_FLAG" = y ]]; then 1739b83ec4edSjmcp export TONICBUILD="" 1740b83ec4edSjmcpelse 1741b83ec4edSjmcp export TONICBUILD="#" 1742b83ec4edSjmcpfi 1743b83ec4edSjmcp 17447c478bd9Sstevel@tonic-gateif [ "${SUNWSPRO}" != "" ]; then 17457c478bd9Sstevel@tonic-gate PATH="${SUNWSPRO}/bin:$PATH" 17467c478bd9Sstevel@tonic-gate export PATH 17477c478bd9Sstevel@tonic-gatefi 17487c478bd9Sstevel@tonic-gate 174999e4a37bSWill Fiveashhostname=$(uname -n) 175099e4a37bSWill Fiveashif [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]] 175199e4a37bSWill Fiveashthen 175299e4a37bSWill Fiveash maxjobs= 175399e4a37bSWill Fiveash if [[ -f $HOME/.make.machines ]] 175499e4a37bSWill Fiveash then 175599e4a37bSWill Fiveash # Note: there is a hard tab and space character in the []s 175699e4a37bSWill Fiveash # below. 175799e4a37bSWill Fiveash egrep -i "^[ ]*$hostname[ \.]" \ 175899e4a37bSWill Fiveash $HOME/.make.machines | read host jobs 175999e4a37bSWill Fiveash maxjobs=${jobs##*=} 17607c478bd9Sstevel@tonic-gate fi 176199e4a37bSWill Fiveash 176299e4a37bSWill Fiveash if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]] 176399e4a37bSWill Fiveash then 176499e4a37bSWill Fiveash # default 176599e4a37bSWill Fiveash maxjobs=4 17667c478bd9Sstevel@tonic-gate fi 176799e4a37bSWill Fiveash 176899e4a37bSWill Fiveash export DMAKE_MAX_JOBS=$maxjobs 176999e4a37bSWill Fiveashfi 177099e4a37bSWill Fiveash 17717c478bd9Sstevel@tonic-gateDMAKE_MODE=parallel; 17727c478bd9Sstevel@tonic-gateexport DMAKE_MODE 17737c478bd9Sstevel@tonic-gate 17747c478bd9Sstevel@tonic-gateif [ -z "${ROOT}" ]; then 17757c478bd9Sstevel@tonic-gate echo "ROOT must be set." 17767c478bd9Sstevel@tonic-gate exit 1 17777c478bd9Sstevel@tonic-gatefi 17787c478bd9Sstevel@tonic-gate 17797c478bd9Sstevel@tonic-gate# 17807c478bd9Sstevel@tonic-gate# if -V flag was given, reset VERSION to V_ARG 17817c478bd9Sstevel@tonic-gate# 17827c478bd9Sstevel@tonic-gateif [ "$V_FLAG" = "y" ]; then 17837c478bd9Sstevel@tonic-gate VERSION=$V_ARG 17847c478bd9Sstevel@tonic-gatefi 17857c478bd9Sstevel@tonic-gate 178604a42e3eSszhou# 178704a42e3eSszhou# Check for IHV root for copying ihv proto area 178804a42e3eSszhou# 178904a42e3eSszhouif [ "$X_FLAG" = "y" ]; then 179004a42e3eSszhou if [ "$IA32_IHV_ROOT" = "" ]; then 179104a42e3eSszhou echo "IA32_IHV_ROOT: must be set for copying ihv proto" 179204a42e3eSszhou args_ok=n 179304a42e3eSszhou fi 179404a42e3eSszhou if [ ! -d "$IA32_IHV_ROOT" ]; then 179504a42e3eSszhou echo "$IA32_IHV_ROOT: not found" 179604a42e3eSszhou args_ok=n 179704a42e3eSszhou fi 17986fec3625Sdduvall if [ "$IA32_IHV_WS" = "" ]; then 17996fec3625Sdduvall echo "IA32_IHV_WS: must be set for copying ihv proto" 18006fec3625Sdduvall args_ok=n 18016fec3625Sdduvall fi 18026fec3625Sdduvall if [ ! -d "$IA32_IHV_WS" ]; then 18036fec3625Sdduvall echo "$IA32_IHV_WS: not found" 18046fec3625Sdduvall args_ok=n 18056fec3625Sdduvall fi 180604a42e3eSszhoufi 180704a42e3eSszhou 18087c478bd9Sstevel@tonic-gate# Append source version 18097c478bd9Sstevel@tonic-gateif [ "$SE_FLAG" = "y" ]; then 18107c478bd9Sstevel@tonic-gate VERSION="${VERSION}:EXPORT" 18117c478bd9Sstevel@tonic-gatefi 18127c478bd9Sstevel@tonic-gate 18137c478bd9Sstevel@tonic-gateif [ "$SD_FLAG" = "y" ]; then 18147c478bd9Sstevel@tonic-gate VERSION="${VERSION}:DOMESTIC" 18157c478bd9Sstevel@tonic-gatefi 18167c478bd9Sstevel@tonic-gate 18177c478bd9Sstevel@tonic-gateif [ "$SH_FLAG" = "y" ]; then 18187c478bd9Sstevel@tonic-gate VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT" 18197c478bd9Sstevel@tonic-gatefi 18207c478bd9Sstevel@tonic-gate 18211fe69678Skupferif [ "$SO_FLAG" = "y" ]; then 18221fe69678Skupfer VERSION="${VERSION}:OPEN_ONLY" 18231fe69678Skupferfi 18241fe69678Skupfer 18257c478bd9Sstevel@tonic-gateTMPDIR="/tmp/nightly.tmpdir.$$" 18267c478bd9Sstevel@tonic-gateexport TMPDIR 18277c478bd9Sstevel@tonic-gaterm -rf ${TMPDIR} 18287c478bd9Sstevel@tonic-gatemkdir -p $TMPDIR || exit 1 182985f46905SMark J. Nelsonchmod 777 $TMPDIR 18307c478bd9Sstevel@tonic-gate 18317c478bd9Sstevel@tonic-gate# 18327c478bd9Sstevel@tonic-gate# Keep elfsign's use of pkcs11_softtoken from looking in the user home 18337c478bd9Sstevel@tonic-gate# directory, which doesn't always work. Needed until all build machines 18347c478bd9Sstevel@tonic-gate# have the fix for 6271754 18357c478bd9Sstevel@tonic-gate# 18367c478bd9Sstevel@tonic-gateSOFTTOKEN_DIR=$TMPDIR 18377c478bd9Sstevel@tonic-gateexport SOFTTOKEN_DIR 18387c478bd9Sstevel@tonic-gate 1839ead1f93eSLiane Praza# 1840ead1f93eSLiane Praza# Tools should only be built non-DEBUG. Keep track of the tools proto 1841ead1f93eSLiane Praza# area path relative to $TOOLS, because the latter changes in an 1842ead1f93eSLiane Praza# export build. 1843ead1f93eSLiane Praza# 1844ead1f93eSLiane Praza# TOOLS_PROTO is included below for builds other than usr/src/tools 1845ead1f93eSLiane Praza# that look for this location. For usr/src/tools, this will be 1846ead1f93eSLiane Praza# overridden on the $MAKE command line in build_tools(). 1847ead1f93eSLiane Praza# 18487c478bd9Sstevel@tonic-gateTOOLS=${SRC}/tools 1849ead1f93eSLiane PrazaTOOLS_PROTO_REL=proto/root_${MACH}-nd 1850ead1f93eSLiane PrazaTOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 1851ead1f93eSLiane Praza 18527c478bd9Sstevel@tonic-gateunset CFLAGS LD_LIBRARY_PATH LDFLAGS 18537c478bd9Sstevel@tonic-gate 18547c478bd9Sstevel@tonic-gate# create directories that are automatically removed if the nightly script 18557c478bd9Sstevel@tonic-gate# fails to start correctly 1856597bd30bSMike Kupferfunction newdir { 18577c478bd9Sstevel@tonic-gate dir=$1 18587c478bd9Sstevel@tonic-gate toadd= 18597c478bd9Sstevel@tonic-gate while [ ! -d $dir ]; do 18607c478bd9Sstevel@tonic-gate toadd="$dir $toadd" 18617c478bd9Sstevel@tonic-gate dir=`dirname $dir` 18627c478bd9Sstevel@tonic-gate done 18637c478bd9Sstevel@tonic-gate torm= 18647c478bd9Sstevel@tonic-gate newlist= 18657c478bd9Sstevel@tonic-gate for dir in $toadd; do 18667c478bd9Sstevel@tonic-gate if staffer mkdir $dir; then 18677c478bd9Sstevel@tonic-gate newlist="$ISUSER $dir $newlist" 18687c478bd9Sstevel@tonic-gate torm="$dir $torm" 18697c478bd9Sstevel@tonic-gate else 18707c478bd9Sstevel@tonic-gate [ -z "$torm" ] || staffer rmdir $torm 18717c478bd9Sstevel@tonic-gate return 1 18727c478bd9Sstevel@tonic-gate fi 18737c478bd9Sstevel@tonic-gate done 18747c478bd9Sstevel@tonic-gate newdirlist="$newlist $newdirlist" 18757c478bd9Sstevel@tonic-gate return 0 18767c478bd9Sstevel@tonic-gate} 18777c478bd9Sstevel@tonic-gatenewdirlist= 18787c478bd9Sstevel@tonic-gate 18797c478bd9Sstevel@tonic-gate[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 18807c478bd9Sstevel@tonic-gate 18817c478bd9Sstevel@tonic-gate# since this script assumes the build is from full source, it nullifies 18827c478bd9Sstevel@tonic-gate# variables likely to have been set by a "ws" script; nullification 18837c478bd9Sstevel@tonic-gate# confines the search space for headers and libraries to the proto area 18847c478bd9Sstevel@tonic-gate# built from this immediate source. 18857c478bd9Sstevel@tonic-gateENVLDLIBS1= 18867c478bd9Sstevel@tonic-gateENVLDLIBS2= 18877c478bd9Sstevel@tonic-gateENVLDLIBS3= 18887c478bd9Sstevel@tonic-gateENVCPPFLAGS1= 18897c478bd9Sstevel@tonic-gateENVCPPFLAGS2= 18907c478bd9Sstevel@tonic-gateENVCPPFLAGS3= 18917c478bd9Sstevel@tonic-gateENVCPPFLAGS4= 18927c478bd9Sstevel@tonic-gatePARENT_ROOT= 18937c478bd9Sstevel@tonic-gate 18947c478bd9Sstevel@tonic-gateexport ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 18957c478bd9Sstevel@tonic-gate PARENT_ROOT 18967c478bd9Sstevel@tonic-gate 18977c478bd9Sstevel@tonic-gatePKGARCHIVE_ORIG=$PKGARCHIVE 18987c478bd9Sstevel@tonic-gateIA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS 18997c478bd9Sstevel@tonic-gate 19007c478bd9Sstevel@tonic-gate# 19017c478bd9Sstevel@tonic-gate# Juggle the logs and optionally send mail on completion. 19027c478bd9Sstevel@tonic-gate# 19037c478bd9Sstevel@tonic-gate 1904597bd30bSMike Kupferfunction logshuffle { 1905fd7cef36Ssuha LLOG="$ATLOG/log.`date '+%F.%H:%M'`" 19067c478bd9Sstevel@tonic-gate if [ -f $LLOG -o -d $LLOG ]; then 19077c478bd9Sstevel@tonic-gate LLOG=$LLOG.$$ 19087c478bd9Sstevel@tonic-gate fi 19097c478bd9Sstevel@tonic-gate mkdir $LLOG 19104802ef38Srscott export LLOG 19117c478bd9Sstevel@tonic-gate 19127c478bd9Sstevel@tonic-gate if [ "$build_ok" = "y" ]; then 19137c478bd9Sstevel@tonic-gate mv $ATLOG/proto_list_${MACH} $LLOG 191496ccc8cbSesaxe 19152e02daeeSRainer Orth if [ -f $ATLOG/proto_list_tools_${MACH} ]; then 19162e02daeeSRainer Orth mv $ATLOG/proto_list_tools_${MACH} $LLOG 19172e02daeeSRainer Orth fi 19182e02daeeSRainer Orth 191996ccc8cbSesaxe if [ -f $TMPDIR/wsdiff.results ]; then 192096ccc8cbSesaxe mv $TMPDIR/wsdiff.results $LLOG 192196ccc8cbSesaxe fi 19224e5b757fSkupfer 19234e5b757fSkupfer if [ -f $TMPDIR/wsdiff-nd.results ]; then 19244e5b757fSkupfer mv $TMPDIR/wsdiff-nd.results $LLOG 19254e5b757fSkupfer fi 19267c478bd9Sstevel@tonic-gate fi 19277c478bd9Sstevel@tonic-gate 19287c478bd9Sstevel@tonic-gate # 19297c478bd9Sstevel@tonic-gate # Now that we're about to send mail, it's time to check the noise 19307c478bd9Sstevel@tonic-gate # file. In the event that an error occurs beyond this point, it will 19317c478bd9Sstevel@tonic-gate # be recorded in the nightly.log file, but nowhere else. This would 19327c478bd9Sstevel@tonic-gate # include only errors that cause the copying of the noise log to fail 19337c478bd9Sstevel@tonic-gate # or the mail itself not to be sent. 19347c478bd9Sstevel@tonic-gate # 19357c478bd9Sstevel@tonic-gate 19367c478bd9Sstevel@tonic-gate exec >>$LOGFILE 2>&1 19377c478bd9Sstevel@tonic-gate if [ -s $build_noise_file ]; then 19387c478bd9Sstevel@tonic-gate echo "\n==== Nightly build noise ====\n" | 19397c478bd9Sstevel@tonic-gate tee -a $LOGFILE >>$mail_msg_file 19407c478bd9Sstevel@tonic-gate cat $build_noise_file >>$LOGFILE 19417c478bd9Sstevel@tonic-gate cat $build_noise_file >>$mail_msg_file 19427c478bd9Sstevel@tonic-gate echo | tee -a $LOGFILE >>$mail_msg_file 19437c478bd9Sstevel@tonic-gate fi 19447c478bd9Sstevel@tonic-gate rm -f $build_noise_file 19457c478bd9Sstevel@tonic-gate 19467c478bd9Sstevel@tonic-gate case "$build_ok" in 19477c478bd9Sstevel@tonic-gate y) 19487c478bd9Sstevel@tonic-gate state=Completed 19497c478bd9Sstevel@tonic-gate ;; 19507c478bd9Sstevel@tonic-gate i) 19517c478bd9Sstevel@tonic-gate state=Interrupted 19527c478bd9Sstevel@tonic-gate ;; 19537c478bd9Sstevel@tonic-gate *) 19547c478bd9Sstevel@tonic-gate state=Failed 19557c478bd9Sstevel@tonic-gate ;; 19567c478bd9Sstevel@tonic-gate esac 195740bc9153Srscott NIGHTLY_STATUS=$state 195840bc9153Srscott export NIGHTLY_STATUS 19597c478bd9Sstevel@tonic-gate 196047703246Ssommerfe run_hook POST_NIGHTLY $state 196147703246Ssommerfe run_hook SYS_POST_NIGHTLY $state 19624802ef38Srscott 1963cdf0c1d5Smjnelson cat $build_time_file $build_environ_file $mail_msg_file \ 1964cdf0c1d5Smjnelson > ${LLOG}/mail_msg 19657c478bd9Sstevel@tonic-gate if [ "$m_FLAG" = "y" ]; then 1966cdf0c1d5Smjnelson cat ${LLOG}/mail_msg | /usr/bin/mailx -s \ 19677c478bd9Sstevel@tonic-gate "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 19687c478bd9Sstevel@tonic-gate ${MAILTO} 19697c478bd9Sstevel@tonic-gate fi 19707c478bd9Sstevel@tonic-gate 19717c478bd9Sstevel@tonic-gate if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 19727c478bd9Sstevel@tonic-gate staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 19737c478bd9Sstevel@tonic-gate staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 19747c478bd9Sstevel@tonic-gate fi 19757c478bd9Sstevel@tonic-gate 19767c478bd9Sstevel@tonic-gate mv $LOGFILE $LLOG 19777c478bd9Sstevel@tonic-gate} 19787c478bd9Sstevel@tonic-gate 19797c478bd9Sstevel@tonic-gate# 19807c478bd9Sstevel@tonic-gate# Remove the locks and temporary files on any exit 19817c478bd9Sstevel@tonic-gate# 1982597bd30bSMike Kupferfunction cleanup { 19837c478bd9Sstevel@tonic-gate logshuffle 19847c478bd9Sstevel@tonic-gate 19857c478bd9Sstevel@tonic-gate [ -z "$lockfile" ] || staffer rm -f $lockfile 19867c478bd9Sstevel@tonic-gate [ -z "$atloglockfile" ] || rm -f $atloglockfile 19877c478bd9Sstevel@tonic-gate [ -z "$ulockfile" ] || staffer rm -f $ulockfile 19887c478bd9Sstevel@tonic-gate [ -z "$Ulockfile" ] || rm -f $Ulockfile 19897c478bd9Sstevel@tonic-gate 19907c478bd9Sstevel@tonic-gate set -- $newdirlist 19917c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 19927c478bd9Sstevel@tonic-gate ISUSER=$1 staffer rmdir $2 19937c478bd9Sstevel@tonic-gate shift; shift 19947c478bd9Sstevel@tonic-gate done 19957c478bd9Sstevel@tonic-gate rm -rf $TMPDIR 19967c478bd9Sstevel@tonic-gate} 19977c478bd9Sstevel@tonic-gate 1998597bd30bSMike Kupferfunction cleanup_signal { 19997c478bd9Sstevel@tonic-gate build_ok=i 20007c478bd9Sstevel@tonic-gate # this will trigger cleanup(), above. 20017c478bd9Sstevel@tonic-gate exit 1 20027c478bd9Sstevel@tonic-gate} 20037c478bd9Sstevel@tonic-gate 20047c478bd9Sstevel@tonic-gatetrap cleanup 0 20057c478bd9Sstevel@tonic-gatetrap cleanup_signal 1 2 3 15 20067c478bd9Sstevel@tonic-gate 20077c478bd9Sstevel@tonic-gate# 20087c478bd9Sstevel@tonic-gate# Generic lock file processing -- make sure that the lock file doesn't 20097c478bd9Sstevel@tonic-gate# exist. If it does, it should name the build host and PID. If it 20107c478bd9Sstevel@tonic-gate# doesn't, then make sure we can create it. Clean up locks that are 20117c478bd9Sstevel@tonic-gate# known to be stale (assumes host name is unique among build systems 20127c478bd9Sstevel@tonic-gate# for the workspace). 2013cdf0c1d5Smjnelson# 2014597bd30bSMike Kupferfunction create_lock { 20157c478bd9Sstevel@tonic-gate lockf=$1 20167c478bd9Sstevel@tonic-gate lockvar=$2 20178312e758Sdduvall 20187c478bd9Sstevel@tonic-gate ldir=`dirname $lockf` 20197c478bd9Sstevel@tonic-gate [ -d $ldir ] || newdir $ldir || exit 1 20207c478bd9Sstevel@tonic-gate eval $lockvar=$lockf 20218312e758Sdduvall 20228312e758Sdduvall while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do 20238312e758Sdduvall basews=`basename $CODEMGR_WS` 20248312e758Sdduvall ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid 20258312e758Sdduvall if [ "$host" != "$hostname" ]; then 20268312e758Sdduvall echo "$MACH build of $basews apparently" \ 20278312e758Sdduvall "already started by $user on $host as $pid." 20288312e758Sdduvall exit 1 20298312e758Sdduvall elif kill -s 0 $pid 2>/dev/null; then 20308312e758Sdduvall echo "$MACH build of $basews already started" \ 20318312e758Sdduvall "by $user as $pid." 20328312e758Sdduvall exit 1 20338312e758Sdduvall else 20348312e758Sdduvall # stale lock; clear it out and try again 20358312e758Sdduvall rm -f $lockf 20368312e758Sdduvall fi 20378312e758Sdduvall done 20387c478bd9Sstevel@tonic-gate} 20397c478bd9Sstevel@tonic-gate 20404e5b757fSkupfer# 20414e5b757fSkupfer# Return the list of interesting proto areas, depending on the current 20424e5b757fSkupfer# options. 20434e5b757fSkupfer# 2044597bd30bSMike Kupferfunction allprotos { 2045c7453724SMike Kupfer typeset roots="$ROOT" 2046b83ec4edSjmcp 2047c7453724SMike Kupfer if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then 2048c7453724SMike Kupfer roots="$roots $ROOT-nd" 20494e5b757fSkupfer fi 20504e5b757fSkupfer 2051b83ec4edSjmcp if [[ $O_FLAG = y ]]; then 2052b83ec4edSjmcp roots="$roots $ROOT-closed" 2053b83ec4edSjmcp [ $MULTI_PROTO = yes ] && roots="$roots $ROOT-nd-closed" 2054b83ec4edSjmcp fi 2055b83ec4edSjmcp 20564e5b757fSkupfer echo $roots 20574e5b757fSkupfer} 20584e5b757fSkupfer 20597c478bd9Sstevel@tonic-gate# Ensure no other instance of this script is running on this host. 20607c478bd9Sstevel@tonic-gate# LOCKNAME can be set in <env_file>, and is by default, but is not 20617c478bd9Sstevel@tonic-gate# required due to the use of $ATLOG below. 20627c478bd9Sstevel@tonic-gateif [ -n "$LOCKNAME" ]; then 20637c478bd9Sstevel@tonic-gate create_lock /tmp/$LOCKNAME "lockfile" 20647c478bd9Sstevel@tonic-gatefi 20657c478bd9Sstevel@tonic-gate# 20667c478bd9Sstevel@tonic-gate# Create from one, two, or three other locks: 20677c478bd9Sstevel@tonic-gate# $ATLOG/nightly.lock 20687c478bd9Sstevel@tonic-gate# - protects against multiple builds in same workspace 20697c478bd9Sstevel@tonic-gate# $PARENT_WS/usr/src/nightly.$MACH.lock 20707c478bd9Sstevel@tonic-gate# - protects against multiple 'u' copy-backs 20717c478bd9Sstevel@tonic-gate# $NIGHTLY_PARENT_ROOT/nightly.lock 20727c478bd9Sstevel@tonic-gate# - protects against multiple 'U' copy-backs 20737c478bd9Sstevel@tonic-gate# 20747c478bd9Sstevel@tonic-gate# Overriding ISUSER to 1 causes the lock to be created as root if the 20757c478bd9Sstevel@tonic-gate# script is run as root. The default is to create it as $STAFFER. 20767c478bd9Sstevel@tonic-gateISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 20777c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" ]; then 20787c478bd9Sstevel@tonic-gate create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 20797c478bd9Sstevel@tonic-gatefi 20807c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" ]; then 20817c478bd9Sstevel@tonic-gate # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 20827c478bd9Sstevel@tonic-gate ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 20837c478bd9Sstevel@tonic-gatefi 20847c478bd9Sstevel@tonic-gate 20857c478bd9Sstevel@tonic-gate# Locks have been taken, so we're doing a build and we're committed to 20867c478bd9Sstevel@tonic-gate# the directories we may have created so far. 20877c478bd9Sstevel@tonic-gatenewdirlist= 20887c478bd9Sstevel@tonic-gate 20897c478bd9Sstevel@tonic-gate# 20907c478bd9Sstevel@tonic-gate# Create mail_msg_file 20917c478bd9Sstevel@tonic-gate# 20927c478bd9Sstevel@tonic-gatemail_msg_file="${TMPDIR}/mail_msg" 20937c478bd9Sstevel@tonic-gatetouch $mail_msg_file 20947c478bd9Sstevel@tonic-gatebuild_time_file="${TMPDIR}/build_time" 2095cdf0c1d5Smjnelsonbuild_environ_file="${TMPDIR}/build_environ" 2096cdf0c1d5Smjnelsontouch $build_environ_file 20977c478bd9Sstevel@tonic-gate# 20987c478bd9Sstevel@tonic-gate# Move old LOGFILE aside 20997c478bd9Sstevel@tonic-gate# ATLOG directory already made by 'create_lock' above 21007c478bd9Sstevel@tonic-gate# 21017c478bd9Sstevel@tonic-gateif [ -f $LOGFILE ]; then 21027c478bd9Sstevel@tonic-gate mv -f $LOGFILE ${LOGFILE}- 21037c478bd9Sstevel@tonic-gatefi 21047c478bd9Sstevel@tonic-gate# 21057c478bd9Sstevel@tonic-gate# Build OsNet source 21067c478bd9Sstevel@tonic-gate# 21077c478bd9Sstevel@tonic-gateSTART_DATE=`date` 21087c478bd9Sstevel@tonic-gateSECONDS=0 21097c478bd9Sstevel@tonic-gateecho "\n==== Nightly $maketype build started: $START_DATE ====" \ 21107c478bd9Sstevel@tonic-gate | tee -a $LOGFILE > $build_time_file 21117c478bd9Sstevel@tonic-gate 2112cdf0c1d5Smjnelsonecho "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 2113cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 2114cdf0c1d5Smjnelson 21157c478bd9Sstevel@tonic-gate# make sure we log only to the nightly build file 21167c478bd9Sstevel@tonic-gatebuild_noise_file="${TMPDIR}/build_noise" 21177c478bd9Sstevel@tonic-gateexec </dev/null >$build_noise_file 2>&1 21187c478bd9Sstevel@tonic-gate 211947703246Ssommerferun_hook SYS_PRE_NIGHTLY 212047703246Ssommerferun_hook PRE_NIGHTLY 212147703246Ssommerfe 21227c478bd9Sstevel@tonic-gateecho "\n==== list of environment variables ====\n" >> $LOGFILE 21237c478bd9Sstevel@tonic-gateenv >> $LOGFILE 21247c478bd9Sstevel@tonic-gate 21257c478bd9Sstevel@tonic-gateecho "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 21267c478bd9Sstevel@tonic-gate 2127d77e7149Ssommerfeif [ "$P_FLAG" = "y" ]; then 2128d77e7149Ssommerfe obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE 2129d77e7149Ssommerfefi 2130d77e7149Ssommerfe 2131d77e7149Ssommerfeif [ "$T_FLAG" = "y" ]; then 2132d77e7149Ssommerfe obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE 2133d77e7149Ssommerfefi 2134d77e7149Ssommerfe 21351fe69678Skupferif is_source_build; then 21367c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then 21377c478bd9Sstevel@tonic-gate echo "WARNING: the -S flags do not support incremental" \ 21387c478bd9Sstevel@tonic-gate "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE 21397c478bd9Sstevel@tonic-gate i_FLAG=n 21407c478bd9Sstevel@tonic-gate i_CMD_LINE_FLAG=n 21417c478bd9Sstevel@tonic-gate fi 21427c478bd9Sstevel@tonic-gate if [ "$N_FLAG" = "n" ]; then 21437c478bd9Sstevel@tonic-gate echo "WARNING: the -S flags do not support protocmp;" \ 21447c478bd9Sstevel@tonic-gate "protocmp disabled\n" | \ 21457c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 21467c478bd9Sstevel@tonic-gate N_FLAG=y 21477c478bd9Sstevel@tonic-gate fi 21487c478bd9Sstevel@tonic-gate if [ "$l_FLAG" = "y" ]; then 21497c478bd9Sstevel@tonic-gate echo "WARNING: the -S flags do not support lint;" \ 21507c478bd9Sstevel@tonic-gate "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE 21517c478bd9Sstevel@tonic-gate l_FLAG=n 21527c478bd9Sstevel@tonic-gate fi 21537c478bd9Sstevel@tonic-gate if [ "$C_FLAG" = "y" ]; then 21547c478bd9Sstevel@tonic-gate echo "WARNING: the -S flags do not support cstyle;" \ 21557c478bd9Sstevel@tonic-gate "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE 21567c478bd9Sstevel@tonic-gate C_FLAG=n 21577c478bd9Sstevel@tonic-gate fi 21587c478bd9Sstevel@tonic-gateelse 21597c478bd9Sstevel@tonic-gate if [ "$N_FLAG" = "y" ]; then 21607c478bd9Sstevel@tonic-gate if [ "$p_FLAG" = "y" ]; then 21617c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 21627c478bd9Sstevel@tonic-gateWARNING: the p option (create packages) is set, but so is the N option (do 21637c478bd9Sstevel@tonic-gate not run protocmp); this is dangerous; you should unset the N option 21647c478bd9Sstevel@tonic-gateEOF 21657c478bd9Sstevel@tonic-gate else 21667c478bd9Sstevel@tonic-gate cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 21677c478bd9Sstevel@tonic-gateWarning: the N option (do not run protocmp) is set; it probably shouldn't be 21687c478bd9Sstevel@tonic-gateEOF 21697c478bd9Sstevel@tonic-gate fi 21707c478bd9Sstevel@tonic-gate echo "" | tee -a $mail_msg_file >> $LOGFILE 21717c478bd9Sstevel@tonic-gate fi 21727c478bd9Sstevel@tonic-gatefi 21737c478bd9Sstevel@tonic-gate 21747c478bd9Sstevel@tonic-gateif [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 21754e5b757fSkupfer # 21764e5b757fSkupfer # In the past we just complained but went ahead with the lint 2177ead1f93eSLiane Praza # pass, even though the proto area was built non-DEBUG. It's 2178ead1f93eSLiane Praza # unlikely that non-DEBUG headers will make a difference, but 21794e5b757fSkupfer # rather than assuming it's a safe combination, force the user 2180ead1f93eSLiane Praza # to specify a DEBUG build. 21814e5b757fSkupfer # 21824e5b757fSkupfer echo "WARNING: DEBUG build not requested; disabling lint.\n" \ 21837c478bd9Sstevel@tonic-gate | tee -a $mail_msg_file >> $LOGFILE 21844e5b757fSkupfer l_FLAG=n 21857c478bd9Sstevel@tonic-gatefi 21867c478bd9Sstevel@tonic-gate 21877c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" ]; then 21887c478bd9Sstevel@tonic-gate if [ "$i_FLAG" = "y" ]; then 21897c478bd9Sstevel@tonic-gate echo "WARNING: the -f flag cannot be used during incremental" \ 21907c478bd9Sstevel@tonic-gate "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 21917c478bd9Sstevel@tonic-gate f_FLAG=n 21927c478bd9Sstevel@tonic-gate fi 219311a78ea0SMark J. Nelson if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then 219411a78ea0SMark J. Nelson echo "WARNING: the -f flag requires -l, and -p;" \ 219511a78ea0SMark J. Nelson "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 21967c478bd9Sstevel@tonic-gate f_FLAG=n 21977c478bd9Sstevel@tonic-gate fi 21987c478bd9Sstevel@tonic-gatefi 21997c478bd9Sstevel@tonic-gate 220096ccc8cbSesaxeif [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 22014e5b757fSkupfer echo "WARNING: -w specified, but $ROOT does not exist;" \ 220296ccc8cbSesaxe "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 220396ccc8cbSesaxe w_FLAG=n 220496ccc8cbSesaxefi 220596ccc8cbSesaxe 22067c478bd9Sstevel@tonic-gateif [ "$t_FLAG" = "n" ]; then 22077c478bd9Sstevel@tonic-gate # 22087c478bd9Sstevel@tonic-gate # We're not doing a tools build, so make sure elfsign(1) is 22097c478bd9Sstevel@tonic-gate # new enough to safely sign non-crypto binaries. We test 22107c478bd9Sstevel@tonic-gate # debugging output from elfsign to detect the old version. 22117c478bd9Sstevel@tonic-gate # 22127c478bd9Sstevel@tonic-gate newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 22137c478bd9Sstevel@tonic-gate -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 22147c478bd9Sstevel@tonic-gate | egrep algorithmOID` 22157c478bd9Sstevel@tonic-gate if [ -z "$newelfsigntest" ]; then 22167c478bd9Sstevel@tonic-gate echo "WARNING: /usr/bin/elfsign out of date;" \ 22177c478bd9Sstevel@tonic-gate "will only sign crypto modules\n" | \ 22187c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 22197c478bd9Sstevel@tonic-gate export ELFSIGN_OBJECT=true 22207c478bd9Sstevel@tonic-gate elif [ "$VERIFY_ELFSIGN" = "y" ]; then 22217c478bd9Sstevel@tonic-gate echo "WARNING: VERIFY_ELFSIGN=y requires" \ 22227c478bd9Sstevel@tonic-gate "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 22237c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 22247c478bd9Sstevel@tonic-gate fi 22257c478bd9Sstevel@tonic-gatefi 22267c478bd9Sstevel@tonic-gate 22274e5b757fSkupfer[ "$O_FLAG" = y ] && MULTI_PROTO=yes 22284e5b757fSkupfer 22294e5b757fSkupfercase $MULTI_PROTO in 22304e5b757fSkupferyes|no) ;; 22314e5b757fSkupfer*) 22324e5b757fSkupfer echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \ 22334e5b757fSkupfer "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE 22344e5b757fSkupfer echo "Setting MULTI_PROTO to \"no\".\n" | \ 22354e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 22364e5b757fSkupfer export MULTI_PROTO=no 22374e5b757fSkupfer ;; 22384e5b757fSkupferesac 22394e5b757fSkupfer 2240597bd30bSMike Kupfer# If CODESIGN_USER is set, we'll want the crypto that we just built. 2241597bd30bSMike Kupferif [[ -n "$CODESIGN_USER" && -n "$ON_CRYPTO_BINS" ]]; then 2242597bd30bSMike Kupfer echo "Clearing ON_CRYPTO_BINS for signing build." >> "$LOGFILE" 2243597bd30bSMike Kupfer unset ON_CRYPTO_BINS 2244597bd30bSMike Kupferfi 2245597bd30bSMike Kupfer 22467c478bd9Sstevel@tonic-gateecho "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 22477c478bd9Sstevel@tonic-gateecho $VERSION | tee -a $mail_msg_file >> $LOGFILE 22487c478bd9Sstevel@tonic-gate 224996ccc8cbSesaxe# Save the current proto area if we're comparing against the last build 225096ccc8cbSesaxeif [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 225196ccc8cbSesaxe if [ -d "$ROOT.prev" ]; then 225296ccc8cbSesaxe rm -rf $ROOT.prev 225396ccc8cbSesaxe fi 225496ccc8cbSesaxe mv $ROOT $ROOT.prev 225596ccc8cbSesaxefi 225696ccc8cbSesaxe 22574e5b757fSkupfer# Same for non-DEBUG proto area 22584e5b757fSkupferif [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then 22594e5b757fSkupfer if [ -d "$ROOT-nd.prev" ]; then 22604e5b757fSkupfer rm -rf $ROOT-nd.prev 22614e5b757fSkupfer fi 22624e5b757fSkupfer mv $ROOT-nd $ROOT-nd.prev 22634e5b757fSkupferfi 22644e5b757fSkupfer 2265*445b6314SRichard Lowe# 2266*445b6314SRichard Lowe# Echo the SCM type of the parent workspace, this can't just be which_scm 2267*445b6314SRichard Lowe# as that does not know how to identify various network repositories. 2268*445b6314SRichard Lowe# 2269*445b6314SRichard Lowefunction parent_wstype { 2270*445b6314SRichard Lowe typeset scm_type junk 227130635de9SJohn.Zolnowsky@Sun.COM 227230635de9SJohn.Zolnowsky@Sun.COM CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \ 2273*445b6314SRichard Lowe | read scm_type junk 2274*445b6314SRichard Lowe if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then 227530635de9SJohn.Zolnowsky@Sun.COM # Probe BRINGOVER_WS to determine its type 227630635de9SJohn.Zolnowsky@Sun.COM if [[ $BRINGOVER_WS == svn*://* ]]; then 2277*445b6314SRichard Lowe scm_type="subversion" 227830635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == file://* ]] && 227930635de9SJohn.Zolnowsky@Sun.COM egrep -s "This is a Subversion repository" \ 228030635de9SJohn.Zolnowsky@Sun.COM ${BRINGOVER_WS#file://}/README.txt 2> /dev/null; then 2281*445b6314SRichard Lowe scm_type="subversion" 228230635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == ssh://* ]]; then 2283*445b6314SRichard Lowe scm_type="mercurial" 228430635de9SJohn.Zolnowsky@Sun.COM elif [[ $BRINGOVER_WS == http://* ]] && \ 2285*445b6314SRichard Lowe wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \ 228630635de9SJohn.Zolnowsky@Sun.COM egrep -s "application/mercurial" 2> /dev/null; then 2287*445b6314SRichard Lowe scm_type="mercurial" 2288*445b6314SRichard Lowe elif svn info $BRINGOVER_WS > /dev/null 2>&1; then 2289*445b6314SRichard Lowe scm_type="subversion" 229030635de9SJohn.Zolnowsky@Sun.COM else 2291*445b6314SRichard Lowe scm_type="none" 229230635de9SJohn.Zolnowsky@Sun.COM fi 229330635de9SJohn.Zolnowsky@Sun.COM fi 229430635de9SJohn.Zolnowsky@Sun.COM 229530635de9SJohn.Zolnowsky@Sun.COM # fold both unsupported and unrecognized results into "none" 2296*445b6314SRichard Lowe case "$scm_type" in 229730635de9SJohn.Zolnowsky@Sun.COM none|subversion|teamware|mercurial) 229830635de9SJohn.Zolnowsky@Sun.COM ;; 2299*445b6314SRichard Lowe *) scm_type=none 230030635de9SJohn.Zolnowsky@Sun.COM ;; 230130635de9SJohn.Zolnowsky@Sun.COM esac 230230635de9SJohn.Zolnowsky@Sun.COM 2303*445b6314SRichard Lowe echo $scm_type 230430635de9SJohn.Zolnowsky@Sun.COM} 230530635de9SJohn.Zolnowsky@Sun.COM 2306*445b6314SRichard Lowe# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS 2307*445b6314SRichard Lowefunction child_wstype { 2308*445b6314SRichard Lowe typeset scm_type junk 2309*445b6314SRichard Lowe 2310*445b6314SRichard Lowe # Probe CODEMGR_WS to determine its type 2311*445b6314SRichard Lowe if [[ -d $CODEMGR_WS ]]; then 2312*445b6314SRichard Lowe $WHICH_SCM | read scm_type junk || exit 1 2313*445b6314SRichard Lowe fi 2314*445b6314SRichard Lowe 2315*445b6314SRichard Lowe case "$scm_type" in 2316*445b6314SRichard Lowe none|subversion|teamware|mercurial) 2317*445b6314SRichard Lowe ;; 2318*445b6314SRichard Lowe *) scm_type=none 2319*445b6314SRichard Lowe ;; 2320*445b6314SRichard Lowe esac 2321*445b6314SRichard Lowe 2322*445b6314SRichard Lowe echo $scm_type 2323*445b6314SRichard Lowe} 2324*445b6314SRichard Lowe 2325*445b6314SRichard Loweexport SCM_TYPE=$(child_wstype) 232630635de9SJohn.Zolnowsky@Sun.COM 23277c478bd9Sstevel@tonic-gate# 23287c478bd9Sstevel@tonic-gate# Decide whether to clobber 23297c478bd9Sstevel@tonic-gate# 23307c478bd9Sstevel@tonic-gateif [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 23317c478bd9Sstevel@tonic-gate echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 23327c478bd9Sstevel@tonic-gate 23337c478bd9Sstevel@tonic-gate cd $SRC 23347c478bd9Sstevel@tonic-gate # remove old clobber file 23357c478bd9Sstevel@tonic-gate rm -f $SRC/clobber.out 23367c478bd9Sstevel@tonic-gate rm -f $SRC/clobber-${MACH}.out 23377c478bd9Sstevel@tonic-gate 23387c478bd9Sstevel@tonic-gate # Remove all .make.state* files, just in case we are restarting 23397c478bd9Sstevel@tonic-gate # the build after having interrupted a previous 'make clobber'. 2340cdf0c1d5Smjnelson find . \( -name SCCS -o -name .hg -o -name .svn \ 2341cdf0c1d5Smjnelson -o -name 'interfaces.*' \) -prune \ 23427c478bd9Sstevel@tonic-gate -o -name '.make.*' -print | xargs rm -f 23437c478bd9Sstevel@tonic-gate 23447c478bd9Sstevel@tonic-gate $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 23457c478bd9Sstevel@tonic-gate echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 23467c478bd9Sstevel@tonic-gate grep "$MAKE:" $SRC/clobber-${MACH}.out | 23477c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" \ 23487c478bd9Sstevel@tonic-gate >> $mail_msg_file 23497c478bd9Sstevel@tonic-gate 23504e5b757fSkupfer if [[ "$t_FLAG" = "y" || "$O_FLAG" = "y" ]]; then 23517c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 23527c478bd9Sstevel@tonic-gate cd ${TOOLS} 23537c478bd9Sstevel@tonic-gate rm -f ${TOOLS}/clobber-${MACH}.out 2354ead1f93eSLiane Praza $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \ 23557c478bd9Sstevel@tonic-gate tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 23567c478bd9Sstevel@tonic-gate echo "\n==== Make tools clobber ERRORS ====\n" \ 23577c478bd9Sstevel@tonic-gate >> $mail_msg_file 23587c478bd9Sstevel@tonic-gate grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 23597c478bd9Sstevel@tonic-gate >> $mail_msg_file 23607c478bd9Sstevel@tonic-gate rm -rf ${TOOLS_PROTO} 23617c478bd9Sstevel@tonic-gate mkdir -p ${TOOLS_PROTO} 23627c478bd9Sstevel@tonic-gate fi 236396ccc8cbSesaxe 2364c7453724SMike Kupfer typeset roots=$(allprotos) 2365c7453724SMike Kupfer echo "\n\nClearing $roots" >> "$LOGFILE" 2366c7453724SMike Kupfer rm -rf $roots 23677c478bd9Sstevel@tonic-gate 23687c478bd9Sstevel@tonic-gate # Get back to a clean workspace as much as possible to catch 23697c478bd9Sstevel@tonic-gate # problems that only occur on fresh workspaces. 23707c478bd9Sstevel@tonic-gate # Remove all .make.state* files, libraries, and .o's that may 2371fb23a357Skupfer # have been omitted from clobber. A couple of libraries are 2372cdf0c1d5Smjnelson # under source code control, so leave them alone. 23737c478bd9Sstevel@tonic-gate # We should probably blow away temporary directories too. 23747c478bd9Sstevel@tonic-gate cd $SRC 2375cdf0c1d5Smjnelson find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \ 2376cdf0c1d5Smjnelson -o -name 'interfaces.*' \) -prune -o \ 23777c478bd9Sstevel@tonic-gate \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 2378fb23a357Skupfer -name '*.o' \) -print | \ 2379fb23a357Skupfer grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 23807c478bd9Sstevel@tonic-gateelse 23817c478bd9Sstevel@tonic-gate echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 23827c478bd9Sstevel@tonic-gatefi 23837c478bd9Sstevel@tonic-gate 2384597bd30bSMike Kupfertype bringover_teamware > /dev/null 2>&1 || function bringover_teamware { 23857c478bd9Sstevel@tonic-gate # sleep on the parent workspace's lock 23867c478bd9Sstevel@tonic-gate while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks 23877c478bd9Sstevel@tonic-gate do 23887c478bd9Sstevel@tonic-gate sleep 120 23897c478bd9Sstevel@tonic-gate done 23907c478bd9Sstevel@tonic-gate 2391fd7cef36Ssuha if [[ -z $BRINGOVER ]]; then 2392fd7cef36Ssuha BRINGOVER=$TEAMWARE/bin/bringover 2393fd7cef36Ssuha fi 239432f1e47bSsommerfe 2395cdf0c1d5Smjnelson staffer $BRINGOVER -c "nightly update" -p $BRINGOVER_WS \ 239632f1e47bSsommerfe -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 || 239732f1e47bSsommerfe touch $TMPDIR/bringover_failed 239832f1e47bSsommerfe 2399d77e7149Ssommerfe staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1 2400d77e7149Ssommerfe if [ -s $TMPDIR/bringovercheck.out ]; then 2401d77e7149Ssommerfe echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n" 2402d77e7149Ssommerfe cat $TMPDIR/bringovercheck.out 2403d77e7149Ssommerfe fi 2404cdf0c1d5Smjnelson} 240532f1e47bSsommerfe 2406597bd30bSMike Kupfertype bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial { 2407cdf0c1d5Smjnelson typeset -x PATH=$PATH 2408cdf0c1d5Smjnelson 2409cdf0c1d5Smjnelson # If the repository doesn't exist yet, then we want to populate it. 2410cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.hg ]]; then 2411cdf0c1d5Smjnelson staffer hg init $CODEMGR_WS 24128cca05f6SMark J. Nelson staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc 24138cca05f6SMark J. Nelson staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc 2414f457028bSMark J. Nelson touch $TMPDIR/new_repository 2415cdf0c1d5Smjnelson fi 24165c53ea7aSmjnelson 24175c53ea7aSmjnelson # 24185c53ea7aSmjnelson # If the user set CLOSED_BRINGOVER_WS and didn't set CLOSED_IS_PRESENT 24195c53ea7aSmjnelson # to "no," then we'll want to initialise the closed repository 24205c53ea7aSmjnelson # 24215c53ea7aSmjnelson # We use $orig_closed_is_present instead of $CLOSED_IS_PRESENT, 24225c53ea7aSmjnelson # because for newly-created source trees, the latter will be "no" 24235c53ea7aSmjnelson # until after the bringover completes. 24245c53ea7aSmjnelson # 24255c53ea7aSmjnelson if [[ "$orig_closed_is_present" != "no" && \ 24265c53ea7aSmjnelson -n "$CLOSED_BRINGOVER_WS" && \ 24275c53ea7aSmjnelson ! -d $CODEMGR_WS/usr/closed/.hg ]]; then 24285c53ea7aSmjnelson staffer mkdir -p $CODEMGR_WS/usr/closed 24295c53ea7aSmjnelson staffer hg init $CODEMGR_WS/usr/closed 24308cca05f6SMark J. Nelson staffer echo "[paths]" > $CODEMGR_WS/usr/closed/.hg/hgrc 24318cca05f6SMark J. Nelson staffer echo "default=$CLOSED_BRINGOVER_WS" >> $CODEMGR_WS/usr/closed/.hg/hgrc 2432f457028bSMark J. Nelson touch $TMPDIR/new_closed 24335c53ea7aSmjnelson export CLOSED_IS_PRESENT=yes 2434cdf0c1d5Smjnelson fi 2435cdf0c1d5Smjnelson 2436cdf0c1d5Smjnelson typeset -x HGMERGE="/bin/false" 2437cdf0c1d5Smjnelson 2438cdf0c1d5Smjnelson # 24395c53ea7aSmjnelson # If the user has changes, regardless of whether those changes are 24405c53ea7aSmjnelson # committed, and regardless of whether those changes conflict, then 24415c53ea7aSmjnelson # we'll attempt to merge them either implicitly (uncommitted) or 24425c53ea7aSmjnelson # explicitly (committed). 2443cdf0c1d5Smjnelson # 24445c53ea7aSmjnelson # These are the messages we'll use to help clarify mercurial output 24455c53ea7aSmjnelson # in those cases. 24465c53ea7aSmjnelson # 24475c53ea7aSmjnelson typeset mergefailmsg="\ 24485c53ea7aSmjnelson***\n\ 24495c53ea7aSmjnelson*** nightly was unable to automatically merge your changes. You should\n\ 24505c53ea7aSmjnelson*** redo the full merge manually, following the steps outlined by mercurial\n\ 24515c53ea7aSmjnelson*** above, then restart nightly.\n\ 24525c53ea7aSmjnelson***\n" 24535c53ea7aSmjnelson typeset mergepassmsg="\ 24545c53ea7aSmjnelson***\n\ 24555c53ea7aSmjnelson*** nightly successfully merged your changes. This means that your working\n\ 24565c53ea7aSmjnelson*** directory has been updated, but those changes are not yet committed.\n\ 24575c53ea7aSmjnelson*** After nightly completes, you should validate the results of the merge,\n\ 24585c53ea7aSmjnelson*** then use hg commit manually.\n\ 24595c53ea7aSmjnelson***\n" 24605c53ea7aSmjnelson 24615c53ea7aSmjnelson # 24625c53ea7aSmjnelson # For each repository in turn: 24635c53ea7aSmjnelson # 24645c53ea7aSmjnelson # 1. Do the pull. If this fails, dump the output and bail out. 24655c53ea7aSmjnelson # 24665c53ea7aSmjnelson # 2. If the pull resulted in an extra head, do an explicit merge. 24675c53ea7aSmjnelson # If this fails, dump the output and bail out. 24685c53ea7aSmjnelson # 24695c53ea7aSmjnelson # Because we can't rely on Mercurial to exit with a failure code 24705c53ea7aSmjnelson # when a merge fails (Mercurial issue #186), we must grep the 24715c53ea7aSmjnelson # output of pull/merge to check for attempted and/or failed merges. 24725c53ea7aSmjnelson # 24735c53ea7aSmjnelson # 3. If a merge failed, set the message and fail the bringover. 24745c53ea7aSmjnelson # 24755c53ea7aSmjnelson # 4. Otherwise, if a merge succeeded, set the message 24765c53ea7aSmjnelson # 24775c53ea7aSmjnelson # 5. Dump the output, and any message from step 3 or 4. 24785c53ea7aSmjnelson # 24795c53ea7aSmjnelson 2480f457028bSMark J. Nelson typeset HG_SOURCE=$BRINGOVER_WS 2481f457028bSMark J. Nelson if [ ! -f $TMPDIR/new_repository ]; then 2482f457028bSMark J. Nelson HG_SOURCE=$TMPDIR/open_bundle.hg 2483f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \ 2484f457028bSMark J. Nelson -v $BRINGOVER_WS > $TMPDIR/incoming_open.out 2485f457028bSMark J. Nelson 2486f457028bSMark J. Nelson # 2487f457028bSMark J. Nelson # If there are no incoming changesets, then incoming will 2488f457028bSMark J. Nelson # fail, and there will be no bundle file. Reset the source, 2489f457028bSMark J. Nelson # to allow the remaining logic to complete with no false 2490f457028bSMark J. Nelson # negatives. (Unlike incoming, pull will return success 2491f457028bSMark J. Nelson # for the no-change case.) 2492f457028bSMark J. Nelson # 2493f457028bSMark J. Nelson if (( $? != 0 )); then 2494f457028bSMark J. Nelson HG_SOURCE=$BRINGOVER_WS 2495f457028bSMark J. Nelson fi 2496f457028bSMark J. Nelson fi 2497f457028bSMark J. Nelson 2498f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \ 24995c53ea7aSmjnelson > $TMPDIR/pull_open.out 2>&1 25005c53ea7aSmjnelson if (( $? != 0 )); then 25015c53ea7aSmjnelson printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS" 25025c53ea7aSmjnelson cat $TMPDIR/pull_open.out 25035c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then 25045c53ea7aSmjnelson printf "$mergefailmsg" 25055c53ea7aSmjnelson fi 25065c53ea7aSmjnelson touch $TMPDIR/bringover_failed 25075c53ea7aSmjnelson return 25085c53ea7aSmjnelson fi 25095c53ea7aSmjnelson 2510cdf0c1d5Smjnelson if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then 25115c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS merge \ 25125c53ea7aSmjnelson >> $TMPDIR/pull_open.out 2>&1 25135c53ea7aSmjnelson if (( $? != 0 )); then 25145c53ea7aSmjnelson printf "%s: merge failed as follows:\n\n" \ 25155c53ea7aSmjnelson "$CODEMGR_WS" 25165c53ea7aSmjnelson cat $TMPDIR/pull_open.out 25175c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_open.out \ 25185c53ea7aSmjnelson > /dev/null 2>&1; then 25195c53ea7aSmjnelson printf "$mergefailmsg" 25205c53ea7aSmjnelson fi 2521cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 25225c53ea7aSmjnelson return 2523cdf0c1d5Smjnelson fi 2524cdf0c1d5Smjnelson fi 25255c53ea7aSmjnelson 25265c53ea7aSmjnelson printf "updated %s with the following results:\n" "$CODEMGR_WS" 25275c53ea7aSmjnelson cat $TMPDIR/pull_open.out 25285c53ea7aSmjnelson if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then 25295c53ea7aSmjnelson printf "$mergepassmsg" 25305c53ea7aSmjnelson fi 25315c53ea7aSmjnelson printf "\n" 25325c53ea7aSmjnelson 25335c53ea7aSmjnelson # 25345c53ea7aSmjnelson # We only want to update usr/closed if it exists, and we haven't been 25355c53ea7aSmjnelson # told not to via $CLOSED_IS_PRESENT, and we actually know where to 25365c53ea7aSmjnelson # pull from ($CLOSED_BRINGOVER_WS). 25375c53ea7aSmjnelson # 25385c53ea7aSmjnelson if [[ $CLOSED_IS_PRESENT = yes && \ 25395c53ea7aSmjnelson -d $CODEMGR_WS/usr/closed/.hg && \ 25405c53ea7aSmjnelson -n $CLOSED_BRINGOVER_WS ]]; then 25415c53ea7aSmjnelson 2542f457028bSMark J. Nelson HG_SOURCE=$CLOSED_BRINGOVER_WS 2543f457028bSMark J. Nelson if [ ! -f $TMPDIR/new_closed ]; then 2544f457028bSMark J. Nelson HG_SOURCE=$TMPDIR/closed_bundle.hg 2545f457028bSMark J. Nelson staffer hg --cwd $CODEMGR_WS/usr/closed incoming \ 2546f457028bSMark J. Nelson --bundle $HG_SOURCE -v $CLOSED_BRINGOVER_WS \ 2547f457028bSMark J. Nelson > $TMPDIR/incoming_closed.out 2548f457028bSMark J. Nelson 2549f457028bSMark J. Nelson # 2550f457028bSMark J. Nelson # If there are no incoming changesets, then incoming will 2551f457028bSMark J. Nelson # fail, and there will be no bundle file. Reset the source, 2552f457028bSMark J. Nelson # to allow the remaining logic to complete with no false 2553f457028bSMark J. Nelson # negatives. (Unlike incoming, pull will return success 2554f457028bSMark J. Nelson # for the no-change case.) 2555f457028bSMark J. Nelson # 2556f457028bSMark J. Nelson if (( $? != 0 )); then 2557f457028bSMark J. Nelson HG_SOURCE=$CLOSED_BRINGOVER_WS 2558f457028bSMark J. Nelson fi 2559f457028bSMark J. Nelson fi 2560f457028bSMark J. Nelson 25615c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS/usr/closed pull -u \ 2562f457028bSMark J. Nelson $HG_SOURCE > $TMPDIR/pull_closed.out 2>&1 25635c53ea7aSmjnelson if (( $? != 0 )); then 25645c53ea7aSmjnelson printf "closed pull failed as follows:\n\n" 25655c53ea7aSmjnelson cat $TMPDIR/pull_closed.out 25665c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_closed.out \ 25675c53ea7aSmjnelson > /dev/null 2>&1; then 25685c53ea7aSmjnelson printf "$mergefailmsg" 25695c53ea7aSmjnelson fi 25705c53ea7aSmjnelson touch $TMPDIR/bringover_failed 25715c53ea7aSmjnelson return 25725c53ea7aSmjnelson fi 25735c53ea7aSmjnelson 2574cdf0c1d5Smjnelson if grep "not updating" $TMPDIR/pull_closed.out > /dev/null 2>&1; then 25755c53ea7aSmjnelson staffer hg --cwd $CODEMGR_WS/usr/closed merge \ 25765c53ea7aSmjnelson >> $TMPDIR/pull_closed.out 2>&1 25775c53ea7aSmjnelson if (( $? != 0 )); then 25785c53ea7aSmjnelson printf "closed merge failed as follows:\n\n" 25795c53ea7aSmjnelson cat $TMPDIR/pull_closed.out 25805c53ea7aSmjnelson if grep "^merging.*failed" $TMPDIR/pull_closed.out > /dev/null 2>&1; then 25815c53ea7aSmjnelson printf "$mergefailmsg" 25825c53ea7aSmjnelson fi 2583cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 25845c53ea7aSmjnelson return 25855c53ea7aSmjnelson fi 25865c53ea7aSmjnelson fi 25875c53ea7aSmjnelson 25885c53ea7aSmjnelson printf "updated %s with the following results:\n" \ 25895c53ea7aSmjnelson "$CODEMGR_WS/usr/closed" 25905c53ea7aSmjnelson cat $TMPDIR/pull_closed.out 25915c53ea7aSmjnelson if grep "^merging" $TMPDIR/pull_closed.out > /dev/null 2>&1; then 25925c53ea7aSmjnelson printf "$mergepassmsg" 2593cdf0c1d5Smjnelson fi 2594cdf0c1d5Smjnelson fi 2595f457028bSMark J. Nelson 2596f457028bSMark J. Nelson # 2597f457028bSMark J. Nelson # Per-changeset output is neither useful nor manageable for a 2598f457028bSMark J. Nelson # newly-created repository. 2599f457028bSMark J. Nelson # 2600f457028bSMark J. Nelson if [ -f $TMPDIR/new_repository ]; then 2601f457028bSMark J. Nelson return 2602f457028bSMark J. Nelson fi 2603f457028bSMark J. Nelson 2604f457028bSMark J. Nelson printf "\nadded the following changesets to open repository:\n" 2605f457028bSMark J. Nelson cat $TMPDIR/incoming_open.out 2606f457028bSMark J. Nelson 2607f457028bSMark J. Nelson # 2608f457028bSMark J. Nelson # The closed repository could have been newly created, even though 2609f457028bSMark J. Nelson # the open one previously existed... 2610f457028bSMark J. Nelson # 2611f457028bSMark J. Nelson if [ -f $TMPDIR/new_closed ]; then 2612f457028bSMark J. Nelson return 2613f457028bSMark J. Nelson fi 2614f457028bSMark J. Nelson 2615f457028bSMark J. Nelson if [ -f $TMPDIR/incoming_closed.out ]; then 2616f457028bSMark J. Nelson printf "\nadded the following changesets to closed repository:\n" 2617f457028bSMark J. Nelson cat $TMPDIR/incoming_closed.out 2618f457028bSMark J. Nelson fi 2619cdf0c1d5Smjnelson} 2620cdf0c1d5Smjnelson 2621597bd30bSMike Kupfertype bringover_subversion > /dev/null 2>&1 || function bringover_subversion { 2622cdf0c1d5Smjnelson typeset -x PATH=$PATH 2623cdf0c1d5Smjnelson 2624cdf0c1d5Smjnelson if [[ ! -d $CODEMGR_WS/.svn ]]; then 2625cdf0c1d5Smjnelson staffer svn checkout $BRINGOVER_WS $CODEMGR_WS || 2626cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 2627cdf0c1d5Smjnelson else 2628cdf0c1d5Smjnelson typeset root 2629cdf0c1d5Smjnelson root=$(staffer svn info $CODEMGR_WS | 2630cdf0c1d5Smjnelson nawk '/^Repository Root:/ {print $NF}') 2631cdf0c1d5Smjnelson if [[ $root != $BRINGOVER_WS ]]; then 2632cdf0c1d5Smjnelson # We fail here because there's no way to update 2633cdf0c1d5Smjnelson # from a named repo. 2634cdf0c1d5Smjnelson cat <<-EOF 2635cdf0c1d5Smjnelson \$BRINGOVER_WS doesn't match repository root: 2636cdf0c1d5Smjnelson \$BRINGOVER_WS: $BRINGOVER_WS 2637cdf0c1d5Smjnelson Repository root: $root 2638cdf0c1d5Smjnelson EOF 2639cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 2640cdf0c1d5Smjnelson else 2641cdf0c1d5Smjnelson # If a conflict happens, svn still exits 0. 2642cdf0c1d5Smjnelson staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out || 2643cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 2644cdf0c1d5Smjnelson if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then 2645cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 2646cdf0c1d5Smjnelson fi 2647cdf0c1d5Smjnelson fi 2648cdf0c1d5Smjnelson fi 2649cdf0c1d5Smjnelson} 2650cdf0c1d5Smjnelson 2651597bd30bSMike Kupfertype bringover_none > /dev/null 2>&1 || function bringover_none { 2652cdf0c1d5Smjnelson echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS." 2653cdf0c1d5Smjnelson touch $TMPDIR/bringover_failed 2654cdf0c1d5Smjnelson} 2655cdf0c1d5Smjnelson 2656cdf0c1d5Smjnelson# 2657cdf0c1d5Smjnelson# Decide whether to bringover to the codemgr workspace 2658cdf0c1d5Smjnelson# 2659cdf0c1d5Smjnelsonif [ "$n_FLAG" = "n" ]; then 2660*445b6314SRichard Lowe PARENT_SCM_TYPE=$(parent_wstype) 2661ca0ac982Smjnelson 2662ca0ac982Smjnelson if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then 2663ca0ac982Smjnelson echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \ 2664ca0ac982Smjnelson "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE 2665ca0ac982Smjnelson exit 1 2666ca0ac982Smjnelson fi 2667ca0ac982Smjnelson 2668cdf0c1d5Smjnelson run_hook PRE_BRINGOVER 2669cdf0c1d5Smjnelson 2670cdf0c1d5Smjnelson echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 2671cdf0c1d5Smjnelson echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 2672cdf0c1d5Smjnelson 2673ca0ac982Smjnelson eval "bringover_${PARENT_SCM_TYPE}" 2>&1 | 2674cdf0c1d5Smjnelson tee -a $mail_msg_file >> $LOGFILE 267532f1e47bSsommerfe 267632f1e47bSsommerfe if [ -f $TMPDIR/bringover_failed ]; then 267732f1e47bSsommerfe rm -f $TMPDIR/bringover_failed 267832f1e47bSsommerfe build_ok=n 267932f1e47bSsommerfe echo "trouble with bringover, quitting at `date`." | 26807c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 26817c478bd9Sstevel@tonic-gate exit 1 26827c478bd9Sstevel@tonic-gate fi 2683085d331dSkupfer 2684ca0ac982Smjnelson # 2685ca0ac982Smjnelson # It's possible that we used the bringover above to create 2686ca0ac982Smjnelson # $CODEMGR_WS. If so, then SCM_TYPE was previously "none," 2687ca0ac982Smjnelson # but should now be the same as $BRINGOVER_WS. 2688ca0ac982Smjnelson # 2689ca0ac982Smjnelson [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE 2690ca0ac982Smjnelson 269147703246Ssommerfe run_hook POST_BRINGOVER 269247703246Ssommerfe 2693085d331dSkupfer # 2694085d331dSkupfer # Possible transition from pre-split workspace to split 2695085d331dSkupfer # workspace. See if the bringover changed anything. 2696085d331dSkupfer # 2697085d331dSkupfer CLOSED_IS_PRESENT="$orig_closed_is_present" 2698085d331dSkupfer check_closed_tree 2699b83ec4edSjmcp 27007c478bd9Sstevel@tonic-gateelse 27017c478bd9Sstevel@tonic-gate echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 27027c478bd9Sstevel@tonic-gatefi 27037c478bd9Sstevel@tonic-gate 2704b83ec4edSjmcpif [[ "$O_FLAG" = y && "$CLOSED_IS_PRESENT" != "yes" ]]; then 2705b83ec4edSjmcp build_ok=n 2706b83ec4edSjmcp echo "OpenSolaris binary deliverables need usr/closed." \ 2707b83ec4edSjmcp | tee -a "$mail_msg_file" >> $LOGFILE 2708b83ec4edSjmcp exit 1 2709b83ec4edSjmcpfi 2710b83ec4edSjmcp 2711597bd30bSMike Kupferif [ "$CLOSED_IS_PRESENT" = no ]; then 2712865a69a7SMike Kupfer # 2713865a69a7SMike Kupfer # Not all consolidations have a closed tree, and even if they 2714865a69a7SMike Kupfer # did, they wouldn't necessarily have signed crypto. But if 2715865a69a7SMike Kupfer # the current source base does have signed crypto and it can't 2716865a69a7SMike Kupfer # be generated, error out, rather than silently building 2717865a69a7SMike Kupfer # unusable binaries. 2718865a69a7SMike Kupfer # 2719865a69a7SMike Kupfer grep -s ELFSIGN_CRYPTO "$SRC/Makefile.master" > /dev/null 2720865a69a7SMike Kupfer if (( $? == 0 )); then 2721597bd30bSMike Kupfer crypto_is_present >> "$LOGFILE" 2722597bd30bSMike Kupfer if (( $? != 0 )); then 2723597bd30bSMike Kupfer build_ok=n 2724597bd30bSMike Kupfer echo "A crypto tarball must be provided when" \ 2725597bd30bSMike Kupfer "there is no closed tree." | 2726597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 2727597bd30bSMike Kupfer exit 1 2728597bd30bSMike Kupfer fi 2729597bd30bSMike Kupfer fi 2730865a69a7SMike Kupferfi 2731597bd30bSMike Kupfer 2732cdf0c1d5Smjnelsonecho "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE 2733cdf0c1d5Smjnelson 2734cdf0c1d5Smjnelson# System 2735cdf0c1d5Smjnelsonwhence uname | tee -a $build_environ_file >> $LOGFILE 2736cdf0c1d5Smjnelsonuname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE 2737cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 2738cdf0c1d5Smjnelson 2739cdf0c1d5Smjnelson# nightly 2740cdf0c1d5Smjnelsonecho "$0 $@" | tee -a $build_environ_file >> $LOGFILE 274178add226Sjmcpif [[ $nightly_path = "/opt/onbld/bin/nightly" ]]; then 274278add226Sjmcp # We assume that if you have /opt/onbld/bin/nightly, then 274378add226Sjmcp # you have some form of the onbld package installed. If this 274478add226Sjmcp # is not true then your nightly is almost definitely out of 274578add226Sjmcp # date and should not be used. 274678add226Sjmcp /usr/bin/pkg info \*onbld\* | \ 274778add226Sjmcp egrep "Name:|Publisher:|Version:|Packaging:|FMRI:" 2748cdf0c1d5Smjnelsonelse 274930635de9SJohn.Zolnowsky@Sun.COM echo "$nightly_ls" 2750cdf0c1d5Smjnelsonfi | tee -a $build_environ_file >> $LOGFILE 2751cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 2752cdf0c1d5Smjnelson 2753cdf0c1d5Smjnelson# make 2754cdf0c1d5Smjnelsonwhence $MAKE | tee -a $build_environ_file >> $LOGFILE 2755cdf0c1d5Smjnelson$MAKE -v | tee -a $build_environ_file >> $LOGFILE 2756cdf0c1d5Smjnelsonecho "number of concurrent jobs = $DMAKE_MAX_JOBS" | 2757cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2758cdf0c1d5Smjnelson 2759cdf0c1d5Smjnelson# 2760cdf0c1d5Smjnelson# Report the compiler versions. 2761cdf0c1d5Smjnelson# 2762cdf0c1d5Smjnelson 2763cdf0c1d5Smjnelsonif [[ ! -f $SRC/Makefile ]]; then 2764cdf0c1d5Smjnelson build_ok=n 2765cdf0c1d5Smjnelson echo "\nUnable to find \"Makefile\" in $SRC." | \ 2766cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2767cdf0c1d5Smjnelson exit 1 2768cdf0c1d5Smjnelsonfi 2769cdf0c1d5Smjnelson 2770cdf0c1d5Smjnelson( cd $SRC 2771cdf0c1d5Smjnelson for target in cc-version cc64-version java-version; do 2772cdf0c1d5Smjnelson echo 2773cdf0c1d5Smjnelson # 2774cdf0c1d5Smjnelson # Put statefile somewhere we know we can write to rather than trip 2775cdf0c1d5Smjnelson # over a read-only $srcroot. 2776cdf0c1d5Smjnelson # 2777cdf0c1d5Smjnelson rm -f $TMPDIR/make-state 2778cdf0c1d5Smjnelson export SRC 2779cdf0c1d5Smjnelson if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 2780cdf0c1d5Smjnelson continue 2781cdf0c1d5Smjnelson fi 2782cdf0c1d5Smjnelson touch $TMPDIR/nocompiler 2783cdf0c1d5Smjnelson done 2784cdf0c1d5Smjnelson echo 2785cdf0c1d5Smjnelson) | tee -a $build_environ_file >> $LOGFILE 2786cdf0c1d5Smjnelson 2787cdf0c1d5Smjnelsonif [ -f $TMPDIR/nocompiler ]; then 2788cdf0c1d5Smjnelson rm -f $TMPDIR/nocompiler 2789cdf0c1d5Smjnelson build_ok=n 2790cdf0c1d5Smjnelson echo "Aborting due to missing compiler." | 2791cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2792cdf0c1d5Smjnelson exit 1 2793cdf0c1d5Smjnelsonfi 2794cdf0c1d5Smjnelson 2795cdf0c1d5Smjnelson# as 2796cdf0c1d5Smjnelsonwhence as | tee -a $build_environ_file >> $LOGFILE 2797cdf0c1d5Smjnelsonas -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE 2798cdf0c1d5Smjnelsonecho | tee -a $build_environ_file >> $LOGFILE 2799cdf0c1d5Smjnelson 2800cdf0c1d5Smjnelson# Check that we're running a capable link-editor 2801cdf0c1d5Smjnelsonwhence ld | tee -a $build_environ_file >> $LOGFILE 2802cdf0c1d5SmjnelsonLDVER=`ld -V 2>&1` 2803cdf0c1d5Smjnelsonecho $LDVER | tee -a $build_environ_file >> $LOGFILE 2804cdf0c1d5SmjnelsonLDVER=`echo $LDVER | sed -e "s/.*-1\.//" -e "s/:.*//"` 2805cdf0c1d5Smjnelsonif [ `expr $LDVER \< 422` -eq 1 ]; then 2806cdf0c1d5Smjnelson echo "The link-editor needs to be at version 422 or higher to build" | \ 2807cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2808cdf0c1d5Smjnelson echo "the latest stuff. Hope your build works." | \ 2809cdf0c1d5Smjnelson tee -a $build_environ_file >> $LOGFILE 2810cdf0c1d5Smjnelsonfi 2811cdf0c1d5Smjnelson 28127c478bd9Sstevel@tonic-gate# 28134e5b757fSkupfer# Build and use the workspace's tools if requested 28147c478bd9Sstevel@tonic-gate# 28154e5b757fSkupferif [[ "$t_FLAG" = "y" || "$O_FLAG" = y ]]; then 28164e5b757fSkupfer set_non_debug_build_flags 28177c478bd9Sstevel@tonic-gate 28187c478bd9Sstevel@tonic-gate build_tools ${TOOLS_PROTO} 2819ead1f93eSLiane Praza if [[ $? != 0 && "$t_FLAG" = y ]]; then 28204e5b757fSkupfer use_tools $TOOLS_PROTO 28214e5b757fSkupfer fi 28227c478bd9Sstevel@tonic-gatefi 28237c478bd9Sstevel@tonic-gate 28246fec3625Sdduvall# 28256fec3625Sdduvall# copy ihv proto area in addition to the build itself 28266fec3625Sdduvall# 28276fec3625Sdduvallif [ "$X_FLAG" = "y" ]; then 28286fec3625Sdduvall copy_ihv_proto 28296fec3625Sdduvallfi 28306fec3625Sdduvall 28317c478bd9Sstevel@tonic-gateif [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then 28327c478bd9Sstevel@tonic-gate echo "\n==== NOT Building base OS-Net source ====\n" | \ 28337c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 28347c478bd9Sstevel@tonic-gateelse 28354e5b757fSkupfer # timestamp the start of the normal build; the findunref tool uses it. 28364e5b757fSkupfer touch $SRC/.build.tstamp 28374e5b757fSkupfer 28387c478bd9Sstevel@tonic-gate normal_build 28397c478bd9Sstevel@tonic-gatefi 28407c478bd9Sstevel@tonic-gate 28414e5b757fSkupfer# 2842597bd30bSMike Kupfer# Generate the THIRDPARTYLICENSE files if needed. This is done after 2843597bd30bSMike Kupfer# the build, so that dynamically-created license files are there. 2844597bd30bSMike Kupfer# It's done before findunref to help identify license files that need 2845597bd30bSMike Kupfer# to be added to tools/opensolaris/license-list. 28465d715dd7Skupfer# 28475d715dd7Skupferif [ "$O_FLAG" = y -a "$build_ok" = y ]; then 2848597bd30bSMike Kupfer echo "\n==== Generating THIRDPARTYLICENSE files ====\n" | 2849597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 28505d715dd7Skupfer 28515084e753SMark J. Nelson if [ -d $ROOT/licenses/usr ]; then 28525084e753SMark J. Nelson ( cd $ROOT/licenses ; \ 28535084e753SMark J. Nelson mktpl $SRC/pkg/license-list ) >> "$LOGFILE" 2>&1 2854cdf0c1d5Smjnelson if (( $? != 0 )) ; then 28555d715dd7Skupfer echo "Couldn't create THIRDPARTYLICENSE files" | 2856597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 28575d715dd7Skupfer fi 28585084e753SMark J. Nelson else 28595084e753SMark J. Nelson echo "No licenses found under $ROOT/licenses" | 28605084e753SMark J. Nelson tee -a "$mail_msg_file" >> "$LOGFILE" 28615084e753SMark J. Nelson fi 28625d715dd7Skupferfi 28635d715dd7Skupfer 28647c478bd9Sstevel@tonic-gateORIG_SRC=$SRC 28657c478bd9Sstevel@tonic-gateBINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 28667c478bd9Sstevel@tonic-gate 28677c478bd9Sstevel@tonic-gateif [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 28687c478bd9Sstevel@tonic-gate save_binaries 28697c478bd9Sstevel@tonic-gatefi 28707c478bd9Sstevel@tonic-gate 28717c478bd9Sstevel@tonic-gate 28727c478bd9Sstevel@tonic-gate# EXPORT_SRC comes after CRYPT_SRC since a domestic build will need 28737c478bd9Sstevel@tonic-gate# $SRC pointing to the export_source usr/src. 2874cdf0c1d5Smjnelson 28757c478bd9Sstevel@tonic-gateif [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 2876cdf0c1d5Smjnelson if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then 2877cdf0c1d5Smjnelson set_up_source_build ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC 28787c478bd9Sstevel@tonic-gate fi 28797c478bd9Sstevel@tonic-gate 2880cdf0c1d5Smjnelson if [ $build_ok = y ]; then 2881cdf0c1d5Smjnelson set_up_source_build ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC 2882cdf0c1d5Smjnelson fi 2883cdf0c1d5Smjnelsonfi 2884cdf0c1d5Smjnelson 2885cdf0c1d5Smjnelsonif [ "$SD_FLAG" = "y" -a $build_ok = y ]; then 28867c478bd9Sstevel@tonic-gate # drop the crypt files in place. 28877c478bd9Sstevel@tonic-gate cd ${EXPORT_SRC} 28887c478bd9Sstevel@tonic-gate echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \ 28897c478bd9Sstevel@tonic-gate >> ${LOGFILE} 28907c478bd9Sstevel@tonic-gate zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \ 28917c478bd9Sstevel@tonic-gate cpio -idmucvB 2>/dev/null >> ${LOGFILE} 28927c478bd9Sstevel@tonic-gate if [ "$?" = "0" ]; then 28937c478bd9Sstevel@tonic-gate echo "\n==== DOMESTIC extraction succeeded ====\n" \ 28947c478bd9Sstevel@tonic-gate >> $mail_msg_file 28957c478bd9Sstevel@tonic-gate else 28967c478bd9Sstevel@tonic-gate echo "\n==== DOMESTIC extraction failed ====\n" \ 28977c478bd9Sstevel@tonic-gate >> $mail_msg_file 28987c478bd9Sstevel@tonic-gate fi 28997c478bd9Sstevel@tonic-gate 29007c478bd9Sstevel@tonic-gatefi 29017c478bd9Sstevel@tonic-gate 2902c7453724SMike Kupferif [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then 29031fe69678Skupfer # 29041fe69678Skupfer # Copy the open sources into their own tree, set up the closed 29054e5b757fSkupfer # binaries, and set up the environment. The build looks for 29064e5b757fSkupfer # the closed binaries in a location that depends on whether 29074e5b757fSkupfer # it's a DEBUG build, so we might need to make two copies. 29081fe69678Skupfer # 2909cdf0c1d5Smjnelson # If copy_source fails, it will have already generated an 2910cdf0c1d5Smjnelson # error message and set build_ok=n, so we don't need to worry 2911cdf0c1d5Smjnelson # about that here. 2912cdf0c1d5Smjnelson # 29131fe69678Skupfer copy_source $CODEMGR_WS $OPEN_SRCDIR OPEN_SOURCE usr/src 2914cdf0c1d5Smjnelsonfi 2915cdf0c1d5Smjnelson 2916c7453724SMike Kupferif [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then 29171fe69678Skupfer 2918b83ec4edSjmcp echo "\n==== Generating skeleton closed binaries for" \ 2919b83ec4edSjmcp "open-only build ====\n" | \ 2920b83ec4edSjmcp tee -a $LOGFILE >> $mail_msg_file 29214e5b757fSkupfer 2922b83ec4edSjmcp rm -rf $CODEMGR_WS/closed.skel 29234e5b757fSkupfer if [ "$D_FLAG" = y ]; then 2924b83ec4edSjmcp mkclosed $MACH $ROOT $CODEMGR_WS/closed.skel/root_$MACH \ 2925b83ec4edSjmcp >>$LOGFILE 2>&1 2926cdf0c1d5Smjnelson if (( $? != 0 )) ; then 2927b83ec4edSjmcp echo "Couldn't create skeleton DEBUG closed binaries." | 29281fe69678Skupfer tee -a $mail_msg_file >> $LOGFILE 29291fe69678Skupfer fi 29304e5b757fSkupfer fi 29314e5b757fSkupfer if [ "$F_FLAG" = n ]; then 29324e5b757fSkupfer root=$ROOT 29334e5b757fSkupfer [ "$MULTI_PROTO" = yes ] && root=$ROOT-nd 2934b83ec4edSjmcp mkclosed $MACH $root $CODEMGR_WS/closed.skel/root_$MACH-nd \ 29354e5b757fSkupfer >>$LOGFILE 2>&1 2936cdf0c1d5Smjnelson if (( $? != 0 )) ; then 2937b83ec4edSjmcp echo "Couldn't create skeleton non-DEBUG closed binaries." | 29384e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 29394e5b757fSkupfer fi 29404e5b757fSkupfer fi 29414e5b757fSkupfer 2942b83ec4edSjmcp SRC=$OPEN_SRCDIR/usr/src 2943b83ec4edSjmcp # Try not to clobber any user-provided closed binaries. 2944b83ec4edSjmcp export ON_CLOSED_BINS=$CODEMGR_WS/closed.skel 29454e5b757fSkupfer export CLOSED_IS_PRESENT=no 29461fe69678Skupferfi 29471fe69678Skupfer 29481fe69678Skupferif is_source_build && [ $build_ok = y ] ; then 29494e5b757fSkupfer # remove proto area(s) here, since we don't clobber 29504e5b757fSkupfer rm -rf `allprotos` 29517c478bd9Sstevel@tonic-gate if [ "$t_FLAG" = "y" ]; then 29524e5b757fSkupfer set_non_debug_build_flags 2953b91d9e0fSdanmcd ORIG_TOOLS=$TOOLS 29541fe69678Skupfer # 29551fe69678Skupfer # SRC was set earlier to point to the source build 29561fe69678Skupfer # source tree (e.g., $EXPORT_SRC). 29571fe69678Skupfer # 29581fe69678Skupfer TOOLS=${SRC}/tools 2959b06f2c55SMark J. Nelson TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO 2960b06f2c55SMark J. Nelson build_tools ${TOOLS_PROTO} 2961b06f2c55SMark J. Nelson if [[ $? != 0 ]]; then 2962b06f2c55SMark J. Nelson use_tools ${TOOLS_PROTO} 2963b06f2c55SMark J. Nelson fi 29647c478bd9Sstevel@tonic-gate fi 29657c478bd9Sstevel@tonic-gate 29667c478bd9Sstevel@tonic-gate export EXPORT_RELEASE_BUILD ; EXPORT_RELEASE_BUILD=# 29677c478bd9Sstevel@tonic-gate normal_build 29687c478bd9Sstevel@tonic-gatefi 29697c478bd9Sstevel@tonic-gate 29701fe69678Skupferif [[ "$SO_FLAG" = "y" && "$build_ok" = "y" ]]; then 29711fe69678Skupfer rm -rf $ON_CLOSED_BINS 29721fe69678Skupferfi 29731fe69678Skupfer 29744e5b757fSkupfer# 29754e5b757fSkupfer# There are several checks that need to look at the proto area, but 29764e5b757fSkupfer# they only need to look at one, and they don't care whether it's 29774e5b757fSkupfer# DEBUG or non-DEBUG. 29784e5b757fSkupfer# 29794e5b757fSkupferif [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then 29804e5b757fSkupfer checkroot=$ROOT-nd 29814e5b757fSkupferelse 29824e5b757fSkupfer checkroot=$ROOT 29834e5b757fSkupferfi 29844e5b757fSkupfer 29857c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 29867c478bd9Sstevel@tonic-gate echo "\n==== Creating protolist system file at `date` ====" \ 29877c478bd9Sstevel@tonic-gate >> $LOGFILE 29884e5b757fSkupfer protolist $checkroot > $ATLOG/proto_list_${MACH} 29897c478bd9Sstevel@tonic-gate echo "==== protolist system file created at `date` ====\n" \ 29907c478bd9Sstevel@tonic-gate >> $LOGFILE 29917c478bd9Sstevel@tonic-gate 29927c478bd9Sstevel@tonic-gate if [ "$N_FLAG" != "y" ]; then 29937c478bd9Sstevel@tonic-gate 2994ead1f93eSLiane Praza E1= 2995ead1f93eSLiane Praza f1= 2996ead1f93eSLiane Praza if [ -d "$SRC/pkgdefs" ]; then 2997ead1f93eSLiane Praza f1="$SRC/pkgdefs/etc/exception_list_$MACH" 2998ead1f93eSLiane Praza if [ "$X_FLAG" = "y" ]; then 2999ead1f93eSLiane Praza f1="$f1 $IA32_IHV_WS/usr/src/pkgdefs/etc/exception_list_$MACH" 30007c478bd9Sstevel@tonic-gate fi 30016fec3625Sdduvall fi 30027c478bd9Sstevel@tonic-gate 3003ead1f93eSLiane Praza for f in $f1; do 3004ead1f93eSLiane Praza if [ -f "$f" ]; then 3005ead1f93eSLiane Praza E1="$E1 -e $f" 3006ead1f93eSLiane Praza fi 3007ead1f93eSLiane Praza done 3008ead1f93eSLiane Praza 3009ead1f93eSLiane Praza E2= 3010ead1f93eSLiane Praza f2= 3011ead1f93eSLiane Praza if [ -d "$SRC/pkg" ]; then 3012ead1f93eSLiane Praza f2="$f2 exceptions/packaging" 3013ead1f93eSLiane Praza if [ "$CLOSED_IS_PRESENT" = "no" ]; then 3014ead1f93eSLiane Praza f2="$f2 exceptions/packaging.open" 3015ead1f93eSLiane Praza else 3016ead1f93eSLiane Praza f2="$f2 exceptions/packaging.closed" 3017ead1f93eSLiane Praza fi 3018ead1f93eSLiane Praza fi 3019ead1f93eSLiane Praza 3020ead1f93eSLiane Praza for f in $f2; do 3021ead1f93eSLiane Praza if [ -f "$f" ]; then 3022ead1f93eSLiane Praza E2="$E2 -e $f" 3023ead1f93eSLiane Praza fi 3024ead1f93eSLiane Praza done 3025ead1f93eSLiane Praza 30267c478bd9Sstevel@tonic-gate if [ -f "$REF_PROTO_LIST" ]; then 3027ead1f93eSLiane Praza # 3028b4add148Sdduvall # For builds that copy the IHV proto area (-X), add the 3029b4add148Sdduvall # IHV proto list to the reference list if the reference 3030b4add148Sdduvall # was built without -X. 3031b4add148Sdduvall # 3032b4add148Sdduvall # For builds that don't copy the IHV proto area, add the 3033b4add148Sdduvall # IHV proto list to the build's proto list if the 3034b4add148Sdduvall # reference was built with -X. 3035b4add148Sdduvall # 3036b4add148Sdduvall # Use the presence of the first file entry of the cached 3037b4add148Sdduvall # IHV proto list in the reference list to determine 3038ead1f93eSLiane Praza # whether it was built with -X or not. 3039ead1f93eSLiane Praza # 3040a51a9b36SMark J. Nelson IHV_REF_PROTO_LIST=$SRC/pkg/proto_list_ihv_$MACH 3041b4add148Sdduvall grepfor=$(nawk '$1 == "f" { print $2; exit }' \ 3042b4add148Sdduvall $IHV_REF_PROTO_LIST 2> /dev/null) 3043b4add148Sdduvall if [ $? = 0 -a -n "$grepfor" ]; then 3044b4add148Sdduvall if [ "$X_FLAG" = "y" ]; then 3045b4add148Sdduvall grep -w "$grepfor" \ 3046b4add148Sdduvall $REF_PROTO_LIST > /dev/null 3047b4add148Sdduvall if [ ! "$?" = "0" ]; then 3048b4add148Sdduvall REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST" 3049b4add148Sdduvall fi 3050b4add148Sdduvall else 3051b4add148Sdduvall grep -w "$grepfor" \ 3052b4add148Sdduvall $REF_PROTO_LIST > /dev/null 3053b4add148Sdduvall if [ "$?" = "0" ]; then 3054b4add148Sdduvall IHV_PROTO_LIST="$IHV_REF_PROTO_LIST" 3055b4add148Sdduvall fi 3056b4add148Sdduvall fi 3057b4add148Sdduvall fi 3058ead1f93eSLiane Praza fi 3059ead1f93eSLiane Praza fi 3060b4add148Sdduvall 306187916a32SMark J. Nelson if [ "$N_FLAG" != "y" -a -f $SRC/pkgdefs/Makefile ]; then 3062ead1f93eSLiane Praza echo "\n==== Impact on SVr4 packages ====\n" >> $mail_msg_file 3063ead1f93eSLiane Praza # 3064ead1f93eSLiane Praza # Compare the build's proto list with current package 3065ead1f93eSLiane Praza # definitions to audit the quality of package 3066ead1f93eSLiane Praza # definitions and makefile install targets. Use the 3067ead1f93eSLiane Praza # current exception list. 3068ead1f93eSLiane Praza # 3069ead1f93eSLiane Praza PKGDEFS_LIST="" 3070ead1f93eSLiane Praza for d in $abssrcdirs; do 3071ead1f93eSLiane Praza if [ -d $d/pkgdefs ]; then 3072ead1f93eSLiane Praza PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs" 3073ead1f93eSLiane Praza fi 3074ead1f93eSLiane Praza done 3075ead1f93eSLiane Praza if [ "$X_FLAG" = "y" -a \ 3076ead1f93eSLiane Praza -d $IA32_IHV_WS/usr/src/pkgdefs ]; then 3077ead1f93eSLiane Praza PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs" 3078ead1f93eSLiane Praza fi 3079ead1f93eSLiane Praza $PROTOCMPTERSE \ 3080ead1f93eSLiane Praza "Files missing from the proto area:" \ 3081ead1f93eSLiane Praza "Files missing from packages:" \ 3082ead1f93eSLiane Praza "Inconsistencies between pkgdefs and proto area:" \ 3083ead1f93eSLiane Praza ${E1} \ 3084ead1f93eSLiane Praza ${PKGDEFS_LIST} \ 3085ead1f93eSLiane Praza $ATLOG/proto_list_${MACH} \ 3086ead1f93eSLiane Praza >> $mail_msg_file 3087ead1f93eSLiane Praza fi 3088ead1f93eSLiane Praza 3089ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then 3090ead1f93eSLiane Praza echo "\n==== Validating manifests against proto area ====\n" \ 3091ead1f93eSLiane Praza >> $mail_msg_file 3092ead1f93eSLiane Praza ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) \ 3093ead1f93eSLiane Praza >> $mail_msg_file 3094ead1f93eSLiane Praza 3095ead1f93eSLiane Praza fi 3096ead1f93eSLiane Praza 3097ead1f93eSLiane Praza if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then 3098ead1f93eSLiane Praza echo "\n==== Impact on proto area ====\n" >> $mail_msg_file 3099ead1f93eSLiane Praza if [ -n "$E2" ]; then 3100ead1f93eSLiane Praza ELIST=$E2 3101ead1f93eSLiane Praza else 3102ead1f93eSLiane Praza ELIST=$E1 3103ead1f93eSLiane Praza fi 31047c478bd9Sstevel@tonic-gate $PROTOCMPTERSE \ 31057c478bd9Sstevel@tonic-gate "Files in yesterday's proto area, but not today's:" \ 31067c478bd9Sstevel@tonic-gate "Files in today's proto area, but not yesterday's:" \ 31077c478bd9Sstevel@tonic-gate "Files that changed between yesterday and today:" \ 31087c478bd9Sstevel@tonic-gate ${ELIST} \ 31097c478bd9Sstevel@tonic-gate -d $REF_PROTO_LIST \ 3110b4add148Sdduvall $REF_IHV_PROTO \ 31117c478bd9Sstevel@tonic-gate $ATLOG/proto_list_${MACH} \ 3112b4add148Sdduvall $IHV_PROTO_LIST \ 31137c478bd9Sstevel@tonic-gate >> $mail_msg_file 31147c478bd9Sstevel@tonic-gate fi 31157c478bd9Sstevel@tonic-gatefi 31167c478bd9Sstevel@tonic-gate 31177c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 31187c478bd9Sstevel@tonic-gate staffer cp $ATLOG/proto_list_${MACH} \ 31197c478bd9Sstevel@tonic-gate $PARENT_WS/usr/src/proto_list_${MACH} 31207c478bd9Sstevel@tonic-gatefi 31217c478bd9Sstevel@tonic-gate 31227c478bd9Sstevel@tonic-gate# Update parent proto area if necessary. This is done now 31237c478bd9Sstevel@tonic-gate# so that the proto area has either DEBUG or non-DEBUG kernels. 31247c478bd9Sstevel@tonic-gate# Note that this clears out the lock file, so we can dispense with 31257c478bd9Sstevel@tonic-gate# the variable now. 31267c478bd9Sstevel@tonic-gateif [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 31277c478bd9Sstevel@tonic-gate echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 31287c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 3129ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT/* 31307c478bd9Sstevel@tonic-gate unset Ulockfile 31317c478bd9Sstevel@tonic-gate mkdir -p $NIGHTLY_PARENT_ROOT 31324e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 3133ead1f93eSLiane Praza ( cd $ROOT; tar cf - . | 31344e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 31357c478bd9Sstevel@tonic-gate tee -a $mail_msg_file >> $LOGFILE 31367c478bd9Sstevel@tonic-gate fi 31374e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 3138ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_ROOT-nd/* 31394e5b757fSkupfer mkdir -p $NIGHTLY_PARENT_ROOT-nd 31404e5b757fSkupfer cd $ROOT-nd 31414e5b757fSkupfer ( tar cf - . | 31424e5b757fSkupfer ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 | 31434e5b757fSkupfer tee -a $mail_msg_file >> $LOGFILE 31444e5b757fSkupfer fi 31456798c3f0SMark J. Nelson if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then 3146ead1f93eSLiane Praza echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \ 3147ead1f93eSLiane Praza tee -a $LOGFILE >> $mail_msg_file 3148ead1f93eSLiane Praza rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/* 3149ead1f93eSLiane Praza mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT 3150ead1f93eSLiane Praza if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 3151ead1f93eSLiane Praza ( cd $TOOLS_PROTO; tar cf - . | 31526798c3f0SMark J. Nelson ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 31536798c3f0SMark J. Nelson umask 0; tar xpf - ) ) 2>&1 | 3154ead1f93eSLiane Praza tee -a $mail_msg_file >> $LOGFILE 3155ead1f93eSLiane Praza fi 31564e5b757fSkupfer fi 31576798c3f0SMark J. Nelsonfi 31587c478bd9Sstevel@tonic-gate 31597c478bd9Sstevel@tonic-gate# 316075ce41a5SAli Bahrami# ELF verification: ABI (-A) and runtime (-r) checks 31617c478bd9Sstevel@tonic-gate# 316275ce41a5SAli Bahramiif [[ ($build_ok = y) && ( ($A_FLAG = y) || ($r_FLAG = y) ) ]]; then 316375ce41a5SAli Bahrami # Directory ELF-data.$MACH holds the files produced by these tests. 316475ce41a5SAli Bahrami elf_ddir=$SRC/ELF-data.$MACH 31657c478bd9Sstevel@tonic-gate 316675ce41a5SAli Bahrami # If there is a previous ELF-data backup directory, remove it. Then, 316775ce41a5SAli Bahrami # rotate current ELF-data directory into its place and create a new 316875ce41a5SAli Bahrami # empty directory 316975ce41a5SAli Bahrami rm -rf $elf_ddir.ref 317075ce41a5SAli Bahrami if [[ -d $elf_ddir ]]; then 317175ce41a5SAli Bahrami mv $elf_ddir $elf_ddir.ref 317275ce41a5SAli Bahrami fi 317375ce41a5SAli Bahrami mkdir -p $elf_ddir 317475ce41a5SAli Bahrami 317575ce41a5SAli Bahrami # Call find_elf to produce a list of the ELF objects in the proto area. 317675ce41a5SAli Bahrami # This list is passed to check_rtime and interface_check, preventing 317775ce41a5SAli Bahrami # them from separately calling find_elf to do the same work twice. 317875ce41a5SAli Bahrami find_elf -fr $checkroot > $elf_ddir/object_list 317975ce41a5SAli Bahrami 318075ce41a5SAli Bahrami if [[ $A_FLAG = y ]]; then 31817c478bd9Sstevel@tonic-gate echo "\n==== Check versioning and ABI information ====\n" | \ 31827c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 31837c478bd9Sstevel@tonic-gate 318475ce41a5SAli Bahrami # Produce interface description for the proto. Report errors. 318575ce41a5SAli Bahrami interface_check -o -w $elf_ddir -f object_list \ 318675ce41a5SAli Bahrami -i interface -E interface.err 318775ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.err ]]; then 318875ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/interface.err \ 318975ce41a5SAli Bahrami >> $mail_msg_file 31907c478bd9Sstevel@tonic-gate fi 31917c478bd9Sstevel@tonic-gate 31925253169eSAli Bahrami # If ELF_DATA_BASELINE_DIR is defined, compare the new interface 31935253169eSAli Bahrami # description file to that from the baseline gate. Issue a 31945253169eSAli Bahrami # warning if the baseline is not present, and keep going. 31955253169eSAli Bahrami if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then 31965253169eSAli Bahrami base_ifile="$ELF_DATA_BASELINE_DIR/interface" 31977c478bd9Sstevel@tonic-gate 31985253169eSAli Bahrami echo "\n==== Compare versioning and ABI information" \ 3199e599109eSAli Bahrami "to baseline ====\n" | \ 32005253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 3201e599109eSAli Bahrami echo "Baseline: $base_ifile\n" >> $LOGFILE 32025253169eSAli Bahrami 32035253169eSAli Bahrami if [[ -f $base_ifile ]]; then 32045253169eSAli Bahrami interface_cmp -d -o $base_ifile \ 320575ce41a5SAli Bahrami $elf_ddir/interface > $elf_ddir/interface.cmp 320675ce41a5SAli Bahrami if [[ -s $elf_ddir/interface.cmp ]]; then 32075253169eSAli Bahrami echo | tee -a $LOGFILE >> $mail_msg_file 32085253169eSAli Bahrami tee -a $LOGFILE < \ 32095253169eSAli Bahrami $elf_ddir/interface.cmp \ 321075ce41a5SAli Bahrami >> $mail_msg_file 32117c478bd9Sstevel@tonic-gate fi 32125253169eSAli Bahrami else 32135253169eSAli Bahrami echo "baseline not available. comparison" \ 32145253169eSAli Bahrami "skipped" | \ 32155253169eSAli Bahrami tee -a $LOGFILE >> $mail_msg_file 32165253169eSAli Bahrami fi 32175253169eSAli Bahrami 32185253169eSAli Bahrami fi 32197c478bd9Sstevel@tonic-gate fi 32207c478bd9Sstevel@tonic-gate 322175ce41a5SAli Bahrami if [[ $r_FLAG = y ]]; then 32227c478bd9Sstevel@tonic-gate echo "\n==== Check ELF runtime attributes ====\n" | \ 32237c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 32247c478bd9Sstevel@tonic-gate 3225ead1f93eSLiane Praza # If we're doing a DEBUG build the proto area will be left 322675ce41a5SAli Bahrami # with debuggable objects, thus don't assert -s. 322775ce41a5SAli Bahrami if [[ $D_FLAG = y ]]; then 32287c478bd9Sstevel@tonic-gate rtime_sflag="" 32297c478bd9Sstevel@tonic-gate else 32307c478bd9Sstevel@tonic-gate rtime_sflag="-s" 32317c478bd9Sstevel@tonic-gate fi 323275ce41a5SAli Bahrami check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \ 323375ce41a5SAli Bahrami -D object_list -f object_list -E runtime.err \ 3234622090e3SAli Bahrami -I runtime.attr.raw 3235622090e3SAli Bahrami 3236622090e3SAli Bahrami # check_rtime -I output needs to be sorted in order to 3237622090e3SAli Bahrami # compare it to that from previous builds. 3238622090e3SAli Bahrami sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr 3239622090e3SAli Bahrami rm $elf_ddir/runtime.attr.raw 32407c478bd9Sstevel@tonic-gate 324175ce41a5SAli Bahrami # Report errors 324275ce41a5SAli Bahrami if [[ -s $elf_ddir/runtime.err ]]; then 324375ce41a5SAli Bahrami tee -a $LOGFILE < $elf_ddir/runtime.err \ 32447c478bd9Sstevel@tonic-gate >> $mail_msg_file 324575ce41a5SAli Bahrami fi 32467c478bd9Sstevel@tonic-gate 324775ce41a5SAli Bahrami # If there is an ELF-data directory from a previous build, 324875ce41a5SAli Bahrami # then diff the attr files. These files contain information 324975ce41a5SAli Bahrami # about dependencies, versioning, and runpaths. There is some 325075ce41a5SAli Bahrami # overlap with the ABI checking done above, but this also 325175ce41a5SAli Bahrami # flushes out non-ABI interface differences along with the 325275ce41a5SAli Bahrami # other information. 325375ce41a5SAli Bahrami echo "\n==== Diff ELF runtime attributes" \ 325475ce41a5SAli Bahrami "(since last build) ====\n" | \ 325575ce41a5SAli Bahrami tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file 325675ce41a5SAli Bahrami 325775ce41a5SAli Bahrami if [[ -f $elf_ddir.ref/runtime.attr ]]; then 325875ce41a5SAli Bahrami diff $elf_ddir.ref/runtime.attr \ 325975ce41a5SAli Bahrami $elf_ddir/runtime.attr \ 326075ce41a5SAli Bahrami >> $mail_msg_file 326175ce41a5SAli Bahrami fi 326275ce41a5SAli Bahrami fi 32635253169eSAli Bahrami 32645253169eSAli Bahrami # If -u set, copy contents of ELF-data.$MACH to the parent workspace. 32655253169eSAli Bahrami if [[ "$u_FLAG" = "y" ]]; then 32665253169eSAli Bahrami p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH 32675253169eSAli Bahrami 32685253169eSAli Bahrami # If parent lacks the ELF-data.$MACH directory, create it 32695253169eSAli Bahrami if [[ ! -d $p_elf_ddir ]]; then 32705253169eSAli Bahrami staffer mkdir -p $p_elf_ddir 32715253169eSAli Bahrami fi 32725253169eSAli Bahrami 32735253169eSAli Bahrami # These files are used asynchronously by other builds for ABI 32745253169eSAli Bahrami # verification, as above for the -A option. As such, we require 32755253169eSAli Bahrami # the file replacement to be atomic. Copy the data to a temp 32765253169eSAli Bahrami # file in the same filesystem and then rename into place. 32775253169eSAli Bahrami ( 32785253169eSAli Bahrami cd $elf_ddir 32795253169eSAli Bahrami for elf_dfile in *; do 32805253169eSAli Bahrami staffer cp $elf_dfile \ 32815253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile}.new 32825253169eSAli Bahrami staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \ 32835253169eSAli Bahrami ${p_elf_ddir}/${elf_dfile} 32845253169eSAli Bahrami done 32855253169eSAli Bahrami ) 32865253169eSAli Bahrami fi 32877c478bd9Sstevel@tonic-gatefi 32887c478bd9Sstevel@tonic-gate 32897c478bd9Sstevel@tonic-gate# DEBUG lint of kernel begins 32907c478bd9Sstevel@tonic-gate 32917c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 32927c478bd9Sstevel@tonic-gate if [ "$LINTDIRS" = "" ]; then 32937c478bd9Sstevel@tonic-gate # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 32947c478bd9Sstevel@tonic-gate LINTDIRS="$SRC y" 32957c478bd9Sstevel@tonic-gate fi 32967c478bd9Sstevel@tonic-gate set $LINTDIRS 32977c478bd9Sstevel@tonic-gate while [ $# -gt 0 ]; do 32987c478bd9Sstevel@tonic-gate dolint $1 $2; shift; shift 32997c478bd9Sstevel@tonic-gate done 33007c478bd9Sstevel@tonic-gateelse 33017c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 33027c478bd9Sstevel@tonic-gatefi 33037c478bd9Sstevel@tonic-gate 33047c478bd9Sstevel@tonic-gate# "make check" begins 33057c478bd9Sstevel@tonic-gate 33067c478bd9Sstevel@tonic-gateif [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 33077c478bd9Sstevel@tonic-gate # remove old check.out 33087c478bd9Sstevel@tonic-gate rm -f $SRC/check.out 33097c478bd9Sstevel@tonic-gate 33107c478bd9Sstevel@tonic-gate rm -f $SRC/check-${MACH}.out 33117c478bd9Sstevel@tonic-gate cd $SRC 33127c478bd9Sstevel@tonic-gate $MAKE -ek check 2>&1 | tee -a $SRC/check-${MACH}.out >> $LOGFILE 33137c478bd9Sstevel@tonic-gate echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 33147c478bd9Sstevel@tonic-gate 33157c478bd9Sstevel@tonic-gate grep ":" $SRC/check-${MACH}.out | 33167c478bd9Sstevel@tonic-gate egrep -v "Ignoring unknown host" | \ 33177c478bd9Sstevel@tonic-gate sort | uniq >> $mail_msg_file 33187c478bd9Sstevel@tonic-gateelse 33197c478bd9Sstevel@tonic-gate echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 33207c478bd9Sstevel@tonic-gatefi 33217c478bd9Sstevel@tonic-gate 33227c478bd9Sstevel@tonic-gateecho "\n==== Find core files ====\n" | \ 33237c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 33247c478bd9Sstevel@tonic-gate 3325fb23a357Skupferfind $abssrcdirs -name core -a -type f -exec file {} \; | \ 33267c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $mail_msg_file 33277c478bd9Sstevel@tonic-gate 33287c478bd9Sstevel@tonic-gateif [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 33297c478bd9Sstevel@tonic-gate echo "\n==== Diff unreferenced files (since last build) ====\n" \ 33307c478bd9Sstevel@tonic-gate | tee -a $LOGFILE >>$mail_msg_file 33317c478bd9Sstevel@tonic-gate rm -f $SRC/unref-${MACH}.ref 33327c478bd9Sstevel@tonic-gate if [ -f $SRC/unref-${MACH}.out ]; then 33337c478bd9Sstevel@tonic-gate mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 33347c478bd9Sstevel@tonic-gate fi 33357c478bd9Sstevel@tonic-gate 33369730304dSmeem findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \ 3337cdf0c1d5Smjnelson ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \ 33389730304dSmeem sort > $SRC/unref-${MACH}.out 33397c478bd9Sstevel@tonic-gate 33407c478bd9Sstevel@tonic-gate if [ ! -f $SRC/unref-${MACH}.ref ]; then 33417c478bd9Sstevel@tonic-gate cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 33427c478bd9Sstevel@tonic-gate fi 33437c478bd9Sstevel@tonic-gate 33447c478bd9Sstevel@tonic-gate diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 33457c478bd9Sstevel@tonic-gatefi 33467c478bd9Sstevel@tonic-gate 33475d715dd7Skupfer# 33485d715dd7Skupfer# Generate the OpenSolaris deliverables if requested. Some of these 33495d715dd7Skupfer# steps need to come after findunref and are commented below. 33505d715dd7Skupfer# 3351597bd30bSMike Kupfer 3352597bd30bSMike Kupfer# 3353597bd30bSMike Kupfer# Copy an input crypto tarball to the canonical destination (with 3354597bd30bSMike Kupfer# datestamp), and point the non-stamped symlink at it. 3355c7453724SMike Kupfer# Usage: copyin_crypto from_path suffix 3356597bd30bSMike Kupfer# Returns 0 if successful, non-zero if not. 3357597bd30bSMike Kupfer# 3358c7453724SMike Kupferfunction copyin_crypto { 3359597bd30bSMike Kupfer typeset from=$1 3360597bd30bSMike Kupfer typeset suffix=$2 3361597bd30bSMike Kupfer typeset to=$(cryptodest "$suffix").bz2 3362597bd30bSMike Kupfer typeset -i stat 3363597bd30bSMike Kupfer cp "$from" "$to" 3364597bd30bSMike Kupfer stat=$? 3365597bd30bSMike Kupfer if (( $stat == 0 )); then 3366597bd30bSMike Kupfer cryptolink "$to" "$suffix" 3367597bd30bSMike Kupfer stat=$? 3368597bd30bSMike Kupfer fi 3369597bd30bSMike Kupfer return $stat 3370597bd30bSMike Kupfer} 3371597bd30bSMike Kupfer 3372597bd30bSMike Kupfer# 3373c7453724SMike Kupfer# Copy a crypto tarball to $CODEMGR_WS to go with the other 3374c7453724SMike Kupfer# OpenSolaris deliverables. 3375c7453724SMike Kupfer# Usage: copyout_crypto suffix 3376c7453724SMike Kupfer# where $suffix is "" or "-nd". 3377c7453724SMike Kupfer# 3378c7453724SMike Kupferfunction copyout_crypto { 3379c7453724SMike Kupfer typeset suffix=$1 3380c7453724SMike Kupfer typeset cryptof=on-crypto$suffix.$MACH.tar.bz2 3381c7453724SMike Kupfer [ -f $cryptof ] && rm $cryptof 3382c7453724SMike Kupfer cp $(cryptodest "$suffix").bz2 $cryptof 3383c7453724SMike Kupfer} 3384c7453724SMike Kupfer 3385c7453724SMike Kupfer# 3386597bd30bSMike Kupfer# Pass through the crypto tarball(s) that we were given, putting it in 3387597bd30bSMike Kupfer# the same place that crypto_from_proto puts things. 3388c7453724SMike Kupfer# Returns with non-zero status if there is a problem. 3389597bd30bSMike Kupfer# 3390597bd30bSMike Kupferfunction crypto_passthrough { 3391597bd30bSMike Kupfer echo "Reusing $ON_CRYPTO_BINS for crypto tarball(s)..." >> "$LOGFILE" 3392c7453724SMike Kupfer typeset -i stat=0 3393597bd30bSMike Kupfer if [ "$D_FLAG" = y ]; then 3394c7453724SMike Kupfer copyin_crypto "$ON_CRYPTO_BINS" "" >> "$LOGFILE" 2>&1 3395597bd30bSMike Kupfer if (( $? != 0 )) ; then 3396597bd30bSMike Kupfer echo "Couldn't create DEBUG crypto tarball." | 3397597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 3398c7453724SMike Kupfer stat=1 3399597bd30bSMike Kupfer fi 3400597bd30bSMike Kupfer fi 3401597bd30bSMike Kupfer if [ "$F_FLAG" = n ]; then 3402c7453724SMike Kupfer copyin_crypto $(ndcrypto "$ON_CRYPTO_BINS") "-nd" \ 3403597bd30bSMike Kupfer >> "$LOGFILE" 2>&1 3404597bd30bSMike Kupfer if (( $? != 0 )) ; then 3405597bd30bSMike Kupfer echo "Couldn't create non-DEBUG crypto tarball." | 3406597bd30bSMike Kupfer tee -a "$mail_msg_file" >> "$LOGFILE" 3407c7453724SMike Kupfer stat=1 3408597bd30bSMike Kupfer fi 3409597bd30bSMike Kupfer fi 3410c7453724SMike Kupfer 3411c7453724SMike Kupfer return $stat 3412597bd30bSMike Kupfer} 3413597bd30bSMike Kupfer 3414b83ec4edSjmcp# If we are doing an OpenSolaris _source_ build (-S O) then we do 3415b83ec4edSjmcp# not have usr/closed available to us to generate closedbins from, 3416b83ec4edSjmcp# so skip this part. 3417b83ec4edSjmcpif [ "$SO_FLAG" = n -a "$O_FLAG" = y -a "$build_ok" = y ]; then 34185d715dd7Skupfer echo "\n==== Generating OpenSolaris tarballs ====\n" | \ 34195d715dd7Skupfer tee -a $mail_msg_file >> $LOGFILE 34205d715dd7Skupfer 34215d715dd7Skupfer cd $CODEMGR_WS 34225d715dd7Skupfer 34235d715dd7Skupfer # 3424ead1f93eSLiane Praza # This step grovels through the package manifests, so it 34255d715dd7Skupfer # must come after findunref. 34265d715dd7Skupfer # 3427ead1f93eSLiane Praza # We assume no DEBUG vs non-DEBUG package content variation 3428ead1f93eSLiane Praza # here; if that changes, then the "make all" in $SRC/pkg will 3429ead1f93eSLiane Praza # need to be moved into the conditionals and repeated for each 3430ead1f93eSLiane Praza # different build. 3431ead1f93eSLiane Praza # 34325d715dd7Skupfer echo "Generating closed binaries tarball(s)..." >> $LOGFILE 34335d715dd7Skupfer closed_basename=on-closed-bins 34345d715dd7Skupfer if [ "$D_FLAG" = y ]; then 3435b83ec4edSjmcp bindrop "$closed_basename" >>"$LOGFILE" 2>&1 3436cdf0c1d5Smjnelson if (( $? != 0 )) ; then 34375d715dd7Skupfer echo "Couldn't create DEBUG closed binaries." | 34385d715dd7Skupfer tee -a $mail_msg_file >> $LOGFILE 3439c7453724SMike Kupfer build_ok=n 34405d715dd7Skupfer fi 34415d715dd7Skupfer fi 34425d715dd7Skupfer if [ "$F_FLAG" = n ]; then 3443b83ec4edSjmcp bindrop -n "$closed_basename-nd" >>"$LOGFILE" 2>&1 3444cdf0c1d5Smjnelson if (( $? != 0 )) ; then 34455d715dd7Skupfer echo "Couldn't create non-DEBUG closed binaries." | 34465d715dd7Skupfer tee -a $mail_msg_file >> $LOGFILE 3447c7453724SMike Kupfer build_ok=n 34485d715dd7Skupfer fi 34495d715dd7Skupfer fi 34505d715dd7Skupfer 34515d715dd7Skupfer echo "Generating README.opensolaris..." >> $LOGFILE 34525d715dd7Skupfer cat $SRC/tools/opensolaris/README.opensolaris.tmpl | \ 34535d715dd7Skupfer mkreadme_osol $CODEMGR_WS/README.opensolaris >> $LOGFILE 2>&1 3454cdf0c1d5Smjnelson if (( $? != 0 )) ; then 34555d715dd7Skupfer echo "Couldn't create README.opensolaris." | 34565d715dd7Skupfer tee -a $mail_msg_file >> $LOGFILE 3457c7453724SMike Kupfer build_ok=n 34585d715dd7Skupfer fi 34595d715dd7Skupfer 3460c7453724SMike Kupfer typeset have_crypto=y 3461597bd30bSMike Kupfer if [ -n "$ON_CRYPTO_BINS" ]; then 3462c7453724SMike Kupfer crypto_passthrough || have_crypto=n 3463c7453724SMike Kupfer fi 3464c7453724SMike Kupfer # 3465c7453724SMike Kupfer # Make another copy of the crypto so that all the OpenSolaris 3466c7453724SMike Kupfer # deliverables are in $CODEMGR_WS. 3467c7453724SMike Kupfer # 3468c7453724SMike Kupfer if [ "$have_crypto" != y ]; then 3469c7453724SMike Kupfer build_ok=n 3470c7453724SMike Kupfer else 3471c7453724SMike Kupfer echo "Copying crypto tarball to $CODEMGR_WS" >> "$LOGFILE" 3472c7453724SMike Kupfer if [ "$D_FLAG" = y ]; then 3473c7453724SMike Kupfer copyout_crypto "" >> "$LOGFILE" 2>&1 3474c7453724SMike Kupfer if (( $? != 0 )) ; then 3475c7453724SMike Kupfer echo "Couldn't create DEBUG crypto tarball" | 3476c7453724SMike Kupfer tee -a $mail_msg_file >> "$LOGFILE" 3477c7453724SMike Kupfer build_ok=n 3478c7453724SMike Kupfer fi 3479c7453724SMike Kupfer fi 3480c7453724SMike Kupfer if [ "$F_FLAG" = n ]; then 3481c7453724SMike Kupfer copyout_crypto "-nd" >> "$LOGFILE" 2>&1 3482c7453724SMike Kupfer if (( $? != 0 )) ; then 3483c7453724SMike Kupfer echo "Couldn't create non-DEBUG" \ 3484c7453724SMike Kupfer "crypto tarball" | 3485c7453724SMike Kupfer tee -a $mail_msg_file >> "$LOGFILE" 3486c7453724SMike Kupfer build_ok=n 3487c7453724SMike Kupfer fi 3488c7453724SMike Kupfer fi 3489597bd30bSMike Kupfer fi 34905d715dd7Skupferfi 34915d715dd7Skupfer 34927c478bd9Sstevel@tonic-gate# Verify that the usual lists of files, such as exception lists, 34937c478bd9Sstevel@tonic-gate# contain only valid references to files. If the build has failed, 34947c478bd9Sstevel@tonic-gate# then don't check the proto area. 34957c478bd9Sstevel@tonic-gateCHECK_PATHS=${CHECK_PATHS:-y} 34967c478bd9Sstevel@tonic-gateif [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 34977c478bd9Sstevel@tonic-gate echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 34987c478bd9Sstevel@tonic-gate >>$mail_msg_file 34997c478bd9Sstevel@tonic-gate arg=-b 35007c478bd9Sstevel@tonic-gate [ "$build_ok" = y ] && arg= 35014e5b757fSkupfer checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file 35027c478bd9Sstevel@tonic-gatefi 35037c478bd9Sstevel@tonic-gate 35047c478bd9Sstevel@tonic-gateif [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 35057c478bd9Sstevel@tonic-gate echo "\n==== Impact on file permissions ====\n" \ 35067c478bd9Sstevel@tonic-gate >> $mail_msg_file 3507ead1f93eSLiane Praza 3508ead1f93eSLiane Praza abspkgdefs= 3509ead1f93eSLiane Praza abspkg= 3510ead1f93eSLiane Praza for d in $abssrcdirs; do 3511ead1f93eSLiane Praza if [ -d "$d/pkgdefs" ]; then 3512ead1f93eSLiane Praza abspkgdefs="$abspkgdefs $d" 35137c478bd9Sstevel@tonic-gate fi 3514ead1f93eSLiane Praza if [ -d "$d/pkg" ]; then 3515ead1f93eSLiane Praza abspkg="$abspkg $d" 3516ead1f93eSLiane Praza fi 3517ead1f93eSLiane Praza done 3518ead1f93eSLiane Praza 3519ead1f93eSLiane Praza if [ -n "$abspkgdefs" ]; then 3520ead1f93eSLiane Praza pmodes -qvdP \ 3521ead1f93eSLiane Praza `find $abspkgdefs -name pkginfo.tmpl -print -o \ 3522ead1f93eSLiane Praza -name .del\* -prune | sed -e 's:/pkginfo.tmpl$::' | \ 3523ead1f93eSLiane Praza sort -u` >> $mail_msg_file 3524ead1f93eSLiane Praza fi 3525ead1f93eSLiane Praza 3526ead1f93eSLiane Praza if [ -n "$abspkg" ]; then 3527ead1f93eSLiane Praza for d in "$abspkg"; do 3528ead1f93eSLiane Praza ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file 3529ead1f93eSLiane Praza done 3530ead1f93eSLiane Praza fi 35317c478bd9Sstevel@tonic-gatefi 35327c478bd9Sstevel@tonic-gate 353396ccc8cbSesaxeif [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 35344e5b757fSkupfer if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then 35354e5b757fSkupfer do_wsdiff DEBUG $ROOT.prev $ROOT 35364e5b757fSkupfer fi 353796ccc8cbSesaxe 35384e5b757fSkupfer if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then 35394e5b757fSkupfer do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd 354096ccc8cbSesaxe fi 354196ccc8cbSesaxefi 354296ccc8cbSesaxe 35437c478bd9Sstevel@tonic-gateEND_DATE=`date` 35447c478bd9Sstevel@tonic-gateecho "==== Nightly $maketype build completed: $END_DATE ====" | \ 35457c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 35467c478bd9Sstevel@tonic-gate 3547c341b28aSDarren Moffattypeset -i10 hours 35487c478bd9Sstevel@tonic-gatetypeset -Z2 minutes 35497c478bd9Sstevel@tonic-gatetypeset -Z2 seconds 35507c478bd9Sstevel@tonic-gate 35517c478bd9Sstevel@tonic-gateelapsed_time=$SECONDS 35527c478bd9Sstevel@tonic-gate((hours = elapsed_time / 3600 )) 35537c478bd9Sstevel@tonic-gate((minutes = elapsed_time / 60 % 60)) 35547c478bd9Sstevel@tonic-gate((seconds = elapsed_time % 60)) 35557c478bd9Sstevel@tonic-gate 35567c478bd9Sstevel@tonic-gateecho "\n==== Total build time ====" | \ 35577c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 35587c478bd9Sstevel@tonic-gateecho "\nreal ${hours}:${minutes}:${seconds}" | \ 35597c478bd9Sstevel@tonic-gate tee -a $LOGFILE >> $build_time_file 35607c478bd9Sstevel@tonic-gate 35617c478bd9Sstevel@tonic-gateif [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 35627c478bd9Sstevel@tonic-gate staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 35637c478bd9Sstevel@tonic-gate 35647c478bd9Sstevel@tonic-gate # 35657c478bd9Sstevel@tonic-gate # Produce a master list of unreferenced files -- ideally, we'd 35667c478bd9Sstevel@tonic-gate # generate the master just once after all of the nightlies 35677c478bd9Sstevel@tonic-gate # have finished, but there's no simple way to know when that 35687c478bd9Sstevel@tonic-gate # will be. Instead, we assume that we're the last nightly to 35697c478bd9Sstevel@tonic-gate # finish and merge all of the unref-${MACH}.out files in 35707c478bd9Sstevel@tonic-gate # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 35717c478bd9Sstevel@tonic-gate # finish, then this file will be the authoritative master 35727c478bd9Sstevel@tonic-gate # list. Otherwise, another ${MACH}'s nightly will eventually 35737c478bd9Sstevel@tonic-gate # overwrite ours with its own master, but in the meantime our 35747c478bd9Sstevel@tonic-gate # temporary "master" will be no worse than any older master 35757c478bd9Sstevel@tonic-gate # which was already on the parent. 35767c478bd9Sstevel@tonic-gate # 35777c478bd9Sstevel@tonic-gate 35787c478bd9Sstevel@tonic-gate set -- $PARENT_WS/usr/src/unref-*.out 35797c478bd9Sstevel@tonic-gate cp "$1" ${TMPDIR}/unref.merge 35807c478bd9Sstevel@tonic-gate shift 35817c478bd9Sstevel@tonic-gate 35827c478bd9Sstevel@tonic-gate for unreffile; do 35837c478bd9Sstevel@tonic-gate comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 35847c478bd9Sstevel@tonic-gate mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 35857c478bd9Sstevel@tonic-gate done 35867c478bd9Sstevel@tonic-gate 35877c478bd9Sstevel@tonic-gate staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 35887c478bd9Sstevel@tonic-gatefi 35897c478bd9Sstevel@tonic-gate 35907c478bd9Sstevel@tonic-gate# 35917c478bd9Sstevel@tonic-gate# All done save for the sweeping up. 35927c478bd9Sstevel@tonic-gate# (whichever exit we hit here will trigger the "cleanup" trap which 35937c478bd9Sstevel@tonic-gate# optionally sends mail on completion). 35947c478bd9Sstevel@tonic-gate# 35957c478bd9Sstevel@tonic-gateif [ "$build_ok" = "y" ]; then 35967c478bd9Sstevel@tonic-gate exit 0 35977c478bd9Sstevel@tonic-gatefi 35987c478bd9Sstevel@tonic-gateexit 1 3599