Print this page
4030 remove useless nightly/bldenv options
Reviewed by: Andy Stormont <andyjstormont@gmail.com>


 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 #
 234 # Copy some or all of the source tree.
 235 #
 236 # Returns 0 for success, non-zero for failure.
 237 #
 238 # usage: copy_source CODEMGR_WS DESTDIR LABEL SRCROOT
 239 #
 240 function copy_source {
 241         WS=$1
 242         DEST=$2
 243         label=$3
 244         srcroot=$4
 245 
 246         printf "\n==== Creating %s source from %s (%s) ====\n\n" \
 247             "$DEST" "$WS" "$label" | tee -a $mail_msg_file >> $LOGFILE
 248 
 249         printf "cleaning out %s\n" "$DEST." >> $LOGFILE
 250         rm -rf "$DEST" >> $LOGFILE 2>&1
 251 
 252         printf "creating %s\n" "$DEST." >> $LOGFILE
 253         mkdir -p "$DEST" 2>> $LOGFILE
 254 
 255         if (( $? != 0 )) ; then
 256                 printf "failed to create %s\n" "$DEST" |
 257                     tee -a $mail_msg_file >> $LOGFILE
 258                 build_ok=n
 259                 return 1
 260         fi
 261         cd "$WS"
 262 
 263         printf "populating %s\n" "$DEST." >> $LOGFILE
 264 
 265         case "$SCM_TYPE" in
 266         teamware)
 267                 find $srcroot -name 's\.*' -a -type f -print | \
 268                     sed -e 's,SCCS\/s.,,' | \
 269                     grep -v '/\.del-*' | \
 270                     cpio -pd $DEST >>$LOGFILE 2>&1
 271                 if (( $? != 0 )) ; then
 272                     printf "cpio failed for %s\n" "$DEST" |
 273                         tee -a $mail_msg_file >> $LOGFILE
 274                     build_ok=n
 275                     return 1
 276                 fi
 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
 333             return
 334         fi
 335 
 336         SRC=${DEST}/usr/src
 337 
 338         cd $SRC
 339         rm -f ${MAKETARG}.out
 340         echo "making ${MAKETARG} in ${SRC}." >> $LOGFILE
 341         /bin/time $MAKE -e ${MAKETARG} 2>&1 | \
 342             tee -a $SRC/${MAKETARG}.out >> $LOGFILE
 343         echo "\n==== ${MAKETARG} build errors ====\n" >> $mail_msg_file
 344         egrep ":" $SRC/${MAKETARG}.out | \
 345                 egrep -e "(^${MAKE}:|[  ]error[:        \n])" | \
 346                 egrep -v "Ignoring unknown host" | \
 347                 egrep -v "warning" >> $mail_msg_file
 348 
 349         echo "clearing state files." >> $LOGFILE
 350         find . -name '.make*' -exec rm -f {} \;
 351 }
 352 
 353 # Return library search directive as function of given root.
 354 function myldlibs {
 355         echo "-L$1/lib -L$1/usr/lib"
 356 }
 357 
 358 # Return header search directive as function of given root.
 359 function myheaders {
 360         echo "-I$1/usr/include"
 361 }
 362 
 363 #
 364 # Function to do the build, including package generation.
 365 # usage: build LABEL SUFFIX ND MULTIPROTO
 366 # - LABEL is used to tag build output.
 367 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
 368 #   open-only vs full tree).
 369 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
 370 # - If MULTIPROTO is "yes", it means to name the proto area according to
 371 #   SUFFIX.  Otherwise ("no"), (re)use the standard proto area.
 372 #
 373 function build {
 374         LABEL=$1
 375         SUFFIX=$2
 376         ND=$3
 377         MULTIPROTO=$4
 378         INSTALLOG=install${SUFFIX}-${MACH}
 379         NOISE=noise${SUFFIX}-${MACH}
 380         PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
 381 
 382         ORIGROOT=$ROOT
 383         [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
 384 
 385         if [[ "$O_FLAG" = y ]]; then
 386                 echo "\nSetting CLOSEDROOT= ${ROOT}-closed\n" >> $LOGFILE
 387                 export CLOSEDROOT=${ROOT}-closed
 388         fi
 389 
 390         export ENVLDLIBS1=`myldlibs $ROOT`
 391         export ENVCPPFLAGS1=`myheaders $ROOT`
 392 
 393         this_build_ok=y
 394         #
 395         #       Build OS-Networking source
 396         #
 397         echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
 398                 >> $LOGFILE
 399 
 400         rm -f $SRC/${INSTALLOG}.out
 401         cd $SRC
 402         /bin/time $MAKE -e install 2>&1 | \
 403             tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
 404 
 405         if [[ "$SCM_TYPE" = teamware ]]; then
 406                 echo "\n==== SCCS Noise ($LABEL) ====\n" >> $mail_msg_file
 407                 egrep 'sccs(check:| *get)' $SRC/${INSTALLOG}.out >> \
 408                         $mail_msg_file
 409         fi


 892 
 893 function set_debug_build_flags {
 894         export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
 895         unset RELEASE_BUILD
 896         unset EXTRA_OPTIONS
 897         unset EXTRA_CFLAGS
 898 }
 899 
 900 
 901 MACH=`uname -p`
 902 
 903 if [ "$OPTHOME" = "" ]; then
 904         OPTHOME=/opt
 905         export OPTHOME
 906 fi
 907 if [ "$TEAMWARE" = "" ]; then
 908         TEAMWARE=$OPTHOME/teamware
 909         export TEAMWARE
 910 fi
 911 
 912 USAGE='Usage: nightly [-in] [+t] [-V VERS ] [ -S E|D|H|O ] <env_file>
 913 
 914 Where:
 915         -i      Fast incremental options (no clobber, lint, check)
 916         -n      Do not do a bringover
 917         +t      Use the build tools in $ONBLD_TOOLS/bin
 918         -V VERS set the build version string to VERS
 919         -S      Build a variant of the source product
 920                 E - build exportable source
 921                 D - build domestic source (exportable + crypt)
 922                 H - build hybrid source (binaries + deleted source)
 923                 O - build (only) open source
 924 
 925         <env_file>  file in Bourne shell syntax that sets and exports
 926         variables that configure the operation of this script and many of
 927         the scripts this one calls. If <env_file> does not exist,
 928         it will be looked for in $OPTHOME/onbld/env.
 929 
 930 non-DEBUG is the default build type. Build options can be set in the
 931 NIGHTLY_OPTIONS variable in the <env_file> as follows:
 932 
 933         -A      check for ABI differences in .so files
 934         -C      check for cstyle/hdrchk errors
 935         -D      do a build with DEBUG on
 936         -F      do _not_ do a non-DEBUG build
 937         -G      gate keeper default group of options (-au)
 938         -I      integration engineer default group of options (-ampu)
 939         -M      do not run pmodes (safe file permission checker)
 940         -N      do not run protocmp
 941         -O      generate OpenSolaris deliverables
 942         -R      default group of options for building a release (-mp)
 943         -U      update proto area in the parent
 944         -V VERS set the build version string to VERS
 945         -X      copy x86 IHV proto area
 946         -f      find unreferenced files
 947         -i      do an incremental build (no "make clobber")
 948         -l      do "make lint" in $LINTDIRS (default: $SRC y)
 949         -m      send mail to $MAILTO at end of build
 950         -n      do not do a bringover
 951         -o      build using root privileges to set OWNER/GROUP (old style)
 952         -p      create packages
 953         -r      check ELF runtime attributes in the proto area
 954         -t      build and use the tools in $SRC/tools (default setting)
 955         +t      Use the build tools in $ONBLD_TOOLS/bin
 956         -u      update proto_list_$MACH and friends in the parent workspace;
 957                 when used with -f, also build an unrefmaster.out in the parent
 958         -w      report on differences between previous and current proto areas
 959         -z      compress cpio archives with gzip
 960         -W      Do not report warnings (freeware gate ONLY)
 961         -S      Build a variant of the source product
 962                 E - build exportable source
 963                 D - build domestic source (exportable + crypt)
 964                 H - build hybrid source (binaries + deleted source)
 965                 O - build (only) open source
 966 '
 967 #
 968 #       A log file will be generated under the name $LOGFILE
 969 #       for partially completed build and log.`date '+%F'`
 970 #       in the same directory for fully completed builds.
 971 #
 972 
 973 # default values for low-level FLAGS; G I R are group FLAGS
 974 A_FLAG=n
 975 C_FLAG=n
 976 D_FLAG=n
 977 F_FLAG=n
 978 f_FLAG=n
 979 i_FLAG=n; i_CMD_LINE_FLAG=n
 980 l_FLAG=n
 981 M_FLAG=n
 982 m_FLAG=n
 983 N_FLAG=n
 984 n_FLAG=n
 985 O_FLAG=n
 986 o_FLAG=n
 987 P_FLAG=n
 988 p_FLAG=n
 989 r_FLAG=n
 990 T_FLAG=n
 991 t_FLAG=y
 992 U_FLAG=n
 993 u_FLAG=n
 994 V_FLAG=n
 995 W_FLAG=n
 996 w_FLAG=n
 997 X_FLAG=n
 998 SD_FLAG=n
 999 SE_FLAG=n
1000 SH_FLAG=n
1001 SO_FLAG=n
1002 #
1003 XMOD_OPT=
1004 #
1005 build_ok=y
1006 
1007 function is_source_build {
1008         [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o \
1009             "$SH_FLAG" = "y" -o "$SO_FLAG" = "y" ]
1010         return $?
1011 }
1012 
1013 #
1014 # examine arguments
1015 #
1016 
1017 #
1018 # single function for setting -S flag and doing error checking.
1019 # usage: set_S_flag <type>
1020 # where <type> is the source build type ("E", "D", ...).
1021 #
1022 function set_S_flag {
1023         if is_source_build; then
1024                 echo "Can only build one source variant at a time."
1025                 exit 1
1026         fi
1027         if [ "$1" = "E" ]; then
1028                 SE_FLAG=y
1029         elif [ "$1" = "D" ]; then
1030                 SD_FLAG=y
1031         elif [ "$1" = "H" ]; then
1032                 SH_FLAG=y
1033         elif [ "$1" = "O" ]; then
1034                 SO_FLAG=y
1035         else
1036                 echo "$USAGE"
1037                 exit 1
1038         fi
1039 }
1040 
1041 OPTIND=1
1042 while getopts +inS:tV: FLAG
1043 do
1044         case $FLAG in
1045           i )   i_FLAG=y; i_CMD_LINE_FLAG=y
1046                 ;;
1047           n )   n_FLAG=y
1048                 ;;
1049           S )
1050                 set_S_flag $OPTARG
1051                 ;;
1052          +t )   t_FLAG=n
1053                 ;;
1054           V )   V_FLAG=y
1055                 V_ARG="$OPTARG"
1056                 ;;
1057          \? )   echo "$USAGE"
1058                 exit 1
1059                 ;;
1060         esac
1061 done
1062 
1063 # correct argument count after options
1064 shift `expr $OPTIND - 1`
1065 
1066 # test that the path to the environment-setting file was given
1067 if [ $# -ne 1 ]; then
1068         echo "$USAGE"
1069         exit 1
1070 fi
1071 


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
1234                 ;;
1235           M )   M_FLAG=y
1236                 ;;
1237           m )   m_FLAG=y
1238                 ;;
1239           N )   N_FLAG=y
1240                 ;;
1241           n )   n_FLAG=y
1242                 ;;
1243           O )   O_FLAG=y
1244                 ;;
1245           o )   o_FLAG=y
1246                 ;;
1247           P )   P_FLAG=y
1248                 ;; # obsolete
1249           p )   p_FLAG=y
1250                 ;;
1251           R )   m_FLAG=y
1252                 p_FLAG=y
1253                 ;;
1254           r )   r_FLAG=y
1255                 ;;
1256           S )
1257                 set_S_flag $OPTARG
1258                 ;;
1259           T )   T_FLAG=y
1260                 ;; # obsolete
1261          +t )   t_FLAG=n
1262                 ;;
1263           U )   if [ -z "${PARENT_ROOT}" ]; then
1264                         echo "PARENT_ROOT must be set if the U flag is" \
1265                             "present in NIGHTLY_OPTIONS."
1266                         exit 1
1267                 fi
1268                 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
1269                 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
1270                         NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
1271                 fi
1272                 U_FLAG=y
1273                 ;;
1274           u )   u_FLAG=y
1275                 ;;
1276           W )   W_FLAG=y
1277                 ;;
1278 


