277 ;;
278 mercurial)
279 copy_source_mercurial $DEST $srcroot
280 if (( $? != 0 )) ; then
281 build_ok=n
282 return 1
283 fi
284 ;;
285 *)
286 build_ok=n
287 echo "Tree copy is not supported for workspace type" \
288 "$SCM_TYPE" | tee -a $mail_msg_file >> $LOGFILE
289 return 1
290 ;;
291 esac
292
293 return 0
294 }
295
296 #
297 # Mercurial-specific copy code for copy_source(). Handles the
298 # combined open and closed trees.
299 #
300 # Returns 0 for success, non-zero for failure.
301 #
302 # usage: copy_source_mercurial destdir srcroot
303 #
304 function copy_source_mercurial {
305 typeset dest=$1
306 typeset srcroot=$2
307 typeset open_top closed_top
308
309 case $srcroot in
310 usr)
311 open_top=usr
312 if [[ "$CLOSED_IS_PRESENT" = yes ]]; then
313 closed_top=usr/closed
314 fi
315 ;;
316 usr/closed*)
317 if [[ "$CLOSED_IS_PRESENT" = no ]]; then
318 printf "can't copy %s: closed tree not present.\n" \
319 "$srcroot" | tee -a $mail_msg_file >> $LOGFILE
320 return 1
321 fi
322 closed_top="$srcroot"
323 ;;
324 *)
325 open_top="$srcroot"
326 ;;
327 esac
328
329 if [[ -n "$open_top" ]]; then
330 hg locate -I "$open_top" | cpio -pd "$dest" >>$LOGFILE 2>&1
331 if (( $? != 0 )) ; then
332 printf "cpio failed for %s\n" "$dest" |
333 tee -a $mail_msg_file >> $LOGFILE
334 return 1
335 fi
336 fi
337
338 if [[ -n "$closed_top" ]]; then
339 mkdir -p "$dest/usr/closed" || return 1
340 if [[ "$closed_top" = usr/closed ]]; then
341 (cd usr/closed; hg locate |
342 cpio -pd "$dest/usr/closed") >>$LOGFILE 2>&1
343 if (( $? != 0 )) ; then
344 printf "cpio failed for %s/usr/closed\n" \
345 "$dest" | tee -a $mail_msg_file >> $LOGFILE
346 return 1
347 fi
348 else
349 # copy subtree of usr/closed
350 closed_top=${closed_top#usr/closed/}
351 (cd usr/closed; hg locate -I "$closed_top" |
352 cpio -pd "$dest/usr/closed") >>$LOGFILE 2>&1
353 if (( $? != 0 )) ; then
354 printf "cpio failed for %s/usr/closed/%s\n" \
355 "$dest" "$closed_top" |
356 tee -a $mail_msg_file >> $LOGFILE
357 return 1
358 fi
359 fi
360 fi
361
362 return 0
363 }
364
365 #
366 # function to create (but not build) the export/crypt source tree.
367 # usage: set_up_source_build CODEMGR_WS DESTDIR MAKE_TARGET
368 # Sets SRC to the modified source tree, for use by the caller when it
369 # builds the tree.
370 #
371 function set_up_source_build {
372 WS=$1
373 DEST=$2
374 MAKETARG=$3
375
376 copy_source $WS $DEST $MAKETARG usr
377 if (( $? != 0 )); then
378 echo "\nCould not copy source tree for source build." |
379 tee -a $mail_msg_file >> $LOGFILE
380 build_ok=n
876 echo "PATH=${PATH}" >> $LOGFILE
877 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
878 }
879
880 function staffer {
881 if [ $ISUSER -ne 0 ]; then
882 "$@"
883 else
884 arg="\"$1\""
885 shift
886 for i
887 do
888 arg="$arg \"$i\""
889 done
890 eval su $STAFFER -c \'$arg\'
891 fi
892 }
893
894 #
895 # Verify that the closed tree is present if it needs to be.
896 # Sets CLOSED_IS_PRESENT for future use.
897 #
898 function check_closed_tree {
899 if [ -z "$CLOSED_IS_PRESENT" ]; then
900 if [ -d $CODEMGR_WS/usr/closed ]; then
901 CLOSED_IS_PRESENT="yes"
902 else
903 CLOSED_IS_PRESENT="no"
904 fi
905 export CLOSED_IS_PRESENT
906 fi
907 if [[ "$CLOSED_IS_PRESENT" = no && ! -d "$ON_CLOSED_BINS" ]]; then
908 #
909 # If it's an old (pre-split) tree or an empty
910 # workspace, don't complain.
911 #
912 if grep -s CLOSED_BUILD $SRC/Makefile.master > /dev/null; then
913 echo "If the closed sources are not present," \
914 "ON_CLOSED_BINS"
915 echo "must point to the closed binaries tree."
916 build_ok=n
917 exit 1
918 fi
919 fi
920 }
921
922 function obsolete_build {
923 echo "WARNING: Obsolete $1 build requested; request will be ignored"
924 }
925
926 #
927 # wrapper over wsdiff.
928 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
929 #
930 function do_wsdiff {
931 label=$1
932 oldproto=$2
933 newproto=$3
934
935 wsdiff="wsdiff"
936 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
937
938 echo "\n==== Getting object changes since last build at `date`" \
939 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
1247 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
1248 #
1249 if [ "$BRINGOVER_WS" = "" ]; then
1250 BRINGOVER_WS=$CLONE_WS
1251 fi
1252
1253 #
1254 # If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS
1255 #
1256 if [ "$CLOSED_BRINGOVER_WS" = "" ]; then
1257 CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS
1258 fi
1259
1260 #
1261 # If BRINGOVER_FILES was not specified, default to usr
1262 #
1263 if [ "$BRINGOVER_FILES" = "" ]; then
1264 BRINGOVER_FILES="usr"
1265 fi
1266
1267 #
1268 # If the closed sources are not present, the closed binaries must be
1269 # present for the build to succeed. If there's no pointer to the
1270 # closed binaries, flag that now, rather than forcing the user to wait
1271 # a couple hours (or more) to find out.
1272 #
1273 orig_closed_is_present="$CLOSED_IS_PRESENT"
1274 check_closed_tree
1275
1276 #
1277 # Note: changes to the option letters here should also be applied to the
1278 # bldenv script. `d' is listed for backward compatibility.
1279 #
1280 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
1281 OPTIND=1
1282 while getopts +ABCDdFfGIilMmNnOoPpRrS:TtUuWwXxz FLAG $NIGHTLY_OPTIONS
1283 do
1284 case $FLAG in
1285 A ) A_FLAG=y
1286 #
1287 # If ELF_DATA_BASELINE_DIR is not defined, and we are on SWAN
1288 # (based on CLOSED_IS_PRESENT), then refuse to run. The value
1289 # of ELF version checking is greatly enhanced by including
1290 # the baseline gate comparison.
1291 if [ "$CLOSED_IS_PRESENT" = 'yes' -a \
1292 "$ELF_DATA_BASELINE_DIR" = '' ]; then
1293 echo "ELF_DATA_BASELINE_DIR must be set if the A" \
1294 "flag is present in\nNIGHTLY_OPTIONS and closed" \
1295 "sources are present. Update environment file."
1296 exit 1;
1297 fi
1298 ;;
1299 B ) D_FLAG=y
1300 ;; # old version of D
1301 C ) C_FLAG=y
1302 ;;
1303 D ) D_FLAG=y
1304 ;;
1305 F ) F_FLAG=y
1306 ;;
1307 f ) f_FLAG=y
1308 ;;
1309 G ) u_FLAG=y
1310 ;;
1311 I ) m_FLAG=y
1312 p_FLAG=y
1313 u_FLAG=y
1314 ;;
1315 i ) i_FLAG=y
1316 ;;
1317 l ) l_FLAG=y
1384
1385 # Set default value for STAFFER, if needed.
1386 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
1387 STAFFER=`/usr/xpg4/bin/id -un`
1388 export STAFFER
1389 fi
1390 fi
1391
1392 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
1393 MAILTO=$STAFFER
1394 export MAILTO
1395 fi
1396
1397 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
1398 PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb"
1399 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
1400 export PATH
1401
1402 # roots of source trees, both relative to $SRC and absolute.
1403 relsrcdirs="."
1404 if [[ -d $CODEMGR_WS/usr/closed && "$CLOSED_IS_PRESENT" != no ]]; then
1405 relsrcdirs="$relsrcdirs ../closed"
1406 fi
1407 abssrcdirs=""
1408 for d in $relsrcdirs; do
1409 abssrcdirs="$abssrcdirs $SRC/$d"
1410 done
1411
1412 unset CH
1413 if [ "$o_FLAG" = "y" ]; then
1414 # root invoked old-style build -- make sure it works as it always has
1415 # by exporting 'CH'. The current Makefile.master doesn't use this, but
1416 # the old ones still do.
1417 PROTOCMPTERSE="protocmp.terse"
1418 CH=
1419 export CH
1420 else
1421 PROTOCMPTERSE="protocmp.terse -gu"
1422 fi
1423 POUND_SIGN="#"
1424 # have we set RELEASE_DATE in our env file?
1425 if [ -z "$RELEASE_DATE" ]; then
1426 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
1427 fi
1428 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
1429 BASEWSDIR=$(basename $CODEMGR_WS)
1430 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
1456 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then
1457 if [ -z "$DMAKE_VERSION" ]; then
1458 echo "$MAKE is missing."
1459 exit 1
1460 fi
1461 echo `whence $MAKE`" version is:"
1462 echo " ${DMAKE_VERSION}"
1463 cat <<EOF
1464
1465 This version may not be safe for use. Either set TEAMWARE to a better
1466 path or (if you really want to use this version of dmake anyway), add
1467 the following to your environment to disable this check:
1468
1469 CHECK_DMAKE=n
1470 EOF
1471 exit 1
1472 fi
1473 export PATH
1474 export MAKE
1475
1476 if [[ "$O_FLAG" = y ]]; then
1477 export TONICBUILD=""
1478 else
1479 export TONICBUILD="#"
1480 fi
1481
1482 if [ "${SUNWSPRO}" != "" ]; then
1483 PATH="${SUNWSPRO}/bin:$PATH"
1484 export PATH
1485 fi
1486
1487 hostname=$(uname -n)
1488 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
1489 then
1490 maxjobs=
1491 if [[ -f $HOME/.make.machines ]]
1492 then
1493 # Note: there is a hard tab and space character in the []s
1494 # below.
1495 egrep -i "^[ ]*$hostname[ \.]" \
1496 $HOME/.make.machines | read host jobs
1497 maxjobs=${jobs##*=}
1498 fi
1499
1500 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
1501 then
2138 touch $TMPDIR/bringover_failed
2139
2140 staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1
2141 if [ -s $TMPDIR/bringovercheck.out ]; then
2142 echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n"
2143 cat $TMPDIR/bringovercheck.out
2144 fi
2145 }
2146
2147 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
2148 typeset -x PATH=$PATH
2149
2150 # If the repository doesn't exist yet, then we want to populate it.
2151 if [[ ! -d $CODEMGR_WS/.hg ]]; then
2152 staffer hg init $CODEMGR_WS
2153 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
2154 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
2155 touch $TMPDIR/new_repository
2156 fi
2157
2158 #
2159 # If the user set CLOSED_BRINGOVER_WS and didn't set CLOSED_IS_PRESENT
2160 # to "no," then we'll want to initialise the closed repository
2161 #
2162 # We use $orig_closed_is_present instead of $CLOSED_IS_PRESENT,
2163 # because for newly-created source trees, the latter will be "no"
2164 # until after the bringover completes.
2165 #
2166 if [[ "$orig_closed_is_present" != "no" && \
2167 -n "$CLOSED_BRINGOVER_WS" && \
2168 ! -d $CODEMGR_WS/usr/closed/.hg ]]; then
2169 staffer mkdir -p $CODEMGR_WS/usr/closed
2170 staffer hg init $CODEMGR_WS/usr/closed
2171 staffer echo "[paths]" > $CODEMGR_WS/usr/closed/.hg/hgrc
2172 staffer echo "default=$CLOSED_BRINGOVER_WS" >> $CODEMGR_WS/usr/closed/.hg/hgrc
2173 touch $TMPDIR/new_closed
2174 export CLOSED_IS_PRESENT=yes
2175 fi
2176
2177 typeset -x HGMERGE="/bin/false"
2178
2179 #
2180 # If the user has changes, regardless of whether those changes are
2181 # committed, and regardless of whether those changes conflict, then
2182 # we'll attempt to merge them either implicitly (uncommitted) or
2183 # explicitly (committed).
2184 #
2185 # These are the messages we'll use to help clarify mercurial output
2186 # in those cases.
2187 #
2188 typeset mergefailmsg="\
2189 ***\n\
2190 *** nightly was unable to automatically merge your changes. You should\n\
2191 *** redo the full merge manually, following the steps outlined by mercurial\n\
2192 *** above, then restart nightly.\n\
2193 ***\n"
2194 typeset mergepassmsg="\
2195 ***\n\
2196 *** nightly successfully merged your changes. This means that your working\n\
2255 printf "%s: merge failed as follows:\n\n" \
2256 "$CODEMGR_WS"
2257 cat $TMPDIR/pull_open.out
2258 if grep "^merging.*failed" $TMPDIR/pull_open.out \
2259 > /dev/null 2>&1; then
2260 printf "$mergefailmsg"
2261 fi
2262 touch $TMPDIR/bringover_failed
2263 return
2264 fi
2265 fi
2266
2267 printf "updated %s with the following results:\n" "$CODEMGR_WS"
2268 cat $TMPDIR/pull_open.out
2269 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
2270 printf "$mergepassmsg"
2271 fi
2272 printf "\n"
2273
2274 #
2275 # We only want to update usr/closed if it exists, and we haven't been
2276 # told not to via $CLOSED_IS_PRESENT, and we actually know where to
2277 # pull from ($CLOSED_BRINGOVER_WS).
2278 #
2279 if [[ $CLOSED_IS_PRESENT = yes && \
2280 -d $CODEMGR_WS/usr/closed/.hg && \
2281 -n $CLOSED_BRINGOVER_WS ]]; then
2282
2283 HG_SOURCE=$CLOSED_BRINGOVER_WS
2284 if [ ! -f $TMPDIR/new_closed ]; then
2285 HG_SOURCE=$TMPDIR/closed_bundle.hg
2286 staffer hg --cwd $CODEMGR_WS/usr/closed incoming \
2287 --bundle $HG_SOURCE -v $CLOSED_BRINGOVER_WS \
2288 > $TMPDIR/incoming_closed.out
2289
2290 #
2291 # If there are no incoming changesets, then incoming will
2292 # fail, and there will be no bundle file. Reset the source,
2293 # to allow the remaining logic to complete with no false
2294 # negatives. (Unlike incoming, pull will return success
2295 # for the no-change case.)
2296 #
2297 if (( $? != 0 )); then
2298 HG_SOURCE=$CLOSED_BRINGOVER_WS
2299 fi
2300 fi
2301
2302 staffer hg --cwd $CODEMGR_WS/usr/closed pull -u \
2303 $HG_SOURCE > $TMPDIR/pull_closed.out 2>&1
2304 if (( $? != 0 )); then
2305 printf "closed pull failed as follows:\n\n"
2306 cat $TMPDIR/pull_closed.out
2307 if grep "^merging.*failed" $TMPDIR/pull_closed.out \
2308 > /dev/null 2>&1; then
2309 printf "$mergefailmsg"
2310 fi
2311 touch $TMPDIR/bringover_failed
2312 return
2313 fi
2314
2315 if grep "not updating" $TMPDIR/pull_closed.out > /dev/null 2>&1; then
2316 staffer hg --cwd $CODEMGR_WS/usr/closed merge \
2317 >> $TMPDIR/pull_closed.out 2>&1
2318 if (( $? != 0 )); then
2319 printf "closed merge failed as follows:\n\n"
2320 cat $TMPDIR/pull_closed.out
2321 if grep "^merging.*failed" $TMPDIR/pull_closed.out > /dev/null 2>&1; then
2322 printf "$mergefailmsg"
2323 fi
2324 touch $TMPDIR/bringover_failed
2325 return
2326 fi
2327 fi
2328
2329 printf "updated %s with the following results:\n" \
2330 "$CODEMGR_WS/usr/closed"
2331 cat $TMPDIR/pull_closed.out
2332 if grep "^merging" $TMPDIR/pull_closed.out > /dev/null 2>&1; then
2333 printf "$mergepassmsg"
2334 fi
2335 fi
2336
2337 #
2338 # Per-changeset output is neither useful nor manageable for a
2339 # newly-created repository.
2340 #
2341 if [ -f $TMPDIR/new_repository ]; then
2342 return
2343 fi
2344
2345 printf "\nadded the following changesets to open repository:\n"
2346 cat $TMPDIR/incoming_open.out
2347
2348 #
2349 # The closed repository could have been newly created, even though
2350 # the open one previously existed...
2351 #
2352 if [ -f $TMPDIR/new_closed ]; then
2353 return
2354 fi
2355
2356 if [ -f $TMPDIR/incoming_closed.out ]; then
2357 printf "\nadded the following changesets to closed repository:\n"
2414 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
2415 tee -a $mail_msg_file >> $LOGFILE
2416
2417 if [ -f $TMPDIR/bringover_failed ]; then
2418 rm -f $TMPDIR/bringover_failed
2419 build_ok=n
2420 echo "trouble with bringover, quitting at `date`." |
2421 tee -a $mail_msg_file >> $LOGFILE
2422 exit 1
2423 fi
2424
2425 #
2426 # It's possible that we used the bringover above to create
2427 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
2428 # but should now be the same as $BRINGOVER_WS.
2429 #
2430 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
2431
2432 run_hook POST_BRINGOVER
2433
2434 #
2435 # Possible transition from pre-split workspace to split
2436 # workspace. See if the bringover changed anything.
2437 #
2438 CLOSED_IS_PRESENT="$orig_closed_is_present"
2439 check_closed_tree
2440
2441 else
2442 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
2443 fi
2444
2445 if [[ "$O_FLAG" = y && "$CLOSED_IS_PRESENT" != "yes" ]]; then
2446 build_ok=n
2447 echo "OpenSolaris binary deliverables need usr/closed." \
2448 | tee -a "$mail_msg_file" >> $LOGFILE
2449 exit 1
2450 fi
2451
2452 # Safeguards
2453 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
2454 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
2455 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
2456
2457 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
2458
2459 # System
2460 whence uname | tee -a $build_environ_file >> $LOGFILE
2461 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
2462 echo | tee -a $build_environ_file >> $LOGFILE
2463
2464 # make
2465 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
2605 >> $mail_msg_file
2606 else
2607 echo "\n==== DOMESTIC extraction failed ====\n" \
2608 >> $mail_msg_file
2609 fi
2610
2611 fi
2612
2613 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2614 #
2615 # Copy the open sources into their own tree.
2616 # If copy_source fails, it will have already generated an
2617 # error message and set build_ok=n, so we don't need to worry
2618 # about that here.
2619 #
2620 copy_source $CODEMGR_WS $OPEN_SRCDIR OPEN_SOURCE usr/src
2621 fi
2622
2623 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2624 SRC=$OPEN_SRCDIR/usr/src
2625 export CLOSED_IS_PRESENT=no
2626 fi
2627
2628 if is_source_build && [ $build_ok = y ] ; then
2629 # remove proto area(s) here, since we don't clobber
2630 rm -rf `allprotos`
2631 if [ "$t_FLAG" = "y" ]; then
2632 set_non_debug_build_flags
2633 ORIG_TOOLS=$TOOLS
2634 #
2635 # SRC was set earlier to point to the source build
2636 # source tree (e.g., $EXPORT_SRC).
2637 #
2638 TOOLS=${SRC}/tools
2639 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
2640 build_tools ${TOOLS_PROTO}
2641 if [[ $? != 0 ]]; then
2642 use_tools ${TOOLS_PROTO}
2643 fi
2644 fi
2645
|
277 ;;
278 mercurial)
279 copy_source_mercurial $DEST $srcroot
280 if (( $? != 0 )) ; then
281 build_ok=n
282 return 1
283 fi
284 ;;
285 *)
286 build_ok=n
287 echo "Tree copy is not supported for workspace type" \
288 "$SCM_TYPE" | tee -a $mail_msg_file >> $LOGFILE
289 return 1
290 ;;
291 esac
292
293 return 0
294 }
295
296 #
297 # Mercurial-specific copy code for copy_source().
298 #
299 # Returns 0 for success, non-zero for failure.
300 #
301 # usage: copy_source_mercurial destdir srcroot
302 #
303 function copy_source_mercurial {
304 typeset dest=$1
305 typeset srcroot=$2
306
307 hg locate -I "$srcroot" | cpio -pd "$dest" >>$LOGFILE 2>&1
308 if (( $? != 0 )) ; then
309 printf "cpio failed for %s\n" "$dest" |
310 tee -a $mail_msg_file >> $LOGFILE
311 return 1
312 fi
313
314 return 0
315 }
316
317 #
318 # function to create (but not build) the export/crypt source tree.
319 # usage: set_up_source_build CODEMGR_WS DESTDIR MAKE_TARGET
320 # Sets SRC to the modified source tree, for use by the caller when it
321 # builds the tree.
322 #
323 function set_up_source_build {
324 WS=$1
325 DEST=$2
326 MAKETARG=$3
327
328 copy_source $WS $DEST $MAKETARG usr
329 if (( $? != 0 )); then
330 echo "\nCould not copy source tree for source build." |
331 tee -a $mail_msg_file >> $LOGFILE
332 build_ok=n
828 echo "PATH=${PATH}" >> $LOGFILE
829 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
830 }
831
832 function staffer {
833 if [ $ISUSER -ne 0 ]; then
834 "$@"
835 else
836 arg="\"$1\""
837 shift
838 for i
839 do
840 arg="$arg \"$i\""
841 done
842 eval su $STAFFER -c \'$arg\'
843 fi
844 }
845
846 #
847 # Verify that the closed tree is present if it needs to be.
848 #
849 function check_closed_tree {
850 if [[ ! -d "$ON_CLOSED_BINS" ]]; then
851 echo "ON_CLOSED_BINS must point to the closed binaries tree."
852 build_ok=n
853 exit 1
854 fi
855 }
856
857 function obsolete_build {
858 echo "WARNING: Obsolete $1 build requested; request will be ignored"
859 }
860
861 #
862 # wrapper over wsdiff.
863 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
864 #
865 function do_wsdiff {
866 label=$1
867 oldproto=$2
868 newproto=$3
869
870 wsdiff="wsdiff"
871 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
872
873 echo "\n==== Getting object changes since last build at `date`" \
874 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
1182 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
1183 #
1184 if [ "$BRINGOVER_WS" = "" ]; then
1185 BRINGOVER_WS=$CLONE_WS
1186 fi
1187
1188 #
1189 # If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS
1190 #
1191 if [ "$CLOSED_BRINGOVER_WS" = "" ]; then
1192 CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS
1193 fi
1194
1195 #
1196 # If BRINGOVER_FILES was not specified, default to usr
1197 #
1198 if [ "$BRINGOVER_FILES" = "" ]; then
1199 BRINGOVER_FILES="usr"
1200 fi
1201
1202 check_closed_tree
1203
1204 #
1205 # Note: changes to the option letters here should also be applied to the
1206 # bldenv script. `d' is listed for backward compatibility.
1207 #
1208 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
1209 OPTIND=1
1210 while getopts +ABCDdFfGIilMmNnOoPpRrS:TtUuWwXxz FLAG $NIGHTLY_OPTIONS
1211 do
1212 case $FLAG in
1213 A ) A_FLAG=y
1214 ;;
1215 B ) D_FLAG=y
1216 ;; # old version of D
1217 C ) C_FLAG=y
1218 ;;
1219 D ) D_FLAG=y
1220 ;;
1221 F ) F_FLAG=y
1222 ;;
1223 f ) f_FLAG=y
1224 ;;
1225 G ) u_FLAG=y
1226 ;;
1227 I ) m_FLAG=y
1228 p_FLAG=y
1229 u_FLAG=y
1230 ;;
1231 i ) i_FLAG=y
1232 ;;
1233 l ) l_FLAG=y
1300
1301 # Set default value for STAFFER, if needed.
1302 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
1303 STAFFER=`/usr/xpg4/bin/id -un`
1304 export STAFFER
1305 fi
1306 fi
1307
1308 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
1309 MAILTO=$STAFFER
1310 export MAILTO
1311 fi
1312
1313 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
1314 PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb"
1315 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
1316 export PATH
1317
1318 # roots of source trees, both relative to $SRC and absolute.
1319 relsrcdirs="."
1320 abssrcdirs="$SRC"
1321
1322 unset CH
1323 if [ "$o_FLAG" = "y" ]; then
1324 # root invoked old-style build -- make sure it works as it always has
1325 # by exporting 'CH'. The current Makefile.master doesn't use this, but
1326 # the old ones still do.
1327 PROTOCMPTERSE="protocmp.terse"
1328 CH=
1329 export CH
1330 else
1331 PROTOCMPTERSE="protocmp.terse -gu"
1332 fi
1333 POUND_SIGN="#"
1334 # have we set RELEASE_DATE in our env file?
1335 if [ -z "$RELEASE_DATE" ]; then
1336 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
1337 fi
1338 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
1339 BASEWSDIR=$(basename $CODEMGR_WS)
1340 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
1366 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then
1367 if [ -z "$DMAKE_VERSION" ]; then
1368 echo "$MAKE is missing."
1369 exit 1
1370 fi
1371 echo `whence $MAKE`" version is:"
1372 echo " ${DMAKE_VERSION}"
1373 cat <<EOF
1374
1375 This version may not be safe for use. Either set TEAMWARE to a better
1376 path or (if you really want to use this version of dmake anyway), add
1377 the following to your environment to disable this check:
1378
1379 CHECK_DMAKE=n
1380 EOF
1381 exit 1
1382 fi
1383 export PATH
1384 export MAKE
1385
1386 if [ "${SUNWSPRO}" != "" ]; then
1387 PATH="${SUNWSPRO}/bin:$PATH"
1388 export PATH
1389 fi
1390
1391 hostname=$(uname -n)
1392 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
1393 then
1394 maxjobs=
1395 if [[ -f $HOME/.make.machines ]]
1396 then
1397 # Note: there is a hard tab and space character in the []s
1398 # below.
1399 egrep -i "^[ ]*$hostname[ \.]" \
1400 $HOME/.make.machines | read host jobs
1401 maxjobs=${jobs##*=}
1402 fi
1403
1404 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
1405 then
2042 touch $TMPDIR/bringover_failed
2043
2044 staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1
2045 if [ -s $TMPDIR/bringovercheck.out ]; then
2046 echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n"
2047 cat $TMPDIR/bringovercheck.out
2048 fi
2049 }
2050
2051 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
2052 typeset -x PATH=$PATH
2053
2054 # If the repository doesn't exist yet, then we want to populate it.
2055 if [[ ! -d $CODEMGR_WS/.hg ]]; then
2056 staffer hg init $CODEMGR_WS
2057 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
2058 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
2059 touch $TMPDIR/new_repository
2060 fi
2061
2062 typeset -x HGMERGE="/bin/false"
2063
2064 #
2065 # If the user has changes, regardless of whether those changes are
2066 # committed, and regardless of whether those changes conflict, then
2067 # we'll attempt to merge them either implicitly (uncommitted) or
2068 # explicitly (committed).
2069 #
2070 # These are the messages we'll use to help clarify mercurial output
2071 # in those cases.
2072 #
2073 typeset mergefailmsg="\
2074 ***\n\
2075 *** nightly was unable to automatically merge your changes. You should\n\
2076 *** redo the full merge manually, following the steps outlined by mercurial\n\
2077 *** above, then restart nightly.\n\
2078 ***\n"
2079 typeset mergepassmsg="\
2080 ***\n\
2081 *** nightly successfully merged your changes. This means that your working\n\
2140 printf "%s: merge failed as follows:\n\n" \
2141 "$CODEMGR_WS"
2142 cat $TMPDIR/pull_open.out
2143 if grep "^merging.*failed" $TMPDIR/pull_open.out \
2144 > /dev/null 2>&1; then
2145 printf "$mergefailmsg"
2146 fi
2147 touch $TMPDIR/bringover_failed
2148 return
2149 fi
2150 fi
2151
2152 printf "updated %s with the following results:\n" "$CODEMGR_WS"
2153 cat $TMPDIR/pull_open.out
2154 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
2155 printf "$mergepassmsg"
2156 fi
2157 printf "\n"
2158
2159 #
2160 # Per-changeset output is neither useful nor manageable for a
2161 # newly-created repository.
2162 #
2163 if [ -f $TMPDIR/new_repository ]; then
2164 return
2165 fi
2166
2167 printf "\nadded the following changesets to open repository:\n"
2168 cat $TMPDIR/incoming_open.out
2169
2170 #
2171 # The closed repository could have been newly created, even though
2172 # the open one previously existed...
2173 #
2174 if [ -f $TMPDIR/new_closed ]; then
2175 return
2176 fi
2177
2178 if [ -f $TMPDIR/incoming_closed.out ]; then
2179 printf "\nadded the following changesets to closed repository:\n"
2236 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
2237 tee -a $mail_msg_file >> $LOGFILE
2238
2239 if [ -f $TMPDIR/bringover_failed ]; then
2240 rm -f $TMPDIR/bringover_failed
2241 build_ok=n
2242 echo "trouble with bringover, quitting at `date`." |
2243 tee -a $mail_msg_file >> $LOGFILE
2244 exit 1
2245 fi
2246
2247 #
2248 # It's possible that we used the bringover above to create
2249 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
2250 # but should now be the same as $BRINGOVER_WS.
2251 #
2252 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
2253
2254 run_hook POST_BRINGOVER
2255
2256 check_closed_tree
2257
2258 else
2259 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
2260 fi
2261
2262 if [[ "$O_FLAG" = y ]]; then
2263 build_ok=n
2264 echo "OpenSolaris binary deliverables need usr/closed." \
2265 | tee -a "$mail_msg_file" >> $LOGFILE
2266 exit 1
2267 fi
2268
2269 # Safeguards
2270 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
2271 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
2272 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
2273
2274 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
2275
2276 # System
2277 whence uname | tee -a $build_environ_file >> $LOGFILE
2278 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
2279 echo | tee -a $build_environ_file >> $LOGFILE
2280
2281 # make
2282 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
2422 >> $mail_msg_file
2423 else
2424 echo "\n==== DOMESTIC extraction failed ====\n" \
2425 >> $mail_msg_file
2426 fi
2427
2428 fi
2429
2430 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2431 #
2432 # Copy the open sources into their own tree.
2433 # If copy_source fails, it will have already generated an
2434 # error message and set build_ok=n, so we don't need to worry
2435 # about that here.
2436 #
2437 copy_source $CODEMGR_WS $OPEN_SRCDIR OPEN_SOURCE usr/src
2438 fi
2439
2440 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2441 SRC=$OPEN_SRCDIR/usr/src
2442 fi
2443
2444 if is_source_build && [ $build_ok = y ] ; then
2445 # remove proto area(s) here, since we don't clobber
2446 rm -rf `allprotos`
2447 if [ "$t_FLAG" = "y" ]; then
2448 set_non_debug_build_flags
2449 ORIG_TOOLS=$TOOLS
2450 #
2451 # SRC was set earlier to point to the source build
2452 # source tree (e.g., $EXPORT_SRC).
2453 #
2454 TOOLS=${SRC}/tools
2455 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
2456 build_tools ${TOOLS_PROTO}
2457 if [[ $? != 0 ]]; then
2458 use_tools ${TOOLS_PROTO}
2459 fi
2460 fi
2461
|