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]
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>
31 # Based on the nightly script from the integration folks,
32 # Mostly modified and owned by mike_s.
33 # Changes also by kjc, dmk.
35 # -i on the command line, means fast options, so when it's on the
36 # command line (only), check builds are skipped no matter what
37 # the setting of their individual flags are in NIGHTLY_OPTIONS.
39 # OPTHOME may be set in the environment to override /opt
43 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
44 # under certain circumstances, which can really screw things up; unset it.
48 # Get the absolute path of the nightly script that the user invoked. This
49 # may be a relative path, and we need to do this before changing directory.
50 nightly_path
=`whence $0`
53 # Keep track of where we found nightly so we can invoke the matching
54 # which_scm script. If that doesn't work, don't go guessing, just rely
55 # on the $PATH settings, which will generally give us either /opt/onbld
56 # or the user's workspace.
58 WHICH_SCM
=$
(dirname $nightly_path)/which_scm
59 if [[ ! -x $WHICH_SCM ]]; then
65 print
-u2 "nightly: $*"
70 # Function to do a DEBUG and non-DEBUG build. Needed because we might
71 # need to do another for the source build, and since we only deliver DEBUG or
76 function normal_build
{
78 typeset orig_p_FLAG
="$p_FLAG"
80 if [ "$D_FLAG" = "n" ]; then
81 set_non_debug_build_flags
92 # usage: run_hook HOOKNAME ARGS...
94 # If variable "$HOOKNAME" is defined, insert a section header into
95 # our logs and then run the command with ARGS
99 eval HOOKCMD
=\$
$HOOKNAME
102 if [ -n "$HOOKCMD" ]; then
104 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
105 ( $HOOKCMD "$@" 2>&1 )
106 if [ "$?" -ne 0 ]; then
107 # Let exit status propagate up
112 if [ -f $TMPDIR/abort
]; then
114 echo "\nAborting at request of $HOOKNAME"
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`
148 # Before we build anything via dmake, we need to install
149 # bmake-ified headers to the proto area
151 bmake_build_step_user_dir
$CODEMGR_WS/include all
152 bmake_build_step_user_dir
$CODEMGR_WS/include
install
155 # Build the legacy part of the source
157 echo "\n==== Building legacy source at `date` ($LABEL) ====\n"
160 echo "\n==== dmake install ====\n" >&2
161 if ! /bin
/time $MAKE -e install; then
167 # Build the new part of the source
169 bmake_build_step_user build
171 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n"
176 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
177 if [ -d $SRC/pkg
]; then
178 echo "\n==== Creating $LABEL packages at `date` ====\n"
179 echo "Clearing out $PKGARCHIVE ..."
183 rm -f $SRC/pkg
/${INSTALLOG}.out
185 echo "\n==== package build errors ($LABEL) ====\n" >&2
186 if ! /bin
/time $MAKE -e install; then
192 # Handle it gracefully if -p was set but there so
195 echo "\n==== No $LABEL packages to build ====\n"
198 echo "\n==== Not creating $LABEL packages ====\n"
203 # Build and install the onbld tools.
205 # usage: build_tools DESTROOT
207 # returns non-zero status if the build was successful.
209 function build_tools
{
212 INSTALLOG
=install-
${MACH}
214 echo "\n==== Building tools at `date` ====\n" \
216 rm -f ${TOOLS}/${INSTALLOG}.out
218 echo "\n==== Tools build errors ====\n" >&2
219 if ! /bin
/time $MAKE TOOLS_PROTO
=${DESTROOT} -e install; then
226 # Set up to use locally installed tools.
228 # usage: use_tools TOOLSROOT
234 # If we're not building ON workspace, then the TOOLSROOT
235 # settings here are clearly ignored by the workspace
236 # makefiles, prepending nonexistent directories to PATH is
237 # harmless, and we clearly do not wish to override
240 # If we're building an ON workspace, then the prepended PATH
241 # elements should supercede the preexisting ONBLD_TOOLS paths,
242 # and we want to override ONBLD_TOOLS to catch the tools that
243 # don't have specific path env vars here.
245 # So the only conditional behavior is overriding ONBLD_TOOLS,
246 # and we check for "an ON workspace" by looking for
247 # ${TOOLSROOT}/opt/onbld.
250 STABS
=${TOOLSROOT}/opt
/onbld
/bin
/${MACH}/stabs
252 CTFSTABS
=${TOOLSROOT}/opt
/onbld
/bin
/${MACH}/ctfstabs
254 GENOFFSETS
=${TOOLSROOT}/opt
/onbld
/bin
/genoffsets
258 PATH
="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}"
259 PATH
="${TOOLSROOT}/opt/onbld/bin:${PATH}"
262 if [ -d "${TOOLSROOT}/opt/onbld" ]; then
263 ONBLD_TOOLS
=${TOOLSROOT}/opt
/onbld
267 echo "\n==== New environment settings. ====\n"
268 echo "STABS=${STABS}"
269 echo "CTFSTABS=${CTFSTABS}"
271 echo "ONBLD_TOOLS=${ONBLD_TOOLS}"
275 # wrapper over wsdiff.
276 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
285 echo "\n==== Getting object changes since last build at `date`" \
286 "($label) ====\n" >&2
287 $wsdiff -s -r ${TMPDIR}/wsdiff.results
$oldproto $newproto >&2
288 echo "\n==== Object changes determined at `date` ($label) ====\n" >&2
292 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
296 function set_non_debug_build_flags
{
297 export RELEASE_BUILD
; RELEASE_BUILD
=
302 function set_debug_build_flags
{
311 if [ "$OPTHOME" = "" ]; then
316 USAGE
='Usage: nightly [-in] [-V VERS ] <env_file>
319 -i Fast incremental options (no clobber, check)
320 -V VERS set the build version string to VERS
322 <env_file> file in Bourne shell syntax that sets and exports
323 variables that configure the operation of this script and many of
324 the scripts this one calls.
326 non-DEBUG is the default build type. Build options can be set in the
327 NIGHTLY_OPTIONS variable in the <env_file> as follows:
329 -A check for ABI differences in .so files
330 -C check for cstyle/hdrchk errors
331 -D do a build with DEBUG on
332 -G gate keeper default group of options (-au)
333 -I integration engineer default group of options (-ampu)
334 -M do not run pmodes (safe file permission checker)
335 -N do not run protocmp
336 -R default group of options for building a release (-mp)
337 -U update proto area in the parent
338 -V VERS set the build version string to VERS
339 -f find unreferenced files
340 -i do an incremental build (no "make clobber")
341 -m send mail to $MAILTO at end of build
343 -r check ELF runtime attributes in the proto area
344 -u update proto_list_$MACH and friends in the parent workspace;
345 when used with -f, also build an unrefmaster.out in the parent
346 -w report on differences between previous and current proto areas
349 # A log file will be generated under the name $LOGFILE
350 # for partially completed build and log.`date '+%F'`
351 # in the same directory for fully completed builds.
354 # default values for low-level FLAGS; G I R are group FLAGS
359 i_FLAG
=n
; i_CMD_LINE_FLAG
=n
377 while getopts +iV
:W FLAG
380 i
) i_FLAG
=y
; i_CMD_LINE_FLAG
=y
393 # correct argument count after options
394 shift `expr $OPTIND - 1`
396 # test that the path to the environment-setting file was given
397 if [ $# -ne 1 ]; then
405 LC_ALL
=C
; export LC_ALL
406 LC_COLLATE
=C
; export LC_COLLATE
407 LC_CTYPE
=C
; export LC_CTYPE
408 LC_MESSAGES
=C
; export LC_MESSAGES
409 LC_MONETARY
=C
; export LC_MONETARY
410 LC_NUMERIC
=C
; export LC_NUMERIC
411 LC_TIME
=C
; export LC_TIME
413 # clear environment variables we know to be bad for the build
415 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
416 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
417 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
418 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
419 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
420 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
421 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
422 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
423 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
424 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
425 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
426 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
427 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
428 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
429 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
430 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
431 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
432 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
433 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
434 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
446 # To get ONBLD_TOOLS from the environment, it must come from the env file.
447 # If it comes interactively, it is generally TOOLS_PROTO, which will be
448 # clobbered before the compiler version checks, which will therefore fail.
453 # Setup environmental variables
456 if [[ $1 = */* ]]; then
462 echo "Cannot find env file as either $1"
466 # Check if we have sufficient data to continue...
467 [[ -v CODEMGR_WS
]] || \
468 fatal_error
"Error: Variable CODEMGR_WS not set."
469 [[ -d "${CODEMGR_WS}" ]] || \
470 fatal_error
"Error: ${CODEMGR_WS} is not a directory."
471 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
472 fatal_error
"Error: ${CODEMGR_WS}/usr/src/Makefile not found."
475 # place ourselves in a new task, respecting BUILD_PROJECT if set.
477 if [ -z "$BUILD_PROJECT" ]; then
478 /usr
/bin
/newtask
-c $$
480 /usr
/bin
/newtask
-c $$
-p $BUILD_PROJECT
483 ps
-o taskid
= -p $$ |
read build_taskid
484 ps
-o project
= -p $$ |
read build_project
487 # See if NIGHTLY_OPTIONS is set
489 if [ "$NIGHTLY_OPTIONS" = "" ]; then
490 NIGHTLY_OPTIONS
="-aBm"
494 # Note: changes to the option letters here should also be applied to the
495 # bldenv script. `d' is listed for backward compatibility.
497 NIGHTLY_OPTIONS
=-${NIGHTLY_OPTIONS#-}
499 while getopts +ABCDdfGIiMmNpRrwW FLAG
$NIGHTLY_OPTIONS
505 ;; # old version of D
541 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
542 MAILTO
=`/usr/xpg4/bin/id -un`
546 PATH
="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
547 PATH
="$PATH:/usr/bin:/usr/sbin:/usr/ucb"
548 PATH
="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:.:$OPTHOME/SUNWspro/bin"
551 # roots of source trees, both relative to $SRC and absolute.
555 PROTOCMPTERSE
="protocmp.terse -gu"
557 # have we set RELEASE_DATE in our env file?
558 if [ -z "$RELEASE_DATE" ]; then
559 RELEASE_DATE
=$
(LC_ALL
=C
date +"%B %Y")
561 BUILD_DATE
=$
(LC_ALL
=C
date +%Y-
%b-
%d
)
562 BASEWSDIR
=$
(basename $CODEMGR_WS)
563 DEV_CM
="\"@(#)illumos Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
564 RELEASE_MICRO
=$
(( ($
(date +%Y
) * 12 + $
(date +%m
) - 1) - (2010 * 12 + 8 - 1) ))
566 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
567 # by avoiding repeated shell invocations to evaluate Makefile.master
569 export POUND_SIGN RELEASE_DATE DEV_CM RELEASE_MICRO
571 maketype
="distributed"
572 if [[ -z "$MAKE" ]]; then
574 elif [[ ! -x "$MAKE" ]]; then
575 echo "\$MAKE is set to garbage in the environment"
582 if [[ $DMAKE_MAX_JOBS != +([0-9]) ||
$DMAKE_MAX_JOBS -eq 0 ]]
585 if [[ -f $HOME/.
make.machines
]]
587 # Note: there is a hard tab and space character in the []s
589 egrep -i "^[ ]*$hostname[ \.]" \
590 $HOME/.
make.machines |
read host jobs
594 if [[ $maxjobs != +([0-9]) ||
$maxjobs -eq 0 ]]
600 export DMAKE_MAX_JOBS
=$maxjobs
606 if [ -z "${ROOT}" ]; then
607 echo "ROOT must be set."
612 # if -V flag was given, reset VERSION to V_ARG
614 if [ "$V_FLAG" = "y" ]; then
618 TMPDIR
="/tmp/nightly.tmpdir.$$"
621 mkdir
-p $TMPDIR ||
exit 1
623 # Tools should only be built non-DEBUG. Keep track of the tools proto
624 # area path relative to $TOOLS, because the latter changes in an
627 # TOOLS_PROTO is included below for builds other than usr/src/tools
628 # that look for this location. For usr/src/tools, this will be
629 # overridden on the $MAKE command line in build_tools().
632 TOOLS_PROTO_REL
=proto
/root_
${MACH}-nd
633 TOOLS_PROTO
=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
635 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
637 # create directories that are automatically removed if the nightly script
638 # fails to start correctly
642 while [ ! -d $dir ]; do
648 for dir
in $toadd; do
650 newlist
="$dir $newlist"
653 [ -z "$torm" ] ||
rmdir $torm
657 newdirlist
="$newlist $newdirlist"
662 [ -d $CODEMGR_WS ] || newdir
$CODEMGR_WS ||
exit 1
664 # since this script assumes the build is from full source, it nullifies
665 # variables likely to have been set by a "ws" script; nullification
666 # confines the search space for headers and libraries to the proto area
667 # built from this immediate source.
676 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
677 ENVLDLIBS1 ENVLDLIBS2
680 # Juggle the logs and optionally send mail on completion.
683 function logshuffle
{
684 LLOG
="$ATLOG/log.`date '+%F.%H:%M'`"
685 if [ -f $LLOG -o -d $LLOG ]; then
691 if [ "$build_ok" = "y" ]; then
692 mv $ATLOG/proto_list_
${MACH} $LLOG
694 if [ -f $ATLOG/proto_list_tools_
${MACH} ]; then
695 mv $ATLOG/proto_list_tools_
${MACH} $LLOG
698 if [ -f $TMPDIR/wsdiff.results
]; then
699 mv $TMPDIR/wsdiff.results
$LLOG
702 if [ -f $TMPDIR/wsdiff-nd.results
]; then
703 mv $TMPDIR/wsdiff-nd.results
$LLOG
720 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
724 NIGHTLY_STATUS
=$state
725 export NIGHTLY_STATUS
727 run_hook POST_NIGHTLY
$state
728 run_hook SYS_POST_NIGHTLY
$state
730 echo "Subject: Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
732 cat $build_time_file $mail_msg_file \
734 if [ "$m_FLAG" = "y" ]; then
735 /usr
/bin
/mail ${MAILTO} < ${LLOG}/mail_msg
742 # Remove the temporary files on any exit
748 while [ $# -gt 0 ]; do
755 function cleanup_signal
{
757 # this will trigger cleanup(), above.
762 trap cleanup_signal
1 2 3 15
767 # Create mail_msg_file
769 mail_msg_file
="${TMPDIR}/mail_msg"
771 build_time_file
="${TMPDIR}/build_time"
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 &
784 tee ${TMPDIR}/stdout.txt
< ${TMPDIR}/out.fifo
>> $LOGFILE &
786 exec > ${TMPDIR}/out.fifo
787 exec 2> ${TMPDIR}/err.fifo
794 echo "\n==== Nightly $maketype build started: $START_DATE ====" | \
795 tee -a $build_time_file
797 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" >&2
799 run_hook SYS_PRE_NIGHTLY
802 echo "\n==== list of environment variables ====\n"
805 echo "\n==== Nightly argument issues ====\n" >&2
807 if [ "$N_FLAG" = "y" ]; then
808 if [ "$p_FLAG" = "y" ]; then
810 WARNING: the p option (create packages) is set, but so is the N option (do
811 not run protocmp); this is dangerous; you should unset the N option
815 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
821 if [ "$f_FLAG" = "y" ]; then
822 if [ "$i_FLAG" = "y" ]; then
823 echo "WARNING: the -f flag cannot be used during incremental" \
824 "builds; ignoring -f\n" >&2
827 if [ "${p_FLAG}" != "y" ]; then
828 echo "WARNING: the -f flag requires -p;" \
834 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
835 echo "WARNING: -w specified, but $ROOT does not exist;" \
840 echo "\n==== Build version ====\n" >&2
843 # Save the current proto area if we're comparing against the last build
844 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
845 if [ -d "$ROOT.prev" ]; then
851 # Echo the SCM types of $CODEMGR_WS
852 function child_wstype
{
853 typeset scm_type junk
855 # Probe CODEMGR_WS to determine its type
856 if [[ -d $CODEMGR_WS ]]; then
857 $WHICH_SCM |
read scm_type junk ||
exit 1
871 echo "\n==== bmake $@ ====\n" >&2
872 /bin
/time env
-i PATH
=${GCC_ROOT}/bin
:/usr
/bin \
873 bmake
-j $DMAKE_MAX_JOBS \
878 # usage: bmake_build_step_args <dir> <target> <args...>
879 function bmake_build_step_args
{
883 echo "\n==== \`bmake -C $D $@\` at `date` ($LABEL) ====\n"
885 if ! run_bmake
-C $D "$@"; then
894 # usage: bmake_build_step_user <target>
895 function bmake_build_step_user
{
896 bmake_build_step_args
$CODEMGR_WS $1 \
900 # usage: bmake_build_step_user_dir <dir> <target>
901 function bmake_build_step_user_dir
{
902 bmake_build_step_args
$1 $2 \
906 SCM_TYPE
=$
(child_wstype
)
909 [[ -v CODEMGR_WS
]] || fatal_error
"Error: Variable CODEMGR_WS not set."
910 [[ -d "${CODEMGR_WS}" ]] || fatal_error
"Error: ${CODEMGR_WS} is not a directory."
911 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error
"Error: ${CODEMGR_WS}/usr/src/Makefile not found."
914 # Generate the cfgparam files
916 # We have to do this before running *any* make commands.
918 bmake_build_step_args
$CODEMGR_WS gen-config || build_extras_ok
=n
921 # Decide whether to clobber
923 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
924 echo "\n==== Make clobber at `date` ====\n"
927 # remove old clobber file
928 rm -f $SRC/clobber.out
929 rm -f $SRC/clobber-
${MACH}.out
931 # Remove all .make.state* files, just in case we are restarting
932 # the build after having interrupted a previous 'make clobber'.
933 find . \
( -name SCCS
-o -name .hg
-o -name .svn
-o -name .git \
934 -o -name 'interfaces.*' \
) -prune \
935 -o -name '.make.*' -print |
xargs rm -f
937 echo "\n==== Make clobber ERRORS ====\n" >&2
938 if ! $MAKE -ek clobber
; then
942 echo "\n==== Make tools clobber at `date` ====\n"
944 rm -f ${TOOLS}/clobber-
${MACH}.out
946 echo "\n==== Make tools clobber ERRORS ====\n" >&2
947 if ! $MAKE TOOLS_PROTO
=$TOOLS_PROTO -ek clobber
; then
950 rm -rf ${TOOLS_PROTO}
951 mkdir
-p ${TOOLS_PROTO}
954 echo "\n\nClearing $roots"
957 # Get back to a clean workspace as much as possible to catch
958 # problems that only occur on fresh workspaces.
959 # Remove all .make.state* files, libraries, and .o's that may
960 # have been omitted from clobber. A couple of libraries are
961 # under source code control, so leave them alone.
962 # We should probably blow away temporary directories too.
964 find $relsrcdirs \
( -name SCCS
-o -name .hg
-o -name .svn \
965 -o -name .git
-o -name 'interfaces.*' \
) -prune -o \
966 \
( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
967 -name '*.o' \
) -print | \
968 grep -v 'tools/ctf/dwarf/.*/libdwarf' |
xargs rm -f
969 echo "\n==== bmake cleandir ====\n"
970 run_bmake
-C $CODEMGR_WS cleandir
972 echo "\n==== No clobber at `date` ====\n"
975 echo "\n==== Build environment ====\n" >&2
985 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" >&2
988 # Report the compiler versions.
991 if [[ ! -f $SRC/Makefile
]]; then
993 echo "\nUnable to find \"Makefile\" in $SRC." >&2
1001 # Build and use the workspace's tools if requested
1003 set_non_debug_build_flags
1005 build_tools
${TOOLS_PROTO}
1006 if (( $?
!= 0 )); then
1009 use_tools
$TOOLS_PROTO
1012 # timestamp the start of the normal build; the findunref tool uses it.
1013 touch $SRC/.build.tstamp
1018 BINARCHIVE
=${CODEMGR_WS}/bin-
${MACH}.
cpio.Z
1020 if [ "$build_ok" = "y" ]; then
1021 echo "\n==== Creating protolist system file at `date` ====" \
1022 protolist
$ROOT > $ATLOG/proto_list_
${MACH}
1023 echo "==== protolist system file created at `date` ====\n" \
1025 if [ "$N_FLAG" != "y" ]; then
1030 if [ -f "$f" ]; then
1037 if [ -d "$SRC/pkg" ]; then
1038 f2
="$f2 exceptions/packaging"
1042 if [ -f "$f" ]; then
1048 if [ "$N_FLAG" != "y" -a -d $SRC/pkg
]; then
1049 echo "\n==== Validating manifests against proto area ====\n" >&2
1050 if ! ( cd $SRC/pkg
; $MAKE -e protocmp ROOT
="$ROOT" ) >&2; then
1057 # ELF verification: ABI (-A) and runtime (-r) checks
1059 if [[ ($build_ok = y
) && (($A_FLAG = y
) ||
($r_FLAG = y
)) ]]; then
1060 # Directory ELF-data.$MACH holds the files produced by these tests.
1061 elf_ddir
=$SRC/ELF-data.
$MACH
1063 # If there is a previous ELF-data backup directory, remove it. Then,
1064 # rotate current ELF-data directory into its place and create a new
1066 rm -rf $elf_ddir.ref
1067 if [[ -d $elf_ddir ]]; then
1068 mv $elf_ddir $elf_ddir.ref
1072 # Call find_elf to produce a list of the ELF objects in the proto area.
1073 # This list is passed to check_rtime and interface_check, preventing
1074 # them from separately calling find_elf to do the same work twice.
1075 find_elf
-fr $ROOT > $elf_ddir/object_list
1077 if [[ $A_FLAG = y
]]; then
1078 echo "\n==== Check versioning and ABI information ====\n" >&2
1080 # Produce interface description for the proto. Report errors.
1081 interface_check
-o -w $elf_ddir -f object_list \
1082 -i interface
-E interface.err
1083 if [[ -s $elf_ddir/interface.err
]]; then
1084 cat $elf_ddir/interface.err
>&2
1088 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1089 # description file to that from the baseline gate. Issue a
1090 # warning if the baseline is not present, and keep going.
1091 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1092 base_ifile
="$ELF_DATA_BASELINE_DIR/interface"
1094 echo "\n==== Compare versioning and ABI information" \
1095 "to baseline ====\n" >&2
1096 echo "Baseline: $base_ifile\n"
1098 if [[ -f $base_ifile ]]; then
1099 interface_cmp
-d -o $base_ifile \
1100 $elf_ddir/interface
> $elf_ddir/interface.
cmp
1101 if [[ -s $elf_ddir/interface.
cmp ]]; then
1103 cat $elf_ddir/interface.
cmp >&2
1107 echo "baseline not available. comparison" \
1114 if [[ $r_FLAG = y
]]; then
1115 echo "\n==== Check ELF runtime attributes ====\n" >&2
1117 # If we're doing a DEBUG build the proto area will be left
1118 # with debuggable objects, thus don't assert -s.
1119 if [[ $D_FLAG = y
]]; then
1124 check_rtime
-i -m -v $rtime_sflag -o -w $elf_ddir \
1125 -D object_list
-f object_list
-E runtime.err \
1127 if (( $?
!= 0 )); then
1131 # check_rtime -I output needs to be sorted in order to
1132 # compare it to that from previous builds.
1133 sort $elf_ddir/runtime.attr.raw
> $elf_ddir/runtime.attr
1134 rm $elf_ddir/runtime.attr.raw
1137 if [[ -s $elf_ddir/runtime.err
]]; then
1138 cat $elf_ddir/runtime.err
>&2
1142 # If there is an ELF-data directory from a previous build,
1143 # then diff the attr files. These files contain information
1144 # about dependencies, versioning, and runpaths. There is some
1145 # overlap with the ABI checking done above, but this also
1146 # flushes out non-ABI interface differences along with the
1147 # other information.
1148 echo "\n==== Diff ELF runtime attributes" \
1149 "(since last build) ====\n" >&2
1151 if [[ -f $elf_ddir.ref
/runtime.attr
]]; then
1152 diff $elf_ddir.ref
/runtime.attr \
1153 $elf_ddir/runtime.attr
>&2
1158 # "make check" begins
1160 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
1161 # remove old check.out
1162 rm -f $SRC/check.out
1164 rm -f $SRC/check-
${MACH}.out
1166 echo "\n==== cstyle/hdrchk errors ====\n" >&2
1167 if ! $MAKE -ek check ROOT
="$ROOT"; then
1171 echo "\n==== No '$MAKE check' ====\n"
1174 echo "\n==== Find core files ====\n" >&2
1176 find $abssrcdirs -name core
-a -type f
-exec file {} \
; >&2
1178 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
1179 echo "\n==== Diff unreferenced files (since last build) ====\n" >&2
1180 rm -f $SRC/unref-
${MACH}.ref
1181 if [ -f $SRC/unref-
${MACH}.out
]; then
1182 mv $SRC/unref-
${MACH}.out
$SRC/unref-
${MACH}.ref
1185 findunref
-S $SCM_TYPE -t $SRC/.build.tstamp
-s usr
$CODEMGR_WS \
1186 ${TOOLS}/findunref
/exception_list | \
1187 sort > $SRC/unref-
${MACH}.out
1189 if [ ! -f $SRC/unref-
${MACH}.ref
]; then
1190 cp $SRC/unref-
${MACH}.out
$SRC/unref-
${MACH}.ref
1193 diff $SRC/unref-
${MACH}.ref
$SRC/unref-
${MACH}.out
>&2
1196 # Verify that the usual lists of files, such as exception lists,
1197 # contain only valid references to files. If the build has failed,
1198 # then don't check the proto area.
1199 CHECK_PATHS
=${CHECK_PATHS:-y}
1200 if [ "$CHECK_PATHS" = y
-a "$N_FLAG" != y
]; then
1201 echo "\n==== Check lists of files ====\n" >&2
1203 [ "$build_ok" = y
] && arg
=
1204 checkpaths
$arg $ROOT > $SRC/check-paths.out
2>&1
1205 if [[ -s $SRC/check-paths.out
]]; then
1206 cat $SRC/check-paths.out
>&2
1211 if [ "$M_FLAG" != "y" -a "$build_ok" = y
]; then
1212 echo "\n==== Impact on file permissions ====\n" >&2
1215 for d
in $abssrcdirs; do
1216 if [ -d "$d/pkg" ]; then
1221 if [ -n "$abspkg" ]; then
1222 for d
in "$abspkg"; do
1223 ( cd $d/pkg
; $MAKE -e pmodes
) >&2
1228 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
1229 if [[ "$D_FLAG" = y
]]; then
1230 do_wsdiff DEBUG
$ROOT.prev
$ROOT
1232 do_wsdiff non-DEBUG
$ROOT.prev
$ROOT
1237 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
1238 tee -a $build_time_file
1244 elapsed_time
=$SECONDS
1245 ((hours
= elapsed_time
/ 3600 ))
1246 ((minutes
= elapsed_time
/ 60 % 60))
1247 ((seconds
= elapsed_time
% 60))
1249 echo "\n==== Total build time ====" | \
1250 tee -a $build_time_file
1251 echo "\nreal ${hours}:${minutes}:${seconds}" | \
1252 tee -a $build_time_file
1255 # All done save for the sweeping up.
1256 # (whichever exit we hit here will trigger the "cleanup" trap which
1257 # optionally sends mail on completion).
1259 if [[ "$build_ok" == "y" ]]; then
1260 if [[ "$W_FLAG" == "y" ||
"$build_extras_ok" == "y" ]]; then