1430 #
1431 if [ "$X_FLAG" = "y" ]; then
1432         if [ "$IA32_IHV_ROOT" = "" ]; then
1433                 echo "IA32_IHV_ROOT: must be set for copying ihv proto"
1434                 args_ok=n
1435         fi
1436         if [ ! -d "$IA32_IHV_ROOT" ]; then
1437                 echo "$IA32_IHV_ROOT: not found"
1438                 args_ok=n
1439         fi
1440         if [ "$IA32_IHV_WS" = "" ]; then
1441                 echo "IA32_IHV_WS: must be set for copying ihv proto"
1442                 args_ok=n
1443         fi
1444         if [ ! -d "$IA32_IHV_WS" ]; then
1445                 echo "$IA32_IHV_WS: not found"
1446                 args_ok=n
1447         fi
1448 fi
1449 
1450 # Append source version
1451 if [ "$SE_FLAG" = "y" ]; then
1452         VERSION="${VERSION}:EXPORT"
1453 fi
1454 
1455 if [ "$SD_FLAG" = "y" ]; then
1456         VERSION="${VERSION}:DOMESTIC"
1457 fi
1458 
1459 if [ "$SH_FLAG" = "y" ]; then
1460         VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT"
1461 fi
1462 
1463 if [ "$SO_FLAG" = "y" ]; then
1464         VERSION="${VERSION}:OPEN_ONLY"
1465 fi
1466 
1467 TMPDIR="/tmp/nightly.tmpdir.$$"
1468 export TMPDIR
1469 rm -rf ${TMPDIR}
1470 mkdir -p $TMPDIR || exit 1
1471 chmod 777 $TMPDIR
1472 
1473 #
1474 # Keep elfsign's use of pkcs11_softtoken from looking in the user home
1475 # directory, which doesn't always work.   Needed until all build machines
1476 # have the fix for 6271754
1477 #
1478 SOFTTOKEN_DIR=$TMPDIR
1479 export SOFTTOKEN_DIR
1480 
1481 #
1482 # Tools should only be built non-DEBUG.  Keep track of the tools proto
1483 # area path relative to $TOOLS, because the latter changes in an
1484 # export build.
1485 #
1486 # TOOLS_PROTO is included below for builds other than usr/src/tools


