5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 # Copyright 2008, 2010, Richard Lowe
26 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
27 # Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
28 # Copyright (c) 2017 by Delphix. All rights reserved.
29 # Copyright 2018 Joyent, Inc.
30 # Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
32 # Based on the nightly script from the integration folks,
33 # Mostly modified and owned by mike_s.
34 # Changes also by kjc, dmk.
36 # BRINGOVER_WS may be specified in the env file.
37 # The default is the old behavior of CLONE_WS
39 # -i on the command line, means fast options, so when it's on the
40 # command line (only), lint and check builds are skipped no matter what
41 # the setting of their individual flags are in NIGHTLY_OPTIONS.
43 # LINTDIRS can be set in the env file, format is a list of:
45 # /dirname-to-run-lint-on flag
47 # Where flag is: y - enable lint noise diff output
48 # n - disable lint noise diff output
50 # For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
52 # OPTHOME may be set in the environment to override /opt
56 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
57 # under certain circumstances, which can really screw things up; unset it.
61 # Get the absolute path of the nightly script that the user invoked. This
62 # may be a relative path, and we need to do this before changing directory.
63 nightly_path
=`whence $0`
66 # Keep track of where we found nightly so we can invoke the matching
67 # which_scm script. If that doesn't work, don't go guessing, just rely
68 # on the $PATH settings, which will generally give us either /opt/onbld
69 # or the user's workspace.
71 WHICH_SCM
=$
(dirname $nightly_path)/which_scm
72 if [[ ! -x $WHICH_SCM ]]; then
78 print
-u2 "nightly: $*"
83 # Function to do a DEBUG and non-DEBUG build. Needed because we might
84 # need to do another for the source build, and since we only deliver DEBUG or
89 function normal_build
{
91 typeset orig_p_FLAG
="$p_FLAG"
92 typeset crypto_signer
="$CODESIGN_USER"
96 # non-DEBUG build begins
98 if [ "$F_FLAG" = "n" ]; then
99 set_non_debug_build_flags
100 CODESIGN_USER
="$crypto_signer" \
101 build
"non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
103 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
106 # non-DEBUG build ends
110 if [ "$D_FLAG" = "y" ]; then
111 set_debug_build_flags
112 CODESIGN_USER
="$crypto_signer" \
113 build
"DEBUG" "$suffix" "" "$MULTI_PROTO"
115 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
120 p_FLAG
="$orig_p_FLAG"
124 # usage: run_hook HOOKNAME ARGS...
126 # If variable "$HOOKNAME" is defined, insert a section header into
127 # our logs and then run the command with ARGS
131 eval HOOKCMD
=\$
$HOOKNAME
134 if [ -n "$HOOKCMD" ]; then
136 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
137 ( $HOOKCMD "$@" 2>&1 )
138 if [ "$?" -ne 0 ]; then
139 # Let exit status propagate up
142 ) |
tee -a $mail_msg_file >> $LOGFILE
144 if [ -f $TMPDIR/abort
]; then
146 echo "\nAborting at request of $HOOKNAME" |
147 tee -a $mail_msg_file >> $LOGFILE
153 # Return library search directive as function of given root.
155 echo "-L$1/lib -L$1/usr/lib"
158 # Return header search directive as function of given root.
160 echo "-I$1/usr/include"
164 # Function to do the build, including package generation.
165 # usage: build LABEL SUFFIX ND MULTIPROTO
166 # - LABEL is used to tag build output.
167 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
168 # open-only vs full tree).
169 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
170 # - If MULTIPROTO is "yes", it means to name the proto area according to
171 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
178 INSTALLOG
=install${SUFFIX}-${MACH}
179 NOISE
=noise
${SUFFIX}-${MACH}
180 PKGARCHIVE
=${PKGARCHIVE_ORIG}${SUFFIX}
183 [ $MULTIPROTO = no
] ||
export ROOT
=$ROOT$SUFFIX
185 export ENVLDLIBS1
=`myldlibs $ROOT`
186 export ENVCPPFLAGS1
=`myheaders $ROOT`
190 # Build OS-Networking source
192 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
195 rm -f $SRC/${INSTALLOG}.out
197 /bin
/time $MAKE -e install 2>&1 | \
198 tee -a $SRC/${INSTALLOG}.out
>> $LOGFILE
200 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
201 egrep ":" $SRC/${INSTALLOG}.out |
202 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
203 egrep -v "Ignoring unknown host" | \
204 egrep -v "cc .* -o error " | \
205 egrep -v "warning" |
tee $TMPDIR/build_errs
${SUFFIX} \
207 sed -n "/^Undefined[ ]*first referenced$/,/^ld: fatal:/p" \
208 < $SRC/${INSTALLOG}.out
>> $mail_msg_file
209 if [[ -s $TMPDIR/build_errs
${SUFFIX} ]]; then
213 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
215 if [ "$?" = "0" ]; then
220 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
221 egrep -i warning
: $SRC/${INSTALLOG}.out \
223 |
egrep -v "symbol (\`|')timezone' has differing types:" \
224 |
egrep -v "parameter <PSTAMP> set to" \
225 |
egrep -v "Ignoring unknown host" \
226 |
egrep -v "redefining segment flags attribute for" \
227 |
tee $TMPDIR/build_warnings
${SUFFIX} >> $mail_msg_file
228 if [[ -s $TMPDIR/build_warnings
${SUFFIX} ]]; then
233 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
236 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
237 tail -3 $SRC/${INSTALLOG}.out
>>$mail_msg_file
239 if [ "$i_FLAG" = "n" ]; then
240 rm -f $SRC/${NOISE}.ref
241 if [ -f $SRC/${NOISE}.out
]; then
242 mv $SRC/${NOISE}.out
$SRC/${NOISE}.ref
244 grep : $SRC/${INSTALLOG}.out \
246 |
egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
249 |
egrep -v '^LD_LIBRARY_PATH=' \
250 |
egrep -v 'ar: creating' \
251 |
egrep -v 'ar: writing' \
252 |
egrep -v 'conflicts:' \
253 |
egrep -v ':saved created' \
254 |
egrep -v '^stty.*c:' \
255 |
egrep -v '^mfgname.c:' \
256 |
egrep -v '^uname-i.c:' \
257 |
egrep -v '^volumes.c:' \
258 |
egrep -v '^lint library construction:' \
259 |
egrep -v 'tsort: INFORM:' \
260 |
egrep -v 'stripalign:' \
261 |
egrep -v 'chars, width' \
262 |
egrep -v "symbol (\`|')timezone' has differing types:" \
263 |
egrep -v 'PSTAMP' \
264 |
egrep -v '^Manifying' \
265 |
egrep -v 'Ignoring unknown host' \
266 |
egrep -v 'Processing method:' \
267 |
egrep -v '^Writing' \
268 |
egrep -v 'spellin1:' \
269 |
egrep -v '^adding:' \
270 |
egrep -v "^echo 'msgid" \
271 |
egrep -v '^echo ' \
273 |
egrep -v '^Adding file:' \
274 |
egrep -v 'CLASSPATH=' \
275 |
egrep -v '\/var\/mail\/:saved' \
276 |
egrep -v -- '-DUTS_VERSION=' \
277 |
egrep -v '^Running Mkbootstrap' \
278 |
egrep -v '^Applet length read:' \
279 |
egrep -v 'bytes written:' \
280 |
egrep -v '^File:SolarisAuthApplet.bin' \
281 |
egrep -v -i 'jibversion' \
282 |
egrep -v '^Output size:' \
283 |
egrep -v '^Solo size statistics:' \
284 |
egrep -v '^Using ROM API Version' \
285 |
egrep -v '^Zero Signature length:' \
286 |
egrep -v '^Note \(probably harmless\):' \
288 |
egrep -v -- '-xcache' \
290 |
egrep -v '^cc1: note: -fwritable-strings' \
291 |
egrep -v 'svccfg-native -s svc:/' \
292 |
sort |
uniq >$SRC/${NOISE}.out
293 if [ ! -f $SRC/${NOISE}.ref
]; then
294 cp $SRC/${NOISE}.out
$SRC/${NOISE}.ref
296 echo "\n==== Build noise differences ($LABEL) ====\n" \
298 diff $SRC/${NOISE}.ref
$SRC/${NOISE}.out
>>$mail_msg_file
302 # Re-sign selected binaries using signing server
303 # (gatekeeper builds only)
305 if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then
306 echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE
307 signing_file
="${TMPDIR}/signing"
308 rm -f ${signing_file}
310 signproto
$SRC/tools
/codesign
/creds
2>&1 | \
311 tee -a ${signing_file} >> $LOGFILE
312 echo "\n==== Finished signing proto area at `date` ====\n" \
314 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
316 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
317 if (( $?
== 0 )) ; then
326 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
327 if [ -d $SRC/pkg
]; then
328 echo "\n==== Creating $LABEL packages at `date` ====\n" \
330 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
331 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
332 mkdir
-p $PKGARCHIVE >> "$LOGFILE" 2>&1
334 rm -f $SRC/pkg
/${INSTALLOG}.out
336 /bin
/time $MAKE -e install 2>&1 | \
337 tee -a $SRC/pkg
/${INSTALLOG}.out
>> $LOGFILE
339 echo "\n==== package build errors ($LABEL) ====\n" \
342 egrep "${MAKE}|ERROR|WARNING" $SRC/pkg
/${INSTALLOG}.out | \
345 egrep -v "Ignoring unknown host" | \
346 tee $TMPDIR/package
>> $mail_msg_file
347 if [[ -s $TMPDIR/package
]]; then
353 # Handle it gracefully if -p was set but there so
356 echo "\n==== No $LABEL packages to build ====\n" \
360 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
366 # Usage: dolint /dir y|n
367 # Arg. 2 is a flag to turn on/off the lint diff output
369 if [ ! -d "$1" ]; then
370 echo "dolint error: $1 is not a directory"
374 if [ "$2" != "y" -a "$2" != "n" ]; then
375 echo "dolint internal error: $2 should be 'y' or 'n'"
381 base
=`basename $lintdir`
382 LINTOUT
=$lintdir/lint-
${MACH}.out
383 LINTNOISE
=$lintdir/lint-noise-
${MACH}
384 export ENVLDLIBS1
=`myldlibs $ROOT`
385 export ENVCPPFLAGS1
=`myheaders $ROOT`
387 set_debug_build_flags
390 # '$MAKE lint' in $lintdir
392 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
394 # remove old lint.out
395 rm -f $lintdir/lint.out
$lintdir/lint-noise.out
396 if [ -f $lintdir/lint-noise.ref
]; then
397 mv $lintdir/lint-noise.ref
${LINTNOISE}.ref
403 # Remove all .ln files to ensure a full reference file
405 rm -f Nothing_to_remove \
406 `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
407 -prune -o -type f -name '*.ln' -print `
409 /bin
/time $MAKE -ek lint
2>&1 | \
410 tee -a $LINTOUT >> $LOGFILE
412 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file
414 grep "$MAKE:" $LINTOUT |
415 egrep -v "Ignoring unknown host" | \
416 tee $TMPDIR/lint_errs
>> $mail_msg_file
417 if [[ -s $TMPDIR/lint_errs
]]; then
421 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
423 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
425 tail -3 $LINTOUT >>$mail_msg_file
427 rm -f ${LINTNOISE}.ref
428 if [ -f ${LINTNOISE}.out
]; then
429 mv ${LINTNOISE}.out
${LINTNOISE}.ref
432 egrep -v '^(real|user|sys)' |
433 egrep -v '(library construction)' | \
434 egrep -v ': global crosschecks' | \
435 egrep -v 'Ignoring unknown host' | \
437 sort |
uniq > ${LINTNOISE}.out
438 if [ ! -f ${LINTNOISE}.ref
]; then
439 cp ${LINTNOISE}.out
${LINTNOISE}.ref
442 if [ "$dodiff" != "n" ]; then
443 echo "\n==== lint warnings $base ====\n" \
445 # should be none, though there are a few that were filtered out
447 egrep -i '(warning|lint):' ${LINTNOISE}.out \
448 |
sort |
uniq |
tee $TMPDIR/lint_warns
>> $mail_msg_file
449 if [[ -s $TMPDIR/lint_warns
]]; then
452 echo "\n==== lint noise differences $base ====\n" \
454 diff ${LINTNOISE}.ref
${LINTNOISE}.out \
460 # Build and install the onbld tools.
462 # usage: build_tools DESTROOT
464 # returns non-zero status if the build was successful.
466 function build_tools
{
469 INSTALLOG
=install-
${MACH}
471 echo "\n==== Building tools at `date` ====\n" \
474 rm -f ${TOOLS}/${INSTALLOG}.out
476 /bin
/time $MAKE TOOLS_PROTO
=${DESTROOT} -e install 2>&1 | \
477 tee -a ${TOOLS}/${INSTALLOG}.out
>> $LOGFILE
479 echo "\n==== Tools build errors ====\n" >> $mail_msg_file
481 egrep ":" ${TOOLS}/${INSTALLOG}.out |
482 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
483 egrep -v "Ignoring unknown host" | \
484 egrep -v warning |
tee $TMPDIR/tools_errors
>> $mail_msg_file
486 if [[ -s $TMPDIR/tools_errors
]]; then
493 if [ $ISUSER -ne 0 ]; then
502 eval su
$STAFFER -c \'$arg\'
507 # Verify that the closed bins are present
509 function check_closed_bins
{
510 if [[ -n "$ON_CLOSED_BINS" && ! -d "$ON_CLOSED_BINS" ]]; then
511 echo "ON_CLOSED_BINS must point to the closed binaries tree."
518 # wrapper over wsdiff.
519 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
527 [ "$t_FLAG" = y
] && wsdiff
="wsdiff -t"
529 echo "\n==== Getting object changes since last build at `date`" \
530 "($label) ====\n" |
tee -a $LOGFILE >> $mail_msg_file
531 $wsdiff -s -r ${TMPDIR}/wsdiff.results
$oldproto $newproto 2>&1 | \
532 tee -a $LOGFILE >> $mail_msg_file
533 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
534 tee -a $LOGFILE >> $mail_msg_file
538 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
542 function set_non_debug_build_flags
{
543 export RELEASE_BUILD
; RELEASE_BUILD
=
548 function set_debug_build_flags
{
557 if [ "$OPTHOME" = "" ]; then
562 USAGE
='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
565 -i Fast incremental options (no clobber, lint, check)
566 -n Do not do a bringover
567 +t Use the build tools in $ONBLD_TOOLS/bin
568 -V VERS set the build version string to VERS
570 <env_file> file in Bourne shell syntax that sets and exports
571 variables that configure the operation of this script and many of
572 the scripts this one calls. If <env_file> does not exist,
573 it will be looked for in $OPTHOME/onbld/env.
575 non-DEBUG is the default build type. Build options can be set in the
576 NIGHTLY_OPTIONS variable in the <env_file> as follows:
578 -A check for ABI differences in .so files
579 -C check for cstyle/hdrchk errors
580 -D do a build with DEBUG on
581 -F do _not_ do a non-DEBUG build
582 -G gate keeper default group of options (-au)
583 -I integration engineer default group of options (-ampu)
584 -M do not run pmodes (safe file permission checker)
585 -N do not run protocmp
586 -R default group of options for building a release (-mp)
587 -U update proto area in the parent
588 -V VERS set the build version string to VERS
589 -f find unreferenced files
590 -i do an incremental build (no "make clobber")
591 -l do "make lint" in $LINTDIRS (default: $SRC y)
592 -m send mail to $MAILTO at end of build
593 -n do not do a bringover
595 -r check ELF runtime attributes in the proto area
596 -t build and use the tools in $SRC/tools (default setting)
597 +t Use the build tools in $ONBLD_TOOLS/bin
598 -u update proto_list_$MACH and friends in the parent workspace;
599 when used with -f, also build an unrefmaster.out in the parent
600 -w report on differences between previous and current proto areas
603 # A log file will be generated under the name $LOGFILE
604 # for partially completed build and log.`date '+%F'`
605 # in the same directory for fully completed builds.
608 # default values for low-level FLAGS; G I R are group FLAGS
614 i_FLAG
=n
; i_CMD_LINE_FLAG
=n
637 while getopts +intV
:W FLAG
640 i
) i_FLAG
=y
; i_CMD_LINE_FLAG
=y
657 # correct argument count after options
658 shift `expr $OPTIND - 1`
660 # test that the path to the environment-setting file was given
661 if [ $# -ne 1 ]; then
666 # check if user is running nightly as root
667 # ISUSER is set non-zero if an ordinary user runs nightly, or is zero
668 # when root invokes nightly.
669 /usr
/bin
/id |
grep '^uid=0(' >/dev
/null
2>&1
670 ISUSER
=$?
; export ISUSER
675 LC_ALL
=C
; export LC_ALL
676 LC_COLLATE
=C
; export LC_COLLATE
677 LC_CTYPE
=C
; export LC_CTYPE
678 LC_MESSAGES
=C
; export LC_MESSAGES
679 LC_MONETARY
=C
; export LC_MONETARY
680 LC_NUMERIC
=C
; export LC_NUMERIC
681 LC_TIME
=C
; export LC_TIME
683 # clear environment variables we know to be bad for the build
685 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
686 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
687 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
688 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
689 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
690 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
691 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
692 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
693 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
694 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
695 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
696 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
697 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
698 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
699 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
700 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
701 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
702 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
703 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
704 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
716 # To get ONBLD_TOOLS from the environment, it must come from the env file.
717 # If it comes interactively, it is generally TOOLS_PROTO, which will be
718 # clobbered before the compiler version checks, which will therefore fail.
723 # Setup environmental variables
725 if [ -f /etc
/nightly.conf
]; then
730 if [[ $1 = */* ]]; then
736 if [ -f $OPTHOME/onbld
/env
/$1 ]; then
737 .
$OPTHOME/onbld
/env
/$1
739 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1"
744 # contents of stdenv.sh inserted after next line:
748 # Check if we have sufficient data to continue...
749 [[ -v CODEMGR_WS
]] || fatal_error
"Error: Variable CODEMGR_WS not set."
750 if [[ "${NIGHTLY_OPTIONS}" == ~
(F
)n
]] ; then
751 # Check if the gate data are valid if we don't do a "bringover" below
752 [[ -d "${CODEMGR_WS}" ]] || \
753 fatal_error
"Error: ${CODEMGR_WS} is not a directory."
754 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
755 fatal_error
"Error: ${CODEMGR_WS}/usr/src/Makefile not found."
759 # place ourselves in a new task, respecting BUILD_PROJECT if set.
761 if [ -z "$BUILD_PROJECT" ]; then
762 /usr
/bin
/newtask
-c $$
764 /usr
/bin
/newtask
-c $$
-p $BUILD_PROJECT
767 ps
-o taskid
= -p $$ |
read build_taskid
768 ps
-o project
= -p $$ |
read build_project
771 # See if NIGHTLY_OPTIONS is set
773 if [ "$NIGHTLY_OPTIONS" = "" ]; then
774 NIGHTLY_OPTIONS
="-aBm"
778 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
780 if [ "$BRINGOVER_WS" = "" ]; then
781 BRINGOVER_WS
=$CLONE_WS
785 # If BRINGOVER_FILES was not specified, default to usr
787 if [ "$BRINGOVER_FILES" = "" ]; then
788 BRINGOVER_FILES
="usr"
794 # Note: changes to the option letters here should also be applied to the
795 # bldenv script. `d' is listed for backward compatibility.
797 NIGHTLY_OPTIONS
=-${NIGHTLY_OPTIONS#-}
799 while getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG
$NIGHTLY_OPTIONS
805 ;; # old version of D
841 U
) if [ -z "${PARENT_ROOT}" ]; then
842 echo "PARENT_ROOT must be set if the U flag is" \
843 "present in NIGHTLY_OPTIONS."
846 NIGHTLY_PARENT_ROOT
=$PARENT_ROOT
847 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
848 NIGHTLY_PARENT_TOOLS_ROOT
=$PARENT_TOOLS_ROOT
864 if [ $ISUSER -ne 0 ]; then
865 # Set default value for STAFFER, if needed.
866 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
867 STAFFER
=`/usr/xpg4/bin/id -un`
872 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
877 PATH
="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
878 PATH
="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb"
879 PATH
="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
882 # roots of source trees, both relative to $SRC and absolute.
886 PROTOCMPTERSE
="protocmp.terse -gu"
888 # have we set RELEASE_DATE in our env file?
889 if [ -z "$RELEASE_DATE" ]; then
890 RELEASE_DATE
=$
(LC_ALL
=C
date +"%B %Y")
892 BUILD_DATE
=$
(LC_ALL
=C
date +%Y-
%b-
%d
)
893 BASEWSDIR
=$
(basename $CODEMGR_WS)
894 DEV_CM
="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
896 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
897 # by avoiding repeated shell invocations to evaluate Makefile.master
899 export POUND_SIGN RELEASE_DATE DEV_CM
901 maketype
="distributed"
902 if [[ -z "$MAKE" ]]; then
904 elif [[ ! -x "$MAKE" ]]; then
905 echo "\$MAKE is set to garbage in the environment"
911 if [ "${SUNWSPRO}" != "" ]; then
912 PATH
="${SUNWSPRO}/bin:$PATH"
917 if [[ $DMAKE_MAX_JOBS != +([0-9]) ||
$DMAKE_MAX_JOBS -eq 0 ]]
920 if [[ -f $HOME/.
make.machines
]]
922 # Note: there is a hard tab and space character in the []s
924 egrep -i "^[ ]*$hostname[ \.]" \
925 $HOME/.
make.machines |
read host jobs
929 if [[ $maxjobs != +([0-9]) ||
$maxjobs -eq 0 ]]
935 export DMAKE_MAX_JOBS
=$maxjobs
941 if [ -z "${ROOT}" ]; then
942 echo "ROOT must be set."
947 # if -V flag was given, reset VERSION to V_ARG
949 if [ "$V_FLAG" = "y" ]; then
953 TMPDIR
="/tmp/nightly.tmpdir.$$"
956 mkdir
-p $TMPDIR ||
exit 1
960 # Tools should only be built non-DEBUG. Keep track of the tools proto
961 # area path relative to $TOOLS, because the latter changes in an
964 # TOOLS_PROTO is included below for builds other than usr/src/tools
965 # that look for this location. For usr/src/tools, this will be
966 # overridden on the $MAKE command line in build_tools().
969 TOOLS_PROTO_REL
=proto
/root_
${MACH}-nd
970 TOOLS_PROTO
=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
972 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
974 # create directories that are automatically removed if the nightly script
975 # fails to start correctly
979 while [ ! -d $dir ]; do
985 for dir
in $toadd; do
986 if staffer mkdir
$dir; then
987 newlist
="$ISUSER $dir $newlist"
990 [ -z "$torm" ] || staffer
rmdir $torm
994 newdirlist
="$newlist $newdirlist"
999 [ -d $CODEMGR_WS ] || newdir
$CODEMGR_WS ||
exit 1
1001 # since this script assumes the build is from full source, it nullifies
1002 # variables likely to have been set by a "ws" script; nullification
1003 # confines the search space for headers and libraries to the proto area
1004 # built from this immediate source.
1014 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1015 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
1017 PKGARCHIVE_ORIG
=$PKGARCHIVE
1020 # Juggle the logs and optionally send mail on completion.
1023 function logshuffle
{
1024 LLOG
="$ATLOG/log.`date '+%F.%H:%M'`"
1025 if [ -f $LLOG -o -d $LLOG ]; then
1029 rm -f "$ATLOG/latest" 2>/dev
/null
1033 if [ "$build_ok" = "y" ]; then
1034 mv $ATLOG/proto_list_
${MACH} $LLOG
1036 if [ -f $ATLOG/proto_list_tools_
${MACH} ]; then
1037 mv $ATLOG/proto_list_tools_
${MACH} $LLOG
1040 if [ -f $TMPDIR/wsdiff.results
]; then
1041 mv $TMPDIR/wsdiff.results
$LLOG
1044 if [ -f $TMPDIR/wsdiff-nd.results
]; then
1045 mv $TMPDIR/wsdiff-nd.results
$LLOG
1050 # Now that we're about to send mail, it's time to check the noise
1051 # file. In the event that an error occurs beyond this point, it will
1052 # be recorded in the nightly.log file, but nowhere else. This would
1053 # include only errors that cause the copying of the noise log to fail
1054 # or the mail itself not to be sent.
1057 exec >>$LOGFILE 2>&1
1058 if [ -s $build_noise_file ]; then
1059 echo "\n==== Nightly build noise ====\n" |
1060 tee -a $LOGFILE >>$mail_msg_file
1061 cat $build_noise_file >>$LOGFILE
1062 cat $build_noise_file >>$mail_msg_file
1063 echo |
tee -a $LOGFILE >>$mail_msg_file
1065 rm -f $build_noise_file
1079 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
1083 NIGHTLY_STATUS
=$state
1084 export NIGHTLY_STATUS
1086 run_hook POST_NIGHTLY
$state
1087 run_hook SYS_POST_NIGHTLY
$state
1090 # mailx(1) sets From: based on the -r flag
1094 if [[ -n "${MAILFROM}" ]]; then
1095 mailx_r
="-r ${MAILFROM}"
1098 cat $build_time_file $build_environ_file $mail_msg_file \
1100 if [ "$m_FLAG" = "y" ]; then
1101 cat ${LLOG}/mail_msg |
/usr
/bin
/mailx
${mailx_r} -s \
1102 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1106 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1107 staffer
cp ${LLOG}/mail_msg
$PARENT_WS/usr
/src
/mail_msg-
${MACH}
1108 staffer
cp $LOGFILE $PARENT_WS/usr
/src
/nightly-
${MACH}.log
1113 ln -s "$LLOG" "$ATLOG/latest"
1117 # Remove the locks and temporary files on any exit
1122 [ -z "$lockfile" ] || staffer
rm -f $lockfile
1123 [ -z "$atloglockfile" ] ||
rm -f $atloglockfile
1124 [ -z "$ulockfile" ] || staffer
rm -f $ulockfile
1125 [ -z "$Ulockfile" ] ||
rm -f $Ulockfile
1128 while [ $# -gt 0 ]; do
1129 ISUSER
=$1 staffer
rmdir $2
1135 function cleanup_signal
{
1137 # this will trigger cleanup(), above.
1142 trap cleanup_signal
1 2 3 15
1145 # Generic lock file processing -- make sure that the lock file doesn't
1146 # exist. If it does, it should name the build host and PID. If it
1147 # doesn't, then make sure we can create it. Clean up locks that are
1148 # known to be stale (assumes host name is unique among build systems
1149 # for the workspace).
1151 function create_lock
{
1155 ldir
=`dirname $lockf`
1156 [ -d $ldir ] || newdir
$ldir ||
exit 1
1157 eval $lockvar=$lockf
1159 while ! staffer
ln -s $hostname.
$STAFFER.$$
$lockf 2> /dev
/null
; do
1160 basews
=`basename $CODEMGR_WS`
1161 ls -l $lockf | nawk
'{print $NF}' | IFS
=.
read host user pid
1162 if [ "$host" != "$hostname" ]; then
1163 echo "$MACH build of $basews apparently" \
1164 "already started by $user on $host as $pid."
1166 elif kill -s 0 $pid 2>/dev
/null
; then
1167 echo "$MACH build of $basews already started" \
1171 # stale lock; clear it out and try again
1178 # Return the list of interesting proto areas, depending on the current
1181 function allprotos
{
1182 typeset roots
="$ROOT"
1184 if [[ "$F_FLAG" = n
&& "$MULTI_PROTO" = yes ]]; then
1185 roots
="$roots $ROOT-nd"
1191 # Ensure no other instance of this script is running on this host.
1192 # LOCKNAME can be set in <env_file>, and is by default, but is not
1193 # required due to the use of $ATLOG below.
1194 if [ -n "$LOCKNAME" ]; then
1195 create_lock
/tmp
/$LOCKNAME "lockfile"
1198 # Create from one, two, or three other locks:
1199 # $ATLOG/nightly.lock
1200 # - protects against multiple builds in same workspace
1201 # $PARENT_WS/usr/src/nightly.$MACH.lock
1202 # - protects against multiple 'u' copy-backs
1203 # $NIGHTLY_PARENT_ROOT/nightly.lock
1204 # - protects against multiple 'U' copy-backs
1206 # Overriding ISUSER to 1 causes the lock to be created as root if the
1207 # script is run as root. The default is to create it as $STAFFER.
1208 ISUSER
=1 create_lock
$ATLOG/nightly.lock
"atloglockfile"
1209 if [ "$u_FLAG" = "y" ]; then
1210 create_lock
$PARENT_WS/usr
/src
/nightly.
$MACH.lock
"ulockfile"
1212 if [ "$U_FLAG" = "y" ]; then
1213 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1214 ISUSER
=1 create_lock
$NIGHTLY_PARENT_ROOT/nightly.lock
"Ulockfile"
1217 # Locks have been taken, so we're doing a build and we're committed to
1218 # the directories we may have created so far.
1222 # Create mail_msg_file
1224 mail_msg_file
="${TMPDIR}/mail_msg"
1225 touch $mail_msg_file
1226 build_time_file
="${TMPDIR}/build_time"
1227 build_environ_file
="${TMPDIR}/build_environ"
1228 touch $build_environ_file
1230 # Move old LOGFILE aside
1231 # ATLOG directory already made by 'create_lock' above
1233 if [ -f $LOGFILE ]; then
1234 mv -f $LOGFILE ${LOGFILE}-
1237 # Build OsNet source
1241 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1242 |
tee -a $LOGFILE > $build_time_file
1244 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1245 tee -a $mail_msg_file >> $LOGFILE
1247 # make sure we log only to the nightly build file
1248 build_noise_file
="${TMPDIR}/build_noise"
1249 exec </dev
/null
>$build_noise_file 2>&1
1251 run_hook SYS_PRE_NIGHTLY
1252 run_hook PRE_NIGHTLY
1254 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1257 echo "\n==== Nightly argument issues ====\n" |
tee -a $mail_msg_file >> $LOGFILE
1259 if [ "$N_FLAG" = "y" ]; then
1260 if [ "$p_FLAG" = "y" ]; then
1261 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1262 WARNING: the p option (create packages) is set, but so is the N option (do
1263 not run protocmp); this is dangerous; you should unset the N option
1266 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1267 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1270 echo "" |
tee -a $mail_msg_file >> $LOGFILE
1273 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1275 # In the past we just complained but went ahead with the lint
1276 # pass, even though the proto area was built non-DEBUG. It's
1277 # unlikely that non-DEBUG headers will make a difference, but
1278 # rather than assuming it's a safe combination, force the user
1279 # to specify a DEBUG build.
1281 echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1282 |
tee -a $mail_msg_file >> $LOGFILE
1286 if [ "$f_FLAG" = "y" ]; then
1287 if [ "$i_FLAG" = "y" ]; then
1288 echo "WARNING: the -f flag cannot be used during incremental" \
1289 "builds; ignoring -f\n" |
tee -a $mail_msg_file >> $LOGFILE
1292 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then
1293 echo "WARNING: the -f flag requires -l, and -p;" \
1294 "ignoring -f\n" |
tee -a $mail_msg_file >> $LOGFILE
1299 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1300 echo "WARNING: -w specified, but $ROOT does not exist;" \
1301 "ignoring -w\n" |
tee -a $mail_msg_file >> $LOGFILE
1305 case $MULTI_PROTO in
1308 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1309 "should be \"yes\" or \"no\"." |
tee -a $mail_msg_file >> $LOGFILE
1310 echo "Setting MULTI_PROTO to \"no\".\n" | \
1311 tee -a $mail_msg_file >> $LOGFILE
1312 export MULTI_PROTO
=no
1316 echo "\n==== Build version ====\n" |
tee -a $mail_msg_file >> $LOGFILE
1317 echo $VERSION |
tee -a $mail_msg_file >> $LOGFILE
1319 # Save the current proto area if we're comparing against the last build
1320 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1321 if [ -d "$ROOT.prev" ]; then
1327 # Same for non-DEBUG proto area
1328 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1329 if [ -d "$ROOT-nd.prev" ]; then
1330 rm -rf $ROOT-nd.prev
1332 mv $ROOT-nd $ROOT-nd.prev
1336 # Echo the SCM type of the parent workspace, this can't just be which_scm
1337 # as that does not know how to identify various network repositories.
1339 function parent_wstype
{
1340 typeset scm_type junk
1342 CODEMGR_WS
="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev
/null \
1343 |
read scm_type junk
1344 if [[ -z "$scm_type" ||
"$scm_type" == unknown
]]; then
1345 # Probe BRINGOVER_WS to determine its type
1346 if [[ $BRINGOVER_WS == ssh://* ]]; then
1347 scm_type
="mercurial"
1348 elif [[ $BRINGOVER_WS == http
://* ]] && \
1349 wget
-q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1350 egrep -s "application/mercurial" 2> /dev
/null
; then
1351 scm_type
="mercurial"
1357 # fold both unsupported and unrecognized results into "none"
1368 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1369 function child_wstype
{
1370 typeset scm_type junk
1372 # Probe CODEMGR_WS to determine its type
1373 if [[ -d $CODEMGR_WS ]]; then
1374 $WHICH_SCM |
read scm_type junk ||
exit 1
1387 SCM_TYPE
=$
(child_wstype
)
1390 # Decide whether to clobber
1392 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1393 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1396 # remove old clobber file
1397 rm -f $SRC/clobber.out
1398 rm -f $SRC/clobber-
${MACH}.out
1400 # Remove all .make.state* files, just in case we are restarting
1401 # the build after having interrupted a previous 'make clobber'.
1402 find . \
( -name SCCS
-o -name .hg
-o -name .svn
-o -name .git \
1403 -o -name 'interfaces.*' \
) -prune \
1404 -o -name '.make.*' -print |
xargs rm -f
1406 $MAKE -ek clobber
2>&1 |
tee -a $SRC/clobber-
${MACH}.out
>> $LOGFILE
1407 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1408 grep "$MAKE:" $SRC/clobber-
${MACH}.out |
1409 egrep -v "Ignoring unknown host" | \
1410 tee $TMPDIR/clobber_errs
>> $mail_msg_file
1412 if [[ -s $TMPDIR/clobber_errs
]]; then
1416 if [[ "$t_FLAG" = "y" ]]; then
1417 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1419 rm -f ${TOOLS}/clobber-
${MACH}.out
1420 $MAKE TOOLS_PROTO
=$TOOLS_PROTO -ek clobber
2>&1 | \
1421 tee -a ${TOOLS}/clobber-
${MACH}.out
>> $LOGFILE
1422 echo "\n==== Make tools clobber ERRORS ====\n" \
1424 grep "$MAKE:" ${TOOLS}/clobber-
${MACH}.out \
1426 if (( $?
== 0 )); then
1429 rm -rf ${TOOLS_PROTO}
1430 mkdir
-p ${TOOLS_PROTO}
1433 typeset roots
=$
(allprotos
)
1434 echo "\n\nClearing $roots" >> "$LOGFILE"
1437 # Get back to a clean workspace as much as possible to catch
1438 # problems that only occur on fresh workspaces.
1439 # Remove all .make.state* files, libraries, and .o's that may
1440 # have been omitted from clobber. A couple of libraries are
1441 # under source code control, so leave them alone.
1442 # We should probably blow away temporary directories too.
1444 find $relsrcdirs \
( -name SCCS
-o -name .hg
-o -name .svn \
1445 -o -name .git
-o -name 'interfaces.*' \
) -prune -o \
1446 \
( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1447 -name '*.o' \
) -print | \
1448 grep -v 'tools/ctf/dwarf/.*/libdwarf' |
xargs rm -f
1450 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1453 type bringover_mercurial
> /dev
/null
2>&1 ||
function bringover_mercurial
{
1454 typeset
-x PATH
=$PATH
1456 # If the repository doesn't exist yet, then we want to populate it.
1457 if [[ ! -d $CODEMGR_WS/.hg
]]; then
1458 staffer hg init
$CODEMGR_WS
1459 staffer
echo "[paths]" > $CODEMGR_WS/.hg
/hgrc
1460 staffer
echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg
/hgrc
1461 touch $TMPDIR/new_repository
1464 typeset
-x HGMERGE
="/bin/false"
1467 # If the user has changes, regardless of whether those changes are
1468 # committed, and regardless of whether those changes conflict, then
1469 # we'll attempt to merge them either implicitly (uncommitted) or
1470 # explicitly (committed).
1472 # These are the messages we'll use to help clarify mercurial output
1475 typeset mergefailmsg
="\
1477 *** nightly was unable to automatically merge your changes. You should\n\
1478 *** redo the full merge manually, following the steps outlined by mercurial\n\
1479 *** above, then restart nightly.\n\
1481 typeset mergepassmsg
="\
1483 *** nightly successfully merged your changes. This means that your working\n\
1484 *** directory has been updated, but those changes are not yet committed.\n\
1485 *** After nightly completes, you should validate the results of the merge,\n\
1486 *** then use hg commit manually.\n\
1490 # For each repository in turn:
1492 # 1. Do the pull. If this fails, dump the output and bail out.
1494 # 2. If the pull resulted in an extra head, do an explicit merge.
1495 # If this fails, dump the output and bail out.
1497 # Because we can't rely on Mercurial to exit with a failure code
1498 # when a merge fails (Mercurial issue #186), we must grep the
1499 # output of pull/merge to check for attempted and/or failed merges.
1501 # 3. If a merge failed, set the message and fail the bringover.
1503 # 4. Otherwise, if a merge succeeded, set the message
1505 # 5. Dump the output, and any message from step 3 or 4.
1508 typeset HG_SOURCE
=$BRINGOVER_WS
1509 if [ ! -f $TMPDIR/new_repository
]; then
1510 HG_SOURCE
=$TMPDIR/open_bundle.hg
1511 staffer hg
--cwd $CODEMGR_WS incoming
--bundle $HG_SOURCE \
1512 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
1515 # If there are no incoming changesets, then incoming will
1516 # fail, and there will be no bundle file. Reset the source,
1517 # to allow the remaining logic to complete with no false
1518 # negatives. (Unlike incoming, pull will return success
1519 # for the no-change case.)
1521 if (( $?
!= 0 )); then
1522 HG_SOURCE
=$BRINGOVER_WS
1526 staffer hg
--cwd $CODEMGR_WS pull
-u $HG_SOURCE \
1527 > $TMPDIR/pull_open.out
2>&1
1528 if (( $?
!= 0 )); then
1529 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
1530 cat $TMPDIR/pull_open.out
1531 if grep "^merging.*failed" $TMPDIR/pull_open.out
> /dev
/null
2>&1; then
1532 printf "$mergefailmsg"
1534 touch $TMPDIR/bringover_failed
1538 if grep "not updating" $TMPDIR/pull_open.out
> /dev
/null
2>&1; then
1539 staffer hg
--cwd $CODEMGR_WS merge \
1540 >> $TMPDIR/pull_open.out
2>&1
1541 if (( $?
!= 0 )); then
1542 printf "%s: merge failed as follows:\n\n" \
1544 cat $TMPDIR/pull_open.out
1545 if grep "^merging.*failed" $TMPDIR/pull_open.out \
1546 > /dev
/null
2>&1; then
1547 printf "$mergefailmsg"
1549 touch $TMPDIR/bringover_failed
1554 printf "updated %s with the following results:\n" "$CODEMGR_WS"
1555 cat $TMPDIR/pull_open.out
1556 if grep "^merging" $TMPDIR/pull_open.out
>/dev
/null
2>&1; then
1557 printf "$mergepassmsg"
1562 # Per-changeset output is neither useful nor manageable for a
1563 # newly-created repository.
1565 if [ -f $TMPDIR/new_repository
]; then
1569 printf "\nadded the following changesets to open repository:\n"
1570 cat $TMPDIR/incoming_open.out
1573 type bringover_none
> /dev
/null
2>&1 ||
function bringover_none
{
1574 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1575 touch $TMPDIR/bringover_failed
1579 # Decide whether to bringover to the codemgr workspace
1581 if [ "$n_FLAG" = "n" ]; then
1582 PARENT_SCM_TYPE
=$
(parent_wstype
)
1584 if [[ $SCM_TYPE != none
&& $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
1585 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
1586 "quitting at `date`." |
tee -a $mail_msg_file >> $LOGFILE
1590 run_hook PRE_BRINGOVER
1592 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
1593 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
1595 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
1596 tee -a $mail_msg_file >> $LOGFILE
1598 if [ -f $TMPDIR/bringover_failed
]; then
1599 rm -f $TMPDIR/bringover_failed
1601 echo "trouble with bringover, quitting at `date`." |
1602 tee -a $mail_msg_file >> $LOGFILE
1607 # It's possible that we used the bringover above to create
1608 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
1609 # but should now be the same as $BRINGOVER_WS.
1611 [[ $SCM_TYPE = none
]] && SCM_TYPE
=$PARENT_SCM_TYPE
1613 run_hook POST_BRINGOVER
1618 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
1622 [[ -v CODEMGR_WS
]] || fatal_error
"Error: Variable CODEMGR_WS not set."
1623 [[ -d "${CODEMGR_WS}" ]] || fatal_error
"Error: ${CODEMGR_WS} is not a directory."
1624 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error
"Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1626 if [[ "$t_FLAG" = "y" ]]; then
1627 echo "\n==== Bootstrapping cw ====\n" >> $LOGFILE
1629 set_non_debug_build_flags
1630 rm -f $TMPDIR/make-state
1631 $MAKE -K $TMPDIR/make-state
-e TARGET
=install cw
2>&1 >> $LOGFILE
1632 [[ "$?" -ne 0 ]] && fatal_error
"Error: could not bootstrap cw"
1635 # Switch ONBLD_TOOLS early if -t is specified so that
1636 # we could use bootstrapped cw for compiler checks.
1637 ONBLD_TOOLS
=${TOOLS_PROTO}/opt
/onbld
1641 echo "\n==== Build environment ====\n" |
tee -a $build_environ_file >> $LOGFILE
1644 whence uname |
tee -a $build_environ_file >> $LOGFILE
1645 uname
-a 2>&1 |
tee -a $build_environ_file >> $LOGFILE
1646 echo |
tee -a $build_environ_file >> $LOGFILE
1649 whence
$MAKE |
tee -a $build_environ_file >> $LOGFILE
1650 $MAKE -v |
tee -a $build_environ_file >> $LOGFILE
1651 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
1652 tee -a $build_environ_file >> $LOGFILE
1655 # Report the compiler versions.
1658 if [[ ! -f $SRC/Makefile
]]; then
1660 echo "\nUnable to find \"Makefile\" in $SRC." | \
1661 tee -a $build_environ_file >> $LOGFILE
1666 for target
in cc-version cc64-version java-version openssl-version
; do
1669 # Put statefile somewhere we know we can write to rather than trip
1670 # over a read-only $srcroot.
1672 rm -f $TMPDIR/make-state
1674 if $MAKE -K $TMPDIR/make-state
-e $target 2>/dev
/null
; then
1677 touch $TMPDIR/nocompiler
1680 ) |
tee -a $build_environ_file >> $LOGFILE
1682 if [ -f $TMPDIR/nocompiler
]; then
1683 rm -f $TMPDIR/nocompiler
1685 echo "Aborting due to missing compiler." |
1686 tee -a $build_environ_file >> $LOGFILE
1691 whence as |
tee -a $build_environ_file >> $LOGFILE
1692 as
-V 2>&1 |
head -1 |
tee -a $build_environ_file >> $LOGFILE
1693 echo |
tee -a $build_environ_file >> $LOGFILE
1695 # Check that we're running a capable link-editor
1696 whence ld |
tee -a $build_environ_file >> $LOGFILE
1698 echo $LDVER |
tee -a $build_environ_file >> $LOGFILE
1699 LDVER
=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1700 if [ `expr $LDVER \< 422` -eq 1 ]; then
1701 echo "The link-editor needs to be at version 422 or higher to build" | \
1702 tee -a $build_environ_file >> $LOGFILE
1703 echo "the latest stuff. Hope your build works." | \
1704 tee -a $build_environ_file >> $LOGFILE
1708 # Build and use the workspace's tools if requested
1710 if [[ "$t_FLAG" = "y" ]]; then
1711 set_non_debug_build_flags
1713 build_tools
${TOOLS_PROTO}
1714 if (( $?
!= 0 )); then
1717 STABS
=${TOOLS_PROTO}/opt
/onbld
/bin
/${MACH}/stabs
1719 CTFSTABS
=${TOOLS_PROTO}/opt
/onbld
/bin
/${MACH}/ctfstabs
1721 GENOFFSETS
=${TOOLS_PROTO}/opt
/onbld
/bin
/genoffsets
1724 CTFCONVERT
=${TOOLS_PROTO}/opt
/onbld
/bin
/${MACH}/ctfconvert
1726 CTFMERGE
=${TOOLS_PROTO}/opt
/onbld
/bin
/${MACH}/ctfmerge
1729 PATH
="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
1730 PATH
="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
1733 echo "\n==== New environment settings. ====\n" >> $LOGFILE
1734 echo "STABS=${STABS}" >> $LOGFILE
1735 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
1736 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
1737 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
1738 echo "PATH=${PATH}" >> $LOGFILE
1739 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
1743 # timestamp the start of the normal build; the findunref tool uses it.
1744 touch $SRC/.build.tstamp
1749 BINARCHIVE
=${CODEMGR_WS}/bin-
${MACH}.
cpio.Z
1753 # There are several checks that need to look at the proto area, but
1754 # they only need to look at one, and they don't care whether it's
1755 # DEBUG or non-DEBUG.
1757 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n
]]; then
1763 if [ "$build_ok" = "y" ]; then
1764 echo "\n==== Creating protolist system file at `date` ====" \
1766 protolist
$checkroot > $ATLOG/proto_list_
${MACH}
1767 echo "==== protolist system file created at `date` ====\n" \
1770 if [ "$N_FLAG" != "y" ]; then
1775 if [ -f "$f" ]; then
1782 if [ -d "$SRC/pkg" ]; then
1783 f2
="$f2 exceptions/packaging"
1787 if [ -f "$f" ]; then
1793 if [ "$N_FLAG" != "y" -a -d $SRC/pkg
]; then
1794 echo "\n==== Validating manifests against proto area ====\n" \
1796 ( cd $SRC/pkg
; $MAKE -e protocmp ROOT
="$checkroot" ) | \
1797 tee $TMPDIR/protocmp_noise
>> $mail_msg_file
1798 if [[ -s $TMPDIR/protocmp_noise
]]; then
1803 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1804 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1805 if [ -n "$E2" ]; then
1811 "Files in yesterday's proto area, but not today's:" \
1812 "Files in today's proto area, but not yesterday's:" \
1813 "Files that changed between yesterday and today:" \
1815 -d $REF_PROTO_LIST \
1816 $ATLOG/proto_list_
${MACH} \
1821 if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \
1822 "$build_extras_ok" == "y" ]]; then
1823 staffer
cp $ATLOG/proto_list_
${MACH} \
1824 $PARENT_WS/usr
/src
/proto_list_
${MACH}
1827 # Update parent proto area if necessary. This is done now
1828 # so that the proto area has either DEBUG or non-DEBUG kernels.
1829 # Note that this clears out the lock file, so we can dispense with
1831 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1832 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1833 tee -a $LOGFILE >> $mail_msg_file
1834 rm -rf $NIGHTLY_PARENT_ROOT/*
1836 mkdir
-p $NIGHTLY_PARENT_ROOT
1837 if [[ "$MULTI_PROTO" = no ||
"$D_FLAG" = y
]]; then
1838 ( cd $ROOT; tar cf
- . |
1839 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf
- ) ) 2>&1 |
1840 tee -a $mail_msg_file >> $LOGFILE
1842 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n
]]; then
1843 rm -rf $NIGHTLY_PARENT_ROOT-nd/*
1844 mkdir
-p $NIGHTLY_PARENT_ROOT-nd
1847 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf
- ) ) 2>&1 |
1848 tee -a $mail_msg_file >> $LOGFILE
1850 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1851 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1852 tee -a $LOGFILE >> $mail_msg_file
1853 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1854 mkdir
-p $NIGHTLY_PARENT_TOOLS_ROOT
1855 if [[ "$MULTI_PROTO" = no ||
"$D_FLAG" = y
]]; then
1856 ( cd $TOOLS_PROTO; tar cf
- . |
1857 ( cd $NIGHTLY_PARENT_TOOLS_ROOT;
1858 umask 0; tar xpf
- ) ) 2>&1 |
1859 tee -a $mail_msg_file >> $LOGFILE
1865 # ELF verification: ABI (-A) and runtime (-r) checks
1867 if [[ ($build_ok = y
) && (($A_FLAG = y
) ||
($r_FLAG = y
)) ]]; then
1868 # Directory ELF-data.$MACH holds the files produced by these tests.
1869 elf_ddir
=$SRC/ELF-data.
$MACH
1871 # If there is a previous ELF-data backup directory, remove it. Then,
1872 # rotate current ELF-data directory into its place and create a new
1874 rm -rf $elf_ddir.ref
1875 if [[ -d $elf_ddir ]]; then
1876 mv $elf_ddir $elf_ddir.ref
1880 # Call find_elf to produce a list of the ELF objects in the proto area.
1881 # This list is passed to check_rtime and interface_check, preventing
1882 # them from separately calling find_elf to do the same work twice.
1883 find_elf
-fr $checkroot > $elf_ddir/object_list
1885 if [[ $A_FLAG = y
]]; then
1886 echo "\n==== Check versioning and ABI information ====\n" | \
1887 tee -a $LOGFILE >> $mail_msg_file
1889 # Produce interface description for the proto. Report errors.
1890 interface_check
-o -w $elf_ddir -f object_list \
1891 -i interface
-E interface.err
1892 if [[ -s $elf_ddir/interface.err
]]; then
1893 tee -a $LOGFILE < $elf_ddir/interface.err \
1898 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1899 # description file to that from the baseline gate. Issue a
1900 # warning if the baseline is not present, and keep going.
1901 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1902 base_ifile
="$ELF_DATA_BASELINE_DIR/interface"
1904 echo "\n==== Compare versioning and ABI information" \
1905 "to baseline ====\n" | \
1906 tee -a $LOGFILE >> $mail_msg_file
1907 echo "Baseline: $base_ifile\n" >> $LOGFILE
1909 if [[ -f $base_ifile ]]; then
1910 interface_cmp
-d -o $base_ifile \
1911 $elf_ddir/interface
> $elf_ddir/interface.
cmp
1912 if [[ -s $elf_ddir/interface.
cmp ]]; then
1913 echo |
tee -a $LOGFILE >> $mail_msg_file
1915 $elf_ddir/interface.
cmp \
1920 echo "baseline not available. comparison" \
1922 tee -a $LOGFILE >> $mail_msg_file
1928 if [[ $r_FLAG = y
]]; then
1929 echo "\n==== Check ELF runtime attributes ====\n" | \
1930 tee -a $LOGFILE >> $mail_msg_file
1932 # If we're doing a DEBUG build the proto area will be left
1933 # with debuggable objects, thus don't assert -s.
1934 if [[ $D_FLAG = y
]]; then
1939 check_rtime
-i -m -v $rtime_sflag -o -w $elf_ddir \
1940 -D object_list
-f object_list
-E runtime.err \
1942 if (( $?
!= 0 )); then
1946 # check_rtime -I output needs to be sorted in order to
1947 # compare it to that from previous builds.
1948 sort $elf_ddir/runtime.attr.raw
> $elf_ddir/runtime.attr
1949 rm $elf_ddir/runtime.attr.raw
1952 if [[ -s $elf_ddir/runtime.err
]]; then
1953 tee -a $LOGFILE < $elf_ddir/runtime.err \
1958 # If there is an ELF-data directory from a previous build,
1959 # then diff the attr files. These files contain information
1960 # about dependencies, versioning, and runpaths. There is some
1961 # overlap with the ABI checking done above, but this also
1962 # flushes out non-ABI interface differences along with the
1963 # other information.
1964 echo "\n==== Diff ELF runtime attributes" \
1965 "(since last build) ====\n" | \
1966 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
1968 if [[ -f $elf_ddir.ref
/runtime.attr
]]; then
1969 diff $elf_ddir.ref
/runtime.attr \
1970 $elf_ddir/runtime.attr \
1975 # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
1976 if [[ "$u_FLAG" = "y" ]]; then
1977 p_elf_ddir
=$PARENT_WS/usr
/src
/ELF-data.
$MACH
1979 # If parent lacks the ELF-data.$MACH directory, create it
1980 if [[ ! -d $p_elf_ddir ]]; then
1981 staffer mkdir
-p $p_elf_ddir
1984 # These files are used asynchronously by other builds for ABI
1985 # verification, as above for the -A option. As such, we require
1986 # the file replacement to be atomic. Copy the data to a temp
1987 # file in the same filesystem and then rename into place.
1990 for elf_dfile
in *; do
1991 staffer
cp $elf_dfile \
1992 ${p_elf_ddir}/${elf_dfile}.new
1993 staffer
mv -f ${p_elf_ddir}/${elf_dfile}.new \
1994 ${p_elf_ddir}/${elf_dfile}
2000 # DEBUG lint of kernel begins
2002 if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
2003 if [ "$LINTDIRS" = "" ]; then
2004 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y"
2008 while [ $# -gt 0 ]; do
2009 dolint
$1 $2; shift; shift
2012 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2015 # "make check" begins
2017 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2018 # remove old check.out
2019 rm -f $SRC/check.out
2021 rm -f $SRC/check-
${MACH}.out
2023 $MAKE -ek check ROOT
="$checkroot" 2>&1 |
tee -a $SRC/check-
${MACH}.out \
2025 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2027 grep ":" $SRC/check-
${MACH}.out |
2028 egrep -v "Ignoring unknown host" | \
2029 sort |
uniq |
tee $TMPDIR/check_errors
>> $mail_msg_file
2031 if [[ -s $TMPDIR/check_errors
]]; then
2035 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2038 echo "\n==== Find core files ====\n" | \
2039 tee -a $LOGFILE >> $mail_msg_file
2041 find $abssrcdirs -name core
-a -type f
-exec file {} \
; | \
2042 tee -a $LOGFILE >> $mail_msg_file
2044 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2045 echo "\n==== Diff unreferenced files (since last build) ====\n" \
2046 |
tee -a $LOGFILE >>$mail_msg_file
2047 rm -f $SRC/unref-
${MACH}.ref
2048 if [ -f $SRC/unref-
${MACH}.out
]; then
2049 mv $SRC/unref-
${MACH}.out
$SRC/unref-
${MACH}.ref
2052 findunref
-S $SCM_TYPE -t $SRC/.build.tstamp
-s usr
$CODEMGR_WS \
2053 ${TOOLS}/findunref
/exception_list
2>> $mail_msg_file | \
2054 sort > $SRC/unref-
${MACH}.out
2056 if [ ! -f $SRC/unref-
${MACH}.ref
]; then
2057 cp $SRC/unref-
${MACH}.out
$SRC/unref-
${MACH}.ref
2060 diff $SRC/unref-
${MACH}.ref
$SRC/unref-
${MACH}.out
>>$mail_msg_file
2063 # Verify that the usual lists of files, such as exception lists,
2064 # contain only valid references to files. If the build has failed,
2065 # then don't check the proto area.
2066 CHECK_PATHS
=${CHECK_PATHS:-y}
2067 if [ "$CHECK_PATHS" = y
-a "$N_FLAG" != y
]; then
2068 echo "\n==== Check lists of files ====\n" |
tee -a $LOGFILE \
2071 [ "$build_ok" = y
] && arg
=
2072 checkpaths
$arg $checkroot > $SRC/check-paths.out
2>&1
2073 if [[ -s $SRC/check-paths.out
]]; then
2074 tee -a $LOGFILE < $SRC/check-paths.out
>> $mail_msg_file
2079 if [ "$M_FLAG" != "y" -a "$build_ok" = y
]; then
2080 echo "\n==== Impact on file permissions ====\n" \
2084 for d
in $abssrcdirs; do
2085 if [ -d "$d/pkg" ]; then
2090 if [ -n "$abspkg" ]; then
2091 for d
in "$abspkg"; do
2092 ( cd $d/pkg
; $MAKE -e pmodes
) >> $mail_msg_file
2097 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
2098 if [[ "$MULTI_PROTO" = no ||
"$D_FLAG" = y
]]; then
2099 do_wsdiff DEBUG
$ROOT.prev
$ROOT
2102 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n
]]; then
2103 do_wsdiff non-DEBUG
$ROOT-nd.prev
$ROOT-nd
2108 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2109 tee -a $LOGFILE >> $build_time_file
2115 elapsed_time
=$SECONDS
2116 ((hours
= elapsed_time
/ 3600 ))
2117 ((minutes
= elapsed_time
/ 60 % 60))
2118 ((seconds
= elapsed_time
% 60))
2120 echo "\n==== Total build time ====" | \
2121 tee -a $LOGFILE >> $build_time_file
2122 echo "\nreal ${hours}:${minutes}:${seconds}" | \
2123 tee -a $LOGFILE >> $build_time_file
2125 if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2126 staffer
cp ${SRC}/unref-
${MACH}.out
$PARENT_WS/usr
/src
/
2129 # Produce a master list of unreferenced files -- ideally, we'd
2130 # generate the master just once after all of the nightlies
2131 # have finished, but there's no simple way to know when that
2132 # will be. Instead, we assume that we're the last nightly to
2133 # finish and merge all of the unref-${MACH}.out files in
2134 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
2135 # finish, then this file will be the authoritative master
2136 # list. Otherwise, another ${MACH}'s nightly will eventually
2137 # overwrite ours with its own master, but in the meantime our
2138 # temporary "master" will be no worse than any older master
2139 # which was already on the parent.
2142 set -- $PARENT_WS/usr
/src
/unref-
*.out
2143 cp "$1" ${TMPDIR}/unref.merge
2147 comm -12 ${TMPDIR}/unref.merge
"$unreffile" > ${TMPDIR}/unref.$$
2148 mv ${TMPDIR}/unref.$$
${TMPDIR}/unref.merge
2151 staffer
cp ${TMPDIR}/unref.merge
$PARENT_WS/usr
/src
/unrefmaster.out
2155 # All done save for the sweeping up.
2156 # (whichever exit we hit here will trigger the "cleanup" trap which
2157 # optionally sends mail on completion).
2159 if [[ "$build_ok" == "y" ]]; then
2160 if [[ "$W_FLAG" == "y" ||
"$build_extras_ok" == "y" ]]; then