Print this page
4522 the build doesn't fail nearly often enough
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Jens Elkner <jel+illumos@cs.uni-magdeburg.de>


 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' \


 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 so
 341                         # no pkg directory.
 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"


 378         #
 379         echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
 380 
 381         # remove old lint.out
 382         rm -f $lintdir/lint.out $lintdir/lint-noise.out
 383         if [ -f $lintdir/lint-noise.ref ]; then
 384                 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref
 385         fi
 386 
 387         rm -f $LINTOUT
 388         cd $lintdir
 389         #
 390         # Remove all .ln files to ensure a full reference file
 391         #
 392         rm -f Nothing_to_remove \
 393             `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
 394                 -prune -o -type f -name '*.ln' -print `
 395 
 396         /bin/time $MAKE -ek lint 2>&1 | \
 397             tee -a $LINTOUT >> $LOGFILE

 398         echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file

 399         grep "$MAKE:" $LINTOUT |
 400                 egrep -v "Ignoring unknown host" \
 401                 >> $mail_msg_file



 402 
 403         echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
 404 
 405         echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
 406                 >>$mail_msg_file
 407         tail -3  $LINTOUT >>$mail_msg_file
 408 
 409         rm -f ${LINTNOISE}.ref
 410         if [ -f ${LINTNOISE}.out ]; then
 411                 mv ${LINTNOISE}.out ${LINTNOISE}.ref
 412         fi
 413         grep : $LINTOUT | \
 414                 egrep -v '^(real|user|sys)' |
 415                 egrep -v '(library construction)' | \
 416                 egrep -v ': global crosschecks' | \
 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 
 457         echo "\n==== Tools build errors ====\n" >> $mail_msg_file
 458 
 459         egrep ":" ${TOOLS}/${INSTALLOG}.out |
 460                 egrep -e "(${MAKE}:|[   ]error[:        \n])" | \
 461                 egrep -v "Ignoring unknown host" | \
 462                 egrep -v warning >> $mail_msg_file
 463         return $?




 464 }
 465 
 466 #
 467 # Set up to use locally installed tools.
 468 #
 469 # usage: use_tools TOOLSROOT
 470 #
 471 function use_tools {
 472         TOOLSROOT=$1
 473 
 474         #
 475         # If we're not building ON workspace, then the TOOLSROOT
 476         # settings here are clearly ignored by the workspace
 477         # makefiles, prepending nonexistent directories to PATH is
 478         # harmless, and we clearly do not wish to override
 479         # ONBLD_TOOLS.
 480         #
 481         # If we're building an ON workspace, then the prepended PATH
 482         # elements should supercede the preexisting ONBLD_TOOLS paths,
 483         # and we want to override ONBLD_TOOLS to catch the tools that


 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                 ;;
 691          \? )   echo "$USAGE"
 692                 exit 1


1133         if [ -s $build_noise_file ]; then
1134                 echo "\n==== Nightly build noise ====\n" |
1135                     tee -a $LOGFILE >>$mail_msg_file
1136                 cat $build_noise_file >>$LOGFILE
1137                 cat $build_noise_file >>$mail_msg_file
1138                 echo | tee -a $LOGFILE >>$mail_msg_file
1139         fi
1140         rm -f $build_noise_file
1141 
1142         case "$build_ok" in
1143                 y)
1144                         state=Completed
1145                         ;;
1146                 i)
1147                         state=Interrupted
1148                         ;;
1149                 *)
1150                         state=Failed
1151                         ;;
1152         esac





1153         NIGHTLY_STATUS=$state
1154         export NIGHTLY_STATUS
1155 
1156         run_hook POST_NIGHTLY $state
1157         run_hook SYS_POST_NIGHTLY $state
1158 
1159         #
1160         # mailx(1) sets From: based on the -r flag
1161         # if it is given.
1162         #
1163         mailx_r=
1164         if [[ -n "${MAILFROM}" ]]; then
1165                 mailx_r="-r ${MAILFROM}"
1166         fi
1167 
1168         cat $build_time_file $build_environ_file $mail_msg_file \
1169             > ${LLOG}/mail_msg
1170         if [ "$m_FLAG" = "y" ]; then
1171                 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1172         "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \


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
1488 
1489         # Remove all .make.state* files, just in case we are restarting
1490         # the build after having interrupted a previous 'make clobber'.
1491         find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1492                 -o -name 'interfaces.*' \) -prune \
1493                 -o -name '.make.*' -print | xargs rm -f
1494 
1495         $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1496         echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1497         grep "$MAKE:" $SRC/clobber-${MACH}.out |
1498                 egrep -v "Ignoring unknown host" \
1499                 >> $mail_msg_file