1682                             "by $user as $pid."
1683                         exit 1
1684                 else
1685                         # stale lock; clear it out and try again
1686                         rm -f $lockf
1687                 fi
1688         done
1689 }
1690 
1691 #
1692 # Return the list of interesting proto areas, depending on the current
1693 # options.
1694 #
1695 function allprotos {
1696         typeset roots="$ROOT"
1697 
1698         if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1699                 roots="$roots $ROOT-nd"
1700         fi
1701 
1702         if [[ $O_FLAG = y ]]; then
1703                 roots="$roots $ROOT-closed"
1704                 [ $MULTI_PROTO = yes ] && roots="$roots $ROOT-nd-closed"
1705         fi
1706 
1707         echo $roots
1708 }
1709 
1710 # Ensure no other instance of this script is running on this host.
1711 # LOCKNAME can be set in <env_file>, and is by default, but is not
1712 # required due to the use of $ATLOG below.
1713 if [ -n "$LOCKNAME" ]; then
1714         create_lock /tmp/$LOCKNAME "lockfile"
1715 fi
1716 #
1717 # Create from one, two, or three other locks:
1718 #       $ATLOG/nightly.lock
1719 #               - protects against multiple builds in same workspace
1720 #       $PARENT_WS/usr/src/nightly.$MACH.lock
1721 #               - protects against multiple 'u' copy-backs
1722 #       $NIGHTLY_PARENT_ROOT/nightly.lock
1723 #               - protects against multiple 'U' copy-backs
1724 #
1725 # Overriding ISUSER to 1 causes the lock to be created as root if the
1726 # script is run as root.  The default is to create it as $STAFFER.


1766 # make sure we log only to the nightly build file
1767 build_noise_file="${TMPDIR}/build_noise"
1768 exec </dev/null >$build_noise_file 2>&1
1769 
1770 run_hook SYS_PRE_NIGHTLY
1771 run_hook PRE_NIGHTLY
1772 
1773 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1774 env >> $LOGFILE
1775 
1776 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1777 
1778 if [ "$P_FLAG" = "y" ]; then
1779         obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE
1780 fi
1781 
1782 if [ "$T_FLAG" = "y" ]; then
1783         obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE
1784 fi
1785 
1786 if is_source_build; then
1787         if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then
1788                 echo "WARNING: the -S flags do not support incremental" \
1789                     "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE
1790                 i_FLAG=n
1791                 i_CMD_LINE_FLAG=n
1792         fi
1793         if [ "$N_FLAG" = "n" ]; then
1794                 echo "WARNING: the -S flags do not support protocmp;" \
1795                     "protocmp disabled\n" | \
1796                     tee -a $mail_msg_file >> $LOGFILE
1797                 N_FLAG=y
1798         fi
1799         if [ "$l_FLAG" = "y" ]; then
1800                 echo "WARNING: the -S flags do not support lint;" \
1801                     "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE
1802                 l_FLAG=n
1803         fi
1804         if [ "$C_FLAG" = "y" ]; then
1805                 echo "WARNING: the -S flags do not support cstyle;" \
1806                     "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE
1807                 C_FLAG=n
1808         fi
1809 else
1810         if [ "$N_FLAG" = "y" ]; then
1811                 if [ "$p_FLAG" = "y" ]; then
1812                         cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1813 WARNING: the p option (create packages) is set, but so is the N option (do
1814          not run protocmp); this is dangerous; you should unset the N option
1815 EOF
1816                 else
1817                         cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1818 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1819 EOF
1820                 fi
1821                 echo "" | tee -a $mail_msg_file >> $LOGFILE
1822         fi
1823 fi
1824 
1825 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1826         #
1827         # In the past we just complained but went ahead with the lint
1828         # pass, even though the proto area was built non-DEBUG.  It's
1829         # unlikely that non-DEBUG headers will make a difference, but
1830         # rather than assuming it's a safe combination, force the user
1831         # to specify a DEBUG build.
1832         #
1833         echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1834             | tee -a $mail_msg_file >> $LOGFILE
1835         l_FLAG=n
1836 fi
1837 
1838 if [ "$f_FLAG" = "y" ]; then
1839         if [ "$i_FLAG" = "y" ]; then
1840                 echo "WARNING: the -f flag cannot be used during incremental" \
1841                     "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1842                 f_FLAG=n


