8753 linker errors don't show up in the "mail_msg" file
[unleashed.git] / usr / src / tools / scripts / nightly.sh
blob3da3dd3e4237f38c6dee902c2d9be8432001c90f
1 #!/bin/ksh -p
3 # CDDL HEADER START
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]
20 # CDDL HEADER END
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.
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 # BRINGOVER_WS may be specified in the env file.
35 # The default is the old behavior of CLONE_WS
37 # -i on the command line, means fast options, so when it's on the
38 # command line (only), lint and check builds are skipped no matter what
39 # the setting of their individual flags are in NIGHTLY_OPTIONS.
41 # LINTDIRS can be set in the env file, format is a list of:
43 # /dirname-to-run-lint-on flag
45 # Where flag is: y - enable lint noise diff output
46 # n - disable lint noise diff output
48 # For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
50 # OPTHOME may be set in the environment to override /opt
54 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
55 # under certain circumstances, which can really screw things up; unset it.
57 unset CDPATH
59 # Get the absolute path of the nightly script that the user invoked. This
60 # may be a relative path, and we need to do this before changing directory.
61 nightly_path=`whence $0`
64 # Keep track of where we found nightly so we can invoke the matching
65 # which_scm script. If that doesn't work, don't go guessing, just rely
66 # on the $PATH settings, which will generally give us either /opt/onbld
67 # or the user's workspace.
69 WHICH_SCM=$(dirname $nightly_path)/which_scm
70 if [[ ! -x $WHICH_SCM ]]; then
71 WHICH_SCM=which_scm
74 function fatal_error
76 print -u2 "nightly: $*"
77 exit 1
81 # Function to do a DEBUG and non-DEBUG build. Needed because we might
82 # need to do another for the source build, and since we only deliver DEBUG or
83 # non-DEBUG packages.
85 # usage: normal_build
87 function normal_build {
89 typeset orig_p_FLAG="$p_FLAG"
90 typeset crypto_signer="$CODESIGN_USER"
92 suffix=""
94 # non-DEBUG build begins
96 if [ "$F_FLAG" = "n" ]; then
97 set_non_debug_build_flags
98 CODESIGN_USER="$crypto_signer" \
99 build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
100 else
101 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
104 # non-DEBUG build ends
106 # DEBUG build begins
108 if [ "$D_FLAG" = "y" ]; then
109 set_debug_build_flags
110 CODESIGN_USER="$crypto_signer" \
111 build "DEBUG" "$suffix" "" "$MULTI_PROTO"
112 else
113 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
116 # DEBUG build ends
118 p_FLAG="$orig_p_FLAG"
122 # usage: run_hook HOOKNAME ARGS...
124 # If variable "$HOOKNAME" is defined, insert a section header into
125 # our logs and then run the command with ARGS
127 function run_hook {
128 HOOKNAME=$1
129 eval HOOKCMD=\$$HOOKNAME
130 shift
132 if [ -n "$HOOKCMD" ]; then
134 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
135 ( $HOOKCMD "$@" 2>&1 )
136 if [ "$?" -ne 0 ]; then
137 # Let exit status propagate up
138 touch $TMPDIR/abort
140 ) | tee -a $mail_msg_file >> $LOGFILE
142 if [ -f $TMPDIR/abort ]; then
143 build_ok=n
144 echo "\nAborting at request of $HOOKNAME" |
145 tee -a $mail_msg_file >> $LOGFILE
146 exit 1
151 # Return library search directive as function of given root.
152 function myldlibs {
153 echo "-L$1/lib -L$1/usr/lib"
156 # Return header search directive as function of given root.
157 function myheaders {
158 echo "-I$1/usr/include"
162 # Function to do the build, including package generation.
163 # usage: build LABEL SUFFIX ND MULTIPROTO
164 # - LABEL is used to tag build output.
165 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
166 # open-only vs full tree).
167 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
168 # - If MULTIPROTO is "yes", it means to name the proto area according to
169 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
171 function build {
172 LABEL=$1
173 SUFFIX=$2
174 ND=$3
175 MULTIPROTO=$4
176 INSTALLOG=install${SUFFIX}-${MACH}
177 NOISE=noise${SUFFIX}-${MACH}
178 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
180 ORIGROOT=$ROOT
181 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
183 export ENVLDLIBS1=`myldlibs $ROOT`
184 export ENVCPPFLAGS1=`myheaders $ROOT`
186 this_build_ok=y
188 # Build OS-Networking source
190 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
191 >> $LOGFILE
193 rm -f $SRC/${INSTALLOG}.out
194 cd $SRC
195 /bin/time $MAKE -e install 2>&1 | \
196 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
198 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
199 egrep ":" $SRC/${INSTALLOG}.out |
200 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
201 egrep -v "Ignoring unknown host" | \
202 egrep -v "cc .* -o error " | \
203 egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \
204 >> $mail_msg_file
205 sed -n "/^Undefined[ ]*first referenced$/,/^ld: fatal:/p" \
206 < $SRC/${INSTALLOG}.out >> $mail_msg_file
207 if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then
208 build_ok=n
209 this_build_ok=n
211 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
212 >> $mail_msg_file
213 if [ "$?" = "0" ]; then
214 build_ok=n
215 this_build_ok=n
218 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
219 egrep -i warning: $SRC/${INSTALLOG}.out \
220 | egrep -v '^tic:' \
221 | egrep -v "symbol (\`|')timezone' has differing types:" \
222 | egrep -v "parameter <PSTAMP> set to" \
223 | egrep -v "Ignoring unknown host" \
224 | egrep -v "redefining segment flags attribute for" \
225 | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file
226 if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then
227 build_ok=n
228 this_build_ok=n
231 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
232 >> $LOGFILE
234 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
235 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
237 if [ "$i_FLAG" = "n" ]; then
238 rm -f $SRC/${NOISE}.ref
239 if [ -f $SRC/${NOISE}.out ]; then
240 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
242 grep : $SRC/${INSTALLOG}.out \
243 | egrep -v '^/' \
244 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
245 | egrep -v '^tic:' \
246 | egrep -v '^mcs' \
247 | egrep -v '^LD_LIBRARY_PATH=' \
248 | egrep -v 'ar: creating' \
249 | egrep -v 'ar: writing' \
250 | egrep -v 'conflicts:' \
251 | egrep -v ':saved created' \
252 | egrep -v '^stty.*c:' \
253 | egrep -v '^mfgname.c:' \
254 | egrep -v '^uname-i.c:' \
255 | egrep -v '^volumes.c:' \
256 | egrep -v '^lint library construction:' \
257 | egrep -v 'tsort: INFORM:' \
258 | egrep -v 'stripalign:' \
259 | egrep -v 'chars, width' \
260 | egrep -v "symbol (\`|')timezone' has differing types:" \
261 | egrep -v 'PSTAMP' \
262 | egrep -v '|%WHOANDWHERE%|' \
263 | egrep -v '^Manifying' \
264 | egrep -v 'Ignoring unknown host' \
265 | egrep -v 'Processing method:' \
266 | egrep -v '^Writing' \
267 | egrep -v 'spellin1:' \
268 | egrep -v '^adding:' \
269 | egrep -v "^echo 'msgid" \
270 | egrep -v '^echo ' \
271 | egrep -v '\.c:$' \
272 | egrep -v '^Adding file:' \
273 | egrep -v 'CLASSPATH=' \
274 | egrep -v '\/var\/mail\/:saved' \
275 | egrep -v -- '-DUTS_VERSION=' \
276 | egrep -v '^Running Mkbootstrap' \
277 | egrep -v '^Applet length read:' \
278 | egrep -v 'bytes written:' \
279 | egrep -v '^File:SolarisAuthApplet.bin' \
280 | egrep -v -i 'jibversion' \
281 | egrep -v '^Output size:' \
282 | egrep -v '^Solo size statistics:' \
283 | egrep -v '^Using ROM API Version' \
284 | egrep -v '^Zero Signature length:' \
285 | egrep -v '^Note \(probably harmless\):' \
286 | egrep -v '::' \
287 | egrep -v -- '-xcache' \
288 | egrep -v '^\+' \
289 | egrep -v '^cc1: note: -fwritable-strings' \
290 | egrep -v 'svccfg-native -s svc:/' \
291 | sort | uniq >$SRC/${NOISE}.out
292 if [ ! -f $SRC/${NOISE}.ref ]; then
293 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref
295 echo "\n==== Build noise differences ($LABEL) ====\n" \
296 >>$mail_msg_file
297 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file
301 # Re-sign selected binaries using signing server
302 # (gatekeeper builds only)
304 if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then
305 echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE
306 signing_file="${TMPDIR}/signing"
307 rm -f ${signing_file}
308 export CODESIGN_USER
309 signproto $SRC/tools/codesign/creds 2>&1 | \
310 tee -a ${signing_file} >> $LOGFILE
311 echo "\n==== Finished signing proto area at `date` ====\n" \
312 >> $LOGFILE
313 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
314 >> $mail_msg_file
315 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
316 if (( $? == 0 )) ; then
317 build_ok=n
318 this_build_ok=n
323 # Building Packages
325 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
326 if [ -d $SRC/pkg ]; then
327 echo "\n==== Creating $LABEL packages at `date` ====\n" \
328 >> $LOGFILE
329 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
330 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
331 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
333 rm -f $SRC/pkg/${INSTALLOG}.out
334 cd $SRC/pkg
335 /bin/time $MAKE -e install 2>&1 | \
336 tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE
338 echo "\n==== package build errors ($LABEL) ====\n" \
339 >> $mail_msg_file
341 egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \
342 grep ':' | \
343 grep -v PSTAMP | \
344 egrep -v "Ignoring unknown host" | \
345 tee $TMPDIR/package >> $mail_msg_file
346 if [[ -s $TMPDIR/package ]]; then
347 build_extras_ok=n
348 this_build_ok=n
350 else
352 # Handle it gracefully if -p was set but there so
353 # no pkg directory.
355 echo "\n==== No $LABEL packages to build ====\n" \
356 >> $LOGFILE
358 else
359 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
362 ROOT=$ORIGROOT
365 # Usage: dolint /dir y|n
366 # Arg. 2 is a flag to turn on/off the lint diff output
367 function dolint {
368 if [ ! -d "$1" ]; then
369 echo "dolint error: $1 is not a directory"
370 exit 1
373 if [ "$2" != "y" -a "$2" != "n" ]; then
374 echo "dolint internal error: $2 should be 'y' or 'n'"
375 exit 1
378 lintdir=$1
379 dodiff=$2
380 base=`basename $lintdir`
381 LINTOUT=$lintdir/lint-${MACH}.out
382 LINTNOISE=$lintdir/lint-noise-${MACH}
383 export ENVLDLIBS1=`myldlibs $ROOT`
384 export ENVCPPFLAGS1=`myheaders $ROOT`
386 set_debug_build_flags
389 # '$MAKE lint' in $lintdir
391 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
393 # remove old lint.out
394 rm -f $lintdir/lint.out $lintdir/lint-noise.out
395 if [ -f $lintdir/lint-noise.ref ]; then
396 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref
399 rm -f $LINTOUT
400 cd $lintdir
402 # Remove all .ln files to ensure a full reference file
404 rm -f Nothing_to_remove \
405 `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
406 -prune -o -type f -name '*.ln' -print `
408 /bin/time $MAKE -ek lint 2>&1 | \
409 tee -a $LINTOUT >> $LOGFILE
411 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file
413 grep "$MAKE:" $LINTOUT |
414 egrep -v "Ignoring unknown host" | \
415 tee $TMPDIR/lint_errs >> $mail_msg_file
416 if [[ -s $TMPDIR/lint_errs ]]; then
417 build_extras_ok=n
420 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
422 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
423 >>$mail_msg_file
424 tail -3 $LINTOUT >>$mail_msg_file
426 rm -f ${LINTNOISE}.ref
427 if [ -f ${LINTNOISE}.out ]; then
428 mv ${LINTNOISE}.out ${LINTNOISE}.ref
430 grep : $LINTOUT | \
431 egrep -v '^(real|user|sys)' |
432 egrep -v '(library construction)' | \
433 egrep -v ': global crosschecks' | \
434 egrep -v 'Ignoring unknown host' | \
435 egrep -v '\.c:$' | \
436 sort | uniq > ${LINTNOISE}.out
437 if [ ! -f ${LINTNOISE}.ref ]; then
438 cp ${LINTNOISE}.out ${LINTNOISE}.ref
441 if [ "$dodiff" != "n" ]; then
442 echo "\n==== lint warnings $base ====\n" \
443 >>$mail_msg_file
444 # should be none, though there are a few that were filtered out
445 # above
446 egrep -i '(warning|lint):' ${LINTNOISE}.out \
447 | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file
448 if [[ -s $TMPDIR/lint_warns ]]; then
449 build_extras_ok=n
451 echo "\n==== lint noise differences $base ====\n" \
452 >> $mail_msg_file
453 diff ${LINTNOISE}.ref ${LINTNOISE}.out \
454 >> $mail_msg_file
459 # Build and install the onbld tools.
461 # usage: build_tools DESTROOT
463 # returns non-zero status if the build was successful.
465 function build_tools {
466 DESTROOT=$1
468 INSTALLOG=install-${MACH}
470 echo "\n==== Building tools at `date` ====\n" \
471 >> $LOGFILE
473 rm -f ${TOOLS}/${INSTALLOG}.out
474 cd ${TOOLS}
475 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
476 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
478 echo "\n==== Tools build errors ====\n" >> $mail_msg_file
480 egrep ":" ${TOOLS}/${INSTALLOG}.out |
481 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
482 egrep -v "Ignoring unknown host" | \
483 egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file
485 if [[ -s $TMPDIR/tools_errors ]]; then
486 return 1
488 return 0
492 # Set up to use locally installed tools.
494 # usage: use_tools TOOLSROOT
496 function use_tools {
497 TOOLSROOT=$1
500 # If we're not building ON workspace, then the TOOLSROOT
501 # settings here are clearly ignored by the workspace
502 # makefiles, prepending nonexistent directories to PATH is
503 # harmless, and we clearly do not wish to override
504 # ONBLD_TOOLS.
506 # If we're building an ON workspace, then the prepended PATH
507 # elements should supercede the preexisting ONBLD_TOOLS paths,
508 # and we want to override ONBLD_TOOLS to catch the tools that
509 # don't have specific path env vars here.
511 # So the only conditional behavior is overriding ONBLD_TOOLS,
512 # and we check for "an ON workspace" by looking for
513 # ${TOOLSROOT}/opt/onbld.
516 STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs
517 export STABS
518 CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs
519 export CTFSTABS
520 GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets
521 export GENOFFSETS
523 CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert
524 export CTFCONVERT
525 CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge
526 export CTFMERGE
528 PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}"
529 PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}"
530 export PATH
532 if [ -d "${TOOLSROOT}/opt/onbld" ]; then
533 ONBLD_TOOLS=${TOOLSROOT}/opt/onbld
534 export ONBLD_TOOLS
537 echo "\n==== New environment settings. ====\n" >> $LOGFILE
538 echo "STABS=${STABS}" >> $LOGFILE
539 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
540 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
541 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
542 echo "PATH=${PATH}" >> $LOGFILE
543 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
546 function staffer {
547 if [ $ISUSER -ne 0 ]; then
548 "$@"
549 else
550 arg="\"$1\""
551 shift
552 for i
554 arg="$arg \"$i\""
555 done
556 eval su $STAFFER -c \'$arg\'
561 # Verify that the closed bins are present
563 function check_closed_bins {
564 if [[ -n "$ON_CLOSED_BINS" && ! -d "$ON_CLOSED_BINS" ]]; then
565 echo "ON_CLOSED_BINS must point to the closed binaries tree."
566 build_ok=n
567 exit 1
572 # wrapper over wsdiff.
573 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
575 function do_wsdiff {
576 label=$1
577 oldproto=$2
578 newproto=$3
580 wsdiff="wsdiff"
581 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
583 echo "\n==== Getting object changes since last build at `date`" \
584 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
585 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
586 tee -a $LOGFILE >> $mail_msg_file
587 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
588 tee -a $LOGFILE >> $mail_msg_file
592 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
593 # together.
596 function set_non_debug_build_flags {
597 export RELEASE_BUILD ; RELEASE_BUILD=
598 unset EXTRA_OPTIONS
599 unset EXTRA_CFLAGS
602 function set_debug_build_flags {
603 unset RELEASE_BUILD
604 unset EXTRA_OPTIONS
605 unset EXTRA_CFLAGS
609 MACH=`uname -p`
611 if [ "$OPTHOME" = "" ]; then
612 OPTHOME=/opt
613 export OPTHOME
616 USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
618 Where:
619 -i Fast incremental options (no clobber, lint, check)
620 -n Do not do a bringover
621 +t Use the build tools in $ONBLD_TOOLS/bin
622 -V VERS set the build version string to VERS
624 <env_file> file in Bourne shell syntax that sets and exports
625 variables that configure the operation of this script and many of
626 the scripts this one calls. If <env_file> does not exist,
627 it will be looked for in $OPTHOME/onbld/env.
629 non-DEBUG is the default build type. Build options can be set in the
630 NIGHTLY_OPTIONS variable in the <env_file> as follows:
632 -A check for ABI differences in .so files
633 -C check for cstyle/hdrchk errors
634 -D do a build with DEBUG on
635 -F do _not_ do a non-DEBUG build
636 -G gate keeper default group of options (-au)
637 -I integration engineer default group of options (-ampu)
638 -M do not run pmodes (safe file permission checker)
639 -N do not run protocmp
640 -R default group of options for building a release (-mp)
641 -U update proto area in the parent
642 -V VERS set the build version string to VERS
643 -f find unreferenced files
644 -i do an incremental build (no "make clobber")
645 -l do "make lint" in $LINTDIRS (default: $SRC y)
646 -m send mail to $MAILTO at end of build
647 -n do not do a bringover
648 -p create packages
649 -r check ELF runtime attributes in the proto area
650 -t build and use the tools in $SRC/tools (default setting)
651 +t Use the build tools in $ONBLD_TOOLS/bin
652 -u update proto_list_$MACH and friends in the parent workspace;
653 when used with -f, also build an unrefmaster.out in the parent
654 -w report on differences between previous and current proto areas
657 # A log file will be generated under the name $LOGFILE
658 # for partially completed build and log.`date '+%F'`
659 # in the same directory for fully completed builds.
662 # default values for low-level FLAGS; G I R are group FLAGS
663 A_FLAG=n
664 C_FLAG=n
665 D_FLAG=n
666 F_FLAG=n
667 f_FLAG=n
668 i_FLAG=n; i_CMD_LINE_FLAG=n
669 l_FLAG=n
670 M_FLAG=n
671 m_FLAG=n
672 N_FLAG=n
673 n_FLAG=n
674 p_FLAG=n
675 r_FLAG=n
676 t_FLAG=y
677 U_FLAG=n
678 u_FLAG=n
679 V_FLAG=n
680 w_FLAG=n
681 W_FLAG=n
683 build_ok=y
684 build_extras_ok=y
687 # examine arguments
690 OPTIND=1
691 while getopts +intV:W FLAG
693 case $FLAG in
694 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
696 n ) n_FLAG=y
698 +t ) t_FLAG=n
700 V ) V_FLAG=y
701 V_ARG="$OPTARG"
703 W ) W_FLAG=y
705 \? ) echo "$USAGE"
706 exit 1
708 esac
709 done
711 # correct argument count after options
712 shift `expr $OPTIND - 1`
714 # test that the path to the environment-setting file was given
715 if [ $# -ne 1 ]; then
716 echo "$USAGE"
717 exit 1
720 # check if user is running nightly as root
721 # ISUSER is set non-zero if an ordinary user runs nightly, or is zero
722 # when root invokes nightly.
723 /usr/bin/id | grep '^uid=0(' >/dev/null 2>&1
724 ISUSER=$?; export ISUSER
727 # force locale to C
728 LANG=C; export LANG
729 LC_ALL=C; export LC_ALL
730 LC_COLLATE=C; export LC_COLLATE
731 LC_CTYPE=C; export LC_CTYPE
732 LC_MESSAGES=C; export LC_MESSAGES
733 LC_MONETARY=C; export LC_MONETARY
734 LC_NUMERIC=C; export LC_NUMERIC
735 LC_TIME=C; export LC_TIME
737 # clear environment variables we know to be bad for the build
738 unset LD_OPTIONS
739 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
740 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
741 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
742 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
743 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
744 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
745 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
746 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
747 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
748 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
749 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
750 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
751 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
752 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
753 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
754 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
755 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
756 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
757 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
758 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
760 unset CONFIG
761 unset GROUP
762 unset OWNER
763 unset REMOTE
764 unset ENV
765 unset ARCH
766 unset CLASSPATH
767 unset NAME
770 # To get ONBLD_TOOLS from the environment, it must come from the env file.
771 # If it comes interactively, it is generally TOOLS_PROTO, which will be
772 # clobbered before the compiler version checks, which will therefore fail.
774 unset ONBLD_TOOLS
777 # Setup environmental variables
779 if [ -f /etc/nightly.conf ]; then
780 . /etc/nightly.conf
783 if [ -f $1 ]; then
784 if [[ $1 = */* ]]; then
785 . $1
786 else
787 . ./$1
789 else
790 if [ -f $OPTHOME/onbld/env/$1 ]; then
791 . $OPTHOME/onbld/env/$1
792 else
793 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1"
794 exit 1
798 # contents of stdenv.sh inserted after next line:
799 # STDENV_START
800 # STDENV_END
802 # Check if we have sufficient data to continue...
803 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
804 if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
805 # Check if the gate data are valid if we don't do a "bringover" below
806 [[ -d "${CODEMGR_WS}" ]] || \
807 fatal_error "Error: ${CODEMGR_WS} is not a directory."
808 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
809 fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
813 # place ourselves in a new task, respecting BUILD_PROJECT if set.
815 if [ -z "$BUILD_PROJECT" ]; then
816 /usr/bin/newtask -c $$
817 else
818 /usr/bin/newtask -c $$ -p $BUILD_PROJECT
821 ps -o taskid= -p $$ | read build_taskid
822 ps -o project= -p $$ | read build_project
825 # See if NIGHTLY_OPTIONS is set
827 if [ "$NIGHTLY_OPTIONS" = "" ]; then
828 NIGHTLY_OPTIONS="-aBm"
832 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
834 if [ "$BRINGOVER_WS" = "" ]; then
835 BRINGOVER_WS=$CLONE_WS
839 # If BRINGOVER_FILES was not specified, default to usr
841 if [ "$BRINGOVER_FILES" = "" ]; then
842 BRINGOVER_FILES="usr"
845 check_closed_bins
848 # Note: changes to the option letters here should also be applied to the
849 # bldenv script. `d' is listed for backward compatibility.
851 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
852 OPTIND=1
853 while getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS
855 case $FLAG in
856 A ) A_FLAG=y
858 B ) D_FLAG=y
859 ;; # old version of D
860 C ) C_FLAG=y
862 D ) D_FLAG=y
864 F ) F_FLAG=y
866 f ) f_FLAG=y
868 G ) u_FLAG=y
870 I ) m_FLAG=y
871 p_FLAG=y
872 u_FLAG=y
874 i ) i_FLAG=y
876 l ) l_FLAG=y
878 M ) M_FLAG=y
880 m ) m_FLAG=y
882 N ) N_FLAG=y
884 n ) n_FLAG=y
886 p ) p_FLAG=y
888 R ) m_FLAG=y
889 p_FLAG=y
891 r ) r_FLAG=y
893 +t ) t_FLAG=n
895 U ) if [ -z "${PARENT_ROOT}" ]; then
896 echo "PARENT_ROOT must be set if the U flag is" \
897 "present in NIGHTLY_OPTIONS."
898 exit 1
900 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
901 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
902 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
904 U_FLAG=y
906 u ) u_FLAG=y
908 w ) w_FLAG=y
910 W ) W_FLAG=y
912 \? ) echo "$USAGE"
913 exit 1
915 esac
916 done
918 if [ $ISUSER -ne 0 ]; then
919 # Set default value for STAFFER, if needed.
920 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
921 STAFFER=`/usr/xpg4/bin/id -un`
922 export STAFFER
926 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
927 MAILTO=$STAFFER
928 export MAILTO
931 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
932 PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb"
933 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
934 export PATH
936 # roots of source trees, both relative to $SRC and absolute.
937 relsrcdirs="."
938 abssrcdirs="$SRC"
940 PROTOCMPTERSE="protocmp.terse -gu"
941 POUND_SIGN="#"
942 # have we set RELEASE_DATE in our env file?
943 if [ -z "$RELEASE_DATE" ]; then
944 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
946 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
947 BASEWSDIR=$(basename $CODEMGR_WS)
948 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
950 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
951 # by avoiding repeated shell invocations to evaluate Makefile.master
952 # definitions.
953 export POUND_SIGN RELEASE_DATE DEV_CM
955 maketype="distributed"
956 if [[ -z "$MAKE" ]]; then
957 MAKE=dmake
958 elif [[ ! -x "$MAKE" ]]; then
959 echo "\$MAKE is set to garbage in the environment"
960 exit 1
962 export PATH
963 export MAKE
965 if [ "${SUNWSPRO}" != "" ]; then
966 PATH="${SUNWSPRO}/bin:$PATH"
967 export PATH
970 hostname=$(uname -n)
971 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
972 then
973 maxjobs=
974 if [[ -f $HOME/.make.machines ]]
975 then
976 # Note: there is a hard tab and space character in the []s
977 # below.
978 egrep -i "^[ ]*$hostname[ \.]" \
979 $HOME/.make.machines | read host jobs
980 maxjobs=${jobs##*=}
983 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
984 then
985 # default
986 maxjobs=4
989 export DMAKE_MAX_JOBS=$maxjobs
992 DMAKE_MODE=parallel;
993 export DMAKE_MODE
995 if [ -z "${ROOT}" ]; then
996 echo "ROOT must be set."
997 exit 1
1001 # if -V flag was given, reset VERSION to V_ARG
1003 if [ "$V_FLAG" = "y" ]; then
1004 VERSION=$V_ARG
1007 TMPDIR="/tmp/nightly.tmpdir.$$"
1008 export TMPDIR
1009 rm -rf ${TMPDIR}
1010 mkdir -p $TMPDIR || exit 1
1011 chmod 777 $TMPDIR
1014 # Tools should only be built non-DEBUG. Keep track of the tools proto
1015 # area path relative to $TOOLS, because the latter changes in an
1016 # export build.
1018 # TOOLS_PROTO is included below for builds other than usr/src/tools
1019 # that look for this location. For usr/src/tools, this will be
1020 # overridden on the $MAKE command line in build_tools().
1022 TOOLS=${SRC}/tools
1023 TOOLS_PROTO_REL=proto/root_${MACH}-nd
1024 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
1026 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
1028 # create directories that are automatically removed if the nightly script
1029 # fails to start correctly
1030 function newdir {
1031 dir=$1
1032 toadd=
1033 while [ ! -d $dir ]; do
1034 toadd="$dir $toadd"
1035 dir=`dirname $dir`
1036 done
1037 torm=
1038 newlist=
1039 for dir in $toadd; do
1040 if staffer mkdir $dir; then
1041 newlist="$ISUSER $dir $newlist"
1042 torm="$dir $torm"
1043 else
1044 [ -z "$torm" ] || staffer rmdir $torm
1045 return 1
1047 done
1048 newdirlist="$newlist $newdirlist"
1049 return 0
1051 newdirlist=
1053 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
1055 # since this script assumes the build is from full source, it nullifies
1056 # variables likely to have been set by a "ws" script; nullification
1057 # confines the search space for headers and libraries to the proto area
1058 # built from this immediate source.
1059 ENVLDLIBS1=
1060 ENVLDLIBS2=
1061 ENVLDLIBS3=
1062 ENVCPPFLAGS1=
1063 ENVCPPFLAGS2=
1064 ENVCPPFLAGS3=
1065 ENVCPPFLAGS4=
1066 PARENT_ROOT=
1068 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1069 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
1071 PKGARCHIVE_ORIG=$PKGARCHIVE
1074 # Juggle the logs and optionally send mail on completion.
1077 function logshuffle {
1078 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
1079 if [ -f $LLOG -o -d $LLOG ]; then
1080 LLOG=$LLOG.$$
1082 mkdir $LLOG
1083 export LLOG
1085 if [ "$build_ok" = "y" ]; then
1086 mv $ATLOG/proto_list_${MACH} $LLOG
1088 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
1089 mv $ATLOG/proto_list_tools_${MACH} $LLOG
1092 if [ -f $TMPDIR/wsdiff.results ]; then
1093 mv $TMPDIR/wsdiff.results $LLOG
1096 if [ -f $TMPDIR/wsdiff-nd.results ]; then
1097 mv $TMPDIR/wsdiff-nd.results $LLOG
1102 # Now that we're about to send mail, it's time to check the noise
1103 # file. In the event that an error occurs beyond this point, it will
1104 # be recorded in the nightly.log file, but nowhere else. This would
1105 # include only errors that cause the copying of the noise log to fail
1106 # or the mail itself not to be sent.
1109 exec >>$LOGFILE 2>&1
1110 if [ -s $build_noise_file ]; then
1111 echo "\n==== Nightly build noise ====\n" |
1112 tee -a $LOGFILE >>$mail_msg_file
1113 cat $build_noise_file >>$LOGFILE
1114 cat $build_noise_file >>$mail_msg_file
1115 echo | tee -a $LOGFILE >>$mail_msg_file
1117 rm -f $build_noise_file
1119 case "$build_ok" in
1121 state=Completed
1124 state=Interrupted
1127 state=Failed
1129 esac
1131 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
1132 state=Failed
1135 NIGHTLY_STATUS=$state
1136 export NIGHTLY_STATUS
1138 run_hook POST_NIGHTLY $state
1139 run_hook SYS_POST_NIGHTLY $state
1142 # mailx(1) sets From: based on the -r flag
1143 # if it is given.
1145 mailx_r=
1146 if [[ -n "${MAILFROM}" ]]; then
1147 mailx_r="-r ${MAILFROM}"
1150 cat $build_time_file $build_environ_file $mail_msg_file \
1151 > ${LLOG}/mail_msg
1152 if [ "$m_FLAG" = "y" ]; then
1153 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1154 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1155 ${MAILTO}
1158 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1159 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH}
1160 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log
1163 mv $LOGFILE $LLOG
1167 # Remove the locks and temporary files on any exit
1169 function cleanup {
1170 logshuffle
1172 [ -z "$lockfile" ] || staffer rm -f $lockfile
1173 [ -z "$atloglockfile" ] || rm -f $atloglockfile
1174 [ -z "$ulockfile" ] || staffer rm -f $ulockfile
1175 [ -z "$Ulockfile" ] || rm -f $Ulockfile
1177 set -- $newdirlist
1178 while [ $# -gt 0 ]; do
1179 ISUSER=$1 staffer rmdir $2
1180 shift; shift
1181 done
1182 rm -rf $TMPDIR
1185 function cleanup_signal {
1186 build_ok=i
1187 # this will trigger cleanup(), above.
1188 exit 1
1191 trap cleanup 0
1192 trap cleanup_signal 1 2 3 15
1195 # Generic lock file processing -- make sure that the lock file doesn't
1196 # exist. If it does, it should name the build host and PID. If it
1197 # doesn't, then make sure we can create it. Clean up locks that are
1198 # known to be stale (assumes host name is unique among build systems
1199 # for the workspace).
1201 function create_lock {
1202 lockf=$1
1203 lockvar=$2
1205 ldir=`dirname $lockf`
1206 [ -d $ldir ] || newdir $ldir || exit 1
1207 eval $lockvar=$lockf
1209 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1210 basews=`basename $CODEMGR_WS`
1211 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1212 if [ "$host" != "$hostname" ]; then
1213 echo "$MACH build of $basews apparently" \
1214 "already started by $user on $host as $pid."
1215 exit 1
1216 elif kill -s 0 $pid 2>/dev/null; then
1217 echo "$MACH build of $basews already started" \
1218 "by $user as $pid."
1219 exit 1
1220 else
1221 # stale lock; clear it out and try again
1222 rm -f $lockf
1224 done
1228 # Return the list of interesting proto areas, depending on the current
1229 # options.
1231 function allprotos {
1232 typeset roots="$ROOT"
1234 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1235 roots="$roots $ROOT-nd"
1238 echo $roots
1241 # Ensure no other instance of this script is running on this host.
1242 # LOCKNAME can be set in <env_file>, and is by default, but is not
1243 # required due to the use of $ATLOG below.
1244 if [ -n "$LOCKNAME" ]; then
1245 create_lock /tmp/$LOCKNAME "lockfile"
1248 # Create from one, two, or three other locks:
1249 # $ATLOG/nightly.lock
1250 # - protects against multiple builds in same workspace
1251 # $PARENT_WS/usr/src/nightly.$MACH.lock
1252 # - protects against multiple 'u' copy-backs
1253 # $NIGHTLY_PARENT_ROOT/nightly.lock
1254 # - protects against multiple 'U' copy-backs
1256 # Overriding ISUSER to 1 causes the lock to be created as root if the
1257 # script is run as root. The default is to create it as $STAFFER.
1258 ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile"
1259 if [ "$u_FLAG" = "y" ]; then
1260 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile"
1262 if [ "$U_FLAG" = "y" ]; then
1263 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1264 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile"
1267 # Locks have been taken, so we're doing a build and we're committed to
1268 # the directories we may have created so far.
1269 newdirlist=
1272 # Create mail_msg_file
1274 mail_msg_file="${TMPDIR}/mail_msg"
1275 touch $mail_msg_file
1276 build_time_file="${TMPDIR}/build_time"
1277 build_environ_file="${TMPDIR}/build_environ"
1278 touch $build_environ_file
1280 # Move old LOGFILE aside
1281 # ATLOG directory already made by 'create_lock' above
1283 if [ -f $LOGFILE ]; then
1284 mv -f $LOGFILE ${LOGFILE}-
1287 # Build OsNet source
1289 START_DATE=`date`
1290 SECONDS=0
1291 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1292 | tee -a $LOGFILE > $build_time_file
1294 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1295 tee -a $mail_msg_file >> $LOGFILE
1297 # make sure we log only to the nightly build file
1298 build_noise_file="${TMPDIR}/build_noise"
1299 exec </dev/null >$build_noise_file 2>&1
1301 run_hook SYS_PRE_NIGHTLY
1302 run_hook PRE_NIGHTLY
1304 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1305 env >> $LOGFILE
1307 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1309 if [ "$N_FLAG" = "y" ]; then
1310 if [ "$p_FLAG" = "y" ]; then
1311 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1312 WARNING: the p option (create packages) is set, but so is the N option (do
1313 not run protocmp); this is dangerous; you should unset the N option
1315 else
1316 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1317 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1320 echo "" | tee -a $mail_msg_file >> $LOGFILE
1323 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1325 # In the past we just complained but went ahead with the lint
1326 # pass, even though the proto area was built non-DEBUG. It's
1327 # unlikely that non-DEBUG headers will make a difference, but
1328 # rather than assuming it's a safe combination, force the user
1329 # to specify a DEBUG build.
1331 echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1332 | tee -a $mail_msg_file >> $LOGFILE
1333 l_FLAG=n
1336 if [ "$f_FLAG" = "y" ]; then
1337 if [ "$i_FLAG" = "y" ]; then
1338 echo "WARNING: the -f flag cannot be used during incremental" \
1339 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1340 f_FLAG=n
1342 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then
1343 echo "WARNING: the -f flag requires -l, and -p;" \
1344 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1345 f_FLAG=n
1349 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1350 echo "WARNING: -w specified, but $ROOT does not exist;" \
1351 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE
1352 w_FLAG=n
1355 case $MULTI_PROTO in
1356 yes|no) ;;
1358 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1359 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1360 echo "Setting MULTI_PROTO to \"no\".\n" | \
1361 tee -a $mail_msg_file >> $LOGFILE
1362 export MULTI_PROTO=no
1364 esac
1366 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1367 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1369 # Save the current proto area if we're comparing against the last build
1370 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1371 if [ -d "$ROOT.prev" ]; then
1372 rm -rf $ROOT.prev
1374 mv $ROOT $ROOT.prev
1377 # Same for non-DEBUG proto area
1378 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1379 if [ -d "$ROOT-nd.prev" ]; then
1380 rm -rf $ROOT-nd.prev
1382 mv $ROOT-nd $ROOT-nd.prev
1386 # Echo the SCM type of the parent workspace, this can't just be which_scm
1387 # as that does not know how to identify various network repositories.
1389 function parent_wstype {
1390 typeset scm_type junk
1392 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1393 | read scm_type junk
1394 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1395 # Probe BRINGOVER_WS to determine its type
1396 if [[ $BRINGOVER_WS == ssh://* ]]; then
1397 scm_type="mercurial"
1398 elif [[ $BRINGOVER_WS == http://* ]] && \
1399 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1400 egrep -s "application/mercurial" 2> /dev/null; then
1401 scm_type="mercurial"
1402 else
1403 scm_type="none"
1407 # fold both unsupported and unrecognized results into "none"
1408 case "$scm_type" in
1409 mercurial)
1411 *) scm_type=none
1413 esac
1415 echo $scm_type
1418 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1419 function child_wstype {
1420 typeset scm_type junk
1422 # Probe CODEMGR_WS to determine its type
1423 if [[ -d $CODEMGR_WS ]]; then
1424 $WHICH_SCM | read scm_type junk || exit 1
1427 case "$scm_type" in
1428 none|git|mercurial)
1430 *) scm_type=none
1432 esac
1434 echo $scm_type
1437 SCM_TYPE=$(child_wstype)
1440 # Decide whether to clobber
1442 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1443 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1445 cd $SRC
1446 # remove old clobber file
1447 rm -f $SRC/clobber.out
1448 rm -f $SRC/clobber-${MACH}.out
1450 # Remove all .make.state* files, just in case we are restarting
1451 # the build after having interrupted a previous 'make clobber'.
1452 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1453 -o -name 'interfaces.*' \) -prune \
1454 -o -name '.make.*' -print | xargs rm -f
1456 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1457 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1458 grep "$MAKE:" $SRC/clobber-${MACH}.out |
1459 egrep -v "Ignoring unknown host" | \
1460 tee $TMPDIR/clobber_errs >> $mail_msg_file
1462 if [[ -s $TMPDIR/clobber_errs ]]; then
1463 build_extras_ok=n
1466 if [[ "$t_FLAG" = "y" ]]; then
1467 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1468 cd ${TOOLS}
1469 rm -f ${TOOLS}/clobber-${MACH}.out
1470 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1471 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1472 echo "\n==== Make tools clobber ERRORS ====\n" \
1473 >> $mail_msg_file
1474 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1475 >> $mail_msg_file
1476 if (( $? == 0 )); then
1477 build_extras_ok=n
1479 rm -rf ${TOOLS_PROTO}
1480 mkdir -p ${TOOLS_PROTO}
1483 typeset roots=$(allprotos)
1484 echo "\n\nClearing $roots" >> "$LOGFILE"
1485 rm -rf $roots
1487 # Get back to a clean workspace as much as possible to catch
1488 # problems that only occur on fresh workspaces.
1489 # Remove all .make.state* files, libraries, and .o's that may
1490 # have been omitted from clobber. A couple of libraries are
1491 # under source code control, so leave them alone.
1492 # We should probably blow away temporary directories too.
1493 cd $SRC
1494 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1495 -o -name .git -o -name 'interfaces.*' \) -prune -o \
1496 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1497 -name '*.o' \) -print | \
1498 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
1499 else
1500 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1503 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
1504 typeset -x PATH=$PATH
1506 # If the repository doesn't exist yet, then we want to populate it.
1507 if [[ ! -d $CODEMGR_WS/.hg ]]; then
1508 staffer hg init $CODEMGR_WS
1509 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
1510 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
1511 touch $TMPDIR/new_repository
1514 typeset -x HGMERGE="/bin/false"
1517 # If the user has changes, regardless of whether those changes are
1518 # committed, and regardless of whether those changes conflict, then
1519 # we'll attempt to merge them either implicitly (uncommitted) or
1520 # explicitly (committed).
1522 # These are the messages we'll use to help clarify mercurial output
1523 # in those cases.
1525 typeset mergefailmsg="\
1526 ***\n\
1527 *** nightly was unable to automatically merge your changes. You should\n\
1528 *** redo the full merge manually, following the steps outlined by mercurial\n\
1529 *** above, then restart nightly.\n\
1530 ***\n"
1531 typeset mergepassmsg="\
1532 ***\n\
1533 *** nightly successfully merged your changes. This means that your working\n\
1534 *** directory has been updated, but those changes are not yet committed.\n\
1535 *** After nightly completes, you should validate the results of the merge,\n\
1536 *** then use hg commit manually.\n\
1537 ***\n"
1540 # For each repository in turn:
1542 # 1. Do the pull. If this fails, dump the output and bail out.
1544 # 2. If the pull resulted in an extra head, do an explicit merge.
1545 # If this fails, dump the output and bail out.
1547 # Because we can't rely on Mercurial to exit with a failure code
1548 # when a merge fails (Mercurial issue #186), we must grep the
1549 # output of pull/merge to check for attempted and/or failed merges.
1551 # 3. If a merge failed, set the message and fail the bringover.
1553 # 4. Otherwise, if a merge succeeded, set the message
1555 # 5. Dump the output, and any message from step 3 or 4.
1558 typeset HG_SOURCE=$BRINGOVER_WS
1559 if [ ! -f $TMPDIR/new_repository ]; then
1560 HG_SOURCE=$TMPDIR/open_bundle.hg
1561 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
1562 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
1565 # If there are no incoming changesets, then incoming will
1566 # fail, and there will be no bundle file. Reset the source,
1567 # to allow the remaining logic to complete with no false
1568 # negatives. (Unlike incoming, pull will return success
1569 # for the no-change case.)
1571 if (( $? != 0 )); then
1572 HG_SOURCE=$BRINGOVER_WS
1576 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
1577 > $TMPDIR/pull_open.out 2>&1
1578 if (( $? != 0 )); then
1579 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
1580 cat $TMPDIR/pull_open.out
1581 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1582 printf "$mergefailmsg"
1584 touch $TMPDIR/bringover_failed
1585 return
1588 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1589 staffer hg --cwd $CODEMGR_WS merge \
1590 >> $TMPDIR/pull_open.out 2>&1
1591 if (( $? != 0 )); then
1592 printf "%s: merge failed as follows:\n\n" \
1593 "$CODEMGR_WS"
1594 cat $TMPDIR/pull_open.out
1595 if grep "^merging.*failed" $TMPDIR/pull_open.out \
1596 > /dev/null 2>&1; then
1597 printf "$mergefailmsg"
1599 touch $TMPDIR/bringover_failed
1600 return
1604 printf "updated %s with the following results:\n" "$CODEMGR_WS"
1605 cat $TMPDIR/pull_open.out
1606 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
1607 printf "$mergepassmsg"
1609 printf "\n"
1612 # Per-changeset output is neither useful nor manageable for a
1613 # newly-created repository.
1615 if [ -f $TMPDIR/new_repository ]; then
1616 return
1619 printf "\nadded the following changesets to open repository:\n"
1620 cat $TMPDIR/incoming_open.out
1623 type bringover_none > /dev/null 2>&1 || function bringover_none {
1624 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1625 touch $TMPDIR/bringover_failed
1629 # Decide whether to bringover to the codemgr workspace
1631 if [ "$n_FLAG" = "n" ]; then
1632 PARENT_SCM_TYPE=$(parent_wstype)
1634 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
1635 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
1636 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
1637 exit 1
1640 run_hook PRE_BRINGOVER
1642 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
1643 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
1645 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
1646 tee -a $mail_msg_file >> $LOGFILE
1648 if [ -f $TMPDIR/bringover_failed ]; then
1649 rm -f $TMPDIR/bringover_failed
1650 build_ok=n
1651 echo "trouble with bringover, quitting at `date`." |
1652 tee -a $mail_msg_file >> $LOGFILE
1653 exit 1
1657 # It's possible that we used the bringover above to create
1658 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
1659 # but should now be the same as $BRINGOVER_WS.
1661 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
1663 run_hook POST_BRINGOVER
1665 check_closed_bins
1667 else
1668 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
1671 # Safeguards
1672 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1673 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
1674 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1676 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
1678 # System
1679 whence uname | tee -a $build_environ_file >> $LOGFILE
1680 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
1681 echo | tee -a $build_environ_file >> $LOGFILE
1683 # make
1684 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
1685 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
1686 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
1687 tee -a $build_environ_file >> $LOGFILE
1690 # Report the compiler versions.
1693 if [[ ! -f $SRC/Makefile ]]; then
1694 build_ok=n
1695 echo "\nUnable to find \"Makefile\" in $SRC." | \
1696 tee -a $build_environ_file >> $LOGFILE
1697 exit 1
1700 ( cd $SRC
1701 for target in cc-version cc64-version java-version; do
1702 echo
1704 # Put statefile somewhere we know we can write to rather than trip
1705 # over a read-only $srcroot.
1707 rm -f $TMPDIR/make-state
1708 export SRC
1709 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
1710 continue
1712 touch $TMPDIR/nocompiler
1713 done
1714 echo
1715 ) | tee -a $build_environ_file >> $LOGFILE
1717 if [ -f $TMPDIR/nocompiler ]; then
1718 rm -f $TMPDIR/nocompiler
1719 build_ok=n
1720 echo "Aborting due to missing compiler." |
1721 tee -a $build_environ_file >> $LOGFILE
1722 exit 1
1725 # as
1726 whence as | tee -a $build_environ_file >> $LOGFILE
1727 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
1728 echo | tee -a $build_environ_file >> $LOGFILE
1730 # Check that we're running a capable link-editor
1731 whence ld | tee -a $build_environ_file >> $LOGFILE
1732 LDVER=`ld -V 2>&1`
1733 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
1734 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1735 if [ `expr $LDVER \< 422` -eq 1 ]; then
1736 echo "The link-editor needs to be at version 422 or higher to build" | \
1737 tee -a $build_environ_file >> $LOGFILE
1738 echo "the latest stuff. Hope your build works." | \
1739 tee -a $build_environ_file >> $LOGFILE
1743 # Build and use the workspace's tools if requested
1745 if [[ "$t_FLAG" = "y" ]]; then
1746 set_non_debug_build_flags
1748 build_tools ${TOOLS_PROTO}
1749 if (( $? != 0 )); then
1750 build_ok=n
1751 else
1752 use_tools $TOOLS_PROTO
1756 # timestamp the start of the normal build; the findunref tool uses it.
1757 touch $SRC/.build.tstamp
1759 normal_build
1761 ORIG_SRC=$SRC
1762 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
1766 # There are several checks that need to look at the proto area, but
1767 # they only need to look at one, and they don't care whether it's
1768 # DEBUG or non-DEBUG.
1770 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
1771 checkroot=$ROOT-nd
1772 else
1773 checkroot=$ROOT
1776 if [ "$build_ok" = "y" ]; then
1777 echo "\n==== Creating protolist system file at `date` ====" \
1778 >> $LOGFILE
1779 protolist $checkroot > $ATLOG/proto_list_${MACH}
1780 echo "==== protolist system file created at `date` ====\n" \
1781 >> $LOGFILE
1783 if [ "$N_FLAG" != "y" ]; then
1787 for f in $f1; do
1788 if [ -f "$f" ]; then
1789 E1="$E1 -e $f"
1791 done
1795 if [ -d "$SRC/pkg" ]; then
1796 f2="$f2 exceptions/packaging"
1799 for f in $f2; do
1800 if [ -f "$f" ]; then
1801 E2="$E2 -e $f"
1803 done
1806 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
1807 echo "\n==== Validating manifests against proto area ====\n" \
1808 >> $mail_msg_file
1809 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \
1810 tee $TMPDIR/protocmp_noise >> $mail_msg_file
1811 if [[ -s $TMPDIR/protocmp_noise ]]; then
1812 build_extras_ok=n
1816 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1817 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1818 if [ -n "$E2" ]; then
1819 ELIST=$E2
1820 else
1821 ELIST=$E1
1823 $PROTOCMPTERSE \
1824 "Files in yesterday's proto area, but not today's:" \
1825 "Files in today's proto area, but not yesterday's:" \
1826 "Files that changed between yesterday and today:" \
1827 ${ELIST} \
1828 -d $REF_PROTO_LIST \
1829 $ATLOG/proto_list_${MACH} \
1830 >> $mail_msg_file
1834 if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \
1835 "$build_extras_ok" == "y" ]]; then
1836 staffer cp $ATLOG/proto_list_${MACH} \
1837 $PARENT_WS/usr/src/proto_list_${MACH}
1840 # Update parent proto area if necessary. This is done now
1841 # so that the proto area has either DEBUG or non-DEBUG kernels.
1842 # Note that this clears out the lock file, so we can dispense with
1843 # the variable now.
1844 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1845 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1846 tee -a $LOGFILE >> $mail_msg_file
1847 rm -rf $NIGHTLY_PARENT_ROOT/*
1848 unset Ulockfile
1849 mkdir -p $NIGHTLY_PARENT_ROOT
1850 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1851 ( cd $ROOT; tar cf - . |
1852 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 |
1853 tee -a $mail_msg_file >> $LOGFILE
1855 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
1856 rm -rf $NIGHTLY_PARENT_ROOT-nd/*
1857 mkdir -p $NIGHTLY_PARENT_ROOT-nd
1858 cd $ROOT-nd
1859 ( tar cf - . |
1860 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
1861 tee -a $mail_msg_file >> $LOGFILE
1863 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1864 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1865 tee -a $LOGFILE >> $mail_msg_file
1866 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1867 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
1868 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1869 ( cd $TOOLS_PROTO; tar cf - . |
1870 ( cd $NIGHTLY_PARENT_TOOLS_ROOT;
1871 umask 0; tar xpf - ) ) 2>&1 |
1872 tee -a $mail_msg_file >> $LOGFILE
1878 # ELF verification: ABI (-A) and runtime (-r) checks
1880 if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then
1881 # Directory ELF-data.$MACH holds the files produced by these tests.
1882 elf_ddir=$SRC/ELF-data.$MACH
1884 # If there is a previous ELF-data backup directory, remove it. Then,
1885 # rotate current ELF-data directory into its place and create a new
1886 # empty directory
1887 rm -rf $elf_ddir.ref
1888 if [[ -d $elf_ddir ]]; then
1889 mv $elf_ddir $elf_ddir.ref
1891 mkdir -p $elf_ddir
1893 # Call find_elf to produce a list of the ELF objects in the proto area.
1894 # This list is passed to check_rtime and interface_check, preventing
1895 # them from separately calling find_elf to do the same work twice.
1896 find_elf -fr $checkroot > $elf_ddir/object_list
1898 if [[ $A_FLAG = y ]]; then
1899 echo "\n==== Check versioning and ABI information ====\n" | \
1900 tee -a $LOGFILE >> $mail_msg_file
1902 # Produce interface description for the proto. Report errors.
1903 interface_check -o -w $elf_ddir -f object_list \
1904 -i interface -E interface.err
1905 if [[ -s $elf_ddir/interface.err ]]; then
1906 tee -a $LOGFILE < $elf_ddir/interface.err \
1907 >> $mail_msg_file
1908 build_extras_ok=n
1911 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1912 # description file to that from the baseline gate. Issue a
1913 # warning if the baseline is not present, and keep going.
1914 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1915 base_ifile="$ELF_DATA_BASELINE_DIR/interface"
1917 echo "\n==== Compare versioning and ABI information" \
1918 "to baseline ====\n" | \
1919 tee -a $LOGFILE >> $mail_msg_file
1920 echo "Baseline: $base_ifile\n" >> $LOGFILE
1922 if [[ -f $base_ifile ]]; then
1923 interface_cmp -d -o $base_ifile \
1924 $elf_ddir/interface > $elf_ddir/interface.cmp
1925 if [[ -s $elf_ddir/interface.cmp ]]; then
1926 echo | tee -a $LOGFILE >> $mail_msg_file
1927 tee -a $LOGFILE < \
1928 $elf_ddir/interface.cmp \
1929 >> $mail_msg_file
1930 build_extras_ok=n
1932 else
1933 echo "baseline not available. comparison" \
1934 "skipped" | \
1935 tee -a $LOGFILE >> $mail_msg_file
1941 if [[ $r_FLAG = y ]]; then
1942 echo "\n==== Check ELF runtime attributes ====\n" | \
1943 tee -a $LOGFILE >> $mail_msg_file
1945 # If we're doing a DEBUG build the proto area will be left
1946 # with debuggable objects, thus don't assert -s.
1947 if [[ $D_FLAG = y ]]; then
1948 rtime_sflag=""
1949 else
1950 rtime_sflag="-s"
1952 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
1953 -D object_list -f object_list -E runtime.err \
1954 -I runtime.attr.raw
1955 if (( $? != 0 )); then
1956 build_extras_ok=n
1959 # check_rtime -I output needs to be sorted in order to
1960 # compare it to that from previous builds.
1961 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
1962 rm $elf_ddir/runtime.attr.raw
1964 # Report errors
1965 if [[ -s $elf_ddir/runtime.err ]]; then
1966 tee -a $LOGFILE < $elf_ddir/runtime.err \
1967 >> $mail_msg_file
1968 build_extras_ok=n
1971 # If there is an ELF-data directory from a previous build,
1972 # then diff the attr files. These files contain information
1973 # about dependencies, versioning, and runpaths. There is some
1974 # overlap with the ABI checking done above, but this also
1975 # flushes out non-ABI interface differences along with the
1976 # other information.
1977 echo "\n==== Diff ELF runtime attributes" \
1978 "(since last build) ====\n" | \
1979 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
1981 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
1982 diff $elf_ddir.ref/runtime.attr \
1983 $elf_ddir/runtime.attr \
1984 >> $mail_msg_file
1988 # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
1989 if [[ "$u_FLAG" = "y" ]]; then
1990 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH
1992 # If parent lacks the ELF-data.$MACH directory, create it
1993 if [[ ! -d $p_elf_ddir ]]; then
1994 staffer mkdir -p $p_elf_ddir
1997 # These files are used asynchronously by other builds for ABI
1998 # verification, as above for the -A option. As such, we require
1999 # the file replacement to be atomic. Copy the data to a temp
2000 # file in the same filesystem and then rename into place.
2002 cd $elf_ddir
2003 for elf_dfile in *; do
2004 staffer cp $elf_dfile \
2005 ${p_elf_ddir}/${elf_dfile}.new
2006 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
2007 ${p_elf_ddir}/${elf_dfile}
2008 done
2013 # DEBUG lint of kernel begins
2015 if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
2016 if [ "$LINTDIRS" = "" ]; then
2017 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y"
2018 LINTDIRS="$SRC y"
2020 set $LINTDIRS
2021 while [ $# -gt 0 ]; do
2022 dolint $1 $2; shift; shift
2023 done
2024 else
2025 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2028 # "make check" begins
2030 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2031 # remove old check.out
2032 rm -f $SRC/check.out
2034 rm -f $SRC/check-${MACH}.out
2035 cd $SRC
2036 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
2037 >> $LOGFILE
2038 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2040 grep ":" $SRC/check-${MACH}.out |
2041 egrep -v "Ignoring unknown host" | \
2042 sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file
2044 if [[ -s $TMPDIR/check_errors ]]; then
2045 build_extras_ok=n
2047 else
2048 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2051 echo "\n==== Find core files ====\n" | \
2052 tee -a $LOGFILE >> $mail_msg_file
2054 find $abssrcdirs -name core -a -type f -exec file {} \; | \
2055 tee -a $LOGFILE >> $mail_msg_file
2057 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2058 echo "\n==== Diff unreferenced files (since last build) ====\n" \
2059 | tee -a $LOGFILE >>$mail_msg_file
2060 rm -f $SRC/unref-${MACH}.ref
2061 if [ -f $SRC/unref-${MACH}.out ]; then
2062 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2065 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2066 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2067 sort > $SRC/unref-${MACH}.out
2069 if [ ! -f $SRC/unref-${MACH}.ref ]; then
2070 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2073 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2076 # Verify that the usual lists of files, such as exception lists,
2077 # contain only valid references to files. If the build has failed,
2078 # then don't check the proto area.
2079 CHECK_PATHS=${CHECK_PATHS:-y}
2080 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2081 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2082 >>$mail_msg_file
2083 arg=-b
2084 [ "$build_ok" = y ] && arg=
2085 checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1
2086 if [[ -s $SRC/check-paths.out ]]; then
2087 tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file
2088 build_extras_ok=n
2092 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2093 echo "\n==== Impact on file permissions ====\n" \
2094 >> $mail_msg_file
2096 abspkg=
2097 for d in $abssrcdirs; do
2098 if [ -d "$d/pkg" ]; then
2099 abspkg="$abspkg $d"
2101 done
2103 if [ -n "$abspkg" ]; then
2104 for d in "$abspkg"; do
2105 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
2106 done
2110 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
2111 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2112 do_wsdiff DEBUG $ROOT.prev $ROOT
2115 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2116 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2120 END_DATE=`date`
2121 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2122 tee -a $LOGFILE >> $build_time_file
2124 typeset -i10 hours
2125 typeset -Z2 minutes
2126 typeset -Z2 seconds
2128 elapsed_time=$SECONDS
2129 ((hours = elapsed_time / 3600 ))
2130 ((minutes = elapsed_time / 60 % 60))
2131 ((seconds = elapsed_time % 60))
2133 echo "\n==== Total build time ====" | \
2134 tee -a $LOGFILE >> $build_time_file
2135 echo "\nreal ${hours}:${minutes}:${seconds}" | \
2136 tee -a $LOGFILE >> $build_time_file
2138 if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2139 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
2142 # Produce a master list of unreferenced files -- ideally, we'd
2143 # generate the master just once after all of the nightlies
2144 # have finished, but there's no simple way to know when that
2145 # will be. Instead, we assume that we're the last nightly to
2146 # finish and merge all of the unref-${MACH}.out files in
2147 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
2148 # finish, then this file will be the authoritative master
2149 # list. Otherwise, another ${MACH}'s nightly will eventually
2150 # overwrite ours with its own master, but in the meantime our
2151 # temporary "master" will be no worse than any older master
2152 # which was already on the parent.
2155 set -- $PARENT_WS/usr/src/unref-*.out
2156 cp "$1" ${TMPDIR}/unref.merge
2157 shift
2159 for unreffile; do
2160 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2161 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2162 done
2164 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2168 # All done save for the sweeping up.
2169 # (whichever exit we hit here will trigger the "cleanup" trap which
2170 # optionally sends mail on completion).
2172 if [[ "$build_ok" == "y" ]]; then
2173 if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then
2174 exit 0
2178 exit 1