1500 
1501         if [[ "$t_FLAG" = "y" ]]; then
1502                 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1503                 cd ${TOOLS}
1504                 rm -f ${TOOLS}/clobber-${MACH}.out
1505                 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1506                         tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1507                 echo "\n==== Make tools clobber ERRORS ====\n" \
1508                         >> $mail_msg_file
1509                 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1510                         >> $mail_msg_file



1511                 rm -rf ${TOOLS_PROTO}
1512                 mkdir -p ${TOOLS_PROTO}
1513         fi
1514 
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


1761 
1762 # Check that we're running a capable link-editor
1763 whence ld | tee -a $build_environ_file >> $LOGFILE
1764 LDVER=`ld -V 2>&1`
1765 echo $LDVER | 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


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
1878                 ( cd $ROOT; tar cf - . |
1879                     ( cd $NIGHTLY_PARENT_ROOT;  umask 0; tar xpf - ) ) 2>&1 |
1880                     tee -a $mail_msg_file >> $LOGFILE
1881         fi
1882         if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then


1887                     ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
1888                     tee -a $mail_msg_file >> $LOGFILE
1889         fi
1890         if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1891                 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1892                     tee -a $LOGFILE >> $mail_msg_file
1893                 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1894                 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
1895                 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1896                         ( cd $TOOLS_PROTO; tar cf - . |
1897                             ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 
1898                             umask 0; tar xpf - ) ) 2>&1 |
1899                             tee -a $mail_msg_file >> $LOGFILE
1900                 fi
1901         fi
1902 fi
1903 
1904 #
1905 # ELF verification: ABI (-A) and runtime (-r) checks
1906 #
1907 if [[ ($build_ok = y) && ( ($A_FLAG = y) || ($r_FLAG = y) ) ]]; then
1908         # Directory ELF-data.$MACH holds the files produced by these tests.
1909         elf_ddir=$SRC/ELF-data.$MACH
1910 
1911         # If there is a previous ELF-data backup directory, remove it. Then,
1912         # rotate current ELF-data directory into its place and create a new
1913         # empty directory
1914         rm -rf $elf_ddir.ref
1915         if [[ -d $elf_ddir ]]; then
1916                 mv $elf_ddir $elf_ddir.ref
1917         fi
1918         mkdir -p $elf_ddir
1919 
1920         # Call find_elf to produce a list of the ELF objects in the proto area.
1921         # This list is passed to check_rtime and interface_check, preventing
1922         # them from separately calling find_elf to do the same work twice.
1923         find_elf -fr $checkroot > $elf_ddir/object_list
1924 
1925         if [[ $A_FLAG = y ]]; then
1926                 echo "\n==== Check versioning and ABI information ====\n"  | \
1927                     tee -a $LOGFILE >> $mail_msg_file
1928 
1929                 # Produce interface description for the proto. Report errors.
1930                 interface_check -o -w $elf_ddir -f object_list \
1931                         -i interface -E interface.err
1932                 if [[ -s $elf_ddir/interface.err ]]; then
1933                         tee -a $LOGFILE < $elf_ddir/interface.err \
1934                                 >> $mail_msg_file

1935                 fi
1936 
1937                 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1938                 # description file to that from the baseline gate. Issue a
1939                 # warning if the baseline is not present, and keep going.
1940                 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1941                         base_ifile="$ELF_DATA_BASELINE_DIR/interface"
1942 
1943                         echo "\n==== Compare versioning and ABI information" \
1944                             "to baseline ====\n"  | \
1945                             tee -a $LOGFILE >> $mail_msg_file
1946                         echo "Baseline:  $base_ifile\n" >> $LOGFILE
1947 
1948                         if [[ -f $base_ifile ]]; then
1949                                 interface_cmp -d -o $base_ifile \
1950                                     $elf_ddir/interface > $elf_ddir/interface.cmp
1951                                 if [[ -s $elf_ddir/interface.cmp ]]; then
1952                                         echo | tee -a $LOGFILE >> $mail_msg_file
1953                                         tee -a $LOGFILE < \
1954                                             $elf_ddir/interface.cmp \
1955                                             >> $mail_msg_file

1956                                 fi
1957                         else
1958                                 echo "baseline not available. comparison" \
1959                                     "skipped" | \
1960                                     tee -a $LOGFILE >> $mail_msg_file
1961                         fi
1962 
1963                 fi
1964         fi
1965 
1966         if [[ $r_FLAG = y ]]; then
1967                 echo "\n==== Check ELF runtime attributes ====\n" | \
1968                     tee -a $LOGFILE >> $mail_msg_file
1969 
1970                 # If we're doing a DEBUG build the proto area will be left
1971                 # with debuggable objects, thus don't assert -s.
1972                 if [[ $D_FLAG = y ]]; then
1973                         rtime_sflag=""
1974                 else
1975                         rtime_sflag="-s"
1976                 fi
1977                 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
1978                         -D object_list  -f object_list -E runtime.err \
1979                         -I runtime.attr.raw



1980 
1981                 # check_rtime -I output needs to be sorted in order to 
1982                 # compare it to that from previous builds.
1983                 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
1984                 rm $elf_ddir/runtime.attr.raw
1985 
1986                 # Report errors
1987                 if [[ -s $elf_ddir/runtime.err ]]; then
1988                         tee -a $LOGFILE < $elf_ddir/runtime.err \
1989                                 >> $mail_msg_file

1990                 fi
1991 
1992                 # If there is an ELF-data directory from a previous build,
1993                 # then diff the attr files. These files contain information
1994                 # about dependencies, versioning, and runpaths. There is some
1995                 # overlap with the ABI checking done above, but this also
1996                 # flushes out non-ABI interface differences along with the
1997                 # other information.
1998                 echo "\n==== Diff ELF runtime attributes" \
1999                     "(since last build) ====\n" | \
2000                     tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
2001 
2002                 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
2003                         diff $elf_ddir.ref/runtime.attr \
2004                                 $elf_ddir/runtime.attr \
2005                                 >> $mail_msg_file
2006                 fi
2007         fi
2008 
2009         # If -u set, copy contents of ELF-data.$MACH to the parent workspace.


2043                 dolint $1 $2; shift; shift
2044         done
2045 else
2046         echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2047 fi
2048 
2049 # "make check" begins
2050 
2051 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2052         # remove old check.out
2053         rm -f $SRC/check.out
2054 
2055         rm -f $SRC/check-${MACH}.out
2056         cd $SRC
2057         $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
2058             >> $LOGFILE
2059         echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2060 
2061         grep ":" $SRC/check-${MACH}.out |
2062                 egrep -v "Ignoring unknown host" | \
2063                 sort | uniq >> $mail_msg_file




2064 else
2065         echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2066 fi
2067 
2068 echo "\n==== Find core files ====\n" | \
2069     tee -a $LOGFILE >> $mail_msg_file
2070 
2071 find $abssrcdirs -name core -a -type f -exec file {} \; | \
2072         tee -a $LOGFILE >> $mail_msg_file
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 


2165         # which was already on the parent.
2166         #
2167 
2168         set -- $PARENT_WS/usr/src/unref-*.out
2169         cp "$1" ${TMPDIR}/unref.merge
2170         shift
2171 
2172         for unreffile; do
2173                 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2174                 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2175         done
2176 
2177         staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2178 fi
2179 
2180 #
2181 # All done save for the sweeping up.
2182 # (whichever exit we hit here will trigger the "cleanup" trap which
2183 # optionally sends mail on completion).
2184 #
2185 if [ "$build_ok" = "y" ]; then
2186         exit 0
2187 fi
2188 exit 1


 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" | tee $TMPDIR/build_errs${SUFFIX} \
 203                 >> $mail_msg_file
 204         if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then
 205                 build_ok=n
 206                 this_build_ok=n
 207         fi
 208         grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
 209                 >> $mail_msg_file
 210         if [ "$?" = "0" ]; then
 211                 build_ok=n
 212                 this_build_ok=n
 213         fi
 214 
 215         echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
 216         egrep -i warning: $SRC/${INSTALLOG}.out \
 217                 | egrep -v '^tic:' \
 218                 | egrep -v "symbol (\`|')timezone' has differing types:" \
 219                 | egrep -v "parameter <PSTAMP> set to" \
 220                 | egrep -v "Ignoring unknown host" \
 221                 | egrep -v "redefining segment flags attribute for" \
 222                 | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file
 223         if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then
 224                 build_ok=n
 225                 this_build_ok=n
 226         fi
 227 
 228         echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
 229                 >> $LOGFILE
 230 
 231         echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
 232         tail -3  $SRC/${INSTALLOG}.out >>$mail_msg_file
 233 
 234         if [ "$i_FLAG" = "n" ]; then
 235                 rm -f $SRC/${NOISE}.ref
 236                 if [ -f $SRC/${NOISE}.out ]; then
 237                         mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
 238                 fi
 239                 grep : $SRC/${INSTALLOG}.out \
 240                         | egrep -v '^/' \
 241                         | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
 242                         | egrep -v '^tic:' \
 243                         | egrep -v '^mcs' \
 244                         | egrep -v '^LD_LIBRARY_PATH=' \
 245                         | egrep -v 'ar: creating' \
 246                         | egrep -v 'ar: writing' \


 321         #
 322         if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
 323                 if [ -d $SRC/pkg ]; then
 324                         echo "\n==== Creating $LABEL packages at `date` ====\n" \
 325                                 >> $LOGFILE
 326                         echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
 327                         rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
 328                         mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
 329 
 330                         rm -f $SRC/pkg/${INSTALLOG}.out
 331                         cd $SRC/pkg
 332                         /bin/time $MAKE -e install 2>&1 | \
 333                             tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE
 334 
 335                         echo "\n==== package build errors ($LABEL) ====\n" \
 336                                 >> $mail_msg_file
 337 
 338                         egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \
 339                                 grep ':' | \
 340                                 grep -v PSTAMP | \
 341                                 egrep -v "Ignoring unknown host" | \
 342                                 tee $TMPDIR/package >> $mail_msg_file
 343                         if [[ -s $TMPDIR/package ]]; then
 344                                 build_extras_ok=n
 345                                 this_build_ok=n
 346                         fi
 347                 else
 348                         #
 349                         # Handle it gracefully if -p was set but there so
 350                         # no pkg directory.
 351                         #
 352                         echo "\n==== No $LABEL packages to build ====\n" \
 353                                 >> $LOGFILE
 354                 fi
 355         else
 356                 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
 357         fi
 358 
 359         ROOT=$ORIGROOT
 360 }
 361 
 362 # Usage: dolint /dir y|n
 363 # Arg. 2 is a flag to turn on/off the lint diff output
 364 function dolint {
 365         if [ ! -d "$1" ]; then
 366                 echo "dolint error: $1 is not a directory"


 387         #
 388         echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
 389 
 390         # remove old lint.out
 391         rm -f $lintdir/lint.out $lintdir/lint-noise.out
 392         if [ -f $lintdir/lint-noise.ref ]; then
 393                 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref
 394         fi
 395 
 396         rm -f $LINTOUT
 397         cd $lintdir
 398         #
 399         # Remove all .ln files to ensure a full reference file
 400         #
 401         rm -f Nothing_to_remove \
 402             `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
 403                 -prune -o -type f -name '*.ln' -print `
 404 
 405         /bin/time $MAKE -ek lint 2>&1 | \
 406             tee -a $LINTOUT >> $LOGFILE
 407 
 408         echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file
 409 
 410         grep "$MAKE:" $LINTOUT |
 411                 egrep -v "Ignoring unknown host" | \
 412                 tee $TMPDIR/lint_errs >> $mail_msg_file
 413         if [[ -s $TMPDIR/lint_errs ]]; then
 414                 build_extras_ok=n
 415         fi
 416 
 417         echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
 418 
 419         echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
 420                 >>$mail_msg_file
 421         tail -3  $LINTOUT >>$mail_msg_file
 422 
 423         rm -f ${LINTNOISE}.ref
 424         if [ -f ${LINTNOISE}.out ]; then
 425                 mv ${LINTNOISE}.out ${LINTNOISE}.ref
 426         fi
 427         grep : $LINTOUT | \
 428                 egrep -v '^(real|user|sys)' |
 429                 egrep -v '(library construction)' | \
 430                 egrep -v ': global crosschecks' | \
 431                 egrep -v 'Ignoring unknown host' | \
 432                 egrep -v '\.c:$' | \
 433                 sort | uniq > ${LINTNOISE}.out
 434         if [ ! -f ${LINTNOISE}.ref ]; then
 435                 cp ${LINTNOISE}.out ${LINTNOISE}.ref
 436         fi
 437 
 438         if [ "$dodiff" != "n" ]; then
 439                 echo "\n==== lint warnings $base ====\n" \
 440                         >>$mail_msg_file
 441                 # should be none, though there are a few that were filtered out
 442                 # above
 443                 egrep -i '(warning|lint):' ${LINTNOISE}.out \
 444                         | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file
 445                 if [[ -s $TMPDIR/lint_warns ]]; then
 446                         build_extras_ok=n
 447                 fi
 448                 echo "\n==== lint noise differences $base ====\n" \
 449                         >> $mail_msg_file
 450                 diff ${LINTNOISE}.ref ${LINTNOISE}.out \
 451                         >> $mail_msg_file
 452         fi
 453 }
 454 
 455 #
 456 # Build and install the onbld tools.
 457 #
 458 # usage: build_tools DESTROOT
 459 #
 460 # returns non-zero status if the build was successful.
 461 #
 462 function build_tools {
 463         DESTROOT=$1
 464 
 465         INSTALLOG=install-${MACH}
 466 
 467         echo "\n==== Building tools at `date` ====\n" \
 468                 >> $LOGFILE
 469 
 470         rm -f ${TOOLS}/${INSTALLOG}.out
 471         cd ${TOOLS}
 472         /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
 473             tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
 474 
 475         echo "\n==== Tools build errors ====\n" >> $mail_msg_file
 476 
 477         egrep ":" ${TOOLS}/${INSTALLOG}.out |
 478                 egrep -e "(${MAKE}:|[   ]error[:        \n])" | \
 479                 egrep -v "Ignoring unknown host" | \
 480                 egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file
 481 
 482         if [[ -s $TMPDIR/tools_errors ]]; then
 483                 return 1
 484         fi
 485         return 0
 486 }
 487 
 488 #
 489 # Set up to use locally installed tools.
 490 #
 491 # usage: use_tools TOOLSROOT
 492 #
 493 function use_tools {
 494         TOOLSROOT=$1
 495 
 496         #
 497         # If we're not building ON workspace, then the TOOLSROOT
 498         # settings here are clearly ignored by the workspace
 499         # makefiles, prepending nonexistent directories to PATH is
 500         # harmless, and we clearly do not wish to override
 501         # ONBLD_TOOLS.
 502         #
 503         # If we're building an ON workspace, then the prepended PATH
 504         # elements should supercede the preexisting ONBLD_TOOLS paths,
 505         # and we want to override ONBLD_TOOLS to catch the tools that


 675 A_FLAG=n
 676 C_FLAG=n
 677 D_FLAG=n
 678 F_FLAG=n
 679 f_FLAG=n
 680 i_FLAG=n; i_CMD_LINE_FLAG=n
 681 l_FLAG=n
 682 M_FLAG=n
 683 m_FLAG=n
 684 N_FLAG=n
 685 n_FLAG=n
 686 p_FLAG=n
 687 r_FLAG=n
 688 t_FLAG=y
 689 U_FLAG=n
 690 u_FLAG=n
 691 V_FLAG=n
 692 w_FLAG=n
 693 #
 694 build_ok=y
 695 build_extras_ok=y
 696 
 697 #
 698 # examine arguments
 699 #
 700 
 701 OPTIND=1
 702 while getopts +intV: FLAG
 703 do
 704         case $FLAG in
 705           i )   i_FLAG=y; i_CMD_LINE_FLAG=y
 706                 ;;
 707           n )   n_FLAG=y
 708                 ;;
 709          +t )   t_FLAG=n
 710                 ;;
 711           V )   V_FLAG=y
 712                 V_ARG="$OPTARG"
 713                 ;;
 714          \? )   echo "$USAGE"
 715                 exit 1


1156         if [ -s $build_noise_file ]; then
1157                 echo "\n==== Nightly build noise ====\n" |
1158                     tee -a $LOGFILE >>$mail_msg_file
1159                 cat $build_noise_file >>$LOGFILE
1160                 cat $build_noise_file >>$mail_msg_file
1161                 echo | tee -a $LOGFILE >>$mail_msg_file
1162         fi
1163         rm -f $build_noise_file
1164 
1165         case "$build_ok" in
1166                 y)
1167                         state=Completed
1168                         ;;
1169                 i)
1170                         state=Interrupted
1171                         ;;
1172                 *)
1173                         state=Failed
1174                         ;;
1175         esac
1176 
1177         if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
1178                 state=Failed
1179         fi
1180 
1181         NIGHTLY_STATUS=$state
1182         export NIGHTLY_STATUS
1183 
1184         run_hook POST_NIGHTLY $state
1185         run_hook SYS_POST_NIGHTLY $state
1186 
1187         #
1188         # mailx(1) sets From: based on the -r flag
1189         # if it is given.
1190         #
1191         mailx_r=
1192         if [[ -n "${MAILFROM}" ]]; then
1193                 mailx_r="-r ${MAILFROM}"
1194         fi
1195 
1196         cat $build_time_file $build_environ_file $mail_msg_file \
1197             > ${LLOG}/mail_msg
1198         if [ "$m_FLAG" = "y" ]; then
1199                 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1200         "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \


1506 #
1507 #       Decide whether to clobber
1508 #
1509 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1510         echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1511 
1512         cd $SRC
1513         # remove old clobber file
1514         rm -f $SRC/clobber.out
1515         rm -f $SRC/clobber-${MACH}.out
1516 
1517         # Remove all .make.state* files, just in case we are restarting
1518         # the build after having interrupted a previous 'make clobber'.
1519         find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1520                 -o -name 'interfaces.*' \) -prune \
1521                 -o -name '.make.*' -print | xargs rm -f
1522 
1523         $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1524         echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1525         grep "$MAKE:" $SRC/clobber-${MACH}.out |
1526                 egrep -v "Ignoring unknown host" | \
1527                 tee $TMPDIR/clobber_errs >> $mail_msg_file
1528 
1529         if [[ -s $TMPDIR/clobber_errs ]]; then
1530                 build_extras_ok=n
1531         fi
1532 
1533         if [[ "$t_FLAG" = "y" ]]; then
1534                 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1535                 cd ${TOOLS}
1536                 rm -f ${TOOLS}/clobber-${MACH}.out
1537                 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1538                         tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1539                 echo "\n==== Make tools clobber ERRORS ====\n" \
1540                         >> $mail_msg_file
1541                 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1542                         >> $mail_msg_file
1543                 if (( $? == 0 )); then
1544                         build_extras_ok=n
1545                 fi
1546                 rm -rf ${TOOLS_PROTO}
1547                 mkdir -p ${TOOLS_PROTO}
1548         fi
1549 
1550         typeset roots=$(allprotos)
1551         echo "\n\nClearing $roots" >> "$LOGFILE"
1552         rm -rf $roots
1553 
1554         # Get back to a clean workspace as much as possible to catch
1555         # problems that only occur on fresh workspaces.
1556         # Remove all .make.state* files, libraries, and .o's that may
1557         # have been omitted from clobber.  A couple of libraries are
1558         # under source code control, so leave them alone.
1559         # We should probably blow away temporary directories too.
1560         cd $SRC
1561         find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1562             -o -name .git -o -name 'interfaces.*' \) -prune -o \
1563             \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1564                -name '*.o' \) -print | \
1565             grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f


1796 
1797 # Check that we're running a capable link-editor
1798 whence ld | tee -a $build_environ_file >> $LOGFILE
1799 LDVER=`ld -V 2>&1`
1800 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
1801 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1802 if [ `expr $LDVER \< 422` -eq 1 ]; then
1803         echo "The link-editor needs to be at version 422 or higher to build" | \
1804             tee -a $build_environ_file >> $LOGFILE
1805         echo "the latest stuff.  Hope your build works." | \
1806             tee -a $build_environ_file >> $LOGFILE
1807 fi
1808 
1809 #
1810 # Build and use the workspace's tools if requested
1811 #
1812 if [[ "$t_FLAG" = "y" ]]; then
1813         set_non_debug_build_flags
1814 
1815         build_tools ${TOOLS_PROTO}
1816         if (( $? != 0 )); then
1817                 build_ok=n
1818         else
1819                 use_tools $TOOLS_PROTO
1820         fi
1821 fi
1822 
1823 # timestamp the start of the normal build; the findunref tool uses it.
1824 touch $SRC/.build.tstamp
1825 
1826 normal_build
1827 
1828 ORIG_SRC=$SRC
1829 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
1830 
1831 
1832 #
1833 # There are several checks that need to look at the proto area, but
1834 # they only need to look at one, and they don't care whether it's
1835 # DEBUG or non-DEBUG.
1836 #
1837 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
1838         checkroot=$ROOT-nd


1856                                 E1="$E1 -e $f"
1857                         fi
1858                 done
1859 
1860                 E2=
1861                 f2=
1862                 if [ -d "$SRC/pkg" ]; then
1863                         f2="$f2 exceptions/packaging"
1864                 fi
1865 
1866                 for f in $f2; do
1867                         if [ -f "$f" ]; then
1868                                 E2="$E2 -e $f"
1869                         fi
1870                 done
1871         fi
1872 
1873         if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
1874                 echo "\n==== Validating manifests against proto area ====\n" \
1875                     >> $mail_msg_file
1876                 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \
1877                     tee $TMPDIR/protocmp_noise >> $mail_msg_file
1878                 if [[ -s $TMPDIR/protocmp_noise ]]; then
1879                         build_extras_ok=n
1880                 fi
1881         fi
1882 
1883         if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1884                 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1885                 if [ -n "$E2" ]; then
1886                         ELIST=$E2
1887                 else
1888                         ELIST=$E1
1889                 fi
1890                 $PROTOCMPTERSE \
1891                         "Files in yesterday's proto area, but not today's:" \
1892                         "Files in today's proto area, but not yesterday's:" \
1893                         "Files that changed between yesterday and today:" \
1894                         ${ELIST} \
1895                         -d $REF_PROTO_LIST \
1896                         $ATLOG/proto_list_${MACH} \
1897                         >> $mail_msg_file
1898         fi
1899 fi
1900 
1901 if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \
1902     "$build_extras_ok" == "y" ]]; then
1903         staffer cp $ATLOG/proto_list_${MACH} \
1904                 $PARENT_WS/usr/src/proto_list_${MACH}
1905 fi
1906 
1907 # Update parent proto area if necessary. This is done now
1908 # so that the proto area has either DEBUG or non-DEBUG kernels.
1909 # Note that this clears out the lock file, so we can dispense with
1910 # the variable now.
1911 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1912         echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1913             tee -a $LOGFILE >> $mail_msg_file
1914         rm -rf $NIGHTLY_PARENT_ROOT/*
1915         unset Ulockfile
1916         mkdir -p $NIGHTLY_PARENT_ROOT
1917         if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1918                 ( cd $ROOT; tar cf - . |
1919                     ( cd $NIGHTLY_PARENT_ROOT;  umask 0; tar xpf - ) ) 2>&1 |
1920                     tee -a $mail_msg_file >> $LOGFILE
1921         fi
1922         if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then


1927                     ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
1928                     tee -a $mail_msg_file >> $LOGFILE
1929         fi
1930         if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1931                 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1932                     tee -a $LOGFILE >> $mail_msg_file
1933                 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1934                 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
1935                 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1936                         ( cd $TOOLS_PROTO; tar cf - . |
1937                             ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 
1938                             umask 0; tar xpf - ) ) 2>&1 |
1939                             tee -a $mail_msg_file >> $LOGFILE
1940                 fi
1941         fi
1942 fi
1943 
1944 #
1945 # ELF verification: ABI (-A) and runtime (-r) checks
1946 #
1947 if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then
1948         # Directory ELF-data.$MACH holds the files produced by these tests.
1949         elf_ddir=$SRC/ELF-data.$MACH
1950 
1951         # If there is a previous ELF-data backup directory, remove it. Then,
1952         # rotate current ELF-data directory into its place and create a new
1953         # empty directory
1954         rm -rf $elf_ddir.ref
1955         if [[ -d $elf_ddir ]]; then
1956                 mv $elf_ddir $elf_ddir.ref
1957         fi
1958         mkdir -p $elf_ddir
1959 
1960         # Call find_elf to produce a list of the ELF objects in the proto area.
1961         # This list is passed to check_rtime and interface_check, preventing
1962         # them from separately calling find_elf to do the same work twice.
1963         find_elf -fr $checkroot > $elf_ddir/object_list
1964 
1965         if [[ $A_FLAG = y ]]; then
1966                 echo "\n==== Check versioning and ABI information ====\n"  | \
1967                     tee -a $LOGFILE >> $mail_msg_file
1968 
1969                 # Produce interface description for the proto. Report errors.
1970                 interface_check -o -w $elf_ddir -f object_list \
1971                         -i interface -E interface.err
1972                 if [[ -s $elf_ddir/interface.err ]]; then
1973                         tee -a $LOGFILE < $elf_ddir/interface.err \
1974                             >> $mail_msg_file
1975                         build_extras_ok=n
1976                 fi
1977 
1978                 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1979                 # description file to that from the baseline gate. Issue a
1980                 # warning if the baseline is not present, and keep going.
1981                 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1982                         base_ifile="$ELF_DATA_BASELINE_DIR/interface"
1983 
1984                         echo "\n==== Compare versioning and ABI information" \
1985                             "to baseline ====\n"  | \
1986                             tee -a $LOGFILE >> $mail_msg_file
1987                         echo "Baseline:  $base_ifile\n" >> $LOGFILE
1988 
1989                         if [[ -f $base_ifile ]]; then
1990                                 interface_cmp -d -o $base_ifile \
1991                                     $elf_ddir/interface > $elf_ddir/interface.cmp
1992                                 if [[ -s $elf_ddir/interface.cmp ]]; then
1993                                         echo | tee -a $LOGFILE >> $mail_msg_file
1994                                         tee -a $LOGFILE < \
1995                                             $elf_ddir/interface.cmp \
1996                                             >> $mail_msg_file
1997                                         build_extras_ok=n
1998                                 fi
1999                         else
2000                                 echo "baseline not available. comparison" \
2001                                     "skipped" | \
2002                                     tee -a $LOGFILE >> $mail_msg_file
2003                         fi
2004 
2005                 fi
2006         fi
2007 
2008         if [[ $r_FLAG = y ]]; then
2009                 echo "\n==== Check ELF runtime attributes ====\n" | \
2010                     tee -a $LOGFILE >> $mail_msg_file
2011 
2012                 # If we're doing a DEBUG build the proto area will be left
2013                 # with debuggable objects, thus don't assert -s.
2014                 if [[ $D_FLAG = y ]]; then
2015                         rtime_sflag=""
2016                 else
2017                         rtime_sflag="-s"
2018                 fi
2019                 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
2020                         -D object_list  -f object_list -E runtime.err \
2021                         -I runtime.attr.raw
2022                 if (( $? != 0 )); then
2023                         build_extras_ok=n
2024                 fi
2025 
2026                 # check_rtime -I output needs to be sorted in order to 
2027                 # compare it to that from previous builds.
2028                 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
2029                 rm $elf_ddir/runtime.attr.raw
2030 
2031                 # Report errors
2032                 if [[ -s $elf_ddir/runtime.err ]]; then
2033                         tee -a $LOGFILE < $elf_ddir/runtime.err \
2034                                 >> $mail_msg_file
2035                         build_extras_ok=n
2036                 fi
2037 
2038                 # If there is an ELF-data directory from a previous build,
2039                 # then diff the attr files. These files contain information
2040                 # about dependencies, versioning, and runpaths. There is some
2041                 # overlap with the ABI checking done above, but this also
2042                 # flushes out non-ABI interface differences along with the
2043                 # other information.
2044                 echo "\n==== Diff ELF runtime attributes" \
2045                     "(since last build) ====\n" | \
2046                     tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
2047 
2048                 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
2049                         diff $elf_ddir.ref/runtime.attr \
2050                                 $elf_ddir/runtime.attr \
2051                                 >> $mail_msg_file
2052                 fi
2053         fi
2054 
2055         # If -u set, copy contents of ELF-data.$MACH to the parent workspace.


2089                 dolint $1 $2; shift; shift
2090         done
2091 else
2092         echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2093 fi
2094 
2095 # "make check" begins
2096 
2097 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2098         # remove old check.out
2099         rm -f $SRC/check.out
2100 
2101         rm -f $SRC/check-${MACH}.out
2102         cd $SRC
2103         $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
2104             >> $LOGFILE
2105         echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2106 
2107         grep ":" $SRC/check-${MACH}.out |
2108                 egrep -v "Ignoring unknown host" | \
2109                 sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file
2110 
2111         if [[ -s $TMPDIR/check_errors ]]; then
2112                 build_extras_ok=n
2113         fi
2114 else
2115         echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2116 fi
2117 
2118 echo "\n==== Find core files ====\n" | \
2119     tee -a $LOGFILE >> $mail_msg_file
2120 
2121 find $abssrcdirs -name core -a -type f -exec file {} \; | \
2122         tee -a $LOGFILE >> $mail_msg_file
2123 
2124 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2125         echo "\n==== Diff unreferenced files (since last build) ====\n" \
2126             | tee -a $LOGFILE >>$mail_msg_file
2127         rm -f $SRC/unref-${MACH}.ref
2128         if [ -f $SRC/unref-${MACH}.out ]; then
2129                 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2130         fi
2131 
2132         findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2133             ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2134             sort > $SRC/unref-${MACH}.out
2135 
2136         if [ ! -f $SRC/unref-${MACH}.ref ]; then
2137                 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2138         fi
2139 
2140         diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2141 fi
2142 
2143 # Verify that the usual lists of files, such as exception lists,
2144 # contain only valid references to files.  If the build has failed,
2145 # then don't check the proto area.
2146 CHECK_PATHS=${CHECK_PATHS:-y}
2147 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2148         echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2149                 >>$mail_msg_file
2150         arg=-b
2151         [ "$build_ok" = y ] && arg=
2152         checkpaths $arg $checkroot > $SRC/checkpaths.out 2>&1
2153         if [[ -s $SRC/checkpaths.out ]]; then
2154                 tee -a $LOGFILE < $SRC/checkpaths.out >> $mail_msg_file
2155                 build_extras_ok=n
2156         fi
2157 fi
2158 
2159 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2160         echo "\n==== Impact on file permissions ====\n" \
2161                 >> $mail_msg_file
2162 
2163         abspkg=
2164         for d in $abssrcdirs; do
2165                 if [ -d "$d/pkg" ]; then
2166                         abspkg="$abspkg $d"
2167                 fi
2168         done
2169 
2170         if [ -n "$abspkg" ]; then
2171                 for d in "$abspkg"; do
2172                         ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
2173                 done
2174         fi
2175 fi
2176 


2219         # which was already on the parent.
2220         #
2221 
2222         set -- $PARENT_WS/usr/src/unref-*.out
2223         cp "$1" ${TMPDIR}/unref.merge
2224         shift
2225 
2226         for unreffile; do
2227                 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2228                 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2229         done
2230 
2231         staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2232 fi
2233 
2234 #
2235 # All done save for the sweeping up.
2236 # (whichever exit we hit here will trigger the "cleanup" trap which
2237 # optionally sends mail on completion).
2238 #
2239 if [[ "$build_ok" == "y" && "$build_extras_ok" == "y" ]]; then
2240         exit 0
2241 fi
2242 exit 1