1858         #
1859         # We're not doing a tools build, so make sure elfsign(1) is
1860         # new enough to safely sign non-crypto binaries.  We test
1861         # debugging output from elfsign to detect the old version.
1862         #
1863         newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \
1864             -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \
1865             | egrep algorithmOID`
1866         if [ -z "$newelfsigntest" ]; then
1867                 echo "WARNING: /usr/bin/elfsign out of date;" \
1868                     "will only sign crypto modules\n" | \
1869                     tee -a $mail_msg_file >> $LOGFILE
1870                 export ELFSIGN_OBJECT=true
1871         elif [ "$VERIFY_ELFSIGN" = "y" ]; then
1872                 echo "WARNING: VERIFY_ELFSIGN=y requires" \
1873                     "the -t flag; ignoring VERIFY_ELFSIGN\n" | \
1874                     tee -a $mail_msg_file >> $LOGFILE
1875         fi
1876 fi
1877 
1878 [ "$O_FLAG" = y ] && MULTI_PROTO=yes
1879 
1880 case $MULTI_PROTO in
1881 yes|no) ;;
1882 *)
1883         echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1884             "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1885         echo "Setting MULTI_PROTO to \"no\".\n" | \
1886             tee -a $mail_msg_file >> $LOGFILE
1887         export MULTI_PROTO=no
1888         ;;
1889 esac
1890 
1891 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1892 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1893 
1894 # Save the current proto area if we're comparing against the last build
1895 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1896     if [ -d "$ROOT.prev" ]; then
1897         rm -rf $ROOT.prev
1898     fi
1899     mv $ROOT $ROOT.prev


1975 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1976         echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1977 
1978         cd $SRC
1979         # remove old clobber file
1980         rm -f $SRC/clobber.out
1981         rm -f $SRC/clobber-${MACH}.out
1982 
1983         # Remove all .make.state* files, just in case we are restarting
1984         # the build after having interrupted a previous 'make clobber'.
1985         find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1986                 -o -name 'interfaces.*' \) -prune \
1987                 -o -name '.make.*' -print | xargs rm -f
1988 
1989         $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1990         echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1991         grep "$MAKE:" $SRC/clobber-${MACH}.out |
1992                 egrep -v "Ignoring unknown host" \
1993                 >> $mail_msg_file
1994 
1995         if [[ "$t_FLAG" = "y" || "$O_FLAG" = "y" ]]; then
1996                 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1997                 cd ${TOOLS}
1998                 rm -f ${TOOLS}/clobber-${MACH}.out
1999                 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
2000                         tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
2001                 echo "\n==== Make tools clobber ERRORS ====\n" \
2002                         >> $mail_msg_file
2003                 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
2004                         >> $mail_msg_file
2005                 rm -rf ${TOOLS_PROTO}
2006                 mkdir -p ${TOOLS_PROTO}
2007         fi
2008 
2009         typeset roots=$(allprotos)
2010         echo "\n\nClearing $roots" >> "$LOGFILE"
2011         rm -rf $roots
2012 
2013         # Get back to a clean workspace as much as possible to catch
2014         # problems that only occur on fresh workspaces.
2015         # Remove all .make.state* files, libraries, and .o's that may


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
2283 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
2284 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
2285     tee -a $build_environ_file >> $LOGFILE
2286 
2287 #
2288 # Report the compiler versions.


2323 # as
2324 whence as | tee -a $build_environ_file >> $LOGFILE
2325 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
2326 echo | tee -a $build_environ_file >> $LOGFILE
2327 
2328 # Check that we're running a capable link-editor
2329 whence ld | tee -a $build_environ_file >> $LOGFILE
2330 LDVER=`ld -V 2>&1`
2331 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
2332 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
2333 if [ `expr $LDVER \< 422` -eq 1 ]; then
2334         echo "The link-editor needs to be at version 422 or higher to build" | \
2335             tee -a $build_environ_file >> $LOGFILE
2336         echo "the latest stuff.  Hope your build works." | \
2337             tee -a $build_environ_file >> $LOGFILE
2338 fi
2339 
2340 #
2341 # Build and use the workspace's tools if requested
2342 #
2343 if [[ "$t_FLAG" = "y" || "$O_FLAG" = y ]]; then
2344         set_non_debug_build_flags
2345 
2346         build_tools ${TOOLS_PROTO}
2347         if [[ $? != 0  && "$t_FLAG" = y ]]; then
2348                 use_tools $TOOLS_PROTO
2349         fi
2350 fi
2351 
2352 #
2353 # copy ihv proto area in addition to the build itself
2354 #
2355 if [ "$X_FLAG" = "y" ]; then
2356         copy_ihv_proto
2357 fi
2358 
2359 if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then
2360         echo "\n==== NOT Building base OS-Net source ====\n" | \
2361             tee -a $LOGFILE >> $mail_msg_file
2362 else
2363         # timestamp the start of the normal build; the findunref tool uses it.
2364         touch $SRC/.build.tstamp
2365 
2366         normal_build
2367 fi
2368 
2369 #
2370 # Generate the THIRDPARTYLICENSE files if needed.  This is done after
2371 # the build, so that dynamically-created license files are there.
2372 # It's done before findunref to help identify license files that need
2373 # to be added to tools/opensolaris/license-list.
2374 #
2375 if [ "$O_FLAG" = y -a "$build_ok" = y ]; then
2376         echo "\n==== Generating THIRDPARTYLICENSE files ====\n" |
2377             tee -a "$mail_msg_file" >> "$LOGFILE"
2378 
2379         if [ -d $ROOT/licenses/usr ]; then
2380                 ( cd $ROOT/licenses ; \
2381                     mktpl $SRC/pkg/license-list ) >> "$LOGFILE" 2>&1
2382                 if (( $? != 0 )) ; then
2383                         echo "Couldn't create THIRDPARTYLICENSE files" |
2384                             tee -a "$mail_msg_file" >> "$LOGFILE"
2385                 fi
2386         else
2387                 echo "No licenses found under $ROOT/licenses" |
2388                     tee -a "$mail_msg_file" >> "$LOGFILE"
2389         fi
2390 fi
2391 
2392 ORIG_SRC=$SRC
2393 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
2394 
2395 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
2396         save_binaries
2397 fi
2398 
2399 
2400 # EXPORT_SRC comes after CRYPT_SRC since a domestic build will need
2401 # $SRC pointing to the export_source usr/src.
2402 
2403 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
2404         if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
2405             set_up_source_build ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC
2406         fi
2407 
2408         if [ $build_ok = y ]; then
2409             set_up_source_build ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC
2410         fi
2411 fi
2412 
2413 if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
2414         # drop the crypt files in place.
2415         cd ${EXPORT_SRC}
2416         echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \
2417             >> ${LOGFILE}
2418         zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \
2419             cpio -idmucvB 2>/dev/null >> ${LOGFILE}
2420         if [ "$?" = "0" ]; then
2421                 echo "\n==== DOMESTIC extraction succeeded ====\n" \
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 
2462         normal_build
2463 fi
2464 
2465 #
2466 # There are several checks that need to look at the proto area, but
2467 # they only need to look at one, and they don't care whether it's
2468 # DEBUG or non-DEBUG.
2469 #
2470 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
2471         checkroot=$ROOT-nd
2472 else
2473         checkroot=$ROOT
2474 fi
2475 
2476 if [ "$build_ok" = "y" ]; then
2477         echo "\n==== Creating protolist system file at `date` ====" \
2478                 >> $LOGFILE
2479         protolist $checkroot > $ATLOG/proto_list_${MACH}
2480         echo "==== protolist system file created at `date` ====\n" \
2481                 >> $LOGFILE
2482 
2483         if [ "$N_FLAG" != "y" ]; then


2819         if [ -f $SRC/unref-${MACH}.out ]; then
2820                 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2821         fi
2822 
2823         findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2824             ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2825             sort > $SRC/unref-${MACH}.out
2826 
2827         if [ ! -f $SRC/unref-${MACH}.ref ]; then
2828                 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2829         fi
2830 
2831         diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2832 fi
2833 
2834 #
2835 # Generate the OpenSolaris deliverables if requested.  Some of these
2836 # steps need to come after findunref and are commented below.
2837 #
2838 
2839 # If we are doing an OpenSolaris _source_ build (-S O) then we do
2840 # not have usr/closed available to us to generate closedbins from,
2841 # so skip this part.
2842 if [ "$SO_FLAG" = n -a "$O_FLAG" = y -a "$build_ok" = y ]; then
2843         echo "\n==== Generating OpenSolaris tarballs ====\n" | \
2844             tee -a $mail_msg_file >> $LOGFILE
2845 
2846         cd $CODEMGR_WS
2847 
2848         #
2849         # This step grovels through the package manifests, so it
2850         # must come after findunref.
2851         #
2852         # We assume no DEBUG vs non-DEBUG package content variation
2853         # here; if that changes, then the "make all" in $SRC/pkg will
2854         # need to be moved into the conditionals and repeated for each
2855         # different build.
2856         #
2857         echo "Generating closed binaries tarball(s)..." >> $LOGFILE
2858         closed_basename=on-closed-bins
2859         if [ "$D_FLAG" = y ]; then
2860                 bindrop "$closed_basename" >>"$LOGFILE" 2>&1
2861                 if (( $? != 0 )) ; then
2862                         echo "Couldn't create DEBUG closed binaries." |
2863                             tee -a $mail_msg_file >> $LOGFILE
2864                         build_ok=n
2865                 fi
2866         fi
2867         if [ "$F_FLAG" = n ]; then
2868                 bindrop -n "$closed_basename-nd" >>"$LOGFILE" 2>&1
2869                 if (( $? != 0 )) ; then
2870                         echo "Couldn't create non-DEBUG closed binaries." |
2871                             tee -a $mail_msg_file >> $LOGFILE
2872                         build_ok=n
2873                 fi
2874         fi
2875 
2876         echo "Generating README.opensolaris..." >> $LOGFILE
2877         cat $SRC/tools/opensolaris/README.opensolaris.tmpl | \
2878             mkreadme_osol $CODEMGR_WS/README.opensolaris >> $LOGFILE 2>&1
2879         if (( $? != 0 )) ; then
2880                 echo "Couldn't create README.opensolaris." |
2881                     tee -a $mail_msg_file >> $LOGFILE
2882                 build_ok=n
2883         fi
2884 fi
2885 
2886 # Verify that the usual lists of files, such as exception lists,
2887 # contain only valid references to files.  If the build has failed,
2888 # then don't check the proto area.
2889 CHECK_PATHS=${CHECK_PATHS:-y}
2890 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2891         echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2892                 >>$mail_msg_file
2893         arg=-b
2894         [ "$build_ok" = y ] && arg=
2895         checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file
2896 fi
2897 
2898 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2899         echo "\n==== Impact on file permissions ====\n" \
2900                 >> $mail_msg_file
2901 
2902         abspkgdefs=
2903         abspkg=
2904         for d in $abssrcdirs; do
2905                 if [ -d "$d/pkgdefs" ]; then




 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 #
 253 function build {
 254         LABEL=$1
 255         SUFFIX=$2
 256         ND=$3
 257         MULTIPROTO=$4
 258         INSTALLOG=install${SUFFIX}-${MACH}
 259         NOISE=noise${SUFFIX}-${MACH}
 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


 767 
 768 function set_debug_build_flags {
 769         export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
 770         unset RELEASE_BUILD
 771         unset EXTRA_OPTIONS
 772         unset EXTRA_CFLAGS
 773 }
 774 
 775 
 776 MACH=`uname -p`
 777 
 778 if [ "$OPTHOME" = "" ]; then
 779         OPTHOME=/opt
 780         export OPTHOME
 781 fi
 782 if [ "$TEAMWARE" = "" ]; then
 783         TEAMWARE=$OPTHOME/teamware
 784         export TEAMWARE
 785 fi
 786 
 787 USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
 788 
 789 Where:
 790         -i      Fast incremental options (no clobber, lint, check)
 791         -n      Do not do a bringover
 792         +t      Use the build tools in $ONBLD_TOOLS/bin
 793         -V VERS set the build version string to VERS





 794 
 795         <env_file>  file in Bourne shell syntax that sets and exports
 796         variables that configure the operation of this script and many of
 797         the scripts this one calls. If <env_file> does not exist,
 798         it will be looked for in $OPTHOME/onbld/env.
 799 
 800 non-DEBUG is the default build type. Build options can be set in the
 801 NIGHTLY_OPTIONS variable in the <env_file> as follows:
 802 
 803         -A      check for ABI differences in .so files
 804         -C      check for cstyle/hdrchk errors
 805         -D      do a build with DEBUG on
 806         -F      do _not_ do a non-DEBUG build
 807         -G      gate keeper default group of options (-au)
 808         -I      integration engineer default group of options (-ampu)
 809         -M      do not run pmodes (safe file permission checker)
 810         -N      do not run protocmp

 811         -R      default group of options for building a release (-mp)
 812         -U      update proto area in the parent
 813         -V VERS set the build version string to VERS
 814         -X      copy x86 IHV proto area
 815         -f      find unreferenced files
 816         -i      do an incremental build (no "make clobber")
 817         -l      do "make lint" in $LINTDIRS (default: $SRC y)
 818         -m      send mail to $MAILTO at end of build
 819         -n      do not do a bringover
 820         -o      build using root privileges to set OWNER/GROUP (old style)
 821         -p      create packages
 822         -r      check ELF runtime attributes in the proto area
 823         -t      build and use the tools in $SRC/tools (default setting)
 824         +t      Use the build tools in $ONBLD_TOOLS/bin
 825         -u      update proto_list_$MACH and friends in the parent workspace;
 826                 when used with -f, also build an unrefmaster.out in the parent
 827         -w      report on differences between previous and current proto areas
 828         -z      compress cpio archives with gzip
 829         -W      Do not report warnings (freeware gate ONLY)





 830 '
 831 #
 832 #       A log file will be generated under the name $LOGFILE
 833 #       for partially completed build and log.`date '+%F'`
 834 #       in the same directory for fully completed builds.
 835 #
 836 
 837 # default values for low-level FLAGS; G I R are group FLAGS
 838 A_FLAG=n
 839 C_FLAG=n
 840 D_FLAG=n
 841 F_FLAG=n
 842 f_FLAG=n
 843 i_FLAG=n; i_CMD_LINE_FLAG=n
 844 l_FLAG=n
 845 M_FLAG=n
 846 m_FLAG=n
 847 N_FLAG=n
 848 n_FLAG=n

 849 o_FLAG=n
 850 P_FLAG=n
 851 p_FLAG=n
 852 r_FLAG=n
 853 T_FLAG=n
 854 t_FLAG=y
 855 U_FLAG=n
 856 u_FLAG=n
 857 V_FLAG=n
 858 W_FLAG=n
 859 w_FLAG=n
 860 X_FLAG=n




 861 #
 862 XMOD_OPT=
 863 #
 864 build_ok=y
 865 






 866 #
 867 # examine arguments
 868 #
 869 
























 870 OPTIND=1
 871 while getopts +intV: FLAG
 872 do
 873         case $FLAG in
 874           i )   i_FLAG=y; i_CMD_LINE_FLAG=y
 875                 ;;
 876           n )   n_FLAG=y
 877                 ;;



 878          +t )   t_FLAG=n
 879                 ;;
 880           V )   V_FLAG=y
 881                 V_ARG="$OPTARG"
 882                 ;;
 883          \? )   echo "$USAGE"
 884                 exit 1
 885                 ;;
 886         esac
 887 done
 888 
 889 # correct argument count after options
 890 shift `expr $OPTIND - 1`
 891 
 892 # test that the path to the environment-setting file was given
 893 if [ $# -ne 1 ]; then
 894         echo "$USAGE"
 895         exit 1
 896 fi
 897 


1016 #
1017 if [ "$CLOSED_BRINGOVER_WS" = "" ]; then
1018         CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS
1019 fi
1020 
1021 #
1022 # If BRINGOVER_FILES was not specified, default to usr
1023 #
1024 if [ "$BRINGOVER_FILES" = "" ]; then
1025         BRINGOVER_FILES="usr"
1026 fi
1027 
1028 check_closed_tree
1029 
1030 #
1031 # Note: changes to the option letters here should also be applied to the
1032 #       bldenv script.  `d' is listed for backward compatibility.
1033 #
1034 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
1035 OPTIND=1
1036 while getopts +ABCDdFfGIilMmNnoPpRrTtUuWwXxz FLAG $NIGHTLY_OPTIONS
1037 do
1038         case $FLAG in
1039           A )   A_FLAG=y
1040                 ;;
1041           B )   D_FLAG=y
1042                 ;; # old version of D
1043           C )   C_FLAG=y
1044                 ;;
1045           D )   D_FLAG=y
1046                 ;;
1047           F )   F_FLAG=y
1048                 ;;
1049           f )   f_FLAG=y
1050                 ;;
1051           G )   u_FLAG=y
1052                 ;;
1053           I )   m_FLAG=y
1054                 p_FLAG=y
1055                 u_FLAG=y
1056                 ;;
1057           i )   i_FLAG=y
1058                 ;;
1059           l )   l_FLAG=y
1060                 ;;
1061           M )   M_FLAG=y
1062                 ;;
1063           m )   m_FLAG=y
1064                 ;;
1065           N )   N_FLAG=y
1066                 ;;
1067           n )   n_FLAG=y
1068                 ;;


