nightly.sh revision 91d74a54bc02474ab29fbef3946724a428f27941
#
# 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 2008, 2010, Richard Lowe
# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
#
# 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
#
#
# OPTHOME 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
function fatal_error
{
print -u2 "nightly: $*"
exit 1
}
#
# 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
#
function normal_build {
typeset orig_p_FLAG="$p_FLAG"
typeset crypto_signer="$CODESIGN_USER"
suffix=""
# non-DEBUG build begins
build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
else
fi
# non-DEBUG build ends
# DEBUG build begins
build "DEBUG" "$suffix" "" "$MULTI_PROTO"
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
#
function run_hook {
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
}
# Return library search directive as function of given root.
function myldlibs {
}
# Return header search directive as function of given root.
function myheaders {
}
#
# Function to do the build, including package generation.
# usage: build LABEL SUFFIX ND MULTIPROTO
# - LABEL is used to tag build output.
# - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
# open-only vs full tree).
# - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
# - If MULTIPROTO is "yes", it means to name the proto area according to
# SUFFIX. Otherwise ("no"), (re)use the standard proto area.
#
function build {
LABEL=$1
SUFFIX=$2
ND=$3
MULTIPROTO=$4
[ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
export ENVLDLIBS1=`myldlibs $ROOT`
export ENVCPPFLAGS1=`myheaders $ROOT`
#
# Build OS-Networking source
#
>> $LOGFILE
cd $SRC
if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then
build_ok=n
fi
if [ "$?" = "0" ]; then
build_ok=n
fi
| tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file
if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then
build_ok=n
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
#
# Building Packages
#
>> $LOGFILE
fi
else
#
# Handle it gracefully if -p was set but there so
# no pkg directory.
#
>> $LOGFILE
fi
else
fi
}
# Usage: dolint /dir y|n
function dolint {
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 \
fi
tail -3 $LINTOUT >>$mail_msg_file
fi
fi
# should be none, though there are a few that were filtered out
# above
| sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file
if [[ -s $TMPDIR/lint_warns ]]; then
fi
fi
}
#
# Build and install the onbld tools.
#
# usage: build_tools DESTROOT
#
# returns non-zero status if the build was successful.
#
function build_tools {
DESTROOT=$1
>> $LOGFILE
cd ${TOOLS}
egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file
if [[ -s $TMPDIR/tools_errors ]]; then
return 1
fi
return 0
}
#
# Set up to use locally installed tools.
#
# usage: use_tools TOOLSROOT
#
function use_tools {
TOOLSROOT=$1
#
# If we're not building ON workspace, then the TOOLSROOT
# settings here are clearly ignored by the workspace
# makefiles, prepending nonexistent directories to PATH is
# harmless, and we clearly do not wish to override
# ONBLD_TOOLS.
#
# If we're building an ON workspace, then the prepended PATH
# elements should supercede the preexisting ONBLD_TOOLS paths,
# and we want to override ONBLD_TOOLS to catch the tools that
# don't have specific path env vars here.
#
# So the only conditional behavior is overriding ONBLD_TOOLS,
# and we check for "an ON workspace" by looking for
#
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
export ONBLD_TOOLS
fi
}
function staffer {
"$@"
else
arg="\"$1\""
shift
for i
do
done
fi
}
#
# Verify that the closed bins are present
#
function check_closed_bins {
echo "ON_CLOSED_BINS must point to the closed binaries tree."
build_ok=n
exit 1
fi
}
#
# wrapper over wsdiff.
# usage: do_wsdiff LABEL OLDPROTO NEWPROTO
#
function do_wsdiff {
label=$1
oldproto=$2
newproto=$3
wsdiff="wsdiff"
$wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
tee -a $LOGFILE >> $mail_msg_file
tee -a $LOGFILE >> $mail_msg_file
}
#
# together.
#
function set_non_debug_build_flags {
export RELEASE_BUILD ; RELEASE_BUILD=
unset EXTRA_OPTIONS
unset EXTRA_CFLAGS
}
function set_debug_build_flags {
unset RELEASE_BUILD
unset EXTRA_OPTIONS
unset EXTRA_CFLAGS
}
if [ "$OPTHOME" = "" ]; then
export OPTHOME
fi
USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
Where:
-i Fast incremental options (no clobber, lint, check)
-n Do not do a bringover
+t Use the build tools in $ONBLD_TOOLS/bin
-V VERS set the build version string to VERS
<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
-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
-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
+t Use the build tools in $ONBLD_TOOLS/bin
-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
'
#
# 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
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
p_FLAG=n
r_FLAG=n
t_FLAG=y
U_FLAG=n
u_FLAG=n
V_FLAG=n
w_FLAG=n
W_FLAG=n
#
build_ok=y
#
# examine arguments
#
OPTIND=1
do
i ) i_FLAG=y; i_CMD_LINE_FLAG=y
;;
n ) n_FLAG=y
;;
+t ) t_FLAG=n
;;
V ) V_FLAG=y
;;
W ) W_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
#
# To get ONBLD_TOOLS from the environment, it must come from the env file.
# If it comes interactively, it is generally TOOLS_PROTO, which will be
# clobbered before the compiler version checks, which will therefore fail.
#
unset ONBLD_TOOLS
#
# 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
# Check if we have sufficient data to continue...
if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
# Check if the gate data are valid if we don't do a "bringover" below
[[ -d "${CODEMGR_WS}" ]] || \
fatal_error "Error: ${CODEMGR_WS} is not a directory."
fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
fi
#
# 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 BRINGOVER_FILES was not specified, default to usr
#
if [ "$BRINGOVER_FILES" = "" ]; then
BRINGOVER_FILES="usr"
fi
#
# 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
;;
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 ) u_FLAG=y
;;
I ) 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
;;
p ) p_FLAG=y
;;
R ) m_FLAG=y
p_FLAG=y
;;
r ) r_FLAG=y
;;
+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
if [ -n "${PARENT_TOOLS_ROOT}" ]; then
fi
U_FLAG=y
;;
u ) u_FLAG=y
;;
w ) w_FLAG=y
;;
W ) W_FLAG=y
;;
\? ) echo "$USAGE"
exit 1
;;
esac
done
# 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="."
PROTOCMPTERSE="protocmp.terse -gu"
POUND_SIGN="#"
# have we set RELEASE_DATE in our env file?
if [ -z "$RELEASE_DATE" ]; then
fi
BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
# we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
# by avoiding repeated shell invocations to evaluate Makefile.master
# definitions.
maketype="distributed"
if [[ -z "$MAKE" ]]; then
elif [[ ! -x "$MAKE" ]]; then
echo "\$MAKE is set to garbage in the environment"
exit 1
fi
# 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, if you really want to use this version
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
then
if [[ -f $HOME/.make.machines ]]
then
# Note: there is a hard tab and space character in the []s
# below.
maxjobs=${jobs##*=}
fi
then
# default
maxjobs=4
fi
export DMAKE_MAX_JOBS=$maxjobs
fi
export DMAKE_MODE
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
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
#
# Tools should only be built non-DEBUG. Keep track of the tools proto
# area path relative to $TOOLS, because the latter changes in an
# export build.
#
# overridden on the $MAKE command line in build_tools().
#
# create directories that are automatically removed if the nightly script
# fails to start correctly
function newdir {
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.
#
# Juggle the logs and optionally send mail on completion.
#
function logshuffle {
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
fi
export NIGHTLY_STATUS
#
# mailx(1) sets From: based on the -r flag
# if it is given.
#
if [[ -n "${MAILFROM}" ]]; then
mailx_r="-r ${MAILFROM}"
fi
${MAILTO}
fi
fi
}
#
# Remove the locks and temporary files on any exit
#
function cleanup {
set -- $newdirlist
while [ $# -gt 0 ]; do
shift; shift
done
}
function cleanup_signal {
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).
#
function create_lock {
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.
#
function allprotos {
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 [ "$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
#
# 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
if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then
echo "WARNING: the -f flag requires -l, and -p;" \
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 type of the parent workspace, this can't just be which_scm
# as that does not know how to identify various network repositories.
#
function parent_wstype {
# Probe BRINGOVER_WS to determine its type
if [[ $BRINGOVER_WS == ssh://* ]]; then
scm_type="mercurial"
elif [[ $BRINGOVER_WS == http://* ]] && \
scm_type="mercurial"
else
scm_type="none"
fi
fi
# fold both unsupported and unrecognized results into "none"
;;
;;
esac
echo $scm_type
}
# Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
function child_wstype {
# Probe CODEMGR_WS to determine its type
if [[ -d $CODEMGR_WS ]]; then
$WHICH_SCM | read scm_type junk || exit 1
fi
;;
;;
esac
echo $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" | \
if [[ -s $TMPDIR/clobber_errs ]]; then
fi
if [[ "$t_FLAG" = "y" ]]; then
cd ${TOOLS}
echo "\n==== Make tools clobber ERRORS ====\n" \
if (( $? == 0 )); then
fi
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
# If the repository doesn't exist yet, then we want to populate it.
if [[ ! -d $CODEMGR_WS/.hg ]]; then
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"
#
# 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"
}
echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
}
#
# Decide whether to bringover to the codemgr workspace
#
if [ "$n_FLAG" = "n" ]; then
echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
exit 1
fi
echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
if [ -f $TMPDIR/bringover_failed ]; then
build_ok=n
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.
#
else
echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
fi
# Safeguards
[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
# System
# make
echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
#
# Report the compiler versions.
#
build_ok=n
echo "\nUnable to find \"Makefile\" in $SRC." | \
exit 1
fi
( cd $SRC
echo
#
# Put statefile somewhere we know we can write to rather than trip
# over a read-only $srcroot.
#
export SRC
continue
fi
done
echo
if [ -f $TMPDIR/nocompiler ]; then
build_ok=n
echo "Aborting due to missing compiler." |
exit 1
fi
# as
# Check that we're running a capable link-editor
echo "The link-editor needs to be at version 422 or higher to build" | \
echo "the latest stuff. Hope your build works." | \
fi
#
# Build and use the workspace's tools if requested
#
if [[ "$t_FLAG" = "y" ]]; then
if (( $? != 0 )); then
build_ok=n
else
fi
fi
# timestamp the start of the normal build; the findunref tool uses it.
#
# 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.
#
else
fi
if [ "$build_ok" = "y" ]; then
>> $LOGFILE
>> $LOGFILE
if [ "$N_FLAG" != "y" ]; then
E1=
f1=
if [ -f "$f" ]; then
fi
done
E2=
f2=
if [ -d "$SRC/pkg" ]; then
fi
if [ -f "$f" ]; then
fi
done
fi
echo "\n==== Validating manifests against proto area ====\n" \
if [[ -s $TMPDIR/protocmp_noise ]]; then
fi
fi
echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
if [ -n "$E2" ]; then
else
fi
"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 \
fi
fi
"$build_extras_ok" == "y" ]]; then
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.
echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
unset Ulockfile
fi
fi
if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
( cd $TOOLS_PROTO; tar cf - . |
fi
fi
fi
#
# ELF verification: ABI (-A) and runtime (-r) checks
#
# Directory ELF-data.$MACH holds the files produced by these tests.
# If there is a previous ELF-data backup directory, remove it. Then,
# rotate current ELF-data directory into its place and create a new
# empty directory
if [[ -d $elf_ddir ]]; then
fi
# Call find_elf to produce a list of the ELF objects in the proto area.
# This list is passed to check_rtime and interface_check, preventing
# them from separately calling find_elf to do the same work twice.
if [[ $A_FLAG = y ]]; then
echo "\n==== Check versioning and ABI information ====\n" | \
# Produce interface description for the proto. Report errors.
-i interface -E interface.err
if [[ -s $elf_ddir/interface.err ]]; then
fi
# If ELF_DATA_BASELINE_DIR is defined, compare the new interface
# description file to that from the baseline gate. Issue a
# warning if the baseline is not present, and keep going.
if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
base_ifile="$ELF_DATA_BASELINE_DIR/interface"
echo "\n==== Compare versioning and ABI information" \
"to baseline ====\n" | \
echo "Baseline: $base_ifile\n" >> $LOGFILE
if [[ -f $base_ifile ]]; then
interface_cmp -d -o $base_ifile \
if [[ -s $elf_ddir/interface.cmp ]]; then
fi
else
echo "baseline not available. comparison" \
"skipped" | \
fi
fi
fi
if [[ $r_FLAG = y ]]; then
echo "\n==== Check ELF runtime attributes ====\n" | \
# 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
if (( $? != 0 )); then
fi
# check_rtime -I output needs to be sorted in order to
# compare it to that from previous builds.
# Report errors
if [[ -s $elf_ddir/runtime.err ]]; then
fi
# If there is an ELF-data directory from a previous build,
# then diff the attr files. These files contain information
# about dependencies, versioning, and runpaths. There is some
# overlap with the ABI checking done above, but this also
# flushes out non-ABI interface differences along with the
# other information.
echo "\n==== Diff ELF runtime attributes" \
"(since last build) ====\n" | \
fi
fi
# If -u set, copy contents of ELF-data.$MACH to the parent workspace.
if [[ "$u_FLAG" = "y" ]]; then
# If parent lacks the ELF-data.$MACH directory, create it
if [[ ! -d $p_elf_ddir ]]; then
fi
# These files are used asynchronously by other builds for ABI
# verification, as above for the -A option. As such, we require
# the file replacement to be atomic. Copy the data to a temp
# file in the same filesystem and then rename into place.
(
cd $elf_ddir
${p_elf_ddir}/${elf_dfile}.new
staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
${p_elf_ddir}/${elf_dfile}
done
)
fi
fi
# DEBUG lint of kernel begins
if [ "$LINTDIRS" = "" ]; then
fi
set $LINTDIRS
while [ $# -gt 0 ]; do
done
else
fi
# "make check" begins
# remove old check.out
cd $SRC
>> $LOGFILE
echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
egrep -v "Ignoring unknown host" | \
if [[ -s $TMPDIR/check_errors ]]; then
fi
else
fi
echo "\n==== Find core files ====\n" | \
echo "\n==== Diff unreferenced files (since last build) ====\n" \
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
arg=-b
if [[ -s $SRC/checkpaths.out ]]; then
fi
fi
echo "\n==== Impact on file permissions ====\n" \
for d in $abssrcdirs; do
fi
done
if [ -n "$abspkg" ]; then
( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
done
fi
fi
fi
fi
fi
echo "\n==== Total build time ====" | \
echo "\nreal ${hours}:${minutes}:${seconds}" | \
#
# 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
# 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.
#
shift
for unreffile; do
done
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
fi
exit 1