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 2014 Garrett D'Amore <garrett@damore.org>
30 # Based on the nightly script from the integration folks,
31 # Mostly modified and owned by mike_s.
32 # Changes also by kjc, dmk.
34 # -i on the command line, means fast options, so when it's on the
35 # command line (only), check builds are skipped no matter what
36 # the setting of their individual flags are in NIGHTLY_OPTIONS.
38 # OPTHOME may be set in the environment to override /opt
42 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
43 # under certain circumstances, which can really screw things up; unset it.
47 # Get the absolute path of the nightly script that the user invoked. This
48 # may be a relative path, and we need to do this before changing directory.
49 nightly_path
=`whence $0`
52 # Keep track of where we found nightly so we can invoke the matching
53 # which_scm script. If that doesn't work, don't go guessing, just rely
54 # on the $PATH settings, which will generally give us either /opt/onbld
55 # or the user's workspace.
57 WHICH_SCM
=$
(dirname $nightly_path)/which_scm
58 if [[ ! -x $WHICH_SCM ]]; then
64 print
-u2 "nightly: $*"
69 # Function to do a DEBUG and non-DEBUG build. Needed because we might
70 # need to do another for the source build, and since we only deliver DEBUG or
75 function normal_build
{
77 typeset orig_p_FLAG
="$p_FLAG"
79 if [ "$D_FLAG" = "n" ]; then
80 set_non_debug_build_flags
91 # usage: run_hook HOOKNAME ARGS...
93 # If variable "$HOOKNAME" is defined, insert a section header into
94 # our logs and then run the command with ARGS
98 eval HOOKCMD
=\$
$HOOKNAME
101 if [ -n "$HOOKCMD" ]; then
103 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
104 ( $HOOKCMD "$@" 2>&1 )
105 if [ "$?" -ne 0 ]; then
106 # Let exit status propagate up
109 ) |
tee -a $mail_msg_file >> $LOGFILE
111 if [ -f $TMPDIR/abort
]; then
113 echo "\nAborting at request of $HOOKNAME" |
114 tee -a $mail_msg_file >> $LOGFILE
120 # Return library search directive as function of given root.
122 echo "-L$1/lib -L$1/usr/lib"
125 # Return header search directive as function of given root.
127 echo "-I$1/usr/include"
131 # Function to do the build, including package generation.
133 # - LABEL is used to tag build output.
137 INSTALLOG
=install-
${MACH}
142 export ENVLDLIBS1
=`myldlibs $ROOT`
143 export ENVCPPFLAGS1
=`myheaders $ROOT`
147 # Before we build anything via dmake, we need to install
148 # bmake-ified headers to the proto area
150 bmake_build_step_user_dir
$CODEMGR_WS/include all
151 bmake_build_step_user_dir
$CODEMGR_WS/include
install
154 # Build the legacy part of the source
156 echo "\n==== Building legacy source at `date` ($LABEL) ====\n" \
159 rm -f $SRC/${INSTALLOG}.out
161 /bin
/time $MAKE -e install 2>&1 | \
162 tee -a $SRC/${INSTALLOG}.out
>> $LOGFILE
164 echo "\n==== Legacy build errors ($LABEL) ====\n" >> $mail_msg_file
165 egrep -e "(^(${MAKE}:|\*\*\*)|[ ]error:[ \n])" \
166 ${SRC}/${INSTALLOG}.out |
tee $TMPDIR/build_errs \
168 if [[ -s $TMPDIR/build_errs
]]; then
169 sed 's,$, returned non-zero exit status,' \
170 $TMPDIR/build_errs
>> $mail_msg_file
174 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
176 if [ "$?" = "0" ]; then
182 # Build the new part of the source
184 bmake_build_step_user all
185 bmake_build_step_user
install
187 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
188 cat $SRC/${INSTALLOG}.out \
189 $SRC/${INSTALLOG}-bmake-all.out \
190 $SRC/${INSTALLOG}-bmake-install.out \
191 |
egrep -i warning
: \
193 |
egrep -v "symbol (\`|')timezone' has differing types:" \
194 |
egrep -v "parameter <PSTAMP> set to" \
195 |
egrep -v "Ignoring unknown host" \
196 |
egrep -v "redefining segment flags attribute for" \
197 |
tee $TMPDIR/build_warnings
>> $mail_msg_file
198 if [[ -s $TMPDIR/build_warnings
]]; then
203 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
206 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
207 echo "dmake install:" >>$mail_msg_file
208 tail -3 $SRC/${INSTALLOG}.out
>>$mail_msg_file
209 echo >>$mail_msg_file
210 echo "bmake all:" >>$mail_msg_file
211 tail -3 $SRC/${INSTALLOG}-bmake-all.out
>>$mail_msg_file
212 echo >>$mail_msg_file
213 echo "bmake install:" >>$mail_msg_file
214 tail -3 $SRC/${INSTALLOG}-bmake-install.out
>>$mail_msg_file
216 if [ "$i_FLAG" = "n" ]; then
217 rm -f $SRC/${NOISE}.ref
218 if [ -f $SRC/${NOISE}.out
]; then
219 mv $SRC/${NOISE}.out
$SRC/${NOISE}.ref
221 cat $SRC/${INSTALLOG}.out \
222 $SRC/${INSTALLOG}-bmake-all.out \
223 $SRC/${INSTALLOG}-bmake-install.out \
226 |
egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
229 |
egrep -v '^LD_LIBRARY_PATH=' \
230 |
egrep -v 'ar: creating' \
231 |
egrep -v 'ar: writing' \
232 |
egrep -v 'conflicts:' \
233 |
egrep -v ':saved created' \
234 |
egrep -v '^stty.*c:' \
235 |
egrep -v '^mfgname.c:' \
236 |
egrep -v '^uname-i.c:' \
237 |
egrep -v '^volumes.c:' \
238 |
egrep -v 'tsort: INFORM:' \
239 |
egrep -v 'stripalign:' \
240 |
egrep -v 'chars, width' \
241 |
egrep -v "symbol (\`|')timezone' has differing types:" \
242 |
egrep -v 'PSTAMP' \
243 |
egrep -v '^Manifying' \
244 |
egrep -v 'Ignoring unknown host' \
245 |
egrep -v 'Processing method:' \
246 |
egrep -v '^Writing' \
247 |
egrep -v 'spellin1:' \
248 |
egrep -v '^adding:' \
249 |
egrep -v "^echo 'msgid" \
250 |
egrep -v '^echo ' \
252 |
egrep -v '^Adding file:' \
253 |
egrep -v 'CLASSPATH=' \
254 |
egrep -v '\/var\/mail\/:saved' \
255 |
egrep -v -- '-DUTS_VERSION=' \
256 |
egrep -v '^Running Mkbootstrap' \
257 |
egrep -v '^Applet length read:' \
258 |
egrep -v 'bytes written:' \
259 |
egrep -v '^File:SolarisAuthApplet.bin' \
260 |
egrep -v -i 'jibversion' \
261 |
egrep -v '^Output size:' \
262 |
egrep -v '^Solo size statistics:' \
263 |
egrep -v '^Using ROM API Version' \
264 |
egrep -v '^Zero Signature length:' \
265 |
egrep -v '^Note \(probably harmless\):' \
268 |
egrep -v '^cc1: note: -fwritable-strings' \
269 |
egrep -v 'svccfg-native -s svc:/' \
270 |
sort |
uniq >$SRC/${NOISE}.out
271 if [ ! -f $SRC/${NOISE}.ref
]; then
272 cp $SRC/${NOISE}.out
$SRC/${NOISE}.ref
274 echo "\n==== Build noise differences ($LABEL) ====\n" \
276 diff $SRC/${NOISE}.ref
$SRC/${NOISE}.out
>>$mail_msg_file
282 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
283 if [ -d $SRC/pkg
]; then
284 echo "\n==== Creating $LABEL packages at `date` ====\n" \
286 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
287 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
288 mkdir
-p $PKGARCHIVE >> "$LOGFILE" 2>&1
290 rm -f $SRC/pkg
/${INSTALLOG}.out
292 /bin
/time $MAKE -e install 2>&1 | \
293 tee -a $SRC/pkg
/${INSTALLOG}.out
>> $LOGFILE
295 echo "\n==== package build errors ($LABEL) ====\n" \
298 egrep "${MAKE}|ERROR|WARNING" $SRC/pkg
/${INSTALLOG}.out | \
301 egrep -v "Ignoring unknown host" | \
302 tee $TMPDIR/package
>> $mail_msg_file
303 if [[ -s $TMPDIR/package
]]; then
309 # Handle it gracefully if -p was set but there so
312 echo "\n==== No $LABEL packages to build ====\n" \
316 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
321 # Build and install the onbld tools.
323 # usage: build_tools DESTROOT
325 # returns non-zero status if the build was successful.
327 function build_tools
{
330 INSTALLOG
=install-
${MACH}
332 echo "\n==== Building tools at `date` ====\n" \
335 rm -f ${TOOLS}/${INSTALLOG}.out
337 /bin
/time $MAKE TOOLS_PROTO
=${DESTROOT} -e install 2>&1 | \
338 tee -a ${TOOLS}/${INSTALLOG}.out
>> $LOGFILE
340 echo "\n==== Tools build errors ====\n" >> $mail_msg_file
342 egrep ":" ${TOOLS}/${INSTALLOG}.out |
343 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
344 egrep -v "Ignoring unknown host" | \
345 egrep -v warning |
tee $TMPDIR/tools_errors
>> $mail_msg_file
347 if [[ -s $TMPDIR/tools_errors
]]; then
354 # Set up to use locally installed tools.
356 # usage: use_tools TOOLSROOT
362 # If we're not building ON workspace, then the TOOLSROOT
363 # settings here are clearly ignored by the workspace
364 # makefiles, prepending nonexistent directories to PATH is
365 # harmless, and we clearly do not wish to override
368 # If we're building an ON workspace, then the prepended PATH
369 # elements should supercede the preexisting ONBLD_TOOLS paths,
370 # and we want to override ONBLD_TOOLS to catch the tools that
371 # don't have specific path env vars here.
373 # So the only conditional behavior is overriding ONBLD_TOOLS,
374 # and we check for "an ON workspace" by looking for
375 # ${TOOLSROOT}/opt/onbld.
378 STABS
=${TOOLSROOT}/opt
/onbld
/bin
/${MACH}/stabs
380 CTFSTABS
=${TOOLSROOT}/opt
/onbld
/bin
/${MACH}/ctfstabs
382 GENOFFSETS
=${TOOLSROOT}/opt
/onbld
/bin
/genoffsets
386 PATH
="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}"
387 PATH
="${TOOLSROOT}/opt/onbld/bin:${PATH}"
390 if [ -d "${TOOLSROOT}/opt/onbld" ]; then
391 ONBLD_TOOLS
=${TOOLSROOT}/opt
/onbld
395 echo "\n==== New environment settings. ====\n" >> $LOGFILE
396 echo "STABS=${STABS}" >> $LOGFILE
397 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
398 echo "PATH=${PATH}" >> $LOGFILE
399 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
403 # wrapper over wsdiff.
404 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
413 echo "\n==== Getting object changes since last build at `date`" \
414 "($label) ====\n" |
tee -a $LOGFILE >> $mail_msg_file
415 $wsdiff -s -r ${TMPDIR}/wsdiff.results
$oldproto $newproto 2>&1 | \
416 tee -a $LOGFILE >> $mail_msg_file
417 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
418 tee -a $LOGFILE >> $mail_msg_file
422 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
426 function set_non_debug_build_flags
{
427 export RELEASE_BUILD
; RELEASE_BUILD
=
432 function set_debug_build_flags
{
441 if [ "$OPTHOME" = "" ]; then
446 USAGE
='Usage: nightly [-in] [-V VERS ] <env_file>
449 -i Fast incremental options (no clobber, check)
450 -V VERS set the build version string to VERS
452 <env_file> file in Bourne shell syntax that sets and exports
453 variables that configure the operation of this script and many of
454 the scripts this one calls.
456 non-DEBUG is the default build type. Build options can be set in the
457 NIGHTLY_OPTIONS variable in the <env_file> as follows:
459 -A check for ABI differences in .so files
460 -C check for cstyle/hdrchk errors
461 -D do a build with DEBUG on
462 -G gate keeper default group of options (-au)
463 -I integration engineer default group of options (-ampu)
464 -M do not run pmodes (safe file permission checker)
465 -N do not run protocmp
466 -R default group of options for building a release (-mp)
467 -U update proto area in the parent
468 -V VERS set the build version string to VERS
469 -f find unreferenced files
470 -i do an incremental build (no "make clobber")
471 -m send mail to $MAILTO at end of build
473 -r check ELF runtime attributes in the proto area
474 -u update proto_list_$MACH and friends in the parent workspace;
475 when used with -f, also build an unrefmaster.out in the parent
476 -w report on differences between previous and current proto areas
479 # A log file will be generated under the name $LOGFILE
480 # for partially completed build and log.`date '+%F'`
481 # in the same directory for fully completed builds.
484 # default values for low-level FLAGS; G I R are group FLAGS
489 i_FLAG
=n
; i_CMD_LINE_FLAG
=n
507 while getopts +iV
:W FLAG
510 i
) i_FLAG
=y
; i_CMD_LINE_FLAG
=y
523 # correct argument count after options
524 shift `expr $OPTIND - 1`
526 # test that the path to the environment-setting file was given
527 if [ $# -ne 1 ]; then
535 LC_ALL
=C
; export LC_ALL
536 LC_COLLATE
=C
; export LC_COLLATE
537 LC_CTYPE
=C
; export LC_CTYPE
538 LC_MESSAGES
=C
; export LC_MESSAGES
539 LC_MONETARY
=C
; export LC_MONETARY
540 LC_NUMERIC
=C
; export LC_NUMERIC
541 LC_TIME
=C
; export LC_TIME
543 # clear environment variables we know to be bad for the build
545 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
546 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
547 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
548 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
549 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
550 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
551 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
552 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
553 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
554 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
555 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
556 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
557 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
558 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
559 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
560 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
561 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
562 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
563 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
564 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
576 # To get ONBLD_TOOLS from the environment, it must come from the env file.
577 # If it comes interactively, it is generally TOOLS_PROTO, which will be
578 # clobbered before the compiler version checks, which will therefore fail.
583 # Setup environmental variables
586 if [[ $1 = */* ]]; then
592 echo "Cannot find env file as either $1"
596 # Check if we have sufficient data to continue...
597 [[ -v CODEMGR_WS
]] || \
598 fatal_error
"Error: Variable CODEMGR_WS not set."
599 [[ -d "${CODEMGR_WS}" ]] || \
600 fatal_error
"Error: ${CODEMGR_WS} is not a directory."
601 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
602 fatal_error
"Error: ${CODEMGR_WS}/usr/src/Makefile not found."
605 # place ourselves in a new task, respecting BUILD_PROJECT if set.
607 if [ -z "$BUILD_PROJECT" ]; then
608 /usr
/bin
/newtask
-c $$
610 /usr
/bin
/newtask
-c $$
-p $BUILD_PROJECT
613 ps
-o taskid
= -p $$ |
read build_taskid
614 ps
-o project
= -p $$ |
read build_project
617 # See if NIGHTLY_OPTIONS is set
619 if [ "$NIGHTLY_OPTIONS" = "" ]; then
620 NIGHTLY_OPTIONS
="-aBm"
624 # Note: changes to the option letters here should also be applied to the
625 # bldenv script. `d' is listed for backward compatibility.
627 NIGHTLY_OPTIONS
=-${NIGHTLY_OPTIONS#-}
629 while getopts +ABCDdfGIiMmNpRrwW FLAG
$NIGHTLY_OPTIONS
635 ;; # old version of D
671 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
672 MAILTO
=`/usr/xpg4/bin/id -un`
676 PATH
="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
677 PATH
="$PATH:/usr/bin:/usr/sbin:/usr/ucb"
678 PATH
="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:.:$OPTHOME/SUNWspro/bin"
681 # roots of source trees, both relative to $SRC and absolute.
685 PROTOCMPTERSE
="protocmp.terse -gu"
687 # have we set RELEASE_DATE in our env file?
688 if [ -z "$RELEASE_DATE" ]; then
689 RELEASE_DATE
=$
(LC_ALL
=C
date +"%B %Y")
691 BUILD_DATE
=$
(LC_ALL
=C
date +%Y-
%b-
%d
)
692 BASEWSDIR
=$
(basename $CODEMGR_WS)
693 DEV_CM
="\"@(#)illumos Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
694 RELEASE_MICRO
=$
(( ($
(date +%Y
) * 12 + $
(date +%m
) - 1) - (2010 * 12 + 8 - 1) ))
696 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
697 # by avoiding repeated shell invocations to evaluate Makefile.master
699 export POUND_SIGN RELEASE_DATE DEV_CM RELEASE_MICRO
701 maketype
="distributed"
702 if [[ -z "$MAKE" ]]; then
704 elif [[ ! -x "$MAKE" ]]; then
705 echo "\$MAKE is set to garbage in the environment"
712 if [[ $DMAKE_MAX_JOBS != +([0-9]) ||
$DMAKE_MAX_JOBS -eq 0 ]]
715 if [[ -f $HOME/.
make.machines
]]
717 # Note: there is a hard tab and space character in the []s
719 egrep -i "^[ ]*$hostname[ \.]" \
720 $HOME/.
make.machines |
read host jobs
724 if [[ $maxjobs != +([0-9]) ||
$maxjobs -eq 0 ]]
730 export DMAKE_MAX_JOBS
=$maxjobs
736 if [ -z "${ROOT}" ]; then
737 echo "ROOT must be set."
742 # if -V flag was given, reset VERSION to V_ARG
744 if [ "$V_FLAG" = "y" ]; then
748 TMPDIR
="/tmp/nightly.tmpdir.$$"
751 mkdir
-p $TMPDIR ||
exit 1
755 # Tools should only be built non-DEBUG. Keep track of the tools proto
756 # area path relative to $TOOLS, because the latter changes in an
759 # TOOLS_PROTO is included below for builds other than usr/src/tools
760 # that look for this location. For usr/src/tools, this will be
761 # overridden on the $MAKE command line in build_tools().
764 TOOLS_PROTO_REL
=proto
/root_
${MACH}-nd
765 TOOLS_PROTO
=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
767 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
769 # create directories that are automatically removed if the nightly script
770 # fails to start correctly
774 while [ ! -d $dir ]; do
780 for dir
in $toadd; do
782 newlist
="$dir $newlist"
785 [ -z "$torm" ] ||
rmdir $torm
789 newdirlist
="$newlist $newdirlist"
794 [ -d $CODEMGR_WS ] || newdir
$CODEMGR_WS ||
exit 1
796 # since this script assumes the build is from full source, it nullifies
797 # variables likely to have been set by a "ws" script; nullification
798 # confines the search space for headers and libraries to the proto area
799 # built from this immediate source.
808 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
809 ENVLDLIBS1 ENVLDLIBS2
812 # Juggle the logs and optionally send mail on completion.
815 function logshuffle
{
816 LLOG
="$ATLOG/log.`date '+%F.%H:%M'`"
817 if [ -f $LLOG -o -d $LLOG ]; then
823 if [ "$build_ok" = "y" ]; then
824 mv $ATLOG/proto_list_
${MACH} $LLOG
826 if [ -f $ATLOG/proto_list_tools_
${MACH} ]; then
827 mv $ATLOG/proto_list_tools_
${MACH} $LLOG
830 if [ -f $TMPDIR/wsdiff.results
]; then
831 mv $TMPDIR/wsdiff.results
$LLOG
834 if [ -f $TMPDIR/wsdiff-nd.results
]; then
835 mv $TMPDIR/wsdiff-nd.results
$LLOG
840 # Now that we're about to send mail, it's time to check the noise
841 # file. In the event that an error occurs beyond this point, it will
842 # be recorded in the nightly.log file, but nowhere else. This would
843 # include only errors that cause the copying of the noise log to fail
844 # or the mail itself not to be sent.
848 if [ -s $build_noise_file ]; then
849 echo "\n==== Nightly build noise ====\n" |
850 tee -a $LOGFILE >>$mail_msg_file
851 cat $build_noise_file >>$LOGFILE
852 cat $build_noise_file >>$mail_msg_file
853 echo |
tee -a $LOGFILE >>$mail_msg_file
855 rm -f $build_noise_file
869 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
873 NIGHTLY_STATUS
=$state
874 export NIGHTLY_STATUS
876 run_hook POST_NIGHTLY
$state
877 run_hook SYS_POST_NIGHTLY
$state
880 # mailx(1) sets From: based on the -r flag
884 if [[ -n "${MAILFROM}" ]]; then
885 mailx_r
="-r ${MAILFROM}"
888 cat $build_time_file $build_environ_file $mail_msg_file \
890 if [ "$m_FLAG" = "y" ]; then
891 cat ${LLOG}/mail_msg |
/usr
/bin
/mailx
${mailx_r} -s \
892 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
900 # Remove the temporary files on any exit
906 while [ $# -gt 0 ]; do
913 function cleanup_signal
{
915 # this will trigger cleanup(), above.
920 trap cleanup_signal
1 2 3 15
925 # Create mail_msg_file
927 mail_msg_file
="${TMPDIR}/mail_msg"
929 build_time_file
="${TMPDIR}/build_time"
930 build_environ_file
="${TMPDIR}/build_environ"
931 touch $build_environ_file
935 # Move old LOGFILE aside
937 if [ -f $LOGFILE ]; then
938 mv -f $LOGFILE ${LOGFILE}-
945 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
946 |
tee -a $LOGFILE > $build_time_file
948 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
949 tee -a $mail_msg_file >> $LOGFILE
951 # make sure we log only to the nightly build file
952 build_noise_file
="${TMPDIR}/build_noise"
953 exec </dev
/null
>$build_noise_file 2>&1
955 run_hook SYS_PRE_NIGHTLY
958 echo "\n==== list of environment variables ====\n" >> $LOGFILE
961 echo "\n==== Nightly argument issues ====\n" |
tee -a $mail_msg_file >> $LOGFILE
963 if [ "$N_FLAG" = "y" ]; then
964 if [ "$p_FLAG" = "y" ]; then
965 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
966 WARNING: the p option (create packages) is set, but so is the N option (do
967 not run protocmp); this is dangerous; you should unset the N option
970 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
971 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
974 echo "" |
tee -a $mail_msg_file >> $LOGFILE
977 if [ "$f_FLAG" = "y" ]; then
978 if [ "$i_FLAG" = "y" ]; then
979 echo "WARNING: the -f flag cannot be used during incremental" \
980 "builds; ignoring -f\n" |
tee -a $mail_msg_file >> $LOGFILE
983 if [ "${p_FLAG}" != "y" ]; then
984 echo "WARNING: the -f flag requires -p;" \
985 "ignoring -f\n" |
tee -a $mail_msg_file >> $LOGFILE
990 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
991 echo "WARNING: -w specified, but $ROOT does not exist;" \
992 "ignoring -w\n" |
tee -a $mail_msg_file >> $LOGFILE
996 echo "\n==== Build version ====\n" |
tee -a $mail_msg_file >> $LOGFILE
997 echo $VERSION |
tee -a $mail_msg_file >> $LOGFILE
999 # Save the current proto area if we're comparing against the last build
1000 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1001 if [ -d "$ROOT.prev" ]; then
1007 # Echo the SCM types of $CODEMGR_WS
1008 function child_wstype
{
1009 typeset scm_type junk
1011 # Probe CODEMGR_WS to determine its type
1012 if [[ -d $CODEMGR_WS ]]; then
1013 $WHICH_SCM |
read scm_type junk ||
exit 1
1026 function run_bmake
{
1027 /bin
/time env
-i PATH
=${GCC_ROOT}/bin
:/usr
/bin \
1028 bmake
-j $DMAKE_MAX_JOBS \
1033 # usage: bmake_build_step_args <dir> <target> <args...>
1034 function bmake_build_step_args
{
1038 echo "\n==== \`bmake $1\` at `date` ($LABEL) ====\n" >> $LOGFILE
1040 rm -f $SRC/${INSTALLOG}-bmake-${1}.out
1041 run_bmake
-C $D "$@" | \
1042 tee -a $SRC/${INSTALLOG}-bmake-${1}.out
>> $LOGFILE
1044 echo "\n==== \`bmake $1\` errors ($LABEL) ====\n" >> $mail_msg_file
1045 egrep -e "(^(bmake[^\s]*:|\*\*\*)|[ ]error:[ \n])" \
1046 ${SRC}/${INSTALLOG}-bmake-${1}.out | \
1047 tee $TMPDIR/build_errs-
${1} >> $mail_msg_file
1048 if [ -s $TMPDIR/build_errs-
${1} ] ; then
1049 sed 's,$, returned non-zero exit status,' \
1050 $TMPDIR/build_errs-
${1} >> $mail_msg_file
1059 # usage: bmake_build_step_user <target>
1060 function bmake_build_step_user
{
1061 bmake_build_step_args
$CODEMGR_WS $1 \
1062 DESTDIR
=$ROOT MK_INSTALL_AS_USER
=yes
1065 # usage: bmake_build_step_user_dir <dir> <target>
1066 function bmake_build_step_user_dir
{
1067 bmake_build_step_args
$1 $2 \
1068 DESTDIR
=$ROOT MK_INSTALL_AS_USER
=yes
1071 SCM_TYPE
=$
(child_wstype
)
1074 [[ -v CODEMGR_WS
]] || fatal_error
"Error: Variable CODEMGR_WS not set."
1075 [[ -d "${CODEMGR_WS}" ]] || fatal_error
"Error: ${CODEMGR_WS} is not a directory."
1076 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error
"Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1079 # Generate the cfgparam files
1081 # We have to do this before running *any* make commands.
1083 bmake_build_step_args
$CODEMGR_WS gen-config || build_extras_ok
=n
1086 # Decide whether to clobber
1088 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1089 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1092 # remove old clobber file
1093 rm -f $SRC/clobber.out
1094 rm -f $SRC/clobber-
${MACH}.out
1096 # Remove all .make.state* files, just in case we are restarting
1097 # the build after having interrupted a previous 'make clobber'.
1098 find . \
( -name SCCS
-o -name .hg
-o -name .svn
-o -name .git \
1099 -o -name 'interfaces.*' \
) -prune \
1100 -o -name '.make.*' -print |
xargs rm -f
1102 $MAKE -ek clobber
2>&1 |
tee -a $SRC/clobber-
${MACH}.out
>> $LOGFILE
1103 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1104 grep "$MAKE:" $SRC/clobber-
${MACH}.out |
1105 egrep -v "Ignoring unknown host" | \
1106 tee $TMPDIR/clobber_errs
>> $mail_msg_file
1108 if [[ -s $TMPDIR/clobber_errs
]]; then
1112 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1114 rm -f ${TOOLS}/clobber-
${MACH}.out
1115 $MAKE TOOLS_PROTO
=$TOOLS_PROTO -ek clobber
2>&1 | \
1116 tee -a ${TOOLS}/clobber-
${MACH}.out
>> $LOGFILE
1117 echo "\n==== Make tools clobber ERRORS ====\n" \
1119 grep "$MAKE:" ${TOOLS}/clobber-
${MACH}.out \
1121 if (( $?
== 0 )); then
1124 rm -rf ${TOOLS_PROTO}
1125 mkdir
-p ${TOOLS_PROTO}
1128 echo "\n\nClearing $roots" >> "$LOGFILE"
1131 # Get back to a clean workspace as much as possible to catch
1132 # problems that only occur on fresh workspaces.
1133 # Remove all .make.state* files, libraries, and .o's that may
1134 # have been omitted from clobber. A couple of libraries are
1135 # under source code control, so leave them alone.
1136 # We should probably blow away temporary directories too.
1138 find $relsrcdirs \
( -name SCCS
-o -name .hg
-o -name .svn \
1139 -o -name .git
-o -name 'interfaces.*' \
) -prune -o \
1140 \
( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1141 -name '*.o' \
) -print | \
1142 grep -v 'tools/ctf/dwarf/.*/libdwarf' |
xargs rm -f
1143 echo "\n==== bmake cleandir ====\n" >> $LOGFILE
1144 run_bmake
-C $CODEMGR_WS cleandir
>> $LOGFILE 2>&1
1146 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1149 echo "\n==== Build environment ====\n" |
tee -a $build_environ_file >> $LOGFILE
1152 whence uname |
tee -a $build_environ_file >> $LOGFILE
1153 uname
-a 2>&1 |
tee -a $build_environ_file >> $LOGFILE
1154 echo |
tee -a $build_environ_file >> $LOGFILE
1157 whence
$MAKE |
tee -a $build_environ_file >> $LOGFILE
1158 $MAKE -v |
tee -a $build_environ_file >> $LOGFILE
1159 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
1160 tee -a $build_environ_file >> $LOGFILE
1163 # Report the compiler versions.
1166 if [[ ! -f $SRC/Makefile
]]; then
1168 echo "\nUnable to find \"Makefile\" in $SRC." | \
1169 tee -a $build_environ_file >> $LOGFILE
1173 # Check that we're running a capable link-editor
1174 whence ld |
tee -a $build_environ_file >> $LOGFILE
1176 echo $LDVER |
tee -a $build_environ_file >> $LOGFILE
1177 LDVER
=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1178 if [ `expr $LDVER \< 422` -eq 1 ]; then
1179 echo "The link-editor needs to be at version 422 or higher to build" | \
1180 tee -a $build_environ_file >> $LOGFILE
1181 echo "the latest stuff. Hope your build works." | \
1182 tee -a $build_environ_file >> $LOGFILE
1186 # Build and use the workspace's tools if requested
1188 set_non_debug_build_flags
1190 build_tools
${TOOLS_PROTO}
1191 if (( $?
!= 0 )); then
1194 use_tools
$TOOLS_PROTO
1197 # timestamp the start of the normal build; the findunref tool uses it.
1198 touch $SRC/.build.tstamp
1203 BINARCHIVE
=${CODEMGR_WS}/bin-
${MACH}.
cpio.Z
1205 if [ "$build_ok" = "y" ]; then
1206 echo "\n==== Creating protolist system file at `date` ====" \
1208 protolist
$ROOT > $ATLOG/proto_list_
${MACH}
1209 echo "==== protolist system file created at `date` ====\n" \
1212 if [ "$N_FLAG" != "y" ]; then
1217 if [ -f "$f" ]; then
1224 if [ -d "$SRC/pkg" ]; then
1225 f2
="$f2 exceptions/packaging"
1229 if [ -f "$f" ]; then
1235 if [ "$N_FLAG" != "y" -a -d $SRC/pkg
]; then
1236 echo "\n==== Validating manifests against proto area ====\n" \
1238 ( cd $SRC/pkg
; $MAKE -e protocmp ROOT
="$ROOT" ) | \
1239 tee $TMPDIR/protocmp_noise
>> $mail_msg_file
1240 if [[ -s $TMPDIR/protocmp_noise
]]; then
1247 # ELF verification: ABI (-A) and runtime (-r) checks
1249 if [[ ($build_ok = y
) && (($A_FLAG = y
) ||
($r_FLAG = y
)) ]]; then
1250 # Directory ELF-data.$MACH holds the files produced by these tests.
1251 elf_ddir
=$SRC/ELF-data.
$MACH
1253 # If there is a previous ELF-data backup directory, remove it. Then,
1254 # rotate current ELF-data directory into its place and create a new
1256 rm -rf $elf_ddir.ref
1257 if [[ -d $elf_ddir ]]; then
1258 mv $elf_ddir $elf_ddir.ref
1262 # Call find_elf to produce a list of the ELF objects in the proto area.
1263 # This list is passed to check_rtime and interface_check, preventing
1264 # them from separately calling find_elf to do the same work twice.
1265 find_elf
-fr $ROOT > $elf_ddir/object_list
1267 if [[ $A_FLAG = y
]]; then
1268 echo "\n==== Check versioning and ABI information ====\n" | \
1269 tee -a $LOGFILE >> $mail_msg_file
1271 # Produce interface description for the proto. Report errors.
1272 interface_check
-o -w $elf_ddir -f object_list \
1273 -i interface
-E interface.err
1274 if [[ -s $elf_ddir/interface.err
]]; then
1275 tee -a $LOGFILE < $elf_ddir/interface.err \
1280 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1281 # description file to that from the baseline gate. Issue a
1282 # warning if the baseline is not present, and keep going.
1283 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1284 base_ifile
="$ELF_DATA_BASELINE_DIR/interface"
1286 echo "\n==== Compare versioning and ABI information" \
1287 "to baseline ====\n" | \
1288 tee -a $LOGFILE >> $mail_msg_file
1289 echo "Baseline: $base_ifile\n" >> $LOGFILE
1291 if [[ -f $base_ifile ]]; then
1292 interface_cmp
-d -o $base_ifile \
1293 $elf_ddir/interface
> $elf_ddir/interface.
cmp
1294 if [[ -s $elf_ddir/interface.
cmp ]]; then
1295 echo |
tee -a $LOGFILE >> $mail_msg_file
1297 $elf_ddir/interface.
cmp \
1302 echo "baseline not available. comparison" \
1304 tee -a $LOGFILE >> $mail_msg_file
1310 if [[ $r_FLAG = y
]]; then
1311 echo "\n==== Check ELF runtime attributes ====\n" | \
1312 tee -a $LOGFILE >> $mail_msg_file
1314 # If we're doing a DEBUG build the proto area will be left
1315 # with debuggable objects, thus don't assert -s.
1316 if [[ $D_FLAG = y
]]; then
1321 check_rtime
-i -m -v $rtime_sflag -o -w $elf_ddir \
1322 -D object_list
-f object_list
-E runtime.err \
1324 if (( $?
!= 0 )); then
1328 # check_rtime -I output needs to be sorted in order to
1329 # compare it to that from previous builds.
1330 sort $elf_ddir/runtime.attr.raw
> $elf_ddir/runtime.attr
1331 rm $elf_ddir/runtime.attr.raw
1334 if [[ -s $elf_ddir/runtime.err
]]; then
1335 tee -a $LOGFILE < $elf_ddir/runtime.err \
1340 # If there is an ELF-data directory from a previous build,
1341 # then diff the attr files. These files contain information
1342 # about dependencies, versioning, and runpaths. There is some
1343 # overlap with the ABI checking done above, but this also
1344 # flushes out non-ABI interface differences along with the
1345 # other information.
1346 echo "\n==== Diff ELF runtime attributes" \
1347 "(since last build) ====\n" | \
1348 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
1350 if [[ -f $elf_ddir.ref
/runtime.attr
]]; then
1351 diff $elf_ddir.ref
/runtime.attr \
1352 $elf_ddir/runtime.attr \
1358 # "make check" begins
1360 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
1361 # remove old check.out
1362 rm -f $SRC/check.out
1364 rm -f $SRC/check-
${MACH}.out
1366 $MAKE -ek check ROOT
="$ROOT" 2>&1 |
tee -a $SRC/check-
${MACH}.out \
1368 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
1370 grep ":" $SRC/check-
${MACH}.out |
1371 egrep -v "Ignoring unknown host" | \
1372 sort |
uniq |
tee $TMPDIR/check_errors
>> $mail_msg_file
1374 if [[ -s $TMPDIR/check_errors
]]; then
1378 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
1381 echo "\n==== Find core files ====\n" | \
1382 tee -a $LOGFILE >> $mail_msg_file
1384 find $abssrcdirs -name core
-a -type f
-exec file {} \
; | \
1385 tee -a $LOGFILE >> $mail_msg_file
1387 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
1388 echo "\n==== Diff unreferenced files (since last build) ====\n" \
1389 |
tee -a $LOGFILE >>$mail_msg_file
1390 rm -f $SRC/unref-
${MACH}.ref
1391 if [ -f $SRC/unref-
${MACH}.out
]; then
1392 mv $SRC/unref-
${MACH}.out
$SRC/unref-
${MACH}.ref
1395 findunref
-S $SCM_TYPE -t $SRC/.build.tstamp
-s usr
$CODEMGR_WS \
1396 ${TOOLS}/findunref
/exception_list
2>> $mail_msg_file | \
1397 sort > $SRC/unref-
${MACH}.out
1399 if [ ! -f $SRC/unref-
${MACH}.ref
]; then
1400 cp $SRC/unref-
${MACH}.out
$SRC/unref-
${MACH}.ref
1403 diff $SRC/unref-
${MACH}.ref
$SRC/unref-
${MACH}.out
>>$mail_msg_file
1406 # Verify that the usual lists of files, such as exception lists,
1407 # contain only valid references to files. If the build has failed,
1408 # then don't check the proto area.
1409 CHECK_PATHS
=${CHECK_PATHS:-y}
1410 if [ "$CHECK_PATHS" = y
-a "$N_FLAG" != y
]; then
1411 echo "\n==== Check lists of files ====\n" |
tee -a $LOGFILE \
1414 [ "$build_ok" = y
] && arg
=
1415 checkpaths
$arg $ROOT > $SRC/check-paths.out
2>&1
1416 if [[ -s $SRC/check-paths.out
]]; then
1417 tee -a $LOGFILE < $SRC/check-paths.out
>> $mail_msg_file
1422 if [ "$M_FLAG" != "y" -a "$build_ok" = y
]; then
1423 echo "\n==== Impact on file permissions ====\n" \
1427 for d
in $abssrcdirs; do
1428 if [ -d "$d/pkg" ]; then
1433 if [ -n "$abspkg" ]; then
1434 for d
in "$abspkg"; do
1435 ( cd $d/pkg
; $MAKE -e pmodes
) >> $mail_msg_file
1440 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
1441 if [[ "$D_FLAG" = y
]]; then
1442 do_wsdiff DEBUG
$ROOT.prev
$ROOT
1444 do_wsdiff non-DEBUG
$ROOT.prev
$ROOT
1449 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
1450 tee -a $LOGFILE >> $build_time_file
1456 elapsed_time
=$SECONDS
1457 ((hours
= elapsed_time
/ 3600 ))
1458 ((minutes
= elapsed_time
/ 60 % 60))
1459 ((seconds
= elapsed_time
% 60))
1461 echo "\n==== Total build time ====" | \
1462 tee -a $LOGFILE >> $build_time_file
1463 echo "\nreal ${hours}:${minutes}:${seconds}" | \
1464 tee -a $LOGFILE >> $build_time_file
1467 # All done save for the sweeping up.
1468 # (whichever exit we hit here will trigger the "cleanup" trap which
1469 # optionally sends mail on completion).
1471 if [[ "$build_ok" == "y" ]]; then
1472 if [[ "$W_FLAG" == "y" ||
"$build_extras_ok" == "y" ]]; then