1069           o )   o_FLAG=y
1070                 ;;
1071           P )   P_FLAG=y
1072                 ;; # obsolete
1073           p )   p_FLAG=y
1074                 ;;
1075           R )   m_FLAG=y
1076                 p_FLAG=y
1077                 ;;
1078           r )   r_FLAG=y
1079                 ;;



1080           T )   T_FLAG=y
1081                 ;; # obsolete
1082          +t )   t_FLAG=n
1083                 ;;
1084           U )   if [ -z "${PARENT_ROOT}" ]; then
1085                         echo "PARENT_ROOT must be set if the U flag is" \
1086                             "present in NIGHTLY_OPTIONS."
1087                         exit 1
1088                 fi
1089                 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
1090                 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
1091                         NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
1092                 fi
1093                 U_FLAG=y
1094                 ;;
1095           u )   u_FLAG=y
1096                 ;;
1097           W )   W_FLAG=y
1098                 ;;
1099 


1251 #
1252 if [ "$X_FLAG" = "y" ]; then
1253         if [ "$IA32_IHV_ROOT" = "" ]; then
1254                 echo "IA32_IHV_ROOT: must be set for copying ihv proto"
1255                 args_ok=n
1256         fi
1257         if [ ! -d "$IA32_IHV_ROOT" ]; then
1258                 echo "$IA32_IHV_ROOT: not found"
1259                 args_ok=n
1260         fi
1261         if [ "$IA32_IHV_WS" = "" ]; then
1262                 echo "IA32_IHV_WS: must be set for copying ihv proto"
1263                 args_ok=n
1264         fi
1265         if [ ! -d "$IA32_IHV_WS" ]; then
1266                 echo "$IA32_IHV_WS: not found"
1267                 args_ok=n
1268         fi
1269 fi
1270 

















1271 TMPDIR="/tmp/nightly.tmpdir.$$"
1272 export TMPDIR
1273 rm -rf ${TMPDIR}
1274 mkdir -p $TMPDIR || exit 1
1275 chmod 777 $TMPDIR
1276 
1277 #
1278 # Keep elfsign's use of pkcs11_softtoken from looking in the user home
1279 # directory, which doesn't always work.   Needed until all build machines
1280 # have the fix for 6271754
1281 #
1282 SOFTTOKEN_DIR=$TMPDIR
1283 export SOFTTOKEN_DIR
1284 
1285 #
1286 # Tools should only be built non-DEBUG.  Keep track of the tools proto
1287 # area path relative to $TOOLS, because the latter changes in an
1288 # export build.
1289 #
1290 # TOOLS_PROTO is included below for builds other than usr/src/tools


1486                             "by $user as $pid."
1487                         exit 1
1488                 else
1489                         # stale lock; clear it out and try again
1490                         rm -f $lockf
1491                 fi
1492         done
1493 }
1494 
1495 #
1496 # Return the list of interesting proto areas, depending on the current
1497 # options.
1498 #
1499 function allprotos {
1500         typeset roots="$ROOT"
1501 
1502         if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1503                 roots="$roots $ROOT-nd"
1504         fi
1505 





1506         echo $roots
1507 }
1508 
1509 # Ensure no other instance of this script is running on this host.
1510 # LOCKNAME can be set in <env_file>, and is by default, but is not
1511 # required due to the use of $ATLOG below.
1512 if [ -n "$LOCKNAME" ]; then
1513         create_lock /tmp/$LOCKNAME "lockfile"
1514 fi
1515 #
1516 # Create from one, two, or three other locks:
1517 #       $ATLOG/nightly.lock
1518 #               - protects against multiple builds in same workspace
1519 #       $PARENT_WS/usr/src/nightly.$MACH.lock
1520 #               - protects against multiple 'u' copy-backs
1521 #       $NIGHTLY_PARENT_ROOT/nightly.lock
1522 #               - protects against multiple 'U' copy-backs
1523 #
1524 # Overriding ISUSER to 1 causes the lock to be created as root if the
1525 # script is run as root.  The default is to create it as $STAFFER.


1565 # make sure we log only to the nightly build file
1566 build_noise_file="${TMPDIR}/build_noise"
1567 exec </dev/null >$build_noise_file 2>&1
1568 
1569 run_hook SYS_PRE_NIGHTLY
1570 run_hook PRE_NIGHTLY
1571 
1572 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1573 env >> $LOGFILE
1574 
1575 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1576 
1577 if [ "$P_FLAG" = "y" ]; then
1578         obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE
1579 fi
1580 
1581 if [ "$T_FLAG" = "y" ]; then
1582         obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE
1583 fi
1584 
1585 if [ "$N_FLAG" = "y" ]; then
























1586         if [ "$p_FLAG" = "y" ]; then
1587                 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1588 WARNING: the p option (create packages) is set, but so is the N option (do
1589          not run protocmp); this is dangerous; you should unset the N option
1590 EOF
1591         else
1592                 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1593 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1594 EOF
1595         fi
1596         echo "" | tee -a $mail_msg_file >> $LOGFILE

1597 fi
1598 
1599 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1600         #
1601         # In the past we just complained but went ahead with the lint
1602         # pass, even though the proto area was built non-DEBUG.  It's
1603         # unlikely that non-DEBUG headers will make a difference, but
1604         # rather than assuming it's a safe combination, force the user
1605         # to specify a DEBUG build.
1606         #
1607         echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1608             | tee -a $mail_msg_file >> $LOGFILE
1609         l_FLAG=n
1610 fi
1611 
1612 if [ "$f_FLAG" = "y" ]; then
1613         if [ "$i_FLAG" = "y" ]; then
1614                 echo "WARNING: the -f flag cannot be used during incremental" \
1615                     "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1616                 f_FLAG=n


1632         #
1633         # We're not doing a tools build, so make sure elfsign(1) is
1634         # new enough to safely sign non-crypto binaries.  We test
1635         # debugging output from elfsign to detect the old version.
1636         #
1637         newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \
1638             -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \
1639             | egrep algorithmOID`
1640         if [ -z "$newelfsigntest" ]; then
1641                 echo "WARNING: /usr/bin/elfsign out of date;" \
1642                     "will only sign crypto modules\n" | \
1643                     tee -a $mail_msg_file >> $LOGFILE
1644                 export ELFSIGN_OBJECT=true
1645         elif [ "$VERIFY_ELFSIGN" = "y" ]; then
1646                 echo "WARNING: VERIFY_ELFSIGN=y requires" \
1647                     "the -t flag; ignoring VERIFY_ELFSIGN\n" | \
1648                     tee -a $mail_msg_file >> $LOGFILE
1649         fi
1650 fi
1651 


1652 case $MULTI_PROTO in
1653 yes|no) ;;
1654 *)
1655         echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1656             "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1657         echo "Setting MULTI_PROTO to \"no\".\n" | \
1658             tee -a $mail_msg_file >> $LOGFILE
1659         export MULTI_PROTO=no
1660         ;;
1661 esac
1662 
1663 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1664 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1665 
1666 # Save the current proto area if we're comparing against the last build
1667 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1668     if [ -d "$ROOT.prev" ]; then
1669         rm -rf $ROOT.prev
1670     fi
1671     mv $ROOT $ROOT.prev


1747 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1748         echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1749 
1750         cd $SRC
1751         # remove old clobber file
1752         rm -f $SRC/clobber.out
1753         rm -f $SRC/clobber-${MACH}.out
1754 
1755         # Remove all .make.state* files, just in case we are restarting
1756         # the build after having interrupted a previous 'make clobber'.
1757         find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1758                 -o -name 'interfaces.*' \) -prune \
1759                 -o -name '.make.*' -print | xargs rm -f
1760 
1761         $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1762         echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1763         grep "$MAKE:" $SRC/clobber-${MACH}.out |
1764                 egrep -v "Ignoring unknown host" \
1765                 >> $mail_msg_file
1766 
1767         if [[ "$t_FLAG" = "y" ]]; then
1768                 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1769                 cd ${TOOLS}
1770                 rm -f ${TOOLS}/clobber-${MACH}.out
1771                 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1772                         tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1773                 echo "\n==== Make tools clobber ERRORS ====\n" \
1774                         >> $mail_msg_file
1775                 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1776                         >> $mail_msg_file
1777                 rm -rf ${TOOLS_PROTO}
1778                 mkdir -p ${TOOLS_PROTO}
1779         fi
1780 
1781         typeset roots=$(allprotos)
1782         echo "\n\nClearing $roots" >> "$LOGFILE"
1783         rm -rf $roots
1784 
1785         # Get back to a clean workspace as much as possible to catch
1786         # problems that only occur on fresh workspaces.
1787         # Remove all .make.state* files, libraries, and .o's that may


2014                 echo "trouble with bringover, quitting at `date`." |
2015                         tee -a $mail_msg_file >> $LOGFILE
2016                 exit 1
2017         fi
2018 
2019         #
2020         # It's possible that we used the bringover above to create
2021         # $CODEMGR_WS.  If so, then SCM_TYPE was previously "none,"
2022         # but should now be the same as $BRINGOVER_WS.
2023         #
2024         [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
2025 
2026         run_hook POST_BRINGOVER
2027 
2028         check_closed_tree
2029 
2030 else
2031         echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
2032 fi
2033 







2034 # Safeguards
2035 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
2036 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
2037 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
2038 
2039 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
2040 
2041 # System
2042 whence uname | tee -a $build_environ_file >> $LOGFILE
2043 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
2044 echo | tee -a $build_environ_file >> $LOGFILE
2045 
2046 # make
2047 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
2048 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
2049 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
2050     tee -a $build_environ_file >> $LOGFILE
2051 
2052 #
2053 # Report the compiler versions.


2088 # as
2089 whence as | tee -a $build_environ_file >> $LOGFILE
2090 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
2091 echo | tee -a $build_environ_file >> $LOGFILE
2092 
2093 # Check that we're running a capable link-editor
2094 whence ld | tee -a $build_environ_file >> $LOGFILE
2095 LDVER=`ld -V 2>&1`
2096 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
2097 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
2098 if [ `expr $LDVER \< 422` -eq 1 ]; then
2099         echo "The link-editor needs to be at version 422 or higher to build" | \
2100             tee -a $build_environ_file >> $LOGFILE
2101         echo "the latest stuff.  Hope your build works." | \
2102             tee -a $build_environ_file >> $LOGFILE
2103 fi
2104 
2105 #
2106 # Build and use the workspace's tools if requested
2107 #
2108 if [[ "$t_FLAG" = "y" ]]; then
2109         set_non_debug_build_flags
2110 
2111         build_tools ${TOOLS_PROTO}
2112         if [[ $? != 0  && "$t_FLAG" = y ]]; then
2113                 use_tools $TOOLS_PROTO
2114         fi
2115 fi
2116 
2117 #
2118 # copy ihv proto area in addition to the build itself
2119 #
2120 if [ "$X_FLAG" = "y" ]; then
2121         copy_ihv_proto
2122 fi
2123 
2124 # timestamp the start of the normal build; the findunref tool uses it.
2125 touch $SRC/.build.tstamp

















2126 
2127 normal_build











2128 
2129 ORIG_SRC=$SRC
2130 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
2131 





































































2132 
2133 #
2134 # There are several checks that need to look at the proto area, but
2135 # they only need to look at one, and they don't care whether it's
2136 # DEBUG or non-DEBUG.
2137 #
2138 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
2139         checkroot=$ROOT-nd
2140 else
2141         checkroot=$ROOT
2142 fi
2143 
2144 if [ "$build_ok" = "y" ]; then
2145         echo "\n==== Creating protolist system file at `date` ====" \
2146                 >> $LOGFILE
2147         protolist $checkroot > $ATLOG/proto_list_${MACH}
2148         echo "==== protolist system file created at `date` ====\n" \
2149                 >> $LOGFILE
2150 
2151         if [ "$N_FLAG" != "y" ]; then


2487         if [ -f $SRC/unref-${MACH}.out ]; then
2488                 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2489         fi
2490 
2491         findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2492             ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2493             sort > $SRC/unref-${MACH}.out
2494 
2495         if [ ! -f $SRC/unref-${MACH}.ref ]; then
2496                 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2497         fi
2498 
2499         diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2500 fi
2501 
2502 #
2503 # Generate the OpenSolaris deliverables if requested.  Some of these
2504 # steps need to come after findunref and are commented below.
2505 #
2506 















































2507 # Verify that the usual lists of files, such as exception lists,
2508 # contain only valid references to files.  If the build has failed,
2509 # then don't check the proto area.
2510 CHECK_PATHS=${CHECK_PATHS:-y}
2511 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2512         echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2513                 >>$mail_msg_file
2514         arg=-b
2515         [ "$build_ok" = y ] && arg=
2516         checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file
2517 fi
2518 
2519 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2520         echo "\n==== Impact on file permissions ====\n" \
2521                 >> $mail_msg_file
2522 
2523         abspkgdefs=
2524         abspkg=
2525         for d in $abssrcdirs; do
2526                 if [ -d "$d/pkgdefs" ]; then