Revert "nightly: use make -de"
[unleashed.git] / tools / nightly.sh
blobac3f5688c548ecea09e6ccd8f5d55b44fececde6
1 #!/bin/ksh -p
2 # vim: noet sw=8 ts=8
4 # CDDL HEADER START
6 # The contents of this file are subject to the terms of the
7 # Common Development and Distribution License (the "License").
8 # You may not use this file except in compliance with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
25 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
26 # Copyright 2008, 2010, Richard Lowe
27 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
28 # Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
29 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
30 # Copyright 2018 Joyent, Inc.
32 # Based on the nightly script from the integration folks,
33 # Mostly modified and owned by mike_s.
34 # Changes also by kjc, dmk.
36 # -i on the command line, means fast options, so when it's on the
37 # command line (only), check builds are skipped no matter what
38 # the setting of their individual flags are in NIGHTLY_OPTIONS.
40 # OPTHOME may be set in the environment to override /opt
44 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
45 # under certain circumstances, which can really screw things up; unset it.
47 unset CDPATH
49 # Get the absolute path of the nightly script that the user invoked. This
50 # may be a relative path, and we need to do this before changing directory.
51 nightly_path=`whence $0`
53 function fatal_error
55 print -u2 "nightly: $*"
56 exit 1
60 # Function to do a DEBUG and non-DEBUG build. Needed because we might
61 # need to do another for the source build, and since we only deliver DEBUG or
62 # non-DEBUG packages.
64 # usage: normal_build
66 function normal_build {
68 typeset orig_p_FLAG="$p_FLAG"
70 if [ "$D_FLAG" = "n" ]; then
71 set_non_debug_build_flags
72 build "non-DEBUG"
73 else
74 set_debug_build_flags
75 build "DEBUG"
78 p_FLAG="$orig_p_FLAG"
82 # usage: run_hook HOOKNAME ARGS...
84 # If variable "$HOOKNAME" is defined, insert a section header into
85 # our logs and then run the command with ARGS
87 function run_hook {
88 HOOKNAME=$1
89 eval HOOKCMD=\$$HOOKNAME
90 shift
92 if [ -n "$HOOKCMD" ]; then
94 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
95 ( $HOOKCMD "$@" 2>&1 )
96 if [ "$?" -ne 0 ]; then
97 # Let exit status propagate up
98 touch $TMPDIR/abort
102 if [ -f $TMPDIR/abort ]; then
103 build_ok=n
104 echo "\nAborting at request of $HOOKNAME"
105 exit 1
110 # Return library search directive as function of given root.
111 function myldlibs {
112 echo "-L$1/lib -L$1/usr/lib"
115 # Return header search directive as function of given root.
116 function myheaders {
117 echo "-I$1/usr/include"
121 # Function to do the build, including package generation.
122 # usage: build LABEL
123 # - LABEL is used to tag build output.
125 function build {
126 LABEL=$1
127 INSTALLOG=install-${MACH}
129 export ROOT
131 export ENVLDLIBS1=`myldlibs $ROOT`
132 export ENVCPPFLAGS1=`myheaders $ROOT`
134 this_build_ok=y
136 echo "\n==== bmake -C include all install\n" >&2
138 # Before we build anything via dmake, we need to install
139 # bmake-ified headers and libs to the proto area
141 if ! make -j$DMAKE_MAX_JOBS -C $SRCTOP/include all install DESTDIR=$ROOT; then
142 build_ok=n
143 this_build_ok=n
144 fatal_error "cannot install headers"
146 echo "\n==== bmake -C lib build\n" >&2
147 if ! make -j$DMAKE_MAX_JOBS -C $SRCTOP/lib build DESTDIR=$ROOT; then
148 build_ok=n
149 this_build_ok=n
150 fatal_error "cannot install libraries"
154 # Build the legacy part of the source
156 echo "\n==== Building legacy source at `date` ($LABEL) ====\n"
158 cd $SRC
159 echo "\n==== dmake install ====\n" >&2
160 if ! /bin/time $MAKE -e install; then
161 build_ok=n
162 this_build_ok=n
166 # Build the new part of the source
168 echo "\n==== bmake build ====\n" >&2
169 if ! /bin/time env -i PATH=${GCC_ROOT}/bin:/usr/bin \
170 SRCTOP=$SRCTOP \
171 make -C $SRCTOP -j $DMAKE_MAX_JOBS VERBOSE=yes build DESTDIR=$ROOT; then
172 build_ok=n
173 this_build_ok=n
176 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n"
179 # Building Packages
181 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
182 if [ -d $SRC/pkg ]; then
183 echo "\n==== Creating $LABEL packages at `date` ====\n"
184 echo "Clearing out $PKGARCHIVE ..."
185 rm -rf $PKGARCHIVE
186 mkdir -p $PKGARCHIVE
188 rm -f $SRC/pkg/${INSTALLOG}.out
189 cd $SRC/pkg
190 echo "\n==== dmake -C $SRC/pkg install ====\n" >&2
191 if ! /bin/time $MAKE -e install; then
192 build_extras_ok=n
193 this_build_ok=n
195 else
197 # Handle it gracefully if -p was set but there so
198 # no pkg directory.
200 echo "\n==== No $LABEL packages to build ====\n"
202 else
203 echo "\n==== Not creating $LABEL packages ====\n"
208 # Build and install the onbld tools.
210 # usage: build_tools DESTROOT
212 # returns non-zero status if the build was successful.
214 function build_tools {
215 DESTROOT=$1
217 INSTALLOG=install-${MACH}
219 echo "\n==== Building tools at `date` ====\n" \
221 rm -f ${TOOLS}/${INSTALLOG}.out
222 cd ${TOOLS}
223 if ! $MAKE TOOLS_PROTO=${DESTROOT} -e install; then
224 return 1
226 return 0
230 # Set up to use locally installed tools.
232 # usage: use_tools TOOLSROOT
234 function use_tools {
235 TOOLSROOT=$1
238 # If we're not building ON workspace, then the TOOLSROOT
239 # settings here are clearly ignored by the workspace
240 # makefiles, prepending nonexistent directories to PATH is
241 # harmless, and we clearly do not wish to override
242 # ONBLD_TOOLS.
244 # If we're building an ON workspace, then the prepended PATH
245 # elements should supercede the preexisting ONBLD_TOOLS paths,
246 # and we want to override ONBLD_TOOLS to catch the tools that
247 # don't have specific path env vars here.
249 # So the only conditional behavior is overriding ONBLD_TOOLS,
250 # and we check for "an ON workspace" by looking for
251 # ${TOOLSROOT}/opt/onbld.
254 STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs
255 export STABS
256 CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs
257 export CTFSTABS
258 GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets
259 export GENOFFSETS
262 PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}"
263 PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}"
264 export PATH
266 if [ -d "${TOOLSROOT}/opt/onbld" ]; then
267 ONBLD_TOOLS=${TOOLSROOT}/opt/onbld
268 export ONBLD_TOOLS
271 echo "\n==== New environment settings. ====\n"
272 echo "STABS=${STABS}"
273 echo "CTFSTABS=${CTFSTABS}"
274 echo "PATH=${PATH}"
275 echo "ONBLD_TOOLS=${ONBLD_TOOLS}"
279 # wrapper over wsdiff.
280 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
282 function do_wsdiff {
283 label=$1
284 oldproto=$2
285 newproto=$3
287 wsdiff="wsdiff -t"
289 echo "\n==== Getting object changes since last build at `date`" \
290 "($label) ====\n" >&2
291 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto >&2
292 echo "\n==== Object changes determined at `date` ($label) ====\n" >&2
296 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
297 # together.
300 function set_non_debug_build_flags {
301 export RELEASE_BUILD ; RELEASE_BUILD=
302 unset EXTRA_OPTIONS
303 unset EXTRA_CFLAGS
306 function set_debug_build_flags {
307 unset RELEASE_BUILD
308 unset EXTRA_OPTIONS
309 unset EXTRA_CFLAGS
313 MACH=`uname -p`
315 if [ "$OPTHOME" = "" ]; then
316 OPTHOME=/opt
317 export OPTHOME
320 USAGE='Usage: nightly [-in] [-V VERS ] [env_file]
322 Where:
323 -i Fast incremental options (no clobber, check)
324 -V VERS set the build version string to VERS
326 <env_file> file in Bourne shell syntax that sets and exports
327 variables that configure the operation of this script and many of
328 the scripts this one calls.
330 non-DEBUG is the default build type. Build options can be set in the
331 NIGHTLY_OPTIONS variable in the <env_file> as follows:
333 -A check for ABI differences in .so files
334 -C check for cstyle/hdrchk errors
335 -D do a build with DEBUG on
336 -G gate keeper default group of options (-au)
337 -I integration engineer default group of options (-ampu)
338 -M do not run pmodes (safe file permission checker)
339 -N do not run protocmp
340 -R default group of options for building a release (-mp)
341 -U update proto area in the parent
342 -V VERS set the build version string to VERS
343 -i do an incremental build (no "make clobber")
344 -m send mail to $MAILTO at end of build
345 -p create packages
346 -r check ELF runtime attributes in the proto area
347 -u update proto_list_$MACH and friends in the parent workspace
348 -w report on differences between previous and current proto areas
351 # A log file will be generated under the name $LOGFILE
352 # for partially completed build and log.`date '+%F'`
353 # in the same directory for fully completed builds.
356 # default values for low-level FLAGS; G I R are group FLAGS
357 A_FLAG=n
358 C_FLAG=n
359 D_FLAG=n
360 i_FLAG=n; i_CMD_LINE_FLAG=n
361 M_FLAG=n
362 m_FLAG=n
363 N_FLAG=n
364 p_FLAG=n
365 r_FLAG=n
366 V_FLAG=n
367 w_FLAG=n
368 W_FLAG=n
370 build_ok=y
371 build_extras_ok=y
374 # examine arguments
377 OPTIND=1
378 while getopts +iV:W FLAG
380 case $FLAG in
381 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
383 V ) V_FLAG=y
384 V_ARG="$OPTARG"
386 W ) W_FLAG=y
388 \? ) echo "$USAGE"
389 exit 1
391 esac
392 done
394 # correct argument count after options
395 shift `expr $OPTIND - 1`
397 # test that the path to the environment-setting file was given
398 if [ $# -ne 1 ]; then
399 envfile=$(dirname $0)/env.sh
400 else
401 envfile=$1
405 # force locale to C
406 LANG=C; export LANG
407 LC_ALL=C; export LC_ALL
408 LC_COLLATE=C; export LC_COLLATE
409 LC_CTYPE=C; export LC_CTYPE
410 LC_MESSAGES=C; export LC_MESSAGES
411 LC_MONETARY=C; export LC_MONETARY
412 LC_NUMERIC=C; export LC_NUMERIC
413 LC_TIME=C; export LC_TIME
415 # clear environment variables we know to be bad for the build
416 unset LD_OPTIONS
417 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
418 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
419 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
420 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
421 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
422 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
423 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
424 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
425 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
426 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
427 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
428 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
429 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
430 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
431 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
432 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
433 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
434 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
435 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
436 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
438 unset CONFIG
439 unset GROUP
440 unset OWNER
441 unset REMOTE
442 unset ENV
443 unset ARCH
444 unset CLASSPATH
445 unset NAME
448 # To get ONBLD_TOOLS from the environment, it must come from the env file.
449 # If it comes interactively, it is generally TOOLS_PROTO, which will be
450 # clobbered before the compiler version checks, which will therefore fail.
452 unset ONBLD_TOOLS
455 # Setup environmental variables
457 if [ -f $envfile ]; then
458 . $envfile
459 else
460 echo "Cannot find env file $envfile"
461 exit 1
464 # Check if we have sufficient data to continue...
465 [[ -n "$SRCTOP" ]] || \
466 fatal_error "Error: Variable SRCTOP not set."
467 [[ -d "${SRCTOP}" ]] || \
468 fatal_error "Error: ${SRCTOP} is not a directory."
469 [[ -f "${SRCTOP}/usr/src/Makefile" ]] || \
470 fatal_error "Error: ${SRCTOP}/usr/src/Makefile not found."
473 # place ourselves in a new task, respecting BUILD_PROJECT if set.
475 if [ -z "$BUILD_PROJECT" ]; then
476 /usr/bin/newtask -c $$
477 else
478 /usr/bin/newtask -c $$ -p $BUILD_PROJECT
481 ps -o taskid= -p $$ | read build_taskid
482 ps -o project= -p $$ | read build_project
485 # See if NIGHTLY_OPTIONS is set
487 if [ "$NIGHTLY_OPTIONS" = "" ]; then
488 NIGHTLY_OPTIONS="-aBm"
492 # Note: changes to the option letters here should also be applied to the
493 # bldenv script. `d' is listed for backward compatibility.
495 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
496 OPTIND=1
497 while getopts +ABCDdfGIiMmNpRrwW FLAG $NIGHTLY_OPTIONS
499 case $FLAG in
500 A ) A_FLAG=y
502 B ) D_FLAG=y
503 ;; # old version of D
504 C ) C_FLAG=y
506 D ) D_FLAG=y
508 G ) ;;
509 I ) m_FLAG=y
510 p_FLAG=y
512 i ) i_FLAG=y
514 M ) M_FLAG=y
516 m ) m_FLAG=y
518 N ) N_FLAG=y
520 p ) p_FLAG=y
522 R ) m_FLAG=y
523 p_FLAG=y
525 r ) r_FLAG=y
527 w ) w_FLAG=y
529 W ) W_FLAG=y
531 \? ) echo "$USAGE"
532 exit 1
534 esac
535 done
537 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
538 MAILTO=`/usr/bin/id -un`
539 export MAILTO
542 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/bin"
543 PATH="$PATH:/usr/bin:/usr/sbin:/usr/ucb"
544 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:.:$OPTHOME/SUNWspro/bin"
545 export PATH
547 # roots of source trees, both relative to $SRC and absolute.
548 relsrcdirs="."
549 abssrcdirs="$SRC"
551 PROTOCMPTERSE="protocmp.terse -gu"
552 POUND_SIGN="#"
553 # have we set RELEASE_DATE in our env file?
554 if [ -z "$RELEASE_DATE" ]; then
555 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
557 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
558 BASEWSDIR=$(basename $SRCTOP)
560 # we export POUND_SIGN and RELEASE_DATE to speed up the build process
561 # by avoiding repeated shell invocations to evaluate Makefile.master
562 # definitions.
563 export POUND_SIGN RELEASE_DATE
565 maketype="distributed"
566 if [[ -z "$MAKE" ]]; then
567 MAKE=dmake
568 elif [[ ! -x "$MAKE" ]]; then
569 echo "\$MAKE is set to garbage in the environment"
570 exit 1
572 export PATH
573 export MAKE
575 hostname=$(uname -n)
576 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
577 then
578 maxjobs=
579 if [[ -f $HOME/.make.machines ]]
580 then
581 # Note: there is a hard tab and space character in the []s
582 # below.
583 egrep -i "^[ ]*$hostname[ \.]" \
584 $HOME/.make.machines | read host jobs
585 maxjobs=${jobs##*=}
588 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
589 then
590 # default
591 maxjobs=4
594 export DMAKE_MAX_JOBS=$maxjobs
597 DMAKE_MODE=parallel;
598 export DMAKE_MODE
599 DMAKE_OUTPUT_MODE=TXT2;
600 export DMAKE_OUTPUT_MODE
602 if [ -z "${ROOT}" ]; then
603 echo "ROOT must be set."
604 exit 1
608 # if -V flag was given, reset VERSION to V_ARG
610 if [ "$V_FLAG" = "y" ]; then
611 VERSION=$V_ARG
614 TMPDIR="/tmp/nightly.tmpdir.$$"
615 export TMPDIR
616 rm -rf ${TMPDIR}
617 mkdir -p $TMPDIR || exit 1
619 # Tools should only be built non-DEBUG. Keep track of the tools proto
620 # area path relative to $TOOLS, because the latter changes in an
621 # export build.
623 # TOOLS_PROTO is included below for builds other than usr/src/tools
624 # that look for this location. For usr/src/tools, this will be
625 # overridden on the $MAKE command line in build_tools().
627 TOOLS=${SRC}/tools
628 TOOLS_PROTO_REL=proto/root_${MACH}-nd
629 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
631 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
633 # create directories that are automatically removed if the nightly script
634 # fails to start correctly
635 function newdir {
636 dir=$1
637 toadd=
638 while [ ! -d $dir ]; do
639 toadd="$dir $toadd"
640 dir=`dirname $dir`
641 done
642 torm=
643 newlist=
644 for dir in $toadd; do
645 if mkdir $dir; then
646 newlist="$dir $newlist"
647 torm="$dir $torm"
648 else
649 [ -z "$torm" ] || rmdir $torm
650 return 1
652 done
653 newdirlist="$newlist $newdirlist"
654 return 0
656 newdirlist=
658 [ -d $SRCTOP ] || newdir $SRCTOP || exit 1
660 # since this script assumes the build is from full source, it nullifies
661 # variables likely to have been set by a "ws" script; nullification
662 # confines the search space for headers and libraries to the proto area
663 # built from this immediate source.
664 ENVLDLIBS1=
665 ENVLDLIBS2=
666 ENVLDLIBS3=
667 ENVCPPFLAGS1=
668 ENVCPPFLAGS2=
669 ENVCPPFLAGS3=
670 ENVCPPFLAGS4=
672 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
673 ENVLDLIBS1 ENVLDLIBS2
676 # Juggle the logs and optionally send mail on completion.
679 function logshuffle {
680 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
681 if [ -f $LLOG -o -d $LLOG ]; then
682 LLOG=$LLOG.$$
685 rm -f "$ATLOG/latest" 2>/dev/null
686 mkdir $LLOG
687 export LLOG
689 if [ "$build_ok" = "y" ]; then
690 mv $ATLOG/proto_list_${MACH} $LLOG
692 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
693 mv $ATLOG/proto_list_tools_${MACH} $LLOG
696 if [ -f $TMPDIR/wsdiff.results ]; then
697 mv $TMPDIR/wsdiff.results $LLOG
700 if [ -f $TMPDIR/wsdiff-nd.results ]; then
701 mv $TMPDIR/wsdiff-nd.results $LLOG
705 kill $TEE
706 case "$build_ok" in
708 state=Completed
711 state=Interrupted
714 state=Failed
716 esac
718 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
719 state=Failed
722 NIGHTLY_STATUS=$state
723 export NIGHTLY_STATUS
725 run_hook POST_NIGHTLY $state
726 run_hook SYS_POST_NIGHTLY $state
728 echo "Subject: Nightly ${MACH} Build of `basename ${SRCTOP}` ${state}." \
729 > ${LLOG}/mail_msg
730 cat $build_time_file $mail_msg_file \
731 >> ${LLOG}/mail_msg
732 if [ "$m_FLAG" = "y" ]; then
733 /usr/bin/mail ${MAILTO} < ${LLOG}/mail_msg
736 mv $LOGFILE $LLOG
738 ln -s "$LLOG" "$ATLOG/latest"
742 # Remove the temporary files on any exit
744 function cleanup {
745 logshuffle
747 set -- $newdirlist
748 while [ $# -gt 0 ]; do
749 rmdir $1
750 shift; shift
751 done
752 rm -rf $TMPDIR
755 function cleanup_signal {
756 build_ok=i
757 # this will trigger cleanup(), above.
758 exit 1
761 trap cleanup 0
762 trap cleanup_signal 1 2 3 15
764 newdirlist=
767 # Create mail_msg_file
769 mail_msg_file="${TMPDIR}/mail_msg"
770 touch $mail_msg_file
771 build_time_file="${TMPDIR}/build_time"
773 mkdir -p "$ATLOG"
775 # Move old LOGFILE aside
777 if [ -f $LOGFILE ]; then
778 mv -f $LOGFILE ${LOGFILE}-
781 mkfifo ${TMPDIR}/err.fifo ${TMPDIR}/out.fifo
782 tee $mail_msg_file < ${TMPDIR}/err.fifo >> $LOGFILE &
783 TEE=$!
784 tee ${TMPDIR}/stdout.txt < ${TMPDIR}/out.fifo >> $LOGFILE &
785 TEE="$TEE $!"
786 exec > ${TMPDIR}/out.fifo
787 exec 2> ${TMPDIR}/err.fifo
790 # Build OsNet source
792 START_DATE=`date`
793 SECONDS=0
794 echo "\n==== Nightly $maketype build started: $START_DATE ====" | \
795 tee -a $build_time_file
797 run_hook SYS_PRE_NIGHTLY
798 run_hook PRE_NIGHTLY
800 echo "\n==== list of environment variables ====\n"
803 echo "Building $VERSION
804 on $(uname -srv)" >&2
806 if [[ ! -f $SRC/Makefile ]]; then
807 build_ok=n
808 echo "\nUnable to find \"Makefile\" in $SRC." >&2
809 exit 1
812 # Save the current proto area if we're comparing against the last build
813 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
814 if [ -d "$ROOT.prev" ]; then
815 rm -rf $ROOT.prev
817 mv $ROOT $ROOT.prev
820 # Safeguards
821 [[ -n "${SRCTOP}" ]] || fatal_error "Error: Variable SRCTOP not set."
822 [[ -d "${SRCTOP}" ]] || fatal_error "Error: ${SRCTOP} is not a directory."
823 [[ -f "${SRCTOP}/usr/src/Makefile" ]] || fatal_error "Error: ${SRCTOP}/usr/src/Makefile not found."
826 # Generate the cfgparam files
828 # We have to do this before running *any* make commands.
830 make gen-config || fatal_error "gen-config failed"
833 # Decide whether to clobber
835 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
836 echo "\n==== Make clobber at `date` ====\n"
837 echo "\n==== clobber / cleandir ===="
839 cd $SRC
840 # remove old clobber file
841 rm -f $SRC/clobber.out
842 rm -f $SRC/clobber-${MACH}.out
844 # Remove all .make.state* files, just in case we are restarting
845 # the build after having interrupted a previous 'make clobber'.
846 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
847 -o -name 'interfaces.*' \) -prune \
848 -o -name '.make.*' -print | xargs rm -f
849 if ! $MAKE -ek clobber; then
850 build_extras_ok=n
853 echo "\n==== Make tools clobber at `date` ====\n"
854 cd ${TOOLS}
855 rm -f ${TOOLS}/clobber-${MACH}.out
857 if ! $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber; then
858 build_extras_ok=n
860 rm -rf ${TOOLS_PROTO}
861 mkdir -p ${TOOLS_PROTO}
863 typeset roots=$ROOT
864 echo "\n\nClearing $roots"
865 rm -rf $roots
867 # Get back to a clean workspace as much as possible to catch
868 # problems that only occur on fresh workspaces.
869 # Remove all .make.state* files, libraries, and .o's that may
870 # have been omitted from clobber. A couple of libraries are
871 # under source code control, so leave them alone.
872 # We should probably blow away temporary directories too.
873 cd $SRC
874 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
875 -o -name .git -o -name 'interfaces.*' \) -prune -o \
876 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
877 -name '*.o' \) -print | \
878 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
879 make -C $SRCTOP cleandir
880 else
881 echo "\n==== No clobber at `date` ====\n"
885 # Build and use the workspace's tools if requested
887 set_non_debug_build_flags
889 build_tools ${TOOLS_PROTO}
890 if (( $? != 0 )); then
891 build_ok=n
892 else
893 use_tools $TOOLS_PROTO
896 normal_build
898 ORIG_SRC=$SRC
899 BINARCHIVE=${SRCTOP}/bin-${MACH}.cpio.Z
901 if [ "$build_ok" = "y" ]; then
902 echo "\n==== Creating protolist system file at `date` ====" \
903 protolist $ROOT > $ATLOG/proto_list_${MACH}
904 echo "==== protolist system file created at `date` ====\n" \
906 if [ "$N_FLAG" != "y" ]; then
910 for f in $f1; do
911 if [ -f "$f" ]; then
912 E1="$E1 -e $f"
914 done
918 if [ -d "$SRC/pkg" ]; then
919 f2="$f2 exceptions/packaging"
922 for f in $f2; do
923 if [ -f "$f" ]; then
924 E2="$E2 -e $f"
926 done
929 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
930 echo "\n==== Validating manifests against proto area (protocmp) ====\n" >&2
931 if ! ( cd $SRC/pkg ; /bin/time $MAKE -e protocmp ROOT="$ROOT" ) >&2; then
932 build_extras_ok=n
938 # ELF verification: ABI (-A) and runtime (-r) checks
940 if [ "$build_ok" = y -a '(' "$A_FLAG" = y -o "$r_FLAG" = y ')' ]; then
941 # Directory ELF-data.$MACH holds the files produced by these tests.
942 elf_ddir=$TMPDIR/ELF-data.$MACH
943 mkdir -p $elf_ddir
945 # Call find_elf to produce a list of the ELF objects in the proto area.
946 # This list is passed to check_rtime and interface_check, preventing
947 # them from separately calling find_elf to do the same work twice.
948 find_elf -fr $ROOT > $elf_ddir/object_list
950 if [[ $A_FLAG = y ]]; then
951 echo "\n==== Check versioning and ABI information (interface_check) ====\n" >&2
953 # Produce interface description for the proto. Report errors.
954 /bin/time interface_check -o -w $elf_ddir -f object_list \
955 -i interface -E interface.err
956 if [[ -s $elf_ddir/interface.err ]]; then
957 cat $elf_ddir/interface.err >&2
958 build_extras_ok=n
963 if [[ $r_FLAG = y ]]; then
964 echo "\n==== Check ELF runtime attributes (check_rtime) ====\n" >&2
966 # If we're doing a DEBUG build the proto area will be left
967 # with debuggable objects, thus don't assert -s.
968 if [[ $D_FLAG = y ]]; then
969 rtime_sflag=""
970 else
971 rtime_sflag="-s"
973 /bin/time check_rtime -i -v $rtime_sflag -o -w $elf_ddir \
974 -D object_list -f object_list -E runtime.err \
975 -I runtime.attr.raw
976 if (( $? != 0 )); then
977 build_extras_ok=n
980 # Report errors
981 if [[ -s $elf_ddir/runtime.err ]]; then
982 cat $elf_ddir/runtime.err >&2
983 build_extras_ok=n
988 # "make check" begins
990 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
991 # remove old check.out
992 rm -f $SRC/check.out
994 rm -f $SRC/check-${MACH}.out
995 cd $SRC
996 echo "\n==== dmake check ====\n" >&2
997 if ! /bin/time $MAKE -ek check ROOT="$ROOT"; then
998 build_extras_ok=n
1000 else
1001 echo "\n==== No '$MAKE check' ====\n"
1004 echo "\n==== Find core files ====\n" >&2
1006 find $abssrcdirs -name core -a -type f -exec file {} \; >&2
1008 # Verify that the usual lists of files, such as exception lists,
1009 # contain only valid references to files. If the build has failed,
1010 # then don't check the proto area.
1011 CHECK_PATHS=${CHECK_PATHS:-y}
1012 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
1013 echo "\n==== Check lists of files ====\n" >&2
1014 arg=-b
1015 [ "$build_ok" = y ] && arg=
1016 checkpaths $arg $ROOT > $TMPDIR/check-paths.out 2>&1
1017 if [[ -s $TMPDIR/check-paths.out ]]; then
1018 cat $TMPDIR/check-paths.out >&2
1019 build_extras_ok=n
1023 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
1024 echo "\n==== Impact on file permissions ====\n" >&2
1026 abspkg=
1027 for d in $abssrcdirs; do
1028 if [ -d "$d/pkg" ]; then
1029 abspkg="$abspkg $d"
1031 done
1033 if [ -n "$abspkg" ]; then
1034 for d in "$abspkg"; do
1035 ( cd $d/pkg ; $MAKE -e pmodes ) >&2
1036 done
1040 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
1041 if [[ "$D_FLAG" = y ]]; then
1042 do_wsdiff DEBUG $ROOT.prev $ROOT
1043 else
1044 do_wsdiff non-DEBUG $ROOT.prev $ROOT
1048 END_DATE=`date`
1049 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
1050 tee -a $build_time_file
1052 typeset -i10 hours
1053 typeset -Z2 minutes
1054 typeset -Z2 seconds
1056 elapsed_time=$SECONDS
1057 hours=$(( elapsed_time / 3600 ))
1058 minutes=$(( elapsed_time / 60 % 60 ))
1059 seconds=$((elapsed_time % 60 ))
1061 echo "Total build time ${hours}:${minutes}:${seconds}" |
1062 tee -a $build_time_file
1065 # All done save for the sweeping up.
1066 # (whichever exit we hit here will trigger the "cleanup" trap which
1067 # optionally sends mail on completion).
1069 if [[ "$build_ok" == "y" ]]; then
1070 if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then
1071 exit 0
1075 exit 1