29 # Based on the nightly script from the integration folks,
30 # Mostly modified and owned by mike_s.
31 # Changes also by kjc, dmk.
32 #
33 # BRINGOVER_WS may be specified in the env file.
34 # The default is the old behavior of CLONE_WS
35 #
36 # -i on the command line, means fast options, so when it's on the
37 # command line (only), lint and check builds are skipped no matter what
38 # the setting of their individual flags are in NIGHTLY_OPTIONS.
39 #
40 # LINTDIRS can be set in the env file, format is a list of:
41 #
42 # /dirname-to-run-lint-on flag
43 #
44 # Where flag is: y - enable lint noise diff output
45 # n - disable lint noise diff output
46 #
47 # For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
48 #
49 # OPTHOME and TEAMWARE may be set in the environment to override /opt
50 # and /opt/teamware defaults.
51 #
52
53 #
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.
56 #
57 unset CDPATH
58
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`
62
63 #
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.
68 #
69 WHICH_SCM=$(dirname $nightly_path)/which_scm
70 if [[ ! -x $WHICH_SCM ]]; then
80 #
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.
84 #
85 # usage: normal_build
86 #
87 function normal_build {
88
89 typeset orig_p_FLAG="$p_FLAG"
90 typeset crypto_signer="$CODESIGN_USER"
91
92 suffix=""
93
94 # non-DEBUG build begins
95
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 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \
101 "$p_FLAG" = "y" ]; then
102 copy_ihv_pkgs non-DEBUG -nd
103 fi
104 else
105 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
106 fi
107
108 # non-DEBUG build ends
109
110 # DEBUG build begins
111
112 if [ "$D_FLAG" = "y" ]; then
113 set_debug_build_flags
114 CODESIGN_USER="$crypto_signer" \
115 build "DEBUG" "$suffix" "" "$MULTI_PROTO"
116 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \
117 "$p_FLAG" = "y" ]; then
118 copy_ihv_pkgs DEBUG ""
119 fi
120 else
121 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
122 fi
123
124 # DEBUG build ends
125
126 p_FLAG="$orig_p_FLAG"
127 }
128
129 #
130 # usage: run_hook HOOKNAME ARGS...
131 #
132 # If variable "$HOOKNAME" is defined, insert a section header into
133 # our logs and then run the command with ARGS
134 #
135 function run_hook {
136 HOOKNAME=$1
137 eval HOOKCMD=\$$HOOKNAME
138 shift
139
140 if [ -n "$HOOKCMD" ]; then
141 (
142 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
143 ( $HOOKCMD "$@" 2>&1 )
144 if [ "$?" -ne 0 ]; then
145 # Let exit status propagate up
146 touch $TMPDIR/abort
147 fi
148 ) | tee -a $mail_msg_file >> $LOGFILE
149
150 if [ -f $TMPDIR/abort ]; then
151 build_ok=n
152 echo "\nAborting at request of $HOOKNAME" |
153 tee -a $mail_msg_file >> $LOGFILE
154 exit 1
155 fi
156 fi
157 }
158
159 #
160 # usage: filelist DESTDIR PATTERN
161 #
162 function filelist {
163 DEST=$1
164 PATTERN=$2
165 cd ${DEST}
166 }
167
168 # function to save off binaries after a full build for later
169 # restoration
170 function save_binaries {
171 # save off list of binaries
172 echo "\n==== Saving binaries from build at `date` ====\n" | \
173 tee -a $mail_msg_file >> $LOGFILE
174 rm -f ${BINARCHIVE}
175 cd ${CODEMGR_WS}
176 filelist ${CODEMGR_WS} '^preserve:' >> $LOGFILE
177 filelist ${CODEMGR_WS} '^preserve:' | \
178 cpio -ocB 2>/dev/null | compress \
179 > ${BINARCHIVE}
180 }
181
182 # delete files
183 # usage: hybridize_files DESTDIR MAKE_TARGET
184 function hybridize_files {
185 DEST=$1
186 MAKETARG=$2
187
188 echo "\n==== Hybridizing files at `date` ====\n" | \
189 tee -a $mail_msg_file >> $LOGFILE
190 for i in `filelist ${DEST} '^delete:'`
191 do
192 echo "removing ${i}." | tee -a $mail_msg_file >> $LOGFILE
193 rm -rf "${i}"
194 done
195 for i in `filelist ${DEST} '^hybridize:' `
196 do
197 echo "hybridizing ${i}." | tee -a $mail_msg_file >> $LOGFILE
198 rm -f ${i}+
199 sed -e "/^# HYBRID DELETE START/,/^# HYBRID DELETE END/d" \
200 < ${i} > ${i}+
201 mv ${i}+ ${i}
202 done
203 }
204
205 # restore binaries into the proper source tree.
206 # usage: restore_binaries DESTDIR MAKE_TARGET
207 function restore_binaries {
208 DEST=$1
209 MAKETARG=$2
210
211 echo "\n==== Restoring binaries to ${MAKETARG} at `date` ====\n" | \
212 tee -a $mail_msg_file >> $LOGFILE
213 cd ${DEST}
214 zcat ${BINARCHIVE} | \
215 cpio -idmucvB 2>/dev/null | tee -a $mail_msg_file >> ${LOGFILE}
216 }
217
218 # rename files we save binaries of
219 # usage: rename_files DESTDIR MAKE_TARGET
220 function rename_files {
221 DEST=$1
222 MAKETARG=$2
223 echo "\n==== Renaming source files in ${MAKETARG} at `date` ====\n" | \
224 tee -a $mail_msg_file >> $LOGFILE
225 for i in `filelist ${DEST} '^rename:'`
226 do
227 echo ${i} | tee -a $mail_msg_file >> ${LOGFILE}
228 rm -f ${i}.export
229 mv ${i} ${i}.export
230 done
231 }
232
233 # Return library search directive as function of given root.
234 function myldlibs {
235 echo "-L$1/lib -L$1/usr/lib"
236 }
237
238 # Return header search directive as function of given root.
239 function myheaders {
240 echo "-I$1/usr/include"
241 }
242
243 #
244 # Function to do the build, including package generation.
245 # usage: build LABEL SUFFIX ND MULTIPROTO
246 # - LABEL is used to tag build output.
247 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
248 # open-only vs full tree).
249 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
250 # - If MULTIPROTO is "yes", it means to name the proto area according to
251 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
252 #
260 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
261
262 ORIGROOT=$ROOT
263 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
264
265 export ENVLDLIBS1=`myldlibs $ROOT`
266 export ENVCPPFLAGS1=`myheaders $ROOT`
267
268 this_build_ok=y
269 #
270 # Build OS-Networking source
271 #
272 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
273 >> $LOGFILE
274
275 rm -f $SRC/${INSTALLOG}.out
276 cd $SRC
277 /bin/time $MAKE -e install 2>&1 | \
278 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
279
280 if [[ "$SCM_TYPE" = teamware ]]; then
281 echo "\n==== SCCS Noise ($LABEL) ====\n" >> $mail_msg_file
282 egrep 'sccs(check:| *get)' $SRC/${INSTALLOG}.out >> \
283 $mail_msg_file
284 fi
285
286 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
287 egrep ":" $SRC/${INSTALLOG}.out |
288 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
289 egrep -v "Ignoring unknown host" | \
290 egrep -v "cc .* -o error " | \
291 egrep -v "warning" >> $mail_msg_file
292 if [ "$?" = "0" ]; then
293 build_ok=n
294 this_build_ok=n
295 fi
296 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
297 >> $mail_msg_file
298 if [ "$?" = "0" ]; then
299 build_ok=n
300 this_build_ok=n
301 fi
302
303 if [ "$W_FLAG" = "n" ]; then
304 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
305 egrep -i warning: $SRC/${INSTALLOG}.out \
306 | egrep -v '^tic:' \
307 | egrep -v "symbol (\`|')timezone' has differing types:" \
308 | egrep -v "parameter <PSTAMP> set to" \
309 | egrep -v "Ignoring unknown host" \
310 | egrep -v "redefining segment flags attribute for" \
311 >> $mail_msg_file
312 fi
313
314 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
315 >> $LOGFILE
316
317 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
318 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
319
320 if [ "$i_FLAG" = "n" -a "$W_FLAG" = "n" ]; then
321 rm -f $SRC/${NOISE}.ref
322 if [ -f $SRC/${NOISE}.out ]; then
323 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
324 fi
325 grep : $SRC/${INSTALLOG}.out \
326 | egrep -v '^/' \
327 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
328 | egrep -v '^tic:' \
329 | egrep -v '^mcs' \
330 | egrep -v '^LD_LIBRARY_PATH=' \
331 | egrep -v 'ar: creating' \
332 | egrep -v 'ar: writing' \
333 | egrep -v 'conflicts:' \
334 | egrep -v ':saved created' \
335 | egrep -v '^stty.*c:' \
336 | egrep -v '^mfgname.c:' \
337 | egrep -v '^uname-i.c:' \
338 | egrep -v '^volumes.c:' \
339 | egrep -v '^lint library construction:' \
340 | egrep -v 'tsort: INFORM:' \
389 signing_file="${TMPDIR}/signing"
390 rm -f ${signing_file}
391 export CODESIGN_USER
392 signproto $SRC/tools/codesign/creds 2>&1 | \
393 tee -a ${signing_file} >> $LOGFILE
394 echo "\n==== Finished signing proto area at `date` ====\n" \
395 >> $LOGFILE
396 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
397 >> $mail_msg_file
398 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
399 if (( $? == 0 )) ; then
400 build_ok=n
401 this_build_ok=n
402 fi
403 fi
404
405 #
406 # Building Packages
407 #
408 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
409 if [ -d $SRC/pkg -o -d $SRC/pkgdefs ]; then
410 echo "\n==== Creating $LABEL packages at `date` ====\n" \
411 >> $LOGFILE
412 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
413 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
414 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
415
416 for d in pkg pkgdefs; do
417 if [ ! -f "$SRC/$d/Makefile" ]; then
418 continue
419 fi
420 rm -f $SRC/$d/${INSTALLOG}.out
421 cd $SRC/$d
422 /bin/time $MAKE -e install 2>&1 | \
423 tee -a $SRC/$d/${INSTALLOG}.out >> $LOGFILE
424 done
425
426 echo "\n==== package build errors ($LABEL) ====\n" \
427 >> $mail_msg_file
428
429 for d in pkg pkgdefs; do
430 if [ ! -f "$SRC/$d/Makefile" ]; then
431 continue
432 fi
433
434 egrep "${MAKE}|ERROR|WARNING" $SRC/$d/${INSTALLOG}.out | \
435 grep ':' | \
436 grep -v PSTAMP | \
437 egrep -v "Ignoring unknown host" \
438 >> $mail_msg_file
439 done
440 else
441 #
442 # Handle it gracefully if -p was set but there are
443 # neither pkg nor pkgdefs directories.
444 #
445 echo "\n==== No $LABEL packages to build ====\n" \
446 >> $LOGFILE
447 fi
448 else
449 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
450 fi
451
452 ROOT=$ORIGROOT
453 }
454
455 # Usage: dolint /dir y|n
456 # Arg. 2 is a flag to turn on/off the lint diff output
457 function dolint {
458 if [ ! -d "$1" ]; then
459 echo "dolint error: $1 is not a directory"
460 exit 1
461 fi
462
463 if [ "$2" != "y" -a "$2" != "n" ]; then
519 egrep -v 'Ignoring unknown host' | \
520 egrep -v '\.c:$' | \
521 sort | uniq > ${LINTNOISE}.out
522 if [ ! -f ${LINTNOISE}.ref ]; then
523 cp ${LINTNOISE}.out ${LINTNOISE}.ref
524 fi
525 if [ "$dodiff" != "n" ]; then
526 echo "\n==== lint warnings $base ====\n" \
527 >>$mail_msg_file
528 # should be none, though there are a few that were filtered out
529 # above
530 egrep -i '(warning|lint):' ${LINTNOISE}.out \
531 | sort | uniq >> $mail_msg_file
532 echo "\n==== lint noise differences $base ====\n" \
533 >> $mail_msg_file
534 diff ${LINTNOISE}.ref ${LINTNOISE}.out \
535 >> $mail_msg_file
536 fi
537 }
538
539 # Install proto area from IHV build
540
541 function copy_ihv_proto {
542
543 echo "\n==== Installing IHV proto area ====\n" \
544 >> $LOGFILE
545 if [ -d "$IA32_IHV_ROOT" ]; then
546 if [ ! -d "$ROOT" ]; then
547 echo "mkdir -p $ROOT" >> $LOGFILE
548 mkdir -p $ROOT
549 fi
550 echo "copying $IA32_IHV_ROOT to $ROOT\n" >> $LOGFILE
551 cd $IA32_IHV_ROOT
552 tar cf - . | (cd $ROOT; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
553 else
554 echo "$IA32_IHV_ROOT: not found" >> $LOGFILE
555 fi
556
557 if [ "$MULTI_PROTO" = yes ]; then
558 if [ ! -d "$ROOT-nd" ]; then
559 echo "mkdir -p $ROOT-nd" >> $LOGFILE
560 mkdir -p $ROOT-nd
561 fi
562 # If there's a non-DEBUG version of the IHV proto area,
563 # copy it, but copy something if there's not.
564 if [ -d "$IA32_IHV_ROOT-nd" ]; then
565 echo "copying $IA32_IHV_ROOT-nd to $ROOT-nd\n" >> $LOGFILE
566 cd $IA32_IHV_ROOT-nd
567 elif [ -d "$IA32_IHV_ROOT" ]; then
568 echo "copying $IA32_IHV_ROOT to $ROOT-nd\n" >> $LOGFILE
569 cd $IA32_IHV_ROOT
570 else
571 echo "$IA32_IHV_ROOT{-nd,}: not found" >> $LOGFILE
572 return
573 fi
574 tar cf - . | (cd $ROOT-nd; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
575 fi
576 }
577
578 # Install IHV packages in PKGARCHIVE
579 # usage: copy_ihv_pkgs LABEL SUFFIX
580 function copy_ihv_pkgs {
581 LABEL=$1
582 SUFFIX=$2
583 # always use non-DEBUG IHV packages
584 IA32_IHV_PKGS=${IA32_IHV_PKGS_ORIG}-nd
585 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
586
587 echo "\n==== Installing IHV packages from $IA32_IHV_PKGS ($LABEL) ====\n" \
588 >> $LOGFILE
589 if [ -d "$IA32_IHV_PKGS" ]; then
590 cd $IA32_IHV_PKGS
591 tar cf - * | \
592 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
593 else
594 echo "$IA32_IHV_PKGS: not found" >> $LOGFILE
595 fi
596
597 echo "\n==== Installing IHV packages from $IA32_IHV_BINARY_PKGS ($LABEL) ====\n" \
598 >> $LOGFILE
599 if [ -d "$IA32_IHV_BINARY_PKGS" ]; then
600 cd $IA32_IHV_BINARY_PKGS
601 tar cf - * | \
602 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
603 else
604 echo "$IA32_IHV_BINARY_PKGS: not found" >> $LOGFILE
605 fi
606 }
607
608 #
609 # Build and install the onbld tools.
610 #
611 # usage: build_tools DESTROOT
612 #
613 # returns non-zero status if the build was successful.
614 #
615 function build_tools {
616 DESTROOT=$1
617
618 INSTALLOG=install-${MACH}
619
620 echo "\n==== Building tools at `date` ====\n" \
621 >> $LOGFILE
622
623 rm -f ${TOOLS}/${INSTALLOG}.out
624 cd ${TOOLS}
625 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
626 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
627
702 echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE
703 echo "PATH=${PATH}" >> $LOGFILE
704 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
705 }
706
707 function staffer {
708 if [ $ISUSER -ne 0 ]; then
709 "$@"
710 else
711 arg="\"$1\""
712 shift
713 for i
714 do
715 arg="$arg \"$i\""
716 done
717 eval su $STAFFER -c \'$arg\'
718 fi
719 }
720
721 #
722 # Verify that the closed tree is present if it needs to be.
723 #
724 function check_closed_tree {
725 if [[ ! -d "$ON_CLOSED_BINS" ]]; then
726 echo "ON_CLOSED_BINS must point to the closed binaries tree."
727 build_ok=n
728 exit 1
729 fi
730 }
731
732 function obsolete_build {
733 echo "WARNING: Obsolete $1 build requested; request will be ignored"
734 }
735
736 #
737 # wrapper over wsdiff.
738 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
739 #
740 function do_wsdiff {
741 label=$1
742 oldproto=$2
743 newproto=$3
744
745 wsdiff="wsdiff"
746 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
747
748 echo "\n==== Getting object changes since last build at `date`" \
749 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
750 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
751 tee -a $LOGFILE >> $mail_msg_file
752 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
753 tee -a $LOGFILE >> $mail_msg_file
754 }
755
760
761 function set_non_debug_build_flags {
762 export RELEASE_BUILD ; RELEASE_BUILD=
763 unset EXTRA_OPTIONS
764 unset EXTRA_CFLAGS
765 }
766
767 function set_debug_build_flags {
768 unset RELEASE_BUILD
769 unset EXTRA_OPTIONS
770 unset EXTRA_CFLAGS
771 }
772
773
774 MACH=`uname -p`
775
776 if [ "$OPTHOME" = "" ]; then
777 OPTHOME=/opt
778 export OPTHOME
779 fi
780 if [ "$TEAMWARE" = "" ]; then
781 TEAMWARE=$OPTHOME/teamware
782 export TEAMWARE
783 fi
784
785 USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
786
787 Where:
788 -i Fast incremental options (no clobber, lint, check)
789 -n Do not do a bringover
790 +t Use the build tools in $ONBLD_TOOLS/bin
791 -V VERS set the build version string to VERS
792
793 <env_file> file in Bourne shell syntax that sets and exports
794 variables that configure the operation of this script and many of
795 the scripts this one calls. If <env_file> does not exist,
796 it will be looked for in $OPTHOME/onbld/env.
797
798 non-DEBUG is the default build type. Build options can be set in the
799 NIGHTLY_OPTIONS variable in the <env_file> as follows:
800
801 -A check for ABI differences in .so files
802 -C check for cstyle/hdrchk errors
803 -D do a build with DEBUG on
804 -F do _not_ do a non-DEBUG build
805 -G gate keeper default group of options (-au)
806 -I integration engineer default group of options (-ampu)
807 -M do not run pmodes (safe file permission checker)
808 -N do not run protocmp
809 -R default group of options for building a release (-mp)
810 -U update proto area in the parent
811 -V VERS set the build version string to VERS
812 -X copy x86 IHV proto area
813 -f find unreferenced files
814 -i do an incremental build (no "make clobber")
815 -l do "make lint" in $LINTDIRS (default: $SRC y)
816 -m send mail to $MAILTO at end of build
817 -n do not do a bringover
818 -o build using root privileges to set OWNER/GROUP (old style)
819 -p create packages
820 -r check ELF runtime attributes in the proto area
821 -t build and use the tools in $SRC/tools (default setting)
822 +t Use the build tools in $ONBLD_TOOLS/bin
823 -u update proto_list_$MACH and friends in the parent workspace;
824 when used with -f, also build an unrefmaster.out in the parent
825 -w report on differences between previous and current proto areas
826 -z compress cpio archives with gzip
827 -W Do not report warnings (freeware gate ONLY)
828 '
829 #
830 # A log file will be generated under the name $LOGFILE
831 # for partially completed build and log.`date '+%F'`
832 # in the same directory for fully completed builds.
833 #
834
835 # default values for low-level FLAGS; G I R are group FLAGS
836 A_FLAG=n
837 C_FLAG=n
838 D_FLAG=n
839 F_FLAG=n
840 f_FLAG=n
841 i_FLAG=n; i_CMD_LINE_FLAG=n
842 l_FLAG=n
843 M_FLAG=n
844 m_FLAG=n
845 N_FLAG=n
846 n_FLAG=n
847 o_FLAG=n
848 P_FLAG=n
849 p_FLAG=n
850 r_FLAG=n
851 T_FLAG=n
852 t_FLAG=y
853 U_FLAG=n
854 u_FLAG=n
855 V_FLAG=n
856 W_FLAG=n
857 w_FLAG=n
858 X_FLAG=n
859 #
860 XMOD_OPT=
861 #
862 build_ok=y
863
864 #
865 # examine arguments
866 #
867
868 OPTIND=1
869 while getopts +intV: FLAG
870 do
871 case $FLAG in
872 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
873 ;;
874 n ) n_FLAG=y
875 ;;
876 +t ) t_FLAG=n
877 ;;
878 V ) V_FLAG=y
879 V_ARG="$OPTARG"
880 ;;
993 fi
994
995 ps -o taskid= -p $$ | read build_taskid
996 ps -o project= -p $$ | read build_project
997
998 #
999 # See if NIGHTLY_OPTIONS is set
1000 #
1001 if [ "$NIGHTLY_OPTIONS" = "" ]; then
1002 NIGHTLY_OPTIONS="-aBm"
1003 fi
1004
1005 #
1006 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
1007 #
1008 if [ "$BRINGOVER_WS" = "" ]; then
1009 BRINGOVER_WS=$CLONE_WS
1010 fi
1011
1012 #
1013 # If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS
1014 #
1015 if [ "$CLOSED_BRINGOVER_WS" = "" ]; then
1016 CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS
1017 fi
1018
1019 #
1020 # If BRINGOVER_FILES was not specified, default to usr
1021 #
1022 if [ "$BRINGOVER_FILES" = "" ]; then
1023 BRINGOVER_FILES="usr"
1024 fi
1025
1026 check_closed_tree
1027
1028 #
1029 # Note: changes to the option letters here should also be applied to the
1030 # bldenv script. `d' is listed for backward compatibility.
1031 #
1032 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
1033 OPTIND=1
1034 while getopts +ABCDdFfGIilMmNnoPpRrTtUuWwXxz FLAG $NIGHTLY_OPTIONS
1035 do
1036 case $FLAG in
1037 A ) A_FLAG=y
1038 ;;
1039 B ) D_FLAG=y
1040 ;; # old version of D
1041 C ) C_FLAG=y
1042 ;;
1043 D ) D_FLAG=y
1044 ;;
1045 F ) F_FLAG=y
1046 ;;
1047 f ) f_FLAG=y
1048 ;;
1049 G ) u_FLAG=y
1050 ;;
1051 I ) m_FLAG=y
1052 p_FLAG=y
1053 u_FLAG=y
1054 ;;
1055 i ) i_FLAG=y
1056 ;;
1057 l ) l_FLAG=y
1058 ;;
1059 M ) M_FLAG=y
1060 ;;
1061 m ) m_FLAG=y
1062 ;;
1063 N ) N_FLAG=y
1064 ;;
1065 n ) n_FLAG=y
1066 ;;
1067 o ) o_FLAG=y
1068 ;;
1069 P ) P_FLAG=y
1070 ;; # obsolete
1071 p ) p_FLAG=y
1072 ;;
1073 R ) m_FLAG=y
1074 p_FLAG=y
1075 ;;
1076 r ) r_FLAG=y
1077 ;;
1078 T ) T_FLAG=y
1079 ;; # obsolete
1080 +t ) t_FLAG=n
1081 ;;
1082 U ) if [ -z "${PARENT_ROOT}" ]; then
1083 echo "PARENT_ROOT must be set if the U flag is" \
1084 "present in NIGHTLY_OPTIONS."
1085 exit 1
1086 fi
1087 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
1088 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
1089 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
1090 fi
1091 U_FLAG=y
1092 ;;
1093 u ) u_FLAG=y
1094 ;;
1095 W ) W_FLAG=y
1096 ;;
1097
1098 w ) w_FLAG=y
1099 ;;
1100 X ) # now that we no longer need realmode builds, just
1101 # copy IHV packages. only meaningful on x86.
1102 if [ "$MACH" = "i386" ]; then
1103 X_FLAG=y
1104 fi
1105 ;;
1106 x ) XMOD_OPT="-x"
1107 ;;
1108 \? ) echo "$USAGE"
1109 exit 1
1110 ;;
1111 esac
1112 done
1113
1114 if [ $ISUSER -ne 0 ]; then
1115 if [ "$o_FLAG" = "y" ]; then
1116 echo "Old-style build requires root permission."
1117 exit 1
1118 fi
1119
1120 # Set default value for STAFFER, if needed.
1121 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
1122 STAFFER=`/usr/xpg4/bin/id -un`
1123 export STAFFER
1124 fi
1125 fi
1126
1127 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
1128 MAILTO=$STAFFER
1129 export MAILTO
1130 fi
1131
1132 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
1133 PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb"
1134 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
1135 export PATH
1136
1137 # roots of source trees, both relative to $SRC and absolute.
1138 relsrcdirs="."
1139 abssrcdirs="$SRC"
1140
1141 unset CH
1142 if [ "$o_FLAG" = "y" ]; then
1143 # root invoked old-style build -- make sure it works as it always has
1144 # by exporting 'CH'. The current Makefile.master doesn't use this, but
1145 # the old ones still do.
1146 PROTOCMPTERSE="protocmp.terse"
1147 CH=
1148 export CH
1149 else
1150 PROTOCMPTERSE="protocmp.terse -gu"
1151 fi
1152 POUND_SIGN="#"
1153 # have we set RELEASE_DATE in our env file?
1154 if [ -z "$RELEASE_DATE" ]; then
1155 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
1156 fi
1157 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
1158 BASEWSDIR=$(basename $CODEMGR_WS)
1159 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
1160
1161 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
1162 # by avoiding repeated shell invocations to evaluate Makefile.master definitions.
1163 # we export o_FLAG and X_FLAG for use by makebfu, and by usr/src/pkg/Makefile
1164 export o_FLAG X_FLAG POUND_SIGN RELEASE_DATE DEV_CM
1165
1166 maketype="distributed"
1167 if [[ -z "$MAKE" ]]; then
1168 MAKE=dmake
1169 elif [[ ! -x "$MAKE" ]]; then
1170 echo "\$MAKE is set to garbage in the environment"
1171 exit 1
1172 fi
1173 # get the dmake version string alone
1174 DMAKE_VERSION=$( $MAKE -v )
1175 DMAKE_VERSION=${DMAKE_VERSION#*: }
1176 # focus in on just the dotted version number alone
1177 DMAKE_MAJOR=$( echo $DMAKE_VERSION | \
1178 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' )
1179 # extract the second (or final) integer
1180 DMAKE_MINOR=${DMAKE_MAJOR#*.}
1181 DMAKE_MINOR=${DMAKE_MINOR%%.*}
1182 # extract the first integer
1183 DMAKE_MAJOR=${DMAKE_MAJOR%%.*}
1184 CHECK_DMAKE=${CHECK_DMAKE:-y}
1185 # x86 was built on the 12th, sparc on the 13th.
1186 if [ "$CHECK_DMAKE" = "y" -a \
1187 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \
1188 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \
1189 "$DMAKE_MAJOR" -lt 7 -o \
1190 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then
1191 if [ -z "$DMAKE_VERSION" ]; then
1192 echo "$MAKE is missing."
1193 exit 1
1194 fi
1195 echo `whence $MAKE`" version is:"
1196 echo " ${DMAKE_VERSION}"
1197 cat <<EOF
1198
1199 This version may not be safe for use. Either set TEAMWARE to a better
1200 path or (if you really want to use this version of dmake anyway), add
1201 the following to your environment to disable this check:
1202
1203 CHECK_DMAKE=n
1204 EOF
1205 exit 1
1206 fi
1207 export PATH
1208 export MAKE
1209
1210 if [ "${SUNWSPRO}" != "" ]; then
1211 PATH="${SUNWSPRO}/bin:$PATH"
1212 export PATH
1213 fi
1214
1215 hostname=$(uname -n)
1216 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
1217 then
1218 maxjobs=
1219 if [[ -f $HOME/.make.machines ]]
1220 then
1221 # Note: there is a hard tab and space character in the []s
1232 fi
1233
1234 export DMAKE_MAX_JOBS=$maxjobs
1235 fi
1236
1237 DMAKE_MODE=parallel;
1238 export DMAKE_MODE
1239
1240 if [ -z "${ROOT}" ]; then
1241 echo "ROOT must be set."
1242 exit 1
1243 fi
1244
1245 #
1246 # if -V flag was given, reset VERSION to V_ARG
1247 #
1248 if [ "$V_FLAG" = "y" ]; then
1249 VERSION=$V_ARG
1250 fi
1251
1252 #
1253 # Check for IHV root for copying ihv proto area
1254 #
1255 if [ "$X_FLAG" = "y" ]; then
1256 if [ "$IA32_IHV_ROOT" = "" ]; then
1257 echo "IA32_IHV_ROOT: must be set for copying ihv proto"
1258 args_ok=n
1259 fi
1260 if [ ! -d "$IA32_IHV_ROOT" ]; then
1261 echo "$IA32_IHV_ROOT: not found"
1262 args_ok=n
1263 fi
1264 if [ "$IA32_IHV_WS" = "" ]; then
1265 echo "IA32_IHV_WS: must be set for copying ihv proto"
1266 args_ok=n
1267 fi
1268 if [ ! -d "$IA32_IHV_WS" ]; then
1269 echo "$IA32_IHV_WS: not found"
1270 args_ok=n
1271 fi
1272 fi
1273
1274 TMPDIR="/tmp/nightly.tmpdir.$$"
1275 export TMPDIR
1276 rm -rf ${TMPDIR}
1277 mkdir -p $TMPDIR || exit 1
1278 chmod 777 $TMPDIR
1279
1280 #
1281 # Keep elfsign's use of pkcs11_softtoken from looking in the user home
1282 # directory, which doesn't always work. Needed until all build machines
1283 # have the fix for 6271754
1284 #
1285 SOFTTOKEN_DIR=$TMPDIR
1286 export SOFTTOKEN_DIR
1287
1288 #
1289 # Tools should only be built non-DEBUG. Keep track of the tools proto
1290 # area path relative to $TOOLS, because the latter changes in an
1291 # export build.
1292 #
1293 # TOOLS_PROTO is included below for builds other than usr/src/tools
1327
1328 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
1329
1330 # since this script assumes the build is from full source, it nullifies
1331 # variables likely to have been set by a "ws" script; nullification
1332 # confines the search space for headers and libraries to the proto area
1333 # built from this immediate source.
1334 ENVLDLIBS1=
1335 ENVLDLIBS2=
1336 ENVLDLIBS3=
1337 ENVCPPFLAGS1=
1338 ENVCPPFLAGS2=
1339 ENVCPPFLAGS3=
1340 ENVCPPFLAGS4=
1341 PARENT_ROOT=
1342
1343 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1344 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
1345
1346 PKGARCHIVE_ORIG=$PKGARCHIVE
1347 IA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS
1348
1349 #
1350 # Juggle the logs and optionally send mail on completion.
1351 #
1352
1353 function logshuffle {
1354 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
1355 if [ -f $LLOG -o -d $LLOG ]; then
1356 LLOG=$LLOG.$$
1357 fi
1358 mkdir $LLOG
1359 export LLOG
1360
1361 if [ "$build_ok" = "y" ]; then
1362 mv $ATLOG/proto_list_${MACH} $LLOG
1363
1364 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
1365 mv $ATLOG/proto_list_tools_${MACH} $LLOG
1366 fi
1367
1560 START_DATE=`date`
1561 SECONDS=0
1562 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1563 | tee -a $LOGFILE > $build_time_file
1564
1565 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1566 tee -a $mail_msg_file >> $LOGFILE
1567
1568 # make sure we log only to the nightly build file
1569 build_noise_file="${TMPDIR}/build_noise"
1570 exec </dev/null >$build_noise_file 2>&1
1571
1572 run_hook SYS_PRE_NIGHTLY
1573 run_hook PRE_NIGHTLY
1574
1575 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1576 env >> $LOGFILE
1577
1578 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1579
1580 if [ "$P_FLAG" = "y" ]; then
1581 obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE
1582 fi
1583
1584 if [ "$T_FLAG" = "y" ]; then
1585 obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE
1586 fi
1587
1588 if [ "$N_FLAG" = "y" ]; then
1589 if [ "$p_FLAG" = "y" ]; then
1590 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1591 WARNING: the p option (create packages) is set, but so is the N option (do
1592 not run protocmp); this is dangerous; you should unset the N option
1593 EOF
1594 else
1595 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1596 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1597 EOF
1598 fi
1599 echo "" | tee -a $mail_msg_file >> $LOGFILE
1600 fi
1601
1602 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1603 #
1604 # In the past we just complained but went ahead with the lint
1605 # pass, even though the proto area was built non-DEBUG. It's
1606 # unlikely that non-DEBUG headers will make a difference, but
1607 # rather than assuming it's a safe combination, force the user
1676
1677 # Same for non-DEBUG proto area
1678 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1679 if [ -d "$ROOT-nd.prev" ]; then
1680 rm -rf $ROOT-nd.prev
1681 fi
1682 mv $ROOT-nd $ROOT-nd.prev
1683 fi
1684
1685 #
1686 # Echo the SCM type of the parent workspace, this can't just be which_scm
1687 # as that does not know how to identify various network repositories.
1688 #
1689 function parent_wstype {
1690 typeset scm_type junk
1691
1692 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1693 | read scm_type junk
1694 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1695 # Probe BRINGOVER_WS to determine its type
1696 if [[ $BRINGOVER_WS == svn*://* ]]; then
1697 scm_type="subversion"
1698 elif [[ $BRINGOVER_WS == file://* ]] &&
1699 egrep -s "This is a Subversion repository" \
1700 ${BRINGOVER_WS#file://}/README.txt 2> /dev/null; then
1701 scm_type="subversion"
1702 elif [[ $BRINGOVER_WS == ssh://* ]]; then
1703 scm_type="mercurial"
1704 elif [[ $BRINGOVER_WS == http://* ]] && \
1705 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1706 egrep -s "application/mercurial" 2> /dev/null; then
1707 scm_type="mercurial"
1708 elif svn info $BRINGOVER_WS > /dev/null 2>&1; then
1709 scm_type="subversion"
1710 else
1711 scm_type="none"
1712 fi
1713 fi
1714
1715 # fold both unsupported and unrecognized results into "none"
1716 case "$scm_type" in
1717 none|subversion|teamware|mercurial)
1718 ;;
1719 *) scm_type=none
1720 ;;
1721 esac
1722
1723 echo $scm_type
1724 }
1725
1726 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1727 function child_wstype {
1728 typeset scm_type junk
1729
1730 # Probe CODEMGR_WS to determine its type
1731 if [[ -d $CODEMGR_WS ]]; then
1732 $WHICH_SCM | read scm_type junk || exit 1
1733 fi
1734
1735 case "$scm_type" in
1736 none|subversion|git|teamware|mercurial)
1737 ;;
1738 *) scm_type=none
1739 ;;
1740 esac
1741
1742 echo $scm_type
1743 }
1744
1745 SCM_TYPE=$(child_wstype)
1746
1747 #
1748 # Decide whether to clobber
1749 #
1750 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1751 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1752
1753 cd $SRC
1754 # remove old clobber file
1755 rm -f $SRC/clobber.out
1756 rm -f $SRC/clobber-${MACH}.out
1784 typeset roots=$(allprotos)
1785 echo "\n\nClearing $roots" >> "$LOGFILE"
1786 rm -rf $roots
1787
1788 # Get back to a clean workspace as much as possible to catch
1789 # problems that only occur on fresh workspaces.
1790 # Remove all .make.state* files, libraries, and .o's that may
1791 # have been omitted from clobber. A couple of libraries are
1792 # under source code control, so leave them alone.
1793 # We should probably blow away temporary directories too.
1794 cd $SRC
1795 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1796 -o -name .git -o -name 'interfaces.*' \) -prune -o \
1797 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1798 -name '*.o' \) -print | \
1799 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
1800 else
1801 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1802 fi
1803
1804 type bringover_teamware > /dev/null 2>&1 || function bringover_teamware {
1805 # sleep on the parent workspace's lock
1806 while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks
1807 do
1808 sleep 120
1809 done
1810
1811 if [[ -z $BRINGOVER ]]; then
1812 BRINGOVER=$TEAMWARE/bin/bringover
1813 fi
1814
1815 staffer $BRINGOVER -c "nightly update" -p $BRINGOVER_WS \
1816 -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 ||
1817 touch $TMPDIR/bringover_failed
1818
1819 staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1
1820 if [ -s $TMPDIR/bringovercheck.out ]; then
1821 echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n"
1822 cat $TMPDIR/bringovercheck.out
1823 fi
1824 }
1825
1826 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
1827 typeset -x PATH=$PATH
1828
1829 # If the repository doesn't exist yet, then we want to populate it.
1830 if [[ ! -d $CODEMGR_WS/.hg ]]; then
1831 staffer hg init $CODEMGR_WS
1832 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
1833 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
1834 touch $TMPDIR/new_repository
1835 fi
1836
1837 typeset -x HGMERGE="/bin/false"
1838
1839 #
1840 # If the user has changes, regardless of whether those changes are
1841 # committed, and regardless of whether those changes conflict, then
1842 # we'll attempt to merge them either implicitly (uncommitted) or
1843 # explicitly (committed).
1844 #
1845 # These are the messages we'll use to help clarify mercurial output
1924 fi
1925 fi
1926
1927 printf "updated %s with the following results:\n" "$CODEMGR_WS"
1928 cat $TMPDIR/pull_open.out
1929 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
1930 printf "$mergepassmsg"
1931 fi
1932 printf "\n"
1933
1934 #
1935 # Per-changeset output is neither useful nor manageable for a
1936 # newly-created repository.
1937 #
1938 if [ -f $TMPDIR/new_repository ]; then
1939 return
1940 fi
1941
1942 printf "\nadded the following changesets to open repository:\n"
1943 cat $TMPDIR/incoming_open.out
1944
1945 #
1946 # The closed repository could have been newly created, even though
1947 # the open one previously existed...
1948 #
1949 if [ -f $TMPDIR/new_closed ]; then
1950 return
1951 fi
1952
1953 if [ -f $TMPDIR/incoming_closed.out ]; then
1954 printf "\nadded the following changesets to closed repository:\n"
1955 cat $TMPDIR/incoming_closed.out
1956 fi
1957 }
1958
1959 type bringover_subversion > /dev/null 2>&1 || function bringover_subversion {
1960 typeset -x PATH=$PATH
1961
1962 if [[ ! -d $CODEMGR_WS/.svn ]]; then
1963 staffer svn checkout $BRINGOVER_WS $CODEMGR_WS ||
1964 touch $TMPDIR/bringover_failed
1965 else
1966 typeset root
1967 root=$(staffer svn info $CODEMGR_WS |
1968 nawk '/^Repository Root:/ {print $NF}')
1969 if [[ $root != $BRINGOVER_WS ]]; then
1970 # We fail here because there's no way to update
1971 # from a named repo.
1972 cat <<-EOF
1973 \$BRINGOVER_WS doesn't match repository root:
1974 \$BRINGOVER_WS: $BRINGOVER_WS
1975 Repository root: $root
1976 EOF
1977 touch $TMPDIR/bringover_failed
1978 else
1979 # If a conflict happens, svn still exits 0.
1980 staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out ||
1981 touch $TMPDIR/bringover_failed
1982 if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then
1983 touch $TMPDIR/bringover_failed
1984 fi
1985 fi
1986 fi
1987 }
1988
1989 type bringover_none > /dev/null 2>&1 || function bringover_none {
1990 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1991 touch $TMPDIR/bringover_failed
1992 }
1993
1994 #
1995 # Decide whether to bringover to the codemgr workspace
1996 #
1997 if [ "$n_FLAG" = "n" ]; then
1998 PARENT_SCM_TYPE=$(parent_wstype)
1999
2000 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
2001 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
2002 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
2003 exit 1
2004 fi
2005
2006 run_hook PRE_BRINGOVER
2011 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
2012 tee -a $mail_msg_file >> $LOGFILE
2013
2014 if [ -f $TMPDIR/bringover_failed ]; then
2015 rm -f $TMPDIR/bringover_failed
2016 build_ok=n
2017 echo "trouble with bringover, quitting at `date`." |
2018 tee -a $mail_msg_file >> $LOGFILE
2019 exit 1
2020 fi
2021
2022 #
2023 # It's possible that we used the bringover above to create
2024 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
2025 # but should now be the same as $BRINGOVER_WS.
2026 #
2027 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
2028
2029 run_hook POST_BRINGOVER
2030
2031 check_closed_tree
2032
2033 else
2034 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
2035 fi
2036
2037 # Safeguards
2038 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
2039 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
2040 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
2041
2042 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
2043
2044 # System
2045 whence uname | tee -a $build_environ_file >> $LOGFILE
2046 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
2047 echo | tee -a $build_environ_file >> $LOGFILE
2048
2049 # make
2050 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
2051 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
2100 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
2101 if [ `expr $LDVER \< 422` -eq 1 ]; then
2102 echo "The link-editor needs to be at version 422 or higher to build" | \
2103 tee -a $build_environ_file >> $LOGFILE
2104 echo "the latest stuff. Hope your build works." | \
2105 tee -a $build_environ_file >> $LOGFILE
2106 fi
2107
2108 #
2109 # Build and use the workspace's tools if requested
2110 #
2111 if [[ "$t_FLAG" = "y" ]]; then
2112 set_non_debug_build_flags
2113
2114 build_tools ${TOOLS_PROTO}
2115 if [[ $? != 0 && "$t_FLAG" = y ]]; then
2116 use_tools $TOOLS_PROTO
2117 fi
2118 fi
2119
2120 #
2121 # copy ihv proto area in addition to the build itself
2122 #
2123 if [ "$X_FLAG" = "y" ]; then
2124 copy_ihv_proto
2125 fi
2126
2127 # timestamp the start of the normal build; the findunref tool uses it.
2128 touch $SRC/.build.tstamp
2129
2130 normal_build
2131
2132 ORIG_SRC=$SRC
2133 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
2134
2135
2136 #
2137 # There are several checks that need to look at the proto area, but
2138 # they only need to look at one, and they don't care whether it's
2139 # DEBUG or non-DEBUG.
2140 #
2141 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
2142 checkroot=$ROOT-nd
2143 else
2144 checkroot=$ROOT
2145 fi
2146
2147 if [ "$build_ok" = "y" ]; then
2148 echo "\n==== Creating protolist system file at `date` ====" \
2149 >> $LOGFILE
2150 protolist $checkroot > $ATLOG/proto_list_${MACH}
2151 echo "==== protolist system file created at `date` ====\n" \
2152 >> $LOGFILE
2153
2154 if [ "$N_FLAG" != "y" ]; then
2155
2156 E1=
2157 f1=
2158 if [ -d "$SRC/pkgdefs" ]; then
2159 f1="$SRC/pkgdefs/etc/exception_list_$MACH"
2160 if [ "$X_FLAG" = "y" ]; then
2161 f1="$f1 $IA32_IHV_WS/usr/src/pkgdefs/etc/exception_list_$MACH"
2162 fi
2163 fi
2164
2165 for f in $f1; do
2166 if [ -f "$f" ]; then
2167 E1="$E1 -e $f"
2168 fi
2169 done
2170
2171 E2=
2172 f2=
2173 if [ -d "$SRC/pkg" ]; then
2174 f2="$f2 exceptions/packaging"
2175 fi
2176
2177 for f in $f2; do
2178 if [ -f "$f" ]; then
2179 E2="$E2 -e $f"
2180 fi
2181 done
2182
2183 if [ -f "$REF_PROTO_LIST" ]; then
2184 #
2185 # For builds that copy the IHV proto area (-X), add the
2186 # IHV proto list to the reference list if the reference
2187 # was built without -X.
2188 #
2189 # For builds that don't copy the IHV proto area, add the
2190 # IHV proto list to the build's proto list if the
2191 # reference was built with -X.
2192 #
2193 # Use the presence of the first file entry of the cached
2194 # IHV proto list in the reference list to determine
2195 # whether it was built with -X or not.
2196 #
2197 IHV_REF_PROTO_LIST=$SRC/pkg/proto_list_ihv_$MACH
2198 grepfor=$(nawk '$1 == "f" { print $2; exit }' \
2199 $IHV_REF_PROTO_LIST 2> /dev/null)
2200 if [ $? = 0 -a -n "$grepfor" ]; then
2201 if [ "$X_FLAG" = "y" ]; then
2202 grep -w "$grepfor" \
2203 $REF_PROTO_LIST > /dev/null
2204 if [ ! "$?" = "0" ]; then
2205 REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST"
2206 fi
2207 else
2208 grep -w "$grepfor" \
2209 $REF_PROTO_LIST > /dev/null
2210 if [ "$?" = "0" ]; then
2211 IHV_PROTO_LIST="$IHV_REF_PROTO_LIST"
2212 fi
2213 fi
2214 fi
2215 fi
2216 fi
2217
2218 if [ "$N_FLAG" != "y" -a -f $SRC/pkgdefs/Makefile ]; then
2219 echo "\n==== Impact on SVr4 packages ====\n" >> $mail_msg_file
2220 #
2221 # Compare the build's proto list with current package
2222 # definitions to audit the quality of package
2223 # definitions and makefile install targets. Use the
2224 # current exception list.
2225 #
2226 PKGDEFS_LIST=""
2227 for d in $abssrcdirs; do
2228 if [ -d $d/pkgdefs ]; then
2229 PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs"
2230 fi
2231 done
2232 if [ "$X_FLAG" = "y" -a \
2233 -d $IA32_IHV_WS/usr/src/pkgdefs ]; then
2234 PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs"
2235 fi
2236 $PROTOCMPTERSE \
2237 "Files missing from the proto area:" \
2238 "Files missing from packages:" \
2239 "Inconsistencies between pkgdefs and proto area:" \
2240 ${E1} \
2241 ${PKGDEFS_LIST} \
2242 $ATLOG/proto_list_${MACH} \
2243 >> $mail_msg_file
2244 fi
2245
2246 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
2247 echo "\n==== Validating manifests against proto area ====\n" \
2248 >> $mail_msg_file
2249 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) \
2250 >> $mail_msg_file
2251
2252 fi
2253
2254 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
2255 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
2256 if [ -n "$E2" ]; then
2257 ELIST=$E2
2258 else
2259 ELIST=$E1
2260 fi
2261 $PROTOCMPTERSE \
2262 "Files in yesterday's proto area, but not today's:" \
2263 "Files in today's proto area, but not yesterday's:" \
2264 "Files that changed between yesterday and today:" \
2265 ${ELIST} \
2266 -d $REF_PROTO_LIST \
2267 $REF_IHV_PROTO \
2268 $ATLOG/proto_list_${MACH} \
2269 $IHV_PROTO_LIST \
2270 >> $mail_msg_file
2271 fi
2272 fi
2273
2274 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
2275 staffer cp $ATLOG/proto_list_${MACH} \
2276 $PARENT_WS/usr/src/proto_list_${MACH}
2277 fi
2278
2279 # Update parent proto area if necessary. This is done now
2280 # so that the proto area has either DEBUG or non-DEBUG kernels.
2281 # Note that this clears out the lock file, so we can dispense with
2282 # the variable now.
2283 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
2284 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
2285 tee -a $LOGFILE >> $mail_msg_file
2286 rm -rf $NIGHTLY_PARENT_ROOT/*
2287 unset Ulockfile
2288 mkdir -p $NIGHTLY_PARENT_ROOT
2289 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2485
2486 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2487 echo "\n==== Diff unreferenced files (since last build) ====\n" \
2488 | tee -a $LOGFILE >>$mail_msg_file
2489 rm -f $SRC/unref-${MACH}.ref
2490 if [ -f $SRC/unref-${MACH}.out ]; then
2491 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2492 fi
2493
2494 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2495 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2496 sort > $SRC/unref-${MACH}.out
2497
2498 if [ ! -f $SRC/unref-${MACH}.ref ]; then
2499 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2500 fi
2501
2502 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2503 fi
2504
2505 #
2506 # Generate the OpenSolaris deliverables if requested. Some of these
2507 # steps need to come after findunref and are commented below.
2508 #
2509
2510 # Verify that the usual lists of files, such as exception lists,
2511 # contain only valid references to files. If the build has failed,
2512 # then don't check the proto area.
2513 CHECK_PATHS=${CHECK_PATHS:-y}
2514 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2515 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2516 >>$mail_msg_file
2517 arg=-b
2518 [ "$build_ok" = y ] && arg=
2519 checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file
2520 fi
2521
2522 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2523 echo "\n==== Impact on file permissions ====\n" \
2524 >> $mail_msg_file
2525
2526 abspkgdefs=
2527 abspkg=
2528 for d in $abssrcdirs; do
2529 if [ -d "$d/pkgdefs" ]; then
2530 abspkgdefs="$abspkgdefs $d"
2531 fi
2532 if [ -d "$d/pkg" ]; then
2533 abspkg="$abspkg $d"
2534 fi
2535 done
2536
2537 if [ -n "$abspkgdefs" ]; then
2538 pmodes -qvdP \
2539 `find $abspkgdefs -name pkginfo.tmpl -print -o \
2540 -name .del\* -prune | sed -e 's:/pkginfo.tmpl$::' | \
2541 sort -u` >> $mail_msg_file
2542 fi
2543
2544 if [ -n "$abspkg" ]; then
2545 for d in "$abspkg"; do
2546 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
2547 done
2548 fi
2549 fi
2550
2551 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
2552 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2553 do_wsdiff DEBUG $ROOT.prev $ROOT
2554 fi
2555
2556 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2557 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2558 fi
2559 fi
2560
2561 END_DATE=`date`
2562 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2563 tee -a $LOGFILE >> $build_time_file
|
29 # Based on the nightly script from the integration folks,
30 # Mostly modified and owned by mike_s.
31 # Changes also by kjc, dmk.
32 #
33 # BRINGOVER_WS may be specified in the env file.
34 # The default is the old behavior of CLONE_WS
35 #
36 # -i on the command line, means fast options, so when it's on the
37 # command line (only), lint and check builds are skipped no matter what
38 # the setting of their individual flags are in NIGHTLY_OPTIONS.
39 #
40 # LINTDIRS can be set in the env file, format is a list of:
41 #
42 # /dirname-to-run-lint-on flag
43 #
44 # Where flag is: y - enable lint noise diff output
45 # n - disable lint noise diff output
46 #
47 # For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
48 #
49 # OPTHOME may be set in the environment to override /opt
50 #
51
52 #
53 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
54 # under certain circumstances, which can really screw things up; unset it.
55 #
56 unset CDPATH
57
58 # Get the absolute path of the nightly script that the user invoked. This
59 # may be a relative path, and we need to do this before changing directory.
60 nightly_path=`whence $0`
61
62 #
63 # Keep track of where we found nightly so we can invoke the matching
64 # which_scm script. If that doesn't work, don't go guessing, just rely
65 # on the $PATH settings, which will generally give us either /opt/onbld
66 # or the user's workspace.
67 #
68 WHICH_SCM=$(dirname $nightly_path)/which_scm
69 if [[ ! -x $WHICH_SCM ]]; then
79 #
80 # Function to do a DEBUG and non-DEBUG build. Needed because we might
81 # need to do another for the source build, and since we only deliver DEBUG or
82 # non-DEBUG packages.
83 #
84 # usage: normal_build
85 #
86 function normal_build {
87
88 typeset orig_p_FLAG="$p_FLAG"
89 typeset crypto_signer="$CODESIGN_USER"
90
91 suffix=""
92
93 # non-DEBUG build begins
94
95 if [ "$F_FLAG" = "n" ]; then
96 set_non_debug_build_flags
97 CODESIGN_USER="$crypto_signer" \
98 build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
99 else
100 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
101 fi
102
103 # non-DEBUG build ends
104
105 # DEBUG build begins
106
107 if [ "$D_FLAG" = "y" ]; then
108 set_debug_build_flags
109 CODESIGN_USER="$crypto_signer" \
110 build "DEBUG" "$suffix" "" "$MULTI_PROTO"
111 else
112 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
113 fi
114
115 # DEBUG build ends
116
117 p_FLAG="$orig_p_FLAG"
118 }
119
120 #
121 # usage: run_hook HOOKNAME ARGS...
122 #
123 # If variable "$HOOKNAME" is defined, insert a section header into
124 # our logs and then run the command with ARGS
125 #
126 function run_hook {
127 HOOKNAME=$1
128 eval HOOKCMD=\$$HOOKNAME
129 shift
130
131 if [ -n "$HOOKCMD" ]; then
132 (
133 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
134 ( $HOOKCMD "$@" 2>&1 )
135 if [ "$?" -ne 0 ]; then
136 # Let exit status propagate up
137 touch $TMPDIR/abort
138 fi
139 ) | tee -a $mail_msg_file >> $LOGFILE
140
141 if [ -f $TMPDIR/abort ]; then
142 build_ok=n
143 echo "\nAborting at request of $HOOKNAME" |
144 tee -a $mail_msg_file >> $LOGFILE
145 exit 1
146 fi
147 fi
148 }
149
150 # Return library search directive as function of given root.
151 function myldlibs {
152 echo "-L$1/lib -L$1/usr/lib"
153 }
154
155 # Return header search directive as function of given root.
156 function myheaders {
157 echo "-I$1/usr/include"
158 }
159
160 #
161 # Function to do the build, including package generation.
162 # usage: build LABEL SUFFIX ND MULTIPROTO
163 # - LABEL is used to tag build output.
164 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
165 # open-only vs full tree).
166 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
167 # - If MULTIPROTO is "yes", it means to name the proto area according to
168 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
169 #
177 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
178
179 ORIGROOT=$ROOT
180 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
181
182 export ENVLDLIBS1=`myldlibs $ROOT`
183 export ENVCPPFLAGS1=`myheaders $ROOT`
184
185 this_build_ok=y
186 #
187 # Build OS-Networking source
188 #
189 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
190 >> $LOGFILE
191
192 rm -f $SRC/${INSTALLOG}.out
193 cd $SRC
194 /bin/time $MAKE -e install 2>&1 | \
195 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
196
197 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
198 egrep ":" $SRC/${INSTALLOG}.out |
199 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
200 egrep -v "Ignoring unknown host" | \
201 egrep -v "cc .* -o error " | \
202 egrep -v "warning" >> $mail_msg_file
203 if [ "$?" = "0" ]; then
204 build_ok=n
205 this_build_ok=n
206 fi
207 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
208 >> $mail_msg_file
209 if [ "$?" = "0" ]; then
210 build_ok=n
211 this_build_ok=n
212 fi
213
214 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
215 egrep -i warning: $SRC/${INSTALLOG}.out \
216 | egrep -v '^tic:' \
217 | egrep -v "symbol (\`|')timezone' has differing types:" \
218 | egrep -v "parameter <PSTAMP> set to" \
219 | egrep -v "Ignoring unknown host" \
220 | egrep -v "redefining segment flags attribute for" \
221 >> $mail_msg_file
222
223 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
224 >> $LOGFILE
225
226 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
227 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
228
229 if [ "$i_FLAG" = "n" ]; then
230 rm -f $SRC/${NOISE}.ref
231 if [ -f $SRC/${NOISE}.out ]; then
232 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
233 fi
234 grep : $SRC/${INSTALLOG}.out \
235 | egrep -v '^/' \
236 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
237 | egrep -v '^tic:' \
238 | egrep -v '^mcs' \
239 | egrep -v '^LD_LIBRARY_PATH=' \
240 | egrep -v 'ar: creating' \
241 | egrep -v 'ar: writing' \
242 | egrep -v 'conflicts:' \
243 | egrep -v ':saved created' \
244 | egrep -v '^stty.*c:' \
245 | egrep -v '^mfgname.c:' \
246 | egrep -v '^uname-i.c:' \
247 | egrep -v '^volumes.c:' \
248 | egrep -v '^lint library construction:' \
249 | egrep -v 'tsort: INFORM:' \
298 signing_file="${TMPDIR}/signing"
299 rm -f ${signing_file}
300 export CODESIGN_USER
301 signproto $SRC/tools/codesign/creds 2>&1 | \
302 tee -a ${signing_file} >> $LOGFILE
303 echo "\n==== Finished signing proto area at `date` ====\n" \
304 >> $LOGFILE
305 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
306 >> $mail_msg_file
307 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
308 if (( $? == 0 )) ; then
309 build_ok=n
310 this_build_ok=n
311 fi
312 fi
313
314 #
315 # Building Packages
316 #
317 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
318 if [ -d $SRC/pkg ]; then
319 echo "\n==== Creating $LABEL packages at `date` ====\n" \
320 >> $LOGFILE
321 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
322 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
323 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
324
325 rm -f $SRC/pkg/${INSTALLOG}.out
326 cd $SRC/pkg
327 /bin/time $MAKE -e install 2>&1 | \
328 tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE
329
330 echo "\n==== package build errors ($LABEL) ====\n" \
331 >> $mail_msg_file
332
333 egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \
334 grep ':' | \
335 grep -v PSTAMP | \
336 egrep -v "Ignoring unknown host" \
337 >> $mail_msg_file
338 else
339 #
340 # Handle it gracefully if -p was set but there are
341 # neither pkg directories.
342 #
343 echo "\n==== No $LABEL packages to build ====\n" \
344 >> $LOGFILE
345 fi
346 else
347 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
348 fi
349
350 ROOT=$ORIGROOT
351 }
352
353 # Usage: dolint /dir y|n
354 # Arg. 2 is a flag to turn on/off the lint diff output
355 function dolint {
356 if [ ! -d "$1" ]; then
357 echo "dolint error: $1 is not a directory"
358 exit 1
359 fi
360
361 if [ "$2" != "y" -a "$2" != "n" ]; then
417 egrep -v 'Ignoring unknown host' | \
418 egrep -v '\.c:$' | \
419 sort | uniq > ${LINTNOISE}.out
420 if [ ! -f ${LINTNOISE}.ref ]; then
421 cp ${LINTNOISE}.out ${LINTNOISE}.ref
422 fi
423 if [ "$dodiff" != "n" ]; then
424 echo "\n==== lint warnings $base ====\n" \
425 >>$mail_msg_file
426 # should be none, though there are a few that were filtered out
427 # above
428 egrep -i '(warning|lint):' ${LINTNOISE}.out \
429 | sort | uniq >> $mail_msg_file
430 echo "\n==== lint noise differences $base ====\n" \
431 >> $mail_msg_file
432 diff ${LINTNOISE}.ref ${LINTNOISE}.out \
433 >> $mail_msg_file
434 fi
435 }
436
437 #
438 # Build and install the onbld tools.
439 #
440 # usage: build_tools DESTROOT
441 #
442 # returns non-zero status if the build was successful.
443 #
444 function build_tools {
445 DESTROOT=$1
446
447 INSTALLOG=install-${MACH}
448
449 echo "\n==== Building tools at `date` ====\n" \
450 >> $LOGFILE
451
452 rm -f ${TOOLS}/${INSTALLOG}.out
453 cd ${TOOLS}
454 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
455 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
456
531 echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE
532 echo "PATH=${PATH}" >> $LOGFILE
533 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
534 }
535
536 function staffer {
537 if [ $ISUSER -ne 0 ]; then
538 "$@"
539 else
540 arg="\"$1\""
541 shift
542 for i
543 do
544 arg="$arg \"$i\""
545 done
546 eval su $STAFFER -c \'$arg\'
547 fi
548 }
549
550 #
551 # Verify that the closed bins are present
552 #
553 function check_closed_bins {
554 if [[ ! -d "$ON_CLOSED_BINS" ]]; then
555 echo "ON_CLOSED_BINS must point to the closed binaries tree."
556 build_ok=n
557 exit 1
558 fi
559 }
560
561 #
562 # wrapper over wsdiff.
563 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
564 #
565 function do_wsdiff {
566 label=$1
567 oldproto=$2
568 newproto=$3
569
570 wsdiff="wsdiff"
571 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
572
573 echo "\n==== Getting object changes since last build at `date`" \
574 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
575 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
576 tee -a $LOGFILE >> $mail_msg_file
577 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
578 tee -a $LOGFILE >> $mail_msg_file
579 }
580
585
586 function set_non_debug_build_flags {
587 export RELEASE_BUILD ; RELEASE_BUILD=
588 unset EXTRA_OPTIONS
589 unset EXTRA_CFLAGS
590 }
591
592 function set_debug_build_flags {
593 unset RELEASE_BUILD
594 unset EXTRA_OPTIONS
595 unset EXTRA_CFLAGS
596 }
597
598
599 MACH=`uname -p`
600
601 if [ "$OPTHOME" = "" ]; then
602 OPTHOME=/opt
603 export OPTHOME
604 fi
605
606 USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
607
608 Where:
609 -i Fast incremental options (no clobber, lint, check)
610 -n Do not do a bringover
611 +t Use the build tools in $ONBLD_TOOLS/bin
612 -V VERS set the build version string to VERS
613
614 <env_file> file in Bourne shell syntax that sets and exports
615 variables that configure the operation of this script and many of
616 the scripts this one calls. If <env_file> does not exist,
617 it will be looked for in $OPTHOME/onbld/env.
618
619 non-DEBUG is the default build type. Build options can be set in the
620 NIGHTLY_OPTIONS variable in the <env_file> as follows:
621
622 -A check for ABI differences in .so files
623 -C check for cstyle/hdrchk errors
624 -D do a build with DEBUG on
625 -F do _not_ do a non-DEBUG build
626 -G gate keeper default group of options (-au)
627 -I integration engineer default group of options (-ampu)
628 -M do not run pmodes (safe file permission checker)
629 -N do not run protocmp
630 -R default group of options for building a release (-mp)
631 -U update proto area in the parent
632 -V VERS set the build version string to VERS
633 -f find unreferenced files
634 -i do an incremental build (no "make clobber")
635 -l do "make lint" in $LINTDIRS (default: $SRC y)
636 -m send mail to $MAILTO at end of build
637 -n do not do a bringover
638 -p create packages
639 -r check ELF runtime attributes in the proto area
640 -t build and use the tools in $SRC/tools (default setting)
641 +t Use the build tools in $ONBLD_TOOLS/bin
642 -u update proto_list_$MACH and friends in the parent workspace;
643 when used with -f, also build an unrefmaster.out in the parent
644 -w report on differences between previous and current proto areas
645 '
646 #
647 # A log file will be generated under the name $LOGFILE
648 # for partially completed build and log.`date '+%F'`
649 # in the same directory for fully completed builds.
650 #
651
652 # default values for low-level FLAGS; G I R are group FLAGS
653 A_FLAG=n
654 C_FLAG=n
655 D_FLAG=n
656 F_FLAG=n
657 f_FLAG=n
658 i_FLAG=n; i_CMD_LINE_FLAG=n
659 l_FLAG=n
660 M_FLAG=n
661 m_FLAG=n
662 N_FLAG=n
663 n_FLAG=n
664 p_FLAG=n
665 r_FLAG=n
666 t_FLAG=y
667 U_FLAG=n
668 u_FLAG=n
669 V_FLAG=n
670 w_FLAG=n
671 #
672 build_ok=y
673
674 #
675 # examine arguments
676 #
677
678 OPTIND=1
679 while getopts +intV: FLAG
680 do
681 case $FLAG in
682 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
683 ;;
684 n ) n_FLAG=y
685 ;;
686 +t ) t_FLAG=n
687 ;;
688 V ) V_FLAG=y
689 V_ARG="$OPTARG"
690 ;;
803 fi
804
805 ps -o taskid= -p $$ | read build_taskid
806 ps -o project= -p $$ | read build_project
807
808 #
809 # See if NIGHTLY_OPTIONS is set
810 #
811 if [ "$NIGHTLY_OPTIONS" = "" ]; then
812 NIGHTLY_OPTIONS="-aBm"
813 fi
814
815 #
816 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
817 #
818 if [ "$BRINGOVER_WS" = "" ]; then
819 BRINGOVER_WS=$CLONE_WS
820 fi
821
822 #
823 # If BRINGOVER_FILES was not specified, default to usr
824 #
825 if [ "$BRINGOVER_FILES" = "" ]; then
826 BRINGOVER_FILES="usr"
827 fi
828
829 check_closed_bins
830
831 #
832 # Note: changes to the option letters here should also be applied to the
833 # bldenv script. `d' is listed for backward compatibility.
834 #
835 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
836 OPTIND=1
837 while getopts +ABCDdFfGIilMmNnpRrtUuw FLAG $NIGHTLY_OPTIONS
838 do
839 case $FLAG in
840 A ) A_FLAG=y
841 ;;
842 B ) D_FLAG=y
843 ;; # old version of D
844 C ) C_FLAG=y
845 ;;
846 D ) D_FLAG=y
847 ;;
848 F ) F_FLAG=y
849 ;;
850 f ) f_FLAG=y
851 ;;
852 G ) u_FLAG=y
853 ;;
854 I ) m_FLAG=y
855 p_FLAG=y
856 u_FLAG=y
857 ;;
858 i ) i_FLAG=y
859 ;;
860 l ) l_FLAG=y
861 ;;
862 M ) M_FLAG=y
863 ;;
864 m ) m_FLAG=y
865 ;;
866 N ) N_FLAG=y
867 ;;
868 n ) n_FLAG=y
869 ;;
870 p ) p_FLAG=y
871 ;;
872 R ) m_FLAG=y
873 p_FLAG=y
874 ;;
875 r ) r_FLAG=y
876 ;;
877 +t ) t_FLAG=n
878 ;;
879 U ) if [ -z "${PARENT_ROOT}" ]; then
880 echo "PARENT_ROOT must be set if the U flag is" \
881 "present in NIGHTLY_OPTIONS."
882 exit 1
883 fi
884 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
885 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
886 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
887 fi
888 U_FLAG=y
889 ;;
890 u ) u_FLAG=y
891 ;;
892 w ) w_FLAG=y
893 ;;
894 \? ) echo "$USAGE"
895 exit 1
896 ;;
897 esac
898 done
899
900 if [ $ISUSER -ne 0 ]; then
901 # Set default value for STAFFER, if needed.
902 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
903 STAFFER=`/usr/xpg4/bin/id -un`
904 export STAFFER
905 fi
906 fi
907
908 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
909 MAILTO=$STAFFER
910 export MAILTO
911 fi
912
913 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
914 PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb"
915 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
916 export PATH
917
918 # roots of source trees, both relative to $SRC and absolute.
919 relsrcdirs="."
920 abssrcdirs="$SRC"
921
922 PROTOCMPTERSE="protocmp.terse -gu"
923 POUND_SIGN="#"
924 # have we set RELEASE_DATE in our env file?
925 if [ -z "$RELEASE_DATE" ]; then
926 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
927 fi
928 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
929 BASEWSDIR=$(basename $CODEMGR_WS)
930 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
931
932 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
933 # by avoiding repeated shell invocations to evaluate Makefile.master
934 # definitions.
935 export POUND_SIGN RELEASE_DATE DEV_CM
936
937 maketype="distributed"
938 if [[ -z "$MAKE" ]]; then
939 MAKE=dmake
940 elif [[ ! -x "$MAKE" ]]; then
941 echo "\$MAKE is set to garbage in the environment"
942 exit 1
943 fi
944 # get the dmake version string alone
945 DMAKE_VERSION=$( $MAKE -v )
946 DMAKE_VERSION=${DMAKE_VERSION#*: }
947 # focus in on just the dotted version number alone
948 DMAKE_MAJOR=$( echo $DMAKE_VERSION | \
949 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' )
950 # extract the second (or final) integer
951 DMAKE_MINOR=${DMAKE_MAJOR#*.}
952 DMAKE_MINOR=${DMAKE_MINOR%%.*}
953 # extract the first integer
954 DMAKE_MAJOR=${DMAKE_MAJOR%%.*}
955 CHECK_DMAKE=${CHECK_DMAKE:-y}
956 # x86 was built on the 12th, sparc on the 13th.
957 if [ "$CHECK_DMAKE" = "y" -a \
958 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \
959 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \
960 "$DMAKE_MAJOR" -lt 7 -o \
961 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then
962 if [ -z "$DMAKE_VERSION" ]; then
963 echo "$MAKE is missing."
964 exit 1
965 fi
966 echo `whence $MAKE`" version is:"
967 echo " ${DMAKE_VERSION}"
968 cat <<EOF
969
970 This version may not be safe for use, if you really want to use this version
971 anyway add the following to your environment to disable this check:
972
973 CHECK_DMAKE=n
974 EOF
975 exit 1
976 fi
977 export PATH
978 export MAKE
979
980 if [ "${SUNWSPRO}" != "" ]; then
981 PATH="${SUNWSPRO}/bin:$PATH"
982 export PATH
983 fi
984
985 hostname=$(uname -n)
986 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
987 then
988 maxjobs=
989 if [[ -f $HOME/.make.machines ]]
990 then
991 # Note: there is a hard tab and space character in the []s
1002 fi
1003
1004 export DMAKE_MAX_JOBS=$maxjobs
1005 fi
1006
1007 DMAKE_MODE=parallel;
1008 export DMAKE_MODE
1009
1010 if [ -z "${ROOT}" ]; then
1011 echo "ROOT must be set."
1012 exit 1
1013 fi
1014
1015 #
1016 # if -V flag was given, reset VERSION to V_ARG
1017 #
1018 if [ "$V_FLAG" = "y" ]; then
1019 VERSION=$V_ARG
1020 fi
1021
1022 TMPDIR="/tmp/nightly.tmpdir.$$"
1023 export TMPDIR
1024 rm -rf ${TMPDIR}
1025 mkdir -p $TMPDIR || exit 1
1026 chmod 777 $TMPDIR
1027
1028 #
1029 # Keep elfsign's use of pkcs11_softtoken from looking in the user home
1030 # directory, which doesn't always work. Needed until all build machines
1031 # have the fix for 6271754
1032 #
1033 SOFTTOKEN_DIR=$TMPDIR
1034 export SOFTTOKEN_DIR
1035
1036 #
1037 # Tools should only be built non-DEBUG. Keep track of the tools proto
1038 # area path relative to $TOOLS, because the latter changes in an
1039 # export build.
1040 #
1041 # TOOLS_PROTO is included below for builds other than usr/src/tools
1075
1076 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
1077
1078 # since this script assumes the build is from full source, it nullifies
1079 # variables likely to have been set by a "ws" script; nullification
1080 # confines the search space for headers and libraries to the proto area
1081 # built from this immediate source.
1082 ENVLDLIBS1=
1083 ENVLDLIBS2=
1084 ENVLDLIBS3=
1085 ENVCPPFLAGS1=
1086 ENVCPPFLAGS2=
1087 ENVCPPFLAGS3=
1088 ENVCPPFLAGS4=
1089 PARENT_ROOT=
1090
1091 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1092 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
1093
1094 PKGARCHIVE_ORIG=$PKGARCHIVE
1095
1096 #
1097 # Juggle the logs and optionally send mail on completion.
1098 #
1099
1100 function logshuffle {
1101 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
1102 if [ -f $LLOG -o -d $LLOG ]; then
1103 LLOG=$LLOG.$$
1104 fi
1105 mkdir $LLOG
1106 export LLOG
1107
1108 if [ "$build_ok" = "y" ]; then
1109 mv $ATLOG/proto_list_${MACH} $LLOG
1110
1111 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
1112 mv $ATLOG/proto_list_tools_${MACH} $LLOG
1113 fi
1114
1307 START_DATE=`date`
1308 SECONDS=0
1309 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1310 | tee -a $LOGFILE > $build_time_file
1311
1312 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1313 tee -a $mail_msg_file >> $LOGFILE
1314
1315 # make sure we log only to the nightly build file
1316 build_noise_file="${TMPDIR}/build_noise"
1317 exec </dev/null >$build_noise_file 2>&1
1318
1319 run_hook SYS_PRE_NIGHTLY
1320 run_hook PRE_NIGHTLY
1321
1322 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1323 env >> $LOGFILE
1324
1325 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1326
1327 if [ "$N_FLAG" = "y" ]; then
1328 if [ "$p_FLAG" = "y" ]; then
1329 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1330 WARNING: the p option (create packages) is set, but so is the N option (do
1331 not run protocmp); this is dangerous; you should unset the N option
1332 EOF
1333 else
1334 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1335 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1336 EOF
1337 fi
1338 echo "" | tee -a $mail_msg_file >> $LOGFILE
1339 fi
1340
1341 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1342 #
1343 # In the past we just complained but went ahead with the lint
1344 # pass, even though the proto area was built non-DEBUG. It's
1345 # unlikely that non-DEBUG headers will make a difference, but
1346 # rather than assuming it's a safe combination, force the user
1415
1416 # Same for non-DEBUG proto area
1417 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1418 if [ -d "$ROOT-nd.prev" ]; then
1419 rm -rf $ROOT-nd.prev
1420 fi
1421 mv $ROOT-nd $ROOT-nd.prev
1422 fi
1423
1424 #
1425 # Echo the SCM type of the parent workspace, this can't just be which_scm
1426 # as that does not know how to identify various network repositories.
1427 #
1428 function parent_wstype {
1429 typeset scm_type junk
1430
1431 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1432 | read scm_type junk
1433 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1434 # Probe BRINGOVER_WS to determine its type
1435 if [[ $BRINGOVER_WS == ssh://* ]]; then
1436 scm_type="mercurial"
1437 elif [[ $BRINGOVER_WS == http://* ]] && \
1438 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1439 egrep -s "application/mercurial" 2> /dev/null; then
1440 scm_type="mercurial"
1441 else
1442 scm_type="none"
1443 fi
1444 fi
1445
1446 # fold both unsupported and unrecognized results into "none"
1447 case "$scm_type" in
1448 mercurial)
1449 ;;
1450 *) scm_type=none
1451 ;;
1452 esac
1453
1454 echo $scm_type
1455 }
1456
1457 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1458 function child_wstype {
1459 typeset scm_type junk
1460
1461 # Probe CODEMGR_WS to determine its type
1462 if [[ -d $CODEMGR_WS ]]; then
1463 $WHICH_SCM | read scm_type junk || exit 1
1464 fi
1465
1466 case "$scm_type" in
1467 none|git|mercurial)
1468 ;;
1469 *) scm_type=none
1470 ;;
1471 esac
1472
1473 echo $scm_type
1474 }
1475
1476 SCM_TYPE=$(child_wstype)
1477
1478 #
1479 # Decide whether to clobber
1480 #
1481 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1482 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1483
1484 cd $SRC
1485 # remove old clobber file
1486 rm -f $SRC/clobber.out
1487 rm -f $SRC/clobber-${MACH}.out
1515 typeset roots=$(allprotos)
1516 echo "\n\nClearing $roots" >> "$LOGFILE"
1517 rm -rf $roots
1518
1519 # Get back to a clean workspace as much as possible to catch
1520 # problems that only occur on fresh workspaces.
1521 # Remove all .make.state* files, libraries, and .o's that may
1522 # have been omitted from clobber. A couple of libraries are
1523 # under source code control, so leave them alone.
1524 # We should probably blow away temporary directories too.
1525 cd $SRC
1526 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1527 -o -name .git -o -name 'interfaces.*' \) -prune -o \
1528 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1529 -name '*.o' \) -print | \
1530 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
1531 else
1532 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1533 fi
1534
1535 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
1536 typeset -x PATH=$PATH
1537
1538 # If the repository doesn't exist yet, then we want to populate it.
1539 if [[ ! -d $CODEMGR_WS/.hg ]]; then
1540 staffer hg init $CODEMGR_WS
1541 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
1542 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
1543 touch $TMPDIR/new_repository
1544 fi
1545
1546 typeset -x HGMERGE="/bin/false"
1547
1548 #
1549 # If the user has changes, regardless of whether those changes are
1550 # committed, and regardless of whether those changes conflict, then
1551 # we'll attempt to merge them either implicitly (uncommitted) or
1552 # explicitly (committed).
1553 #
1554 # These are the messages we'll use to help clarify mercurial output
1633 fi
1634 fi
1635
1636 printf "updated %s with the following results:\n" "$CODEMGR_WS"
1637 cat $TMPDIR/pull_open.out
1638 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
1639 printf "$mergepassmsg"
1640 fi
1641 printf "\n"
1642
1643 #
1644 # Per-changeset output is neither useful nor manageable for a
1645 # newly-created repository.
1646 #
1647 if [ -f $TMPDIR/new_repository ]; then
1648 return
1649 fi
1650
1651 printf "\nadded the following changesets to open repository:\n"
1652 cat $TMPDIR/incoming_open.out
1653 }
1654
1655 type bringover_none > /dev/null 2>&1 || function bringover_none {
1656 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1657 touch $TMPDIR/bringover_failed
1658 }
1659
1660 #
1661 # Decide whether to bringover to the codemgr workspace
1662 #
1663 if [ "$n_FLAG" = "n" ]; then
1664 PARENT_SCM_TYPE=$(parent_wstype)
1665
1666 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
1667 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
1668 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
1669 exit 1
1670 fi
1671
1672 run_hook PRE_BRINGOVER
1677 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
1678 tee -a $mail_msg_file >> $LOGFILE
1679
1680 if [ -f $TMPDIR/bringover_failed ]; then
1681 rm -f $TMPDIR/bringover_failed
1682 build_ok=n
1683 echo "trouble with bringover, quitting at `date`." |
1684 tee -a $mail_msg_file >> $LOGFILE
1685 exit 1
1686 fi
1687
1688 #
1689 # It's possible that we used the bringover above to create
1690 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
1691 # but should now be the same as $BRINGOVER_WS.
1692 #
1693 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
1694
1695 run_hook POST_BRINGOVER
1696
1697 check_closed_bins
1698
1699 else
1700 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
1701 fi
1702
1703 # Safeguards
1704 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1705 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
1706 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1707
1708 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
1709
1710 # System
1711 whence uname | tee -a $build_environ_file >> $LOGFILE
1712 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
1713 echo | tee -a $build_environ_file >> $LOGFILE
1714
1715 # make
1716 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
1717 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
1766 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1767 if [ `expr $LDVER \< 422` -eq 1 ]; then
1768 echo "The link-editor needs to be at version 422 or higher to build" | \
1769 tee -a $build_environ_file >> $LOGFILE
1770 echo "the latest stuff. Hope your build works." | \
1771 tee -a $build_environ_file >> $LOGFILE
1772 fi
1773
1774 #
1775 # Build and use the workspace's tools if requested
1776 #
1777 if [[ "$t_FLAG" = "y" ]]; then
1778 set_non_debug_build_flags
1779
1780 build_tools ${TOOLS_PROTO}
1781 if [[ $? != 0 && "$t_FLAG" = y ]]; then
1782 use_tools $TOOLS_PROTO
1783 fi
1784 fi
1785
1786 # timestamp the start of the normal build; the findunref tool uses it.
1787 touch $SRC/.build.tstamp
1788
1789 normal_build
1790
1791 ORIG_SRC=$SRC
1792 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
1793
1794
1795 #
1796 # There are several checks that need to look at the proto area, but
1797 # they only need to look at one, and they don't care whether it's
1798 # DEBUG or non-DEBUG.
1799 #
1800 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
1801 checkroot=$ROOT-nd
1802 else
1803 checkroot=$ROOT
1804 fi
1805
1806 if [ "$build_ok" = "y" ]; then
1807 echo "\n==== Creating protolist system file at `date` ====" \
1808 >> $LOGFILE
1809 protolist $checkroot > $ATLOG/proto_list_${MACH}
1810 echo "==== protolist system file created at `date` ====\n" \
1811 >> $LOGFILE
1812
1813 if [ "$N_FLAG" != "y" ]; then
1814
1815 E1=
1816 f1=
1817 for f in $f1; do
1818 if [ -f "$f" ]; then
1819 E1="$E1 -e $f"
1820 fi
1821 done
1822
1823 E2=
1824 f2=
1825 if [ -d "$SRC/pkg" ]; then
1826 f2="$f2 exceptions/packaging"
1827 fi
1828
1829 for f in $f2; do
1830 if [ -f "$f" ]; then
1831 E2="$E2 -e $f"
1832 fi
1833 done
1834 fi
1835
1836 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
1837 echo "\n==== Validating manifests against proto area ====\n" \
1838 >> $mail_msg_file
1839 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) \
1840 >> $mail_msg_file
1841
1842 fi
1843
1844 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1845 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1846 if [ -n "$E2" ]; then
1847 ELIST=$E2
1848 else
1849 ELIST=$E1
1850 fi
1851 $PROTOCMPTERSE \
1852 "Files in yesterday's proto area, but not today's:" \
1853 "Files in today's proto area, but not yesterday's:" \
1854 "Files that changed between yesterday and today:" \
1855 ${ELIST} \
1856 -d $REF_PROTO_LIST \
1857 $ATLOG/proto_list_${MACH} \
1858 >> $mail_msg_file
1859 fi
1860 fi
1861
1862 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1863 staffer cp $ATLOG/proto_list_${MACH} \
1864 $PARENT_WS/usr/src/proto_list_${MACH}
1865 fi
1866
1867 # Update parent proto area if necessary. This is done now
1868 # so that the proto area has either DEBUG or non-DEBUG kernels.
1869 # Note that this clears out the lock file, so we can dispense with
1870 # the variable now.
1871 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1872 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1873 tee -a $LOGFILE >> $mail_msg_file
1874 rm -rf $NIGHTLY_PARENT_ROOT/*
1875 unset Ulockfile
1876 mkdir -p $NIGHTLY_PARENT_ROOT
1877 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2073
2074 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2075 echo "\n==== Diff unreferenced files (since last build) ====\n" \
2076 | tee -a $LOGFILE >>$mail_msg_file
2077 rm -f $SRC/unref-${MACH}.ref
2078 if [ -f $SRC/unref-${MACH}.out ]; then
2079 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2080 fi
2081
2082 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2083 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2084 sort > $SRC/unref-${MACH}.out
2085
2086 if [ ! -f $SRC/unref-${MACH}.ref ]; then
2087 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2088 fi
2089
2090 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2091 fi
2092
2093 # Verify that the usual lists of files, such as exception lists,
2094 # contain only valid references to files. If the build has failed,
2095 # then don't check the proto area.
2096 CHECK_PATHS=${CHECK_PATHS:-y}
2097 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2098 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2099 >>$mail_msg_file
2100 arg=-b
2101 [ "$build_ok" = y ] && arg=
2102 checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file
2103 fi
2104
2105 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2106 echo "\n==== Impact on file permissions ====\n" \
2107 >> $mail_msg_file
2108
2109 abspkg=
2110 for d in $abssrcdirs; do
2111 if [ -d "$d/pkg" ]; then
2112 abspkg="$abspkg $d"
2113 fi
2114 done
2115
2116 if [ -n "$abspkg" ]; then
2117 for d in "$abspkg"; do
2118 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
2119 done
2120 fi
2121 fi
2122
2123 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
2124 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2125 do_wsdiff DEBUG $ROOT.prev $ROOT
2126 fi
2127
2128 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2129 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2130 fi
2131 fi
2132
2133 END_DATE=`date`
2134 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2135 tee -a $LOGFILE >> $build_time_file
|