nightly.sh revision f457028baae01951069fcd4f4fe9d9a63bda89e2
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Based on the nightly script from the integration folks,
# Mostly modified and owned by mike_s.
# Changes also by kjc, dmk.
#
# BRINGOVER_WS may be specified in the env file.
# The default is the old behavior of CLONE_WS
#
# -i on the command line, means fast options, so when it's on the
# command line (only), lint and check builds are skipped no matter what
# the setting of their individual flags are in NIGHTLY_OPTIONS.
#
# LINTDIRS can be set in the env file, format is a list of:
#
# /dirname-to-run-lint-on flag
#
# Where flag is: y - enable lint noise diff output
# n - disable lint noise diff output
#
#
# -A flag in NIGHTLY_OPTIONS checks ABI diffs in .so files
# This option requires a couple of scripts.
#
# OPTHOME and TEAMWARE may be set in the environment to override /opt
#
#
# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
# under certain circumstances, which can really screw things up; unset it.
#
unset CDPATH
# Get the absolute path of the nightly script that the user invoked. This
# may be a relative path, and we need to do this before changing directory.
nightly_path=`whence $0`
#
# Keep track of where we found nightly so we can invoke the matching
# which_scm script. If that doesn't work, don't go guessing, just rely
# or the user's workspace.
#
if [[ ! -x $WHICH_SCM ]]; then
fi
#
# Print the tag string used to identify a build (e.g., "DEBUG
# open-only")
# usage: tagstring debug-part open-part
#
debug_part=$1
open_part=$2
echo "$debug_part $open_part"
else
echo "$debug_part"
fi
}
#
# Function to do a DEBUG and non-DEBUG build. Needed because we might
# need to do another for the source build, and since we only deliver DEBUG or
# non-DEBUG packages.
#
# usage: normal_build [-O]
# -O OpenSolaris delivery build. Put the proto area and
# (eventually) packages in -open directories. Use skeleton
# closed binaries. Don't generate archives--that needs to be
# done later, after we've generated the closed binaries. Also
# skip the package build (until 6414822 is fixed).
#
typeset orig_p_FLAG="$p_FLAG"
typeset orig_a_FLAG="$a_FLAG"
suffix=""
open_only=""
while getopts O FLAG $*; do
O)
suffix="-open"
open_only="open-only"
p_FLAG=n
a_FLAG=n
;;
esac
done
# non-DEBUG build begins
build "$mytag" "$suffix-nd" "$MULTI_PROTO"
fi
else
fi
# non-DEBUG build ends
# DEBUG build begins
build "$mytag" "$suffix" "$MULTI_PROTO"
fi
else
fi
# DEBUG build ends
}
#
# usage: run_hook HOOKNAME ARGS...
#
# If variable "$HOOKNAME" is defined, insert a section header into
# our logs and then run the command with ARGS
#
HOOKNAME=$1
shift
(
# Let exit status propagate up
fi
) | tee -a $mail_msg_file >> $LOGFILE
build_ok=n
tee -a $mail_msg_file >> $LOGFILE
exit 1
fi
fi
}
#
# usage: filelist DESTDIR PATTERN
#
DEST=$1
PATTERN=$2
cd ${DEST}
if [ ! -f ${OBJFILES} ]; then
return;
fi
do
# wildcard expansion
for j in $i
do
if [ -f "$j" ]; then
echo $j
fi
if [ -d "$j" ]; then
echo $j
fi
done
}
# function to save off binaries after a full build for later
# restoration
# save off list of binaries
tee -a $mail_msg_file >> $LOGFILE
rm -f ${BINARCHIVE}
cd ${CODEMGR_WS}
> ${BINARCHIVE}
}
# delete files
# usage: hybridize_files DESTDIR MAKE_TARGET
DEST=$1
MAKETARG=$2
tee -a $mail_msg_file >> $LOGFILE
do
done
do
rm -f ${i}+
< ${i} > ${i}+
mv ${i}+ ${i}
done
}
# restore binaries into the proper source tree.
# usage: restore_binaries DESTDIR MAKE_TARGET
DEST=$1
MAKETARG=$2
tee -a $mail_msg_file >> $LOGFILE
cd ${DEST}
zcat ${BINARCHIVE} | \
}
# rename files we save binaries of
# usage: rename_files DESTDIR MAKE_TARGET
DEST=$1
MAKETARG=$2
tee -a $mail_msg_file >> $LOGFILE
do
echo ${i} | tee -a $mail_msg_file >> ${LOGFILE}
rm -f ${i}.export
mv ${i} ${i}.export
done
}
#
# Copy some or all of the source tree.
#
# Returns 0 for success, non-zero for failure.
#
# usage: copy_source CODEMGR_WS DESTDIR LABEL SRCROOT
#
WS=$1
DEST=$2
label=$3
srcroot=$4
if (( $? != 0 )) ; then
tee -a $mail_msg_file >> $LOGFILE
build_ok=n
return 1
fi
cd "$WS"
if (( $? != 0 )) ; then
tee -a $mail_msg_file >> $LOGFILE
build_ok=n
return 1
fi
;;
if (( $? != 0 )) ; then
build_ok=n
return 1
fi
;;
*)
build_ok=n
echo "Tree copy is not supported for workspace type" \
return 1
;;
esac
return 0
}
#
# Mercurial-specific copy code for copy_source(). Handles the
# combined open and closed trees.
#
# Returns 0 for success, non-zero for failure.
#
# usage: copy_source_mercurial destdir srcroot
#
function copy_source_mercurial {
typeset dest=$1
typeset srcroot=$2
typeset open_top closed_top
usr)
fi
;;
return 1
fi
;;
*)
;;
esac
if (( $? != 0 )) ; then
tee -a $mail_msg_file >> $LOGFILE
return 1
fi
fi
if (( $? != 0 )) ; then
return 1
fi
else
if (( $? != 0 )) ; then
tee -a $mail_msg_file >> $LOGFILE
return 1
fi
fi
fi
return 0
}
#
# usage: set_up_source_build CODEMGR_WS DESTDIR MAKE_TARGET
# Sets SRC to the modified source tree, for use by the caller when it
# builds the tree.
#
WS=$1
DEST=$2
MAKETARG=$3
if (( $? != 0 )); then
echo "\nCould not copy source tree for source build." |
tee -a $mail_msg_file >> $LOGFILE
build_ok=n
return
fi
cd $SRC
cd ${DEST}
if [ "${MAKETARG}" = "CRYPT_SRC" ]; then
rm -f ${CODEMGR_WS}/crypt_files.cpio.Z
tee -a $mail_msg_file >> $LOGFILE
for i in `cat ${CRYPT_FILES}`
do
# make sure the files exist
if [ -f "$i" ]; then
continue
fi
if [ -d "$i" ]; then
continue
fi
done
fi
if [ "${MAKETARG}" = "EXPORT_SRC" ]; then
# rename first, since we might restore a file
# of the same name (mapfiles)
fi
fi
# save the cleartext
tee -a $mail_msg_file >> $LOGFILE
cd ${DEST}
compress > ${CODEMGR_WS}/${MAKETARG}.cpio.Z
if [ "${MAKETARG}" = "EXPORT_SRC" ]; then
fi
if [ "${MAKETARG}" = "CRYPT_SRC" ]; then
fi
}
# Return library search directive as function of given root.
}
# Return header search directive as function of given root.
}
#
# Wrapper over commands that generate BFU archives. The entire
# command output gets written to LOGFILE, and any unexpected messages
# are written to the mail message. Returns with the status of the
# original command.
#
typeset tmplog
typeset errors
typeset cmd
integer cmd_stat
cmd="$1"
shift
cmd_stat=$?
>> "$mail_msg_file"
fi
return $cmd_stat
}
#
# Function to do the build, including cpio archive and package generation.
# usage: build LABEL SUFFIX MULTIPROTO
# - LABEL is used to tag build output.
# - SUFFIX is used to distinguish files (e.g., debug vs non-debug).
# - If MULTIPROTO is "yes", it means to name the proto area according to
# SUFFIX. Otherwise ("no"), (re)use the standard proto area.
#
LABEL=$1
SUFFIX=$2
MULTIPROTO=$3
CPIODIR=${CPIODIR_ORIG}${SUFFIX}
fi
[ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
export ENVLDLIBS1=`myldlibs $ROOT`
export ENVCPPFLAGS1=`myheaders $ROOT`
#
# Build OS-Networking source
#
>> $LOGFILE
cd $SRC
fi
if [ "$?" = "0" ]; then
build_ok=n
fi
if [ "$?" = "0" ]; then
build_ok=n
fi
fi
>> $LOGFILE
tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
fi
fi
fi
#
# Re-sign selected binaries using signing server
# (gatekeeper builds only)
#
signing_file="${TMPDIR}/signing"
rm -f ${signing_file}
export CODESIGN_USER
tee -a ${signing_file} >> $LOGFILE
>> $LOGFILE
if (( $? == 0 )) ; then
build_ok=n
fi
fi
#
# Create cpio archives for preintegration testing (PIT)
#
>> $LOGFILE
# hack for test folks
else
X=${CPIODIR}
fi
else
>> $LOGFILE
fi
#
# Building Packages
#
>> $LOGFILE
mkdir -p $PKGARCHIVE
#
# Optional build of sparc realmode on i386
#
echo "Clearing out ${SPARC_RM_PKGARCHIVE} ..." \
>> $LOGFILE
rm -rf ${SPARC_RM_PKGARCHIVE}
mkdir -p ${SPARC_RM_PKGARCHIVE}
fi
else
fi
}
# Usage: dolint /dir y|n
if [ ! -d "$1" ]; then
echo "dolint error: $1 is not a directory"
exit 1
fi
if [ "$2" != "y" -a "$2" != "n" ]; then
echo "dolint internal error: $2 should be 'y' or 'n'"
exit 1
fi
lintdir=$1
dodiff=$2
export ENVLDLIBS1=`myldlibs $ROOT`
export ENVCPPFLAGS1=`myheaders $ROOT`
#
# '$MAKE lint' in $lintdir
#
# remove old lint.out
if [ -f $lintdir/lint-noise.ref ]; then
fi
cd $lintdir
#
# Remove all .ln files to ensure a full reference file
#
rm -f Nothing_to_remove \
tail -3 $LINTOUT >>$mail_msg_file
fi
fi
# should be none, though there are a few that were filtered out
# above
| sort | uniq >> $mail_msg_file
fi
}
# Install proto area from IHV build
echo "\n==== Installing IHV proto area ====\n" \
>> $LOGFILE
fi
else
fi
fi
# If there's a non-debug version of the IHV proto area,
# copy it, but copy something if there's not.
cd $IA32_IHV_ROOT-nd
else
return
fi
fi
}
# Install IHV packages in PKGARCHIVE
# usage: copy_ihv_pkgs LABEL SUFFIX
LABEL=$1
SUFFIX=$2
# always use non-DEBUG IHV packages
>> $LOGFILE
else
fi
>> $LOGFILE
else
fi
}
#
# Build and install the onbld tools.
#
# usage: build_tools DESTROOT
#
# returns non-zero status if the build was successful.
#
DESTROOT=$1
>> $LOGFILE
cd ${TOOLS}
egrep -v warning >> $mail_msg_file
return $?
}
#
# Set up to use locally installed tools.
#
# usage: use_tools TOOLSROOT
#
TOOLSROOT=$1
export STABS
export CTFSTABS
export GENOFFSETS
CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert
export CTFCONVERT
export CTFMERGE
export CTFCVTPTBL
export CTFFINDMOD
else
fi
export ELFSIGN
export PATH
}
"$@"
else
arg="\"$1\""
shift
for i
do
done
fi
}
#
# Verify that the closed tree is present if it needs to be.
# Sets CLOSED_IS_PRESENT for future use.
#
if [ -d $CODEMGR_WS/usr/closed ]; then
CLOSED_IS_PRESENT="yes"
else
CLOSED_IS_PRESENT="no"
fi
export CLOSED_IS_PRESENT
fi
#
# If it's an old (pre-split) tree or an empty
# workspace, don't complain.
#
if grep -s CLOSED_BUILD $SRC/Makefile.master > /dev/null; then
echo "If the closed sources are not present," \
"ON_CLOSED_BINS"
echo "must point to the closed binaries tree."
build_ok=n
exit 1
fi
fi
}
echo "WARNING: Obsolete $1 build requested; request will be ignored"
}
#
# wrapper over wsdiff.
# usage: do_wsdiff LABEL OLDPROTO NEWPROTO
#
label=$1
oldproto=$2
newproto=$3
tee -a $LOGFILE >> $mail_msg_file
wsdiff="wsdiff"
$wsdiff -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
tee -a $LOGFILE >> $mail_msg_file
}
#
# together.
#
export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
export RELEASE_BUILD ; RELEASE_BUILD=
unset EXTRA_OPTIONS
unset EXTRA_CFLAGS
}
export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
unset RELEASE_BUILD
unset EXTRA_OPTIONS
unset EXTRA_CFLAGS
}
if [ "$OPTHOME" = "" ]; then
export OPTHOME
fi
if [ "$TEAMWARE" = "" ]; then
export TEAMWARE
fi
USAGE='Usage: nightly [-in] [-V VERS ] [ -S E|D|H|O ] <env_file>
Where:
-i Fast incremental options (no clobber, lint, check)
-n Do not do a bringover
-V VERS set the build version string to VERS
-S Build a variant of the source product
E - build exportable source
D - build domestic source (exportable + crypt)
H - build hybrid source (binaries + deleted source)
O - build (only) open source
<env_file> file in Bourne shell syntax that sets and exports
variables that configure the operation of this script and many of
the scripts this one calls. If <env_file> does not exist,
non-DEBUG is the default build type. Build options can be set in the
NIGHTLY_OPTIONS variable in the <env_file> as follows:
-A check for ABI differences in .so files
-D do a build with DEBUG on
-F do _not_ do a non-DEBUG build
-G gate keeper default group of options (-au)
-I integration engineer default group of options (-ampu)
-M do not run pmodes (safe file permission checker)
-N do not run protocmp
-O generate OpenSolaris deliverables
-R default group of options for building a release (-mp)
-U update proto area in the parent
-V VERS set the build version string to VERS
-X copy x86 IHV proto area
-a create cpio archives
-f find unreferenced files
-i do an incremental build (no "make clobber")
-l do "make lint" in $LINTDIRS (default: $SRC y)
-m send mail to $MAILTO at end of build
-n do not do a bringover
-p create packages
-r check ELF runtime attributes in the proto area
-u update proto_list_$MACH and friends in the parent workspace;
when used with -f, also build an unrefmaster.out in the parent
-w report on differences between previous and current proto areas
-z compress cpio archives with gzip
-W Do not report warnings (freeware gate ONLY)
-S Build a variant of the source product
E - build exportable source
D - build domestic source (exportable + crypt)
H - build hybrid source (binaries + deleted source)
O - build (only) open source
'
#
# -x less public handling of xmod source for the source product
#
# A log file will be generated under the name $LOGFILE
# for partially completed build and log.`date '+%F'`
# in the same directory for fully completed builds.
#
# default values for low-level FLAGS; G I R are group FLAGS
A_FLAG=n
a_FLAG=n
C_FLAG=n
D_FLAG=n
F_FLAG=n
f_FLAG=n
i_FLAG=n; i_CMD_LINE_FLAG=n
l_FLAG=n
M_FLAG=n
m_FLAG=n
N_FLAG=n
n_FLAG=n
O_FLAG=n
o_FLAG=n
P_FLAG=n
p_FLAG=n
r_FLAG=n
T_FLAG=n
t_FLAG=y
U_FLAG=n
u_FLAG=n
V_FLAG=n
W_FLAG=n
w_FLAG=n
X_FLAG=n
z_FLAG=n
SD_FLAG=n
SE_FLAG=n
SH_FLAG=n
SO_FLAG=n
#
#
build_ok=y
return $?
}
#
# examine arguments
#
#
# single function for setting -S flag and doing error checking.
# usage: set_S_flag <type>
# where <type> is the source build type ("E", "D", ...).
#
if is_source_build; then
echo "Can only build one source variant at a time."
exit 1
fi
if [ "$1" = "E" ]; then
SE_FLAG=y
elif [ "$1" = "D" ]; then
SD_FLAG=y
elif [ "$1" = "H" ]; then
SH_FLAG=y
elif [ "$1" = "O" ]; then
SO_FLAG=y
else
echo "$USAGE"
exit 1
fi
}
OPTIND=1
do
i ) i_FLAG=y; i_CMD_LINE_FLAG=y
;;
n ) n_FLAG=y
;;
S )
;;
+t ) t_FLAG=n
;;
V ) V_FLAG=y
;;
\? ) echo "$USAGE"
exit 1
;;
esac
done
# correct argument count after options
# test that the path to the environment-setting file was given
if [ $# -ne 1 ]; then
echo "$USAGE"
exit 1
fi
# check if user is running nightly as root
# ISUSER is set non-zero if an ordinary user runs nightly, or is zero
# when root invokes nightly.
#
# force locale to C
LC_COLLATE=C; export LC_COLLATE
LC_MESSAGES=C; export LC_MESSAGES
LC_MONETARY=C; export LC_MONETARY
LC_NUMERIC=C; export LC_NUMERIC
# clear environment variables we know to be bad for the build
unset LD_OPTIONS
unset CONFIG
unset GROUP
unset OWNER
unset REMOTE
unset ENV
unset ARCH
unset CLASSPATH
unset NAME
#
# Setup environmental variables
#
if [ -f /etc/nightly.conf ]; then
. /etc/nightly.conf
fi
if [ -f $1 ]; then
if [[ $1 = */* ]]; then
. $1
else
. ./$1
fi
else
else
exit 1
fi
fi
# contents of stdenv.sh inserted after next line:
# STDENV_START
# STDENV_END
#
# place ourselves in a new task, respecting BUILD_PROJECT if set.
#
if [ -z "$BUILD_PROJECT" ]; then
else
fi
#
# See if NIGHTLY_OPTIONS is set
#
if [ "$NIGHTLY_OPTIONS" = "" ]; then
NIGHTLY_OPTIONS="-aBm"
fi
#
# If BRINGOVER_WS was not specified, let it default to CLONE_WS
#
if [ "$BRINGOVER_WS" = "" ]; then
fi
#
# If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS
#
if [ "$CLOSED_BRINGOVER_WS" = "" ]; then
fi
#
# If BRINGOVER_FILES was not specified, default to usr
#
if [ "$BRINGOVER_FILES" = "" ]; then
BRINGOVER_FILES="usr"
fi
#
# If the closed sources are not present, the closed binaries must be
# present for the build to succeed. If there's no pointer to the
# closed binaries, flag that now, rather than forcing the user to wait
# a couple hours (or more) to find out.
#
#
# Note: changes to the option letters here should also be applied to the
# bldenv script. `d' is listed for backward compatibility.
#
OPTIND=1
do
A ) A_FLAG=y
;;
a ) a_FLAG=y
;;
B ) D_FLAG=y
;; # old version of D
C ) C_FLAG=y
;;
D ) D_FLAG=y
;;
F ) F_FLAG=y
;;
f ) f_FLAG=y
;;
G ) a_FLAG=y
u_FLAG=y
;;
I ) a_FLAG=y
m_FLAG=y
p_FLAG=y
u_FLAG=y
;;
i ) i_FLAG=y
;;
l ) l_FLAG=y
;;
M ) M_FLAG=y
;;
m ) m_FLAG=y
;;
N ) N_FLAG=y
;;
n ) n_FLAG=y
;;
O ) O_FLAG=y
;;
o ) o_FLAG=y
;;
P ) P_FLAG=y
;; # obsolete
p ) p_FLAG=y
;;
R ) m_FLAG=y
p_FLAG=y
;;
r ) r_FLAG=y
;;
S )
;;
T ) T_FLAG=y
;; # obsolete
+t ) t_FLAG=n
;;
U )
if [ -z "${PARENT_ROOT}" ]; then
echo "PARENT_ROOT must be set if the U flag is" \
"present in NIGHTLY_OPTIONS."
exit 1
fi
U_FLAG=y
;;
u ) u_FLAG=y
;;
W ) W_FLAG=y
;;
w ) w_FLAG=y
;;
X ) # now that we no longer need realmode builds, just
# copy IHV packages. only meaningful on x86.
if [ "$MACH" = "i386" ]; then
X_FLAG=y
fi
;;
x ) XMOD_OPT="-x"
;;
z ) z_FLAG=y
;;
\? ) echo "$USAGE"
exit 1
;;
esac
done
if [ "$o_FLAG" = "y" ]; then
echo "Old-style build requires root permission."
exit 1
fi
# Set default value for STAFFER, if needed.
export STAFFER
fi
fi
export MAILTO
fi
export PATH
# roots of source trees, both relative to $SRC and absolute.
relsrcdirs="."
relsrcdirs="$relsrcdirs ../closed"
fi
abssrcdirs=""
for d in $relsrcdirs; do
abssrcdirs="$abssrcdirs $SRC/$d"
done
unset CH
if [ "$o_FLAG" = "y" ]; then
# root invoked old-style build -- make sure it works as it always has
# by exporting 'CH'. The current Makefile.master doesn't use this, but
# the old ones still do.
CH=
export CH
else
PROTOCMPTERSE="protocmp.terse -gu"
fi
POUND_SIGN="#"
# we export POUND_SIGN to speed up the build process -- prevents evaluation of
# the Makefile.master definitions.
maketype="distributed"
# get the dmake version string alone
DMAKE_VERSION=$( $MAKE -v )
# focus in on just the dotted version number alone
DMAKE_MAJOR=$( echo $DMAKE_VERSION | \
# extract the second (or final) integer
DMAKE_MINOR=${DMAKE_MINOR%%.*}
# extract the first integer
DMAKE_MAJOR=${DMAKE_MAJOR%%.*}
CHECK_DMAKE=${CHECK_DMAKE:-y}
# x86 was built on the 12th, sparc on the 13th.
if [ "$CHECK_DMAKE" = "y" -a \
"$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \
"$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \
if [ -z "$DMAKE_VERSION" ]; then
echo "$MAKE is missing."
exit 1
fi
echo `whence $MAKE`" version is:"
echo " ${DMAKE_VERSION}"
cat <<EOF
This version may not be safe for use. Either set TEAMWARE to a better
path or (if you really want to use this version of dmake anyway), add
the following to your environment to disable this check:
CHECK_DMAKE=n
EOF
exit 1
fi
export PATH
export MAKE
if [ "${SUNWSPRO}" != "" ]; then
export PATH
fi
if [ ! -f $HOME/.make.machines ]; then
else
if [ "$DMAKE_MAX_JOBS" = "" ]; then
fi
fi
export DMAKE_MODE
export DMAKE_MAX_JOBS
if [ -z "${ROOT}" ]; then
echo "ROOT must be set."
exit 1
fi
#
# if -V flag was given, reset VERSION to V_ARG
#
if [ "$V_FLAG" = "y" ]; then
fi
#
# Check for IHV root for copying ihv proto area
#
if [ "$X_FLAG" = "y" ]; then
if [ "$IA32_IHV_ROOT" = "" ]; then
echo "IA32_IHV_ROOT: must be set for copying ihv proto"
args_ok=n
fi
if [ ! -d "$IA32_IHV_ROOT" ]; then
echo "$IA32_IHV_ROOT: not found"
args_ok=n
fi
if [ "$IA32_IHV_WS" = "" ]; then
echo "IA32_IHV_WS: must be set for copying ihv proto"
args_ok=n
fi
if [ ! -d "$IA32_IHV_WS" ]; then
echo "$IA32_IHV_WS: not found"
args_ok=n
fi
fi
# Append source version
if [ "$SE_FLAG" = "y" ]; then
VERSION="${VERSION}:EXPORT"
fi
if [ "$SD_FLAG" = "y" ]; then
VERSION="${VERSION}:DOMESTIC"
fi
if [ "$SH_FLAG" = "y" ]; then
VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT"
fi
if [ "$SO_FLAG" = "y" ]; then
VERSION="${VERSION}:OPEN_ONLY"
fi
TMPDIR="/tmp/nightly.tmpdir.$$"
export TMPDIR
#
# Keep elfsign's use of pkcs11_softtoken from looking in the user home
# directory, which doesn't always work. Needed until all build machines
# have the fix for 6271754
#
export SOFTTOKEN_DIR
# create directories that are automatically removed if the nightly script
# fails to start correctly
dir=$1
while [ ! -d $dir ]; do
done
torm=
else
return 1
fi
done
return 0
}
# since this script assumes the build is from full source, it nullifies
# variables likely to have been set by a "ws" script; nullification
# confines the search space for headers and libraries to the proto area
# built from this immediate source.
if [ "$SPARC_RM_PKGARCHIVE" ]; then
fi
#
# Juggle the logs and optionally send mail on completion.
#
fi
export LLOG
if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
fi
if [ -f $TMPDIR/wsdiff.results ]; then
fi
if [ -f $TMPDIR/wsdiff-nd.results ]; then
fi
fi
#
# Now that we're about to send mail, it's time to check the noise
# file. In the event that an error occurs beyond this point, it will
# be recorded in the nightly.log file, but nowhere else. This would
# include only errors that cause the copying of the noise log to fail
# or the mail itself not to be sent.
#
exec >>$LOGFILE 2>&1
if [ -s $build_noise_file ]; then
echo "\n==== Nightly build noise ====\n" |
tee -a $LOGFILE >>$mail_msg_file
echo | tee -a $LOGFILE >>$mail_msg_file
fi
y)
;;
i)
;;
*)
;;
esac
export NIGHTLY_STATUS
${MAILTO}
fi
fi
}
#
# Remove the locks and temporary files on any exit
#
set -- $newdirlist
while [ $# -gt 0 ]; do
shift; shift
done
}
build_ok=i
# this will trigger cleanup(), above.
exit 1
}
trap cleanup 0
#
# Generic lock file processing -- make sure that the lock file doesn't
# exist. If it does, it should name the build host and PID. If it
# doesn't, then make sure we can create it. Clean up locks that are
# known to be stale (assumes host name is unique among build systems
# for the workspace).
#
lockf=$1
lockvar=$2
exit 1
exit 1
else
# stale lock; clear it out and try again
fi
done
}
#
# Return the list of interesting proto areas, depending on the current
# options.
#
if [ $O_FLAG = y ]; then
# OpenSolaris deliveries require separate proto areas.
fi
[ $MULTI_PROTO = yes ] && roots="$roots $ROOT-nd"
fi
echo $roots
}
# Ensure no other instance of this script is running on this host.
# LOCKNAME can be set in <env_file>, and is by default, but is not
# required due to the use of $ATLOG below.
if [ -n "$LOCKNAME" ]; then
fi
#
# Create from one, two, or three other locks:
# - protects against multiple builds in same workspace
# - protects against multiple 'u' copy-backs
# - protects against multiple 'U' copy-backs
#
# Overriding ISUSER to 1 causes the lock to be created as root if the
# script is run as root. The default is to create it as $STAFFER.
if [ "$u_FLAG" = "y" ]; then
fi
if [ "$U_FLAG" = "y" ]; then
# NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
fi
# Locks have been taken, so we're doing a build and we're committed to
# the directories we may have created so far.
#
# Create mail_msg_file
#
mail_msg_file="${TMPDIR}/mail_msg"
build_time_file="${TMPDIR}/build_time"
build_environ_file="${TMPDIR}/build_environ"
#
# Move old LOGFILE aside
# ATLOG directory already made by 'create_lock' above
#
if [ -f $LOGFILE ]; then
fi
#
# Build OsNet source
#
SECONDS=0
echo "\n==== Nightly $maketype build started: $START_DATE ====" \
echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
# make sure we log only to the nightly build file
build_noise_file="${TMPDIR}/build_noise"
echo "\n==== list of environment variables ====\n" >> $LOGFILE
if [ "$P_FLAG" = "y" ]; then
fi
if [ "$T_FLAG" = "y" ]; then
fi
if is_source_build; then
echo "WARNING: the -S flags do not support incremental" \
i_FLAG=n
fi
if [ "$N_FLAG" = "n" ]; then
echo "WARNING: the -S flags do not support protocmp;" \
"protocmp disabled\n" | \
N_FLAG=y
fi
if [ "$l_FLAG" = "y" ]; then
echo "WARNING: the -S flags do not support lint;" \
l_FLAG=n
fi
if [ "$C_FLAG" = "y" ]; then
echo "WARNING: the -S flags do not support cstyle;" \
C_FLAG=n
fi
else
if [ "$N_FLAG" = "y" ]; then
if [ "$p_FLAG" = "y" ]; then
cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
WARNING: the p option (create packages) is set, but so is the N option (do
not run protocmp); this is dangerous; you should unset the N option
EOF
else
cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
Warning: the N option (do not run protocmp) is set; it probably shouldn't be
EOF
fi
fi
fi
echo "WARNING: OpenSolaris deliveries (-O) require archives;" \
a_FLAG=y
fi
echo "WARNING: Neither DEBUG nor non-DEBUG build requested, but the" \
fi
#
# In the past we just complained but went ahead with the lint
# pass, even though the proto area was built non-debug. It's
# unlikely that non-debug headers will make a difference, but
# rather than assuming it's a safe combination, force the user
# to specify a debug build.
#
echo "WARNING: DEBUG build not requested; disabling lint.\n" \
l_FLAG=n
fi
if [ "$f_FLAG" = "y" ]; then
if [ "$i_FLAG" = "y" ]; then
echo "WARNING: the -f flag cannot be used during incremental" \
f_FLAG=n
fi
echo "WARNING: the -f flag requires -l and -p; ignoring -f\n" | \
f_FLAG=n
fi
fi
echo "WARNING: -w specified, but $ROOT does not exist;" \
w_FLAG=n
fi
if [ "$t_FLAG" = "n" ]; then
#
# We're not doing a tools build, so make sure elfsign(1) is
# new enough to safely sign non-crypto binaries. We test
# debugging output from elfsign to detect the old version.
#
-e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \
if [ -z "$newelfsigntest" ]; then
"will only sign crypto modules\n" | \
export ELFSIGN_OBJECT=true
elif [ "$VERIFY_ELFSIGN" = "y" ]; then
echo "WARNING: VERIFY_ELFSIGN=y requires" \
"the -t flag; ignoring VERIFY_ELFSIGN\n" | \
fi
fi
case $MULTI_PROTO in
*)
echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
echo "Setting MULTI_PROTO to \"no\".\n" | \
export MULTI_PROTO=no
;;
esac
# Save the current proto area if we're comparing against the last build
if [ -d "$ROOT.prev" ]; then
fi
fi
# Same for non-DEBUG proto area
fi
fi
# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
function wstypes {
typeset parent_type child_type junk
| read parent_type junk
# Probe BRINGOVER_WS to determine its type
if [[ $BRINGOVER_WS == svn*://* ]]; then
parent_type="subversion"
elif [[ $BRINGOVER_WS == file://* ]] &&
${BRINGOVER_WS#file://}/README.txt 2> /dev/null; then
parent_type="subversion"
elif [[ $BRINGOVER_WS == ssh://* ]]; then
parent_type="mercurial"
elif svn info $BRINGOVER_WS > /dev/null 2>&1; then
parent_type="subversion"
elif [[ $BRINGOVER_WS == http://* ]] && \
parent_type="mercurial"
else
parent_type="none"
fi
fi
# Probe CODEMGR_WS to determine its type
if [[ -d $CODEMGR_WS ]]; then
$WHICH_SCM | read child_type junk || exit 1
fi
# fold both unsupported and unrecognized results into "none"
;;
*) parent_type=none
;;
esac
;;
*) child_type=none
;;
esac
echo $child_type $parent_type
}
export SCM_TYPE PARENT_SCM_TYPE
#
# Decide whether to clobber
#
cd $SRC
# remove old clobber file
# Remove all .make.state* files, just in case we are restarting
# the build after having interrupted a previous 'make clobber'.
echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
egrep -v "Ignoring unknown host" \
cd ${TOOLS}
echo "\n==== Make tools clobber ERRORS ====\n" \
mkdir -p ${TOOLS_PROTO}
fi
# Get back to a clean workspace as much as possible to catch
# problems that only occur on fresh workspaces.
# Remove all .make.state* files, libraries, and .o's that may
# have been omitted from clobber. A couple of libraries are
# under source code control, so leave them alone.
# We should probably blow away temporary directories too.
cd $SRC
-name '*.o' \) -print | \
else
fi
# sleep on the parent workspace's lock
while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks
do
sleep 120
done
if [[ -z $BRINGOVER ]]; then
fi
-w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 ||
if [ -s $TMPDIR/bringovercheck.out ]; then
echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n"
fi
}
# If the repository doesn't exist yet, then we want to populate it.
if [[ ! -d $CODEMGR_WS/.hg ]]; then
fi
#
# If the user set CLOSED_BRINGOVER_WS and didn't set CLOSED_IS_PRESENT
# to "no," then we'll want to initialise the closed repository
#
# We use $orig_closed_is_present instead of $CLOSED_IS_PRESENT,
# because for newly-created source trees, the latter will be "no"
# until after the bringover completes.
#
! -d $CODEMGR_WS/usr/closed/.hg ]]; then
export CLOSED_IS_PRESENT=yes
fi
#
# If the user has changes, regardless of whether those changes are
# committed, and regardless of whether those changes conflict, then
# we'll attempt to merge them either implicitly (uncommitted) or
# explicitly (committed).
#
# These are the messages we'll use to help clarify mercurial output
# in those cases.
#
typeset mergefailmsg="\
***\n\
*** nightly was unable to automatically merge your changes. You should\n\
*** redo the full merge manually, following the steps outlined by mercurial\n\
*** above, then restart nightly.\n\
***\n"
typeset mergepassmsg="\
***\n\
*** nightly successfully merged your changes. This means that your working\n\
*** directory has been updated, but those changes are not yet committed.\n\
*** After nightly completes, you should validate the results of the merge,\n\
*** then use hg commit manually.\n\
***\n"
#
# For each repository in turn:
#
# 1. Do the pull. If this fails, dump the output and bail out.
#
# 2. If the pull resulted in an extra head, do an explicit merge.
# If this fails, dump the output and bail out.
#
# Because we can't rely on Mercurial to exit with a failure code
# when a merge fails (Mercurial issue #186), we must grep the
#
# 3. If a merge failed, set the message and fail the bringover.
#
# 4. Otherwise, if a merge succeeded, set the message
#
# 5. Dump the output, and any message from step 3 or 4.
#
typeset HG_SOURCE=$BRINGOVER_WS
if [ ! -f $TMPDIR/new_repository ]; then
staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
#
# If there are no incoming changesets, then incoming will
# fail, and there will be no bundle file. Reset the source,
# to allow the remaining logic to complete with no false
# negatives. (Unlike incoming, pull will return success
# for the no-change case.)
#
if (( $? != 0 )); then
fi
fi
staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
> $TMPDIR/pull_open.out 2>&1
if (( $? != 0 )); then
printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
fi
return
fi
staffer hg --cwd $CODEMGR_WS merge \
>> $TMPDIR/pull_open.out 2>&1
if (( $? != 0 )); then
fi
return
fi
fi
printf "updated %s with the following results:\n" "$CODEMGR_WS"
fi
printf "\n"
#
# told not to via $CLOSED_IS_PRESENT, and we actually know where to
# pull from ($CLOSED_BRINGOVER_WS).
#
if [[ $CLOSED_IS_PRESENT = yes && \
-d $CODEMGR_WS/usr/closed/.hg && \
-n $CLOSED_BRINGOVER_WS ]]; then
if [ ! -f $TMPDIR/new_closed ]; then
--bundle $HG_SOURCE -v $CLOSED_BRINGOVER_WS \
#
# If there are no incoming changesets, then incoming will
# fail, and there will be no bundle file. Reset the source,
# to allow the remaining logic to complete with no false
# negatives. (Unlike incoming, pull will return success
# for the no-change case.)
#
if (( $? != 0 )); then
fi
fi
$HG_SOURCE > $TMPDIR/pull_closed.out 2>&1
if (( $? != 0 )); then
printf "closed pull failed as follows:\n\n"
fi
return
fi
>> $TMPDIR/pull_closed.out 2>&1
if (( $? != 0 )); then
printf "closed merge failed as follows:\n\n"
fi
return
fi
fi
fi
fi
#
# Per-changeset output is neither useful nor manageable for a
# newly-created repository.
#
if [ -f $TMPDIR/new_repository ]; then
return
fi
printf "\nadded the following changesets to open repository:\n"
#
# The closed repository could have been newly created, even though
# the open one previously existed...
#
if [ -f $TMPDIR/new_closed ]; then
return
fi
if [ -f $TMPDIR/incoming_closed.out ]; then
printf "\nadded the following changesets to closed repository:\n"
fi
}
if [[ ! -d $CODEMGR_WS/.svn ]]; then
else
typeset root
root=$(staffer svn info $CODEMGR_WS |
if [[ $root != $BRINGOVER_WS ]]; then
# We fail here because there's no way to update
# from a named repo.
cat <<-EOF
\$BRINGOVER_WS doesn't match repository root:
\$BRINGOVER_WS: $BRINGOVER_WS
Repository root: $root
EOF
touch $TMPDIR/bringover_failed
else
# If a conflict happens, svn still exits 0.
staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out ||
touch $TMPDIR/bringover_failed
if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then
touch $TMPDIR/bringover_failed
fi
fi
fi
}
type bringover_none > /dev/null 2>&1 || bringover_none() {
echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
touch $TMPDIR/bringover_failed
}
# Parse the URL.
# The other way to deal with empty components is to echo a string that can
# be eval'ed by the caller to associate values (possibly empty) with
# variables. In that case, passing in a printf string would let the caller
# choose the variable names.
parse_url() {
typeset url method host port path
url=$1
method=${url%%://*}
host=${url#$method://}
path=${host#*/}
host=${host%%/*}
if [[ $host == *:* ]]; then
port=${host#*:}
host=${host%:*}
fi
# method can never be empty. host can only be empty if method is
# file, and that implies it's localhost. path can default to / if
# it's otherwise empty, leaving port as the only component without
# a default, so it has to go last.
echo $method ${host:-localhost} ${path:-/} $port
}
http_get() {
typeset url method host port path
url=$1
if [[ -n $http_proxy ]]; then
parse_url $http_proxy | read method host path port
echo "GET $url HTTP/1.0\r\n" |
mconnect -p ${port:-8080} $host
else
parse_url $url | read method host path port
echo "GET $path HTTP/1.0\r\n" |
mconnect -p ${port:-80} $host
fi
}
#
# Decide whether to bringover to the codemgr workspace
#
if [ "$n_FLAG" = "n" ]; then
if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
"quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
exit 1
fi
run_hook PRE_BRINGOVER
echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
tee -a $mail_msg_file >> $LOGFILE
if [ -f $TMPDIR/bringover_failed ]; then
rm -f $TMPDIR/bringover_failed
build_ok=n
echo "trouble with bringover, quitting at `date`." |
tee -a $mail_msg_file >> $LOGFILE
exit 1
fi
#
# It's possible that we used the bringover above to create
# $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
# but should now be the same as $BRINGOVER_WS.
#
[[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
run_hook POST_BRINGOVER
#
# Possible transition from pre-split workspace to split
# workspace. See if the bringover changed anything.
#
CLOSED_IS_PRESENT="$orig_closed_is_present"
check_closed_tree
else
echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
fi
echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
# System
whence uname | tee -a $build_environ_file >> $LOGFILE
uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
echo | tee -a $build_environ_file >> $LOGFILE
# nightly
echo "$0 $@" | tee -a $build_environ_file >> $LOGFILE
if [[ $nightly_path = "/opt/onbld/bin/nightly" ]] &&
pkginfo SUNWonbld > /dev/null 2>&1 ; then
pkginfo -l SUNWonbld | egrep "PKGINST:|VERSION:|PSTAMP:"
else
echo "$nightly_ls"
fi | tee -a $build_environ_file >> $LOGFILE
echo | tee -a $build_environ_file >> $LOGFILE
# make
whence $MAKE | tee -a $build_environ_file >> $LOGFILE
$MAKE -v | tee -a $build_environ_file >> $LOGFILE
echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
tee -a $build_environ_file >> $LOGFILE
#
# Report the compiler versions.
#
if [[ ! -f $SRC/Makefile ]]; then
build_ok=n
echo "\nUnable to find \"Makefile\" in $SRC." | \
tee -a $build_environ_file >> $LOGFILE
exit 1
fi
( cd $SRC
for target in cc-version cc64-version java-version; do
echo
#
# Put statefile somewhere we know we can write to rather than trip
# over a read-only $srcroot.
#
rm -f $TMPDIR/make-state
export SRC
if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
continue
fi
touch $TMPDIR/nocompiler
done
echo
) | tee -a $build_environ_file >> $LOGFILE
if [ -f $TMPDIR/nocompiler ]; then
rm -f $TMPDIR/nocompiler
build_ok=n
echo "Aborting due to missing compiler." |
tee -a $build_environ_file >> $LOGFILE
exit 1
fi
# as
whence as | tee -a $build_environ_file >> $LOGFILE
as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
echo | tee -a $build_environ_file >> $LOGFILE
# Check that we're running a capable link-editor
whence ld | tee -a $build_environ_file >> $LOGFILE
LDVER=`ld -V 2>&1`
echo $LDVER | tee -a $build_environ_file >> $LOGFILE
LDVER=`echo $LDVER | sed -e "s/.*-1\.//" -e "s/:.*//"`
if [ `expr $LDVER \< 422` -eq 1 ]; then
echo "The link-editor needs to be at version 422 or higher to build" | \
tee -a $build_environ_file >> $LOGFILE
echo "the latest stuff. Hope your build works." | \
tee -a $build_environ_file >> $LOGFILE
fi
#
# Build and use the workspace's tools if requested
#
if [[ "$t_FLAG" = "y" || "$O_FLAG" = y ]]; then
set_non_debug_build_flags
build_tools ${TOOLS_PROTO}
if [[ $? = 0 ]]; then
tools_build_ok=n
fi
if [[ $tools_build_ok = y ]]; then
echo "\n==== Creating protolist tools file at `date` ====" \
>> $LOGFILE
protolist $TOOLS_PROTO > $ATLOG/proto_list_tools_${MACH}
echo "==== protolist tools file created at `date` ====\n" \
>> $LOGFILE
if [ "$N_FLAG" != "y" ]; then
echo "\n==== Impact on tools packages ====\n" \
>> $mail_msg_file
# Use the current tools exception list.
exc=etc/exception_list_$MACH
if [ -f $SRC/tools/$exc ]; then
TOOLS_ELIST="-e $SRC/tools/$exc"
fi
# Compare the build's proto list with current package
# definitions to audit the quality of package
# definitions and makefile install targets.
$PROTOCMPTERSE \
"Files missing from the proto area:" \
"Files missing from packages:" \
"Inconsistencies between pkgdefs and proto area:" \
${TOOLS_ELIST} \
-d $SRC/tools \
$ATLOG/proto_list_tools_${MACH} \
>> $mail_msg_file
fi
fi
if [[ $tools_build_ok = y && "$t_FLAG" = y ]]; then
use_tools $TOOLS_PROTO
export ONBLD_TOOLS=${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}
fi
fi
#
# copy ihv proto area in addition to the build itself
#
if [ "$X_FLAG" = "y" ]; then
copy_ihv_proto
fi
if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then
echo "\n==== NOT Building base OS-Net source ====\n" | \
tee -a $LOGFILE >> $mail_msg_file
else
# timestamp the start of the normal build; the findunref tool uses it.
touch $SRC/.build.tstamp
normal_build
fi
#
# Generate the THIRDPARTYLICENSE files if needed. This is done before
# findunref to help identify license files that need to be added to
# the list.
#
if [ "$O_FLAG" = y -a "$build_ok" = y ]; then
echo "\n==== Generating THIRDPARTYLICENSE files ====\n" | \
tee -a $mail_msg_file >> $LOGFILE
mktpl usr/src/tools/opensolaris/license-list >>$LOGFILE 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create THIRDPARTYLICENSE files" |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
#
# If OpenSolaris deliverables were requested, do the open-only build
# now, so that it happens at roughly the same point as the source
# product builds. This lets us take advantage of checks that come
# later (e.g., the core file check).
#
if [ "$O_FLAG" = y -a "$build_ok" = y ]; then
#
# Generate skeleton (minimal) closed binaries for open-only
# build. There's no need to distinguish debug from non-debug
# binaries, but it simplifies file management to have separate
# trees.
#
echo "\n==== Generating skeleton closed binaries for" \
"open-only build ====\n" | \
tee -a $LOGFILE >> $mail_msg_file
rm -rf $CODEMGR_WS/closed.skel
if [ "$D_FLAG" = y ]; then
mkclosed $MACH $ROOT $CODEMGR_WS/closed.skel/root_$MACH \
>>$LOGFILE 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create skeleton DEBUG closed binaries." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
if [ "$F_FLAG" = n ]; then
mkclosed $MACH $ROOT-nd $CODEMGR_WS/closed.skel/root_$MACH-nd \
>>$LOGFILE 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create skeleton non-DEBUG closed binaries." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
ORIG_CLOSED_IS_PRESENT=$CLOSED_IS_PRESENT
export CLOSED_IS_PRESENT=no
ORIG_ON_CLOSED_BINS="$ON_CLOSED_BINS"
export ON_CLOSED_BINS=$CODEMGR_WS/closed.skel
normal_build -O
ON_CLOSED_BINS=$ORIG_ON_CLOSED_BINS
CLOSED_IS_PRESENT=$ORIG_CLOSED_IS_PRESENT
fi
ORIG_SRC=$SRC
BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
save_binaries
fi
# EXPORT_SRC comes after CRYPT_SRC since a domestic build will need
# $SRC pointing to the export_source usr/src.
if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
set_up_source_build ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC
fi
if [ $build_ok = y ]; then
set_up_source_build ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC
fi
fi
if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
# drop the crypt files in place.
cd ${EXPORT_SRC}
echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \
>> ${LOGFILE}
zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \
cpio -idmucvB 2>/dev/null >> ${LOGFILE}
if [ "$?" = "0" ]; then
echo "\n==== DOMESTIC extraction succeeded ====\n" \
>> $mail_msg_file
else
echo "\n==== DOMESTIC extraction failed ====\n" \
>> $mail_msg_file
fi
fi
if [ "$SO_FLAG" = "y" -a $build_ok = y ]; then
#
# Copy the open sources into their own tree, set up the closed
# binaries, and set up the environment. The build looks for
# the closed binaries in a location that depends on whether
# it's a DEBUG build, so we might need to make two copies.
#
# If copy_source fails, it will have already generated an
# error message and set build_ok=n, so we don't need to worry
# about that here.
#
copy_source $CODEMGR_WS $OPEN_SRCDIR OPEN_SOURCE usr/src
fi
if [ "$SO_FLAG" = "y" -a $build_ok = y ]; then
SRC=$OPEN_SRCDIR/usr/src
# Try not to clobber any user-provided closed binaries.
export ON_CLOSED_BINS=$CODEMGR_WS/closed$$
echo "\n==== Copying skeleton closed binaries to" \
"$ON_CLOSED_BINS ====\n" | \
tee -a $mail_msg_file >> $LOGFILE
if [ "$D_FLAG" = y ]; then
mkclosed $MACH $ROOT $ON_CLOSED_BINS/root_$MACH >>$LOGFILE 2>&1
if (( $? != 0 )) ; then
build_ok=n
echo "Couldn't create DEBUG closed binaries." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
if [ "$F_FLAG" = n ]; then
root=$ROOT
[ "$MULTI_PROTO" = yes ] && root=$ROOT-nd
mkclosed $MACH $root $ON_CLOSED_BINS/root_$MACH-nd \
>>$LOGFILE 2>&1
if (( $? != 0 )) ; then
build_ok=n
echo "Couldn't create non-DEBUG closed binaries." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
export CLOSED_IS_PRESENT=no
fi
if is_source_build && [ $build_ok = y ] ; then
# remove proto area(s) here, since we don't clobber
rm -rf `allprotos`
if [ "$t_FLAG" = "y" ]; then
set_non_debug_build_flags
ORIG_TOOLS=$TOOLS
#
# SRC was set earlier to point to the source build
# source tree (e.g., $EXPORT_SRC).
#
TOOLS=${SRC}/tools
build_tools ${SRC}/tools/proto
TOOLS=$ORIG_TOOLS
fi
export EXPORT_RELEASE_BUILD ; EXPORT_RELEASE_BUILD=#
normal_build
fi
if [[ "$SO_FLAG" = "y" && "$build_ok" = "y" ]]; then
rm -rf $ON_CLOSED_BINS
fi
#
# There are several checks that need to look at the proto area, but
# they only need to look at one, and they don't care whether it's
# DEBUG or non-DEBUG.
#
if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
checkroot=$ROOT-nd
else
checkroot=$ROOT
fi
if [ "$build_ok" = "y" ]; then
echo "\n==== Creating protolist system file at `date` ====" \
>> $LOGFILE
protolist $checkroot > $ATLOG/proto_list_${MACH}
echo "==== protolist system file created at `date` ====\n" \
>> $LOGFILE
if [ "$N_FLAG" != "y" ]; then
echo "\n==== Impact on packages ====\n" >> $mail_msg_file
# If there is a reference proto list, compare the build's proto
# list with the reference to see changes in proto areas.
# Use the current exception list.
exc=etc/exception_list_$MACH
if [ -f $SRC/pkgdefs/$exc ]; then
ELIST="-e $SRC/pkgdefs/$exc"
fi
if [ "$X_FLAG" = "y" -a -f $IA32_IHV_WS/usr/src/pkgdefs/$exc ]; then
ELIST="$ELIST -e $IA32_IHV_WS/usr/src/pkgdefs/$exc"
fi
if [ -f "$REF_PROTO_LIST" ]; then
# For builds that copy the IHV proto area (-X), add the
# IHV proto list to the reference list if the reference
# was built without -X.
#
# For builds that don't copy the IHV proto area, add the
# IHV proto list to the build's proto list if the
# reference was built with -X.
#
# Use the presence of the first file entry of the cached
# IHV proto list in the reference list to determine
# whether it was build with -X or not.
IHV_REF_PROTO_LIST=$SRC/pkgdefs/etc/proto_list_ihv_$MACH
grepfor=$(nawk '$1 == "f" { print $2; exit }' \
$IHV_REF_PROTO_LIST 2> /dev/null)
if [ $? = 0 -a -n "$grepfor" ]; then
if [ "$X_FLAG" = "y" ]; then
grep -w "$grepfor" \
$REF_PROTO_LIST > /dev/null
if [ ! "$?" = "0" ]; then
REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST"
fi
else
grep -w "$grepfor" \
$REF_PROTO_LIST > /dev/null
if [ "$?" = "0" ]; then
IHV_PROTO_LIST="$IHV_REF_PROTO_LIST"
fi
fi
fi
$PROTOCMPTERSE \
"Files in yesterday's proto area, but not today's:" \
"Files in today's proto area, but not yesterday's:" \
"Files that changed between yesterday and today:" \
${ELIST} \
-d $REF_PROTO_LIST \
$REF_IHV_PROTO \
$ATLOG/proto_list_${MACH} \
$IHV_PROTO_LIST \
>> $mail_msg_file
fi
# Compare the build's proto list with current package
# definitions to audit the quality of package definitions
# and makefile install targets. Use the current exception list.
PKGDEFS_LIST=""
for d in $abssrcdirs; do
if [ -d $d/pkgdefs ]; then
PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs"
fi
done
if [ "$X_FLAG" = "y" -a -d $IA32_IHV_WS/usr/src/pkgdefs ]; then
PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs"
fi
$PROTOCMPTERSE \
"Files missing from the proto area:" \
"Files missing from packages:" \
"Inconsistencies between pkgdefs and proto area:" \
${ELIST} \
${PKGDEFS_LIST} \
$ATLOG/proto_list_${MACH} \
>> $mail_msg_file
fi
fi
if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
staffer cp $ATLOG/proto_list_${MACH} \
$PARENT_WS/usr/src/proto_list_${MACH}
fi
# Update parent proto area if necessary. This is done now
# so that the proto area has either DEBUG or non-DEBUG kernels.
# Note that this clears out the lock file, so we can dispense with
# the variable now.
if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
tee -a $LOGFILE >> $mail_msg_file
# The rm -rf command below produces predictable errors if
# nightly is invoked from the parent's $ROOT/opt/onbld/bin,
# and that directory is accessed via NFS. This is because
# deleted-but-still-open files don't actually disappear as
# expected, but rather turn into .nfsXXXX junk files, leaving
# the directory non-empty. Since this is a not-unusual usage
# pattern, and we still want to catch other errors here, we
# take the unusal step of moving aside 'nightly' from that
# directory (if we're using it).
mypath=${nightly_path##*/root_$MACH/}
if [ "$mypath" = $nightly_path ]; then
mypath=opt/onbld/bin/${nightly_path##*/}
fi
if [ $nightly_path -ef $PARENT_WS/proto/root_$MACH/$mypath ]; then
mv -f $nightly_path $PARENT_WS/proto/root_$MACH
fi
rm -rf $PARENT_WS/proto/root_$MACH/*
unset Ulockfile
mkdir -p $NIGHTLY_PARENT_ROOT
if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
cd $ROOT
( tar cf - . |
( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 |
tee -a $mail_msg_file >> $LOGFILE
fi
if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
mkdir -p $NIGHTLY_PARENT_ROOT-nd
cd $ROOT-nd
( tar cf - . |
( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
#
# do shared library interface verification
#
if [ "$A_FLAG" = "y" -a "$build_ok" = "y" ]; then
echo "\n==== Check versioning and ABI information ====\n" | \
tee -a $LOGFILE >> $mail_msg_file
rm -rf $SRC/interfaces.ref
if [ -d $SRC/interfaces.out ]; then
mv $SRC/interfaces.out $SRC/interfaces.ref
fi
rm -rf $SRC/interfaces.out
mkdir -p $SRC/interfaces.out
intf_check -V -m -o -b $SRC/tools/abi/etc \
-d $SRC/interfaces.out $checkroot 2>&1 | sort \
> $SRC/interfaces.out/log
# report any ERROR found in log file
fgrep 'ERROR' $SRC/interfaces.out/log | sed 's/^ERROR: //' | \
tee -a $LOGFILE >> $mail_msg_file
if [ ! -d $SRC/interfaces.ref ] ; then
mkdir -p $SRC/interfaces.ref
if [ -d $SRC/interfaces.out ]; then
cp -r $SRC/interfaces.out/* $SRC/interfaces.ref
fi
fi
echo "\n==== Diff versioning warnings (since last build) ====\n" | \
tee -a $LOGFILE >> $mail_msg_file
out_vers=`grep ^VERSION $SRC/interfaces.out/log`;
ref_vers=`grep ^VERSION $SRC/interfaces.ref/log`;
# Report any differences in WARNING messages between last
# and current build.
if [ "$out_vers" = "$ref_vers" ]; then
diff $SRC/interfaces.ref/log $SRC/interfaces.out/log | \
fgrep 'WARNING' | sed 's/WARNING: //' | \
tee -a $LOGFILE >> $mail_msg_file
fi
fi
if [ "$r_FLAG" = "y" -a "$build_ok" = "y" ]; then
echo "\n==== Check ELF runtime attributes ====\n" | \
tee -a $LOGFILE >> $mail_msg_file
LDDWRONG="wrong class"
CRLERROR="^crle:"
CRLECONF="^crle: configuration file:"
RUNTIMEREF=$SRC/runtime-${MACH}.ref
RUNTIMEOUT=$SRC/runtime-${MACH}.out
rm -f $RUNTIMEREF
if [ -f $RUNTIMEOUT ]; then
egrep -v "$LDDWRONG|$CRLERROR|$CRLECONF" \
$RUNTIMEOUT > $RUNTIMEREF
fi
# If we're doing a debug build the proto area will be left with
# debuggable objects, thus don't assert -s.
if [ "$D_FLAG" = "y" ]; then
rtime_sflag=""
else
rtime_sflag="-s"
fi
check_rtime -d $checkroot -i -m -v -o $rtime_sflag $checkroot 2>&1 | \
egrep -v ": unreferenced object=$checkroot/.*/lib(w|intl|thread|pthread).so" | \
egrep -v ": unused object=$checkroot/.*/lib(w|intl|thread|pthread).so" | \
sort > $RUNTIMEOUT
# Determine any processing errors that will affect the final output
# and display these first.
grep -l "$LDDWRONG" $RUNTIMEOUT > /dev/null
if (( $? == 0 )) ; then
echo "WARNING: wrong class message detected. ldd(1) was unable" | \
tee -a $LOGFILE >> $mail_msg_file
echo "to execute an object, thus it could not be checked fully." | \
tee -a $LOGFILE >> $mail_msg_file
echo "Perhaps a 64-bit object was encountered on a 32-bit system," | \
tee -a $LOGFILE >> $mail_msg_file
echo "or an i386 object was encountered on a sparc system?\n" | \
tee -a $LOGFILE >> $mail_msg_file
fi
grep -l "$CRLECONF" $RUNTIMEOUT > /dev/null
if (( $? == 0 )) ; then
echo "WARNING: creation of an alternative dependency cache failed." | \
tee -a $LOGFILE >> $mail_msg_file
echo "Dependencies will bind to the base system libraries.\n" | \
tee -a $LOGFILE >> $mail_msg_file
grep "$CRLECONF" $RUNTIMEOUT | \
tee -a $LOGFILE >> $mail_msg_file
grep "$CRLERROR" $RUNTIMEOUT | grep -v "$CRLECONF" | \
tee -a $LOGFILE >> $mail_msg_file
echo "\n" | tee -a $LOGFILE >> $mail_msg_file
fi
egrep '<dependency no longer necessary>' $RUNTIMEOUT | \
tee -a $LOGFILE >> $mail_msg_file
# NEEDED= and RPATH= are generated by the -i option
# VERDEF= and VERSION= are generated by the -v option.
# These lines are informational; report anything else that we
# haven't already.
egrep -v "NEEDED=|RPATH=|VERDEF=|VERSION=" $RUNTIMEOUT \
| egrep -v "$LDDWRONG|$CRLERROR|$CRLECONF" \
| tee -a $LOGFILE >> $mail_msg_file
# probably should compare against a 'known ok runpaths' list
if [ ! -f $RUNTIMEREF ]; then
egrep -v "$LDDWRONG|$CRLERROR|$CRLECONF" \
$RUNTIMEOUT > $RUNTIMEREF
fi
echo "\n==== Diff ELF runtime attributes (since last build) ====\n" \
>> $mail_msg_file
egrep -v "$LDDWRONG|$CRLERROR|$CRLECONF" $RUNTIMEOUT | \
diff $RUNTIMEREF - >> $mail_msg_file
fi
# DEBUG lint of kernel begins
if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
if [ "$LINTDIRS" = "" ]; then
# LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y"
LINTDIRS="$SRC y"
fi
set $LINTDIRS
while [ $# -gt 0 ]; do
dolint $1 $2; shift; shift
done
else
echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
fi
# "make check" begins
if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
# remove old check.out
rm -f $SRC/check.out
rm -f $SRC/check-${MACH}.out
cd $SRC
$MAKE -ek check 2>&1 | tee -a $SRC/check-${MACH}.out >> $LOGFILE
echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
grep ":" $SRC/check-${MACH}.out |
egrep -v "Ignoring unknown host" | \
sort | uniq >> $mail_msg_file
else
echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
fi
echo "\n==== Find core files ====\n" | \
tee -a $LOGFILE >> $mail_msg_file
find $abssrcdirs -name core -a -type f -exec file {} \; | \
tee -a $LOGFILE >> $mail_msg_file
if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
echo "\n==== Diff unreferenced files (since last build) ====\n" \
| tee -a $LOGFILE >>$mail_msg_file
rm -f $SRC/unref-${MACH}.ref
if [ -f $SRC/unref-${MACH}.out ]; then
mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
fi
#
# For any SCM other than teamware, we want to disable the
# managed-by-SCCS test in findunref
#
findunref_all=""
if [ "$SCM_TYPE" != teamware ]; then
findunref_all="-a"
fi
findunref $findunref_all -t $SRC/.build.tstamp $SRC/.. \
${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
sort | sed -e s=^./src/=./= -e s=^./closed/=../closed/= \
> $SRC/unref-${MACH}.out
if [ ! -f $SRC/unref-${MACH}.ref ]; then
cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
fi
diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
fi
#
# Generate the OpenSolaris deliverables if requested. Some of these
# steps need to come after findunref and are commented below.
#
if [ "$O_FLAG" = y -a "$build_ok" = y ]; then
echo "\n==== Generating OpenSolaris tarballs ====\n" | \
tee -a $mail_msg_file >> $LOGFILE
cd $CODEMGR_WS
#
# This step grovels through the pkgdefs proto* files, so it
# must come after findunref.
#
echo "Generating closed binaries tarball(s)..." >> $LOGFILE
closed_basename=on-closed-bins
if [ "$D_FLAG" = y ]; then
bindrop "$ROOT" "$ROOT-open" "$closed_basename" \
>>"$LOGFILE" 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create DEBUG closed binaries." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
if [ "$F_FLAG" = n ]; then
bindrop -n "$ROOT-nd" "$ROOT-open-nd" "$closed_basename-nd" \
>>"$LOGFILE" 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create non-DEBUG closed binaries." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
echo "Generating SUNWonbld tarball..." >> $LOGFILE
PKGARCHIVE=$PKGARCHIVE_ORIG
onblddrop >> $LOGFILE 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create SUNWonbld tarball." |
tee -a $mail_msg_file >> $LOGFILE
fi
echo "Generating README.opensolaris..." >> $LOGFILE
cat $SRC/tools/opensolaris/README.opensolaris.tmpl | \
mkreadme_osol $CODEMGR_WS/README.opensolaris >> $LOGFILE 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create README.opensolaris." |
tee -a $mail_msg_file >> $LOGFILE
fi
# This step walks the source tree, so it must come after
# findunref. It depends on README.opensolaris.
echo "Generating source tarball..." >> $LOGFILE
sdrop >>$LOGFILE 2>&1
if (( $? != 0 )) ; then
echo "Couldn't create source tarball." |
tee -a "$mail_msg_file" >> "$LOGFILE"
fi
# This step depends on the closed binaries tarballs.
echo "Generating BFU tarball(s)..." >> $LOGFILE
if [ "$D_FLAG" = y ]; then
makebfu_filt bfudrop "$ROOT-open" \
"$closed_basename.$MACH.tar.bz2" nightly-osol
if (( $? != 0 )) ; then
echo "Couldn't create DEBUG archives tarball." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
if [ "$F_FLAG" = n ]; then
makebfu_filt bfudrop -n "$ROOT-open-nd" \
"$closed_basename-nd.$MACH.tar.bz2" nightly-osol-nd
if (( $? != 0 )) ; then
echo "Couldn't create non-DEBUG archives tarball." |
tee -a $mail_msg_file >> $LOGFILE
fi
fi
fi
# Verify that the usual lists of files, such as exception lists,
# contain only valid references to files. If the build has failed,
# then don't check the proto area.
CHECK_PATHS=${CHECK_PATHS:-y}
if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
>>$mail_msg_file
arg=-b
[ "$build_ok" = y ] && arg=
checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file
fi
if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
echo "\n==== Impact on file permissions ====\n" \
>> $mail_msg_file
#
# Get pkginfo files from usr/src/pkgdefs
#
pmodes -qvdP \
`for d in $abssrcdirs; do
if [ -d "$d/pkgdefs" ]
then
find $d/pkgdefs -name pkginfo.tmpl -print -o -name .del\* -prune
fi
done | sed -e 's:/pkginfo.tmpl$::' | sort -u ` >> $mail_msg_file
fi
if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
do_wsdiff DEBUG $ROOT.prev $ROOT
fi
if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
fi
fi
END_DATE=`date`
echo "==== Nightly $maketype build completed: $END_DATE ====" | \
tee -a $LOGFILE >> $build_time_file
typeset -Z2 minutes
typeset -Z2 seconds
elapsed_time=$SECONDS
((hours = elapsed_time / 3600 ))
((minutes = elapsed_time / 60 % 60))
((seconds = elapsed_time % 60))
echo "\n==== Total build time ====" | \
tee -a $LOGFILE >> $build_time_file
echo "\nreal ${hours}:${minutes}:${seconds}" | \
tee -a $LOGFILE >> $build_time_file
if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
#
# Produce a master list of unreferenced files -- ideally, we'd
# generate the master just once after all of the nightlies
# have finished, but there's no simple way to know when that
# will be. Instead, we assume that we're the last nightly to
# finish and merge all of the unref-${MACH}.out files in
# $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
# finish, then this file will be the authoritative master
# list. Otherwise, another ${MACH}'s nightly will eventually
# overwrite ours with its own master, but in the meantime our
# temporary "master" will be no worse than any older master
# which was already on the parent.
#
set -- $PARENT_WS/usr/src/unref-*.out
cp "$1" ${TMPDIR}/unref.merge
shift
for unreffile; do
comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
done
staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
fi
#
# All done save for the sweeping up.
# (whichever exit we hit here will trigger the "cleanup" trap which
# optionally sends mail on completion).
#
if [ "$build_ok" = "y" ]; then
exit 0
fi
exit 1