1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22# 23# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26# ident "%Z%%M% %I% %E% SMI" 27# 28# Based on the nightly script from the integration folks, 29# Mostly modified and owned by mike_s. 30# Changes also by kjc, dmk. 31# 32# BRINGOVER_WS may be specified in the env file. 33# The default is the old behavior of CLONE_WS 34# 35# -i on the command line, means fast options, so when it's on the 36# command line (only), lint, check, GPROF and TRACE builds are skipped 37# no matter what the setting of their individual flags are in NIGHTLY_OPTIONS. 38# 39# LINTDIRS can be set in the env file, format is a list of: 40# 41# /dirname-to-run-lint-on flag 42# 43# Where flag is: y - enable lint noise diff output 44# n - disable lint noise diff output 45# 46# For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y" 47# 48# -A flag in NIGHTLY_OPTIONS checks ABI diffs in .so files 49# This option requires a couple of scripts. 50# 51# OPTHOME and TEAMWARE may be set in the environment to override /opt 52# and /opt/teamware defaults. 53# 54 55# 56# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 57# under certain circumstances, which can really screw things up; unset it. 58# 59unset CDPATH 60 61# function to do a DEBUG and non-DEBUG build. Needed because we might 62# need to do another for the source build, and since we only deliver DEBUG or 63# non-DEBUG packages. 64 65normal_build() { 66 67 # timestamp the start of a nightly build; the findunref tool uses it. 68 touch $SRC/.build.tstamp 69 70 # non-DEBUG build begins 71 72 if [ "$F_FLAG" = "n" ]; then 73 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 74 export RELEASE_BUILD ; RELEASE_BUILD= 75 unset EXTRA_OPTIONS 76 unset EXTRA_CFLAGS 77 78 build non-DEBUG -nd 79 80 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a "$p_FLAG" = "y" ]; then 81 copy_ihv_pkgs non-DEBUG -nd 82 fi 83 else 84 echo "\n==== No non-DEBUG build ====\n" >> $LOGFILE 85 fi 86 87 # non-DEBUG build ends 88 89 # DEBUG build begins 90 91 if [ "$D_FLAG" = "y" ]; then 92 93 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 94 unset RELEASE_BUILD 95 unset EXTRA_OPTIONS 96 unset EXTRA_CFLAGS 97 98 build DEBUG "" 99 100 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a "$p_FLAG" = "y" ]; then 101 copy_ihv_pkgs DEBUG "" 102 fi 103 104 else 105 echo "\n==== No DEBUG build ====\n" >> $LOGFILE 106 fi 107 108 # DEBUG build ends 109} 110 111filelist() { 112 if [ $# -ne 2 ]; then 113 echo "usage: filelist DESTDIR PATTERN" 114 exit 1; 115 fi 116 DEST=$1 117 PATTERN=$2 118 cd ${DEST} 119 120 OBJFILES=${ORIG_SRC}/xmod/obj_files 121 if [ ! -f ${OBJFILES} ]; then 122 return; 123 fi 124 for i in `grep -v '^#' ${ORIG_SRC}/xmod/obj_files | \ 125 grep ${PATTERN} | cut -d: -f2 | tr -d ' \t'` 126 do 127 # wildcard expansion 128 for j in $i 129 do 130 if [ -f "$j" ]; then 131 echo $j 132 fi 133 if [ -d "$j" ]; then 134 echo $j 135 fi 136 done 137 done | sort | uniq 138} 139 140# function to save off binaries after a full build for later 141# restoration 142save_binaries() { 143 # save off list of binaries 144 echo "\n==== Saving binaries from build at `date` ====\n" | \ 145 tee -a $mail_msg_file >> $LOGFILE 146 rm -f ${BINARCHIVE} 147 cd ${CODEMGR_WS} 148 filelist ${CODEMGR_WS} '^preserve:' >> $LOGFILE 149 filelist ${CODEMGR_WS} '^preserve:' | \ 150 cpio -ocB 2>/dev/null | compress \ 151 > ${BINARCHIVE} 152} 153 154# delete files 155hybridize_files() { 156 if [ $# -ne 2 ]; then 157 echo "usage: hybridize_files DESTDIR MAKE_TARGET" 158 exit 1; 159 fi 160 161 DEST=$1 162 MAKETARG=$2 163 164 echo "\n==== Hybridizing files at `date` ====\n" | \ 165 tee -a $mail_msg_file >> $LOGFILE 166 for i in `filelist ${DEST} '^delete:'` 167 do 168 echo "removing ${i}." | tee -a $mail_msg_file >> $LOGFILE 169 rm -rf "${i}" 170 done 171 for i in `filelist ${DEST} '^hybridize:' ` 172 do 173 echo "hybridizing ${i}." | tee -a $mail_msg_file >> $LOGFILE 174 rm -f ${i}+ 175 sed -e "/^# HYBRID DELETE START/,/^# HYBRID DELETE END/d" \ 176 < ${i} > ${i}+ 177 mv ${i}+ ${i} 178 done 179} 180 181# restore binaries into the proper source tree. 182restore_binaries() { 183 if [ $# -ne 2 ]; then 184 echo "usage: restore_binaries DESTDIR MAKE_TARGET" 185 exit 1; 186 fi 187 188 DEST=$1 189 MAKETARG=$2 190 191 echo "\n==== Restoring binaries to ${MAKETARG} at `date` ====\n" | \ 192 tee -a $mail_msg_file >> $LOGFILE 193 cd ${DEST} 194 zcat ${BINARCHIVE} | \ 195 cpio -idmucvB 2>/dev/null | tee -a $mail_msg_file >> ${LOGFILE} 196} 197 198# rename files we save binaries of 199rename_files() { 200 if [ $# -ne 2 ]; then 201 echo "usage: rename_files DESTDIR MAKE_TARGET" 202 exit 1; 203 fi 204 205 DEST=$1 206 MAKETARG=$2 207 echo "\n==== Renaming source files in ${MAKETARG} at `date` ====\n" | \ 208 tee -a $mail_msg_file >> $LOGFILE 209 for i in `filelist ${DEST} '^rename:'` 210 do 211 echo ${i} | tee -a $mail_msg_file >> ${LOGFILE} 212 rm -f ${i}.export 213 mv ${i} ${i}.export 214 done 215} 216 217# function to create the export/crypt source tree 218# usage: clone_source CODEMGR_WS DESTDIR MAKE_TARGET 219 220clone_source() { 221 222 if [ $# -ne 3 ]; then 223 echo "usage: clone_source CODEMGR_WS DESTDIR MAKE_TARGET" 224 exit 1; 225 fi 226 WS=$1 227 DEST=$2 228 MAKETARG=$3 229 230 echo "\n==== Creating ${DEST} source from ${WS} (${MAKETARG}) ====\n" | \ 231 tee -a $mail_msg_file >> $LOGFILE 232 233 echo "cleaning out ${DEST}." >> $LOGFILE 234 rm -rf "${DEST}" >> $LOGFILE 2>&1 235 236 mkdir -p ${DEST} 237 cd ${WS} 238 239 echo "creating ${DEST}." >> $LOGFILE 240 find usr -name 's\.*' -a -type f -print | \ 241 sed -e 's,SCCS\/s.,,' | \ 242 grep -v '/\.del-*' | \ 243 cpio -pd ${DEST} >>$LOGFILE 2>&1 244 245 SRC=${DEST}/usr/src 246 247 cd $SRC 248 rm -f ${MAKETARG}.out 249 echo "making ${MAKETARG} in ${SRC}." >> $LOGFILE 250 /bin/time $MAKE -e ${MAKETARG} 2>&1 | \ 251 tee -a $SRC/${MAKETARG}.out >> $LOGFILE 252 echo "\n==== ${MAKETARG} build errors ====\n" >> $mail_msg_file 253 egrep ":" $SRC/${MAKETARG}.out | \ 254 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 255 egrep -v "Ignoring unknown host" | \ 256 egrep -v "warning" >> $mail_msg_file 257 258 echo "clearing state files." >> $LOGFILE 259 find . -name '.make*' -exec rm -f {} \; 260 261 cd ${DEST} 262 if [ "${MAKETARG}" = "CRYPT_SRC" ]; then 263 rm -f ${CODEMGR_WS}/crypt_files.cpio.Z 264 echo "\n==== xmod/cry_files that don't exist ====\n" | \ 265 tee -a $mail_msg_file >> $LOGFILE 266 CRYPT_FILES=${WS}/usr/src/xmod/cry_files 267 for i in `cat ${CRYPT_FILES}` 268 do 269 # make sure the files exist 270 if [ -f "$i" ]; then 271 continue 272 fi 273 if [ -d "$i" ]; then 274 continue 275 fi 276 echo "$i" | tee -a $mail_msg_file >> $LOGFILE 277 done 278 find `cat ${CRYPT_FILES}` -print 2>/dev/null | \ 279 cpio -ocB 2>/dev/null | \ 280 compress > ${CODEMGR_WS}/crypt_files.cpio.Z 281 fi 282 283 if [ "${MAKETARG}" = "EXPORT_SRC" ]; then 284 # rename first, since we might restore a file 285 # of the same name (mapfiles) 286 rename_files ${EXPORT_SRC} EXPORT_SRC 287 if [ "$SH_FLAG" = "y" ]; then 288 hybridize_files ${EXPORT_SRC} EXPORT_SRC 289 fi 290 fi 291 292 # save the cleartext 293 echo "\n==== Creating ${MAKETARG}.cpio.Z ====\n" | \ 294 tee -a $mail_msg_file >> $LOGFILE 295 cd ${DEST} 296 rm -f ${MAKETARG}.cpio.Z 297 find usr -depth -print | \ 298 grep -v usr/src/${MAKETARG}.out | \ 299 cpio -ocB 2>/dev/null | \ 300 compress > ${CODEMGR_WS}/${MAKETARG}.cpio.Z 301 if [ "${MAKETARG}" = "EXPORT_SRC" ]; then 302 restore_binaries ${EXPORT_SRC} EXPORT_SRC 303 fi 304 305 if [ "${MAKETARG}" = "CRYPT_SRC" ]; then 306 restore_binaries ${CRYPT_SRC} CRYPT_SRC 307 fi 308 309} 310 311# function to do the build. 312# usage: build LABEL SUFFIX 313 314build() { 315 316 if [ $# -ne 2 ]; then 317 echo "usage: build LABEL SUFFIX" 318 exit 1; 319 fi 320 321 LABEL=$1 322 SUFFIX=$2 323 INSTALLOG=install${SUFFIX}-${MACH} 324 NOISE=noise${SUFFIX}-${MACH} 325 CPIODIR=${CPIODIR_ORIG}${SUFFIX} 326 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 327 if [ "$SPARC_RM_PKGARCHIVE_ORIG" ]; then 328 SPARC_RM_PKGARCHIVE=${SPARC_RM_PKGARCHIVE_ORIG}${SUFFIX} 329 fi 330 331 #remove old logs 332 OLDINSTALLOG=install${SUFFIX} 333 OLDNOISE=noise${SUFFIX} 334 rm -f $SRC/${OLDINSTALLOG}.out 335 rm -f $SRC/${OLDNOISE}.ref 336 if [ -f $SRC/${OLDNOISE}.out ]; then 337 mv $SRC/${OLDNOISE}.out $SRC/${NOISE}.ref 338 fi 339 340 this_build_ok=y 341 # 342 # Build OS-Networking source 343 # 344 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \ 345 >> $LOGFILE 346 347 rm -f $SRC/${INSTALLOG}.out 348 cd $SRC 349 /bin/time $MAKE -e install 2>&1 | \ 350 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE 351 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 352 egrep ":" $SRC/${INSTALLOG}.out | 353 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 354 egrep -v "Ignoring unknown host" | \ 355 egrep -v "cc .* -o error " | \ 356 egrep -v "warning" >> $mail_msg_file 357 if [ "$?" = "0" ]; then 358 build_ok=n 359 this_build_ok=n 360 fi 361 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 362 >> $mail_msg_file 363 if [ "$?" = "0" ]; then 364 build_ok=n 365 this_build_ok=n 366 fi 367 368 if [ "$W_FLAG" = "n" ]; then 369 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 370 # should be none, but there are a few that are pmake 371 # related, and a couple of silly ones. 372 egrep -i warning: $SRC/${INSTALLOG}.out \ 373 | egrep -v '^tic:' \ 374 | egrep -v '^mcs:' \ 375 | egrep -v '^LD_LIBRARY_PATH=' \ 376 | egrep -v 'multiple use of -K option' \ 377 | egrep -v 'option -I appears more than once' \ 378 | egrep -v 'ar: creating' \ 379 | egrep -v 'ar: writing' \ 380 | egrep -v 'conflicts:' \ 381 | egrep -v ':saved created' \ 382 | egrep -v '^stty.*c:' \ 383 | egrep -v '^mfgname.c:' \ 384 | egrep -v '^uname-i.c:' \ 385 | egrep -v '^volumes.c:' \ 386 | egrep -v '^lint library construction:' \ 387 | egrep -v 'tsort: INFORM:' \ 388 | egrep -v 'stripalign:' \ 389 | egrep -v 'chars, width' \ 390 | egrep -v 'option -zdefs/nodefs appears more than' \ 391 | egrep -v "symbol \`timezone' has differing types:" \ 392 | egrep -v "parameter <PSTAMP> set to" \ 393 | egrep -v "^Manifying" \ 394 | egrep -v "Ignoring unknown host" \ 395 | egrep -v "redefining segment flags attribute for" \ 396 >> $mail_msg_file 397 fi 398 399 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 400 >> $LOGFILE 401 402 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 403 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 404 405 if [ "$i_FLAG" = "n" -a "$W_FLAG" = "n" ]; then 406 rm -f $SRC/${NOISE}.ref 407 if [ -f $SRC/${NOISE}.out ]; then 408 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 409 fi 410 grep : $SRC/${INSTALLOG}.out \ 411 | egrep -v '^/' \ 412 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 413 | egrep -v '^tic:' \ 414 | egrep -v '^mcs' \ 415 | egrep -v '^LD_LIBRARY_PATH=' \ 416 | egrep -v 'multiple use of -K option' \ 417 | egrep -v 'option -I appears more than once' \ 418 | egrep -v 'ar: creating' \ 419 | egrep -v 'ar: writing' \ 420 | egrep -v 'conflicts:' \ 421 | egrep -v ':saved created' \ 422 | egrep -v '^stty.*c:' \ 423 | egrep -v '^mfgname.c:' \ 424 | egrep -v '^uname-i.c:' \ 425 | egrep -v '^volumes.c:' \ 426 | egrep -v '^lint library construction:' \ 427 | egrep -v 'tsort: INFORM:' \ 428 | egrep -v 'stripalign:' \ 429 | egrep -v 'chars, width' \ 430 | egrep -v 'option -zdefs/nodefs appears more than' \ 431 | egrep -v "symbol \`timezone' has differing types:" \ 432 | egrep -v 'PSTAMP' \ 433 | egrep -v '|%WHOANDWHERE%|' \ 434 | egrep -v '^Manifying' \ 435 | egrep -v 'Ignoring unknown host' \ 436 | egrep -v 'Processing method:' \ 437 | egrep -v '^Writing' \ 438 | egrep -v 'spellin1:' \ 439 | egrep -v '^adding:' \ 440 | egrep -v "^echo 'msgid" \ 441 | egrep -v '^echo ' \ 442 | egrep -v '\.c:$' \ 443 | egrep -v '^Adding file:' \ 444 | egrep -v 'CLASSPATH=' \ 445 | egrep -v '\/var\/mail\/:saved' \ 446 | egrep -v -- '-DUTS_VERSION=' \ 447 | egrep -v '^Running Mkbootstrap' \ 448 | egrep -v '^Applet length read:' \ 449 | egrep -v 'bytes written:' \ 450 | egrep -v '^File:SolarisAuthApplet.bin' \ 451 | egrep -v -i 'jibversion' \ 452 | egrep -v '^Output size:' \ 453 | egrep -v '^Solo size statistics:' \ 454 | egrep -v '^Using ROM API Version' \ 455 | egrep -v '^Zero Signature length:' \ 456 | egrep -v '^Note \(probably harmless\):' \ 457 | egrep -v '::' \ 458 | egrep -v -- '-xcache' \ 459 | egrep -v '^\+' \ 460 | sort | uniq >$SRC/${NOISE}.out 461 if [ ! -f $SRC/${NOISE}.ref ]; then 462 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 463 fi 464 echo "\n==== Build noise differences ($LABEL) ====\n" \ 465 >>$mail_msg_file 466 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 467 fi 468 469 # 470 # Create cpio archives for preintegration testing (PIT) 471 # 472 if [ "$a_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 473 echo "\n==== Creating $LABEL cpio archives at `date` ====\n" \ 474 >> $LOGFILE 475 makebfu_file="${TMPDIR}/makebfu" 476 rm -f ${makebfu_file} 477 makebfu 2>&1 | \ 478 tee -a ${makebfu_file} >> $LOGFILE 479 echo "\n==== cpio archives build errors ($LABEL) ====\n" \ 480 >> $mail_msg_file 481 grep -v "^Creating .* archive:" ${makebfu_file} | \ 482 grep -v "^Making" | \ 483 grep -v "^$" | \ 484 sort | uniq >> $mail_msg_file 485 rm -f ${makebfu_file} 486 # hack for test folks 487 if [ -z "`echo $PARENT_WS|egrep '^\/ws\/'`" ]; then 488 X=/net/`uname -n`${CPIODIR} 489 else 490 X=${CPIODIR} 491 fi 492 echo "Archive_directory: ${X}" >${TMPDIR}/f 493 cp ${TMPDIR}/f ${CPIODIR}/../../.${MACH}_wgtrun 494 rm -f ${TMPDIR}/f 495 496 else 497 echo "\n==== Not creating $LABEL cpio archives ====\n" \ 498 >> $LOGFILE 499 fi 500 501 # 502 # Building Packages 503 # 504 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 505 echo "\n==== Creating $LABEL packages at `date` ====\n" \ 506 >> $LOGFILE 507 rm -f $SRC/pkgdefs/${INSTALLOG}.out 508 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 509 rm -rf $PKGARCHIVE 510 mkdir -p $PKGARCHIVE 511 512 # 513 # Optional build of sparc realmode on i386 514 # 515 if [ "$MACH" = "i386" ] && [ "${SPARC_RM_PKGARCHIVE}" ]; then 516 echo "Clearing out ${SPARC_RM_PKGARCHIVE} ..." \ 517 >> $LOGFILE 518 rm -rf ${SPARC_RM_PKGARCHIVE} 519 mkdir -p ${SPARC_RM_PKGARCHIVE} 520 fi 521 522 cd $SRC/pkgdefs 523 $MAKE -e install 2>&1 | \ 524 tee -a $SRC/pkgdefs/${INSTALLOG}.out >> $LOGFILE 525 echo "\n==== Package build errors ($LABEL) ====\n" \ 526 >> $mail_msg_file 527 egrep "${MAKE}|ERROR|WARNING" $SRC/pkgdefs/${INSTALLOG}.out | \ 528 grep ':' | \ 529 grep -v PSTAMP | \ 530 egrep -v "Ignoring unknown host" \ 531 >> $mail_msg_file 532 else 533 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 534 fi 535} 536 537dolint() { 538 539 # 540 # Arg. 2 is a flag to turn on/off the lint diff output 541 # 542 dl_usage="Usage: dolint /dir y|n" 543 544 if [ $# -ne 2 ]; then 545 echo $dl_usage 546 exit 1 547 fi 548 549 if [ ! -d "$1" ]; then 550 echo $dl_usage 551 exit 1 552 fi 553 554 if [ "$2" != "y" -a "$2" != "n" ]; then 555 echo $dl_usage 556 exit 1 557 fi 558 559 lintdir=$1 560 dodiff=$2 561 base=`basename $lintdir` 562 LINTOUT=$lintdir/lint-${MACH}.out 563 LINTNOISE=$lintdir/lint-noise-${MACH} 564 565 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 566 unset RELEASE_BUILD 567 unset EXTRA_OPTIONS 568 unset EXTRA_CFLAGS 569 570 # 571 # '$MAKE lint' in $lintdir 572 # 573 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 574 575 # remove old lint.out 576 rm -f $lintdir/lint.out $lintdir/lint-noise.out 577 if [ -f $lintdir/lint-noise.ref ]; then 578 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 579 fi 580 581 rm -f $LINTOUT 582 cd $lintdir 583 # 584 # Remove all .ln files to ensure a full reference file 585 # 586 rm -f Nothing_to_remove \ 587 `find . -name SCCS -prune -o -type f -name '*.ln' -print ` 588 589 /bin/time $MAKE -ek lint 2>&1 | \ 590 tee -a $LINTOUT >> $LOGFILE 591 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 592 grep "$MAKE:" $LINTOUT | 593 egrep -v "Ignoring unknown host" \ 594 >> $mail_msg_file 595 596 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 597 598 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 599 >>$mail_msg_file 600 tail -3 $LINTOUT >>$mail_msg_file 601 602 rm -f ${LINTNOISE}.ref 603 if [ -f ${LINTNOISE}.out ]; then 604 mv ${LINTNOISE}.out ${LINTNOISE}.ref 605 fi 606 #grep : $LINTOUT | 607 #egrep -v '^(name|function|value|argument|real|user|sys)' | 608 #egrep -v 'warning: (name|function|value|possibly)' | 609 #egrep -v 'warning: argument used' | 610 grep : $LINTOUT | \ 611 egrep -v '^(real|user|sys)' | 612 egrep -v '(library construction)' | \ 613 egrep -v ': global crosschecks' | \ 614 egrep -v 'Ignoring unknown host' | \ 615 egrep -v '\.c:$' | \ 616 sort | uniq > ${LINTNOISE}.out 617 if [ ! -f ${LINTNOISE}.ref ]; then 618 cp ${LINTNOISE}.out ${LINTNOISE}.ref 619 fi 620 if [ "$dodiff" != "n" ]; then 621 echo "\n==== lint warnings $base ====\n" \ 622 >>$mail_msg_file 623 # should be none, though there are a few that were filtered out 624 # above 625 egrep -i '(warning|lint):' ${LINTNOISE}.out \ 626 | sort | uniq >> $mail_msg_file 627 echo "\n==== lint noise differences $base ====\n" \ 628 >> $mail_msg_file 629 diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 630 >> $mail_msg_file 631 fi 632} 633 634# Install proto area from IHV build 635 636copy_ihv_proto() { 637 638 echo "\n==== Installing $IA32_IHV_ROOT ====\n" \ 639 >> $LOGFILE 640 if [ -d "$IA32_IHV_ROOT" ]; then 641 if [ ! -d "$ROOT" ]; then 642 echo "mkdir -p $ROOT" >> $LOGFILE 643 mkdir -p $ROOT 644 fi 645 echo "cd $IA32_IHV_ROOT\n" >> $LOGFILE 646 cd $IA32_IHV_ROOT 647 tar -cf - . | (cd $ROOT; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 648 else 649 echo "$IA32_IHV_ROOT: not found" >> $LOGFILE 650 fi 651} 652 653# Install IHV packages in PKGARCHIVE 654 655copy_ihv_pkgs() { 656 657 if [ $# -ne 2 ]; then 658 echo "usage: copy_ihv_pkgs LABEL SUFFIX" 659 exit 1; 660 fi 661 662 LABEL=$1 663 SUFFIX=$2 664 # always use non-DEBUG IHV packages 665 IA32_IHV_PKGS=${IA32_IHV_PKGS_ORIG}-nd 666 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 667 668 echo "\n==== Installing IHV packages from $IA32_IHV_PKGS ($LABEL) ====\n" \ 669 >> $LOGFILE 670 if [ -d "$IA32_IHV_PKGS" ]; then 671 cd $IA32_IHV_PKGS 672 tar -cf - * | \ 673 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 674 else 675 echo "$IA32_IHV_PKGS: not found" >> $LOGFILE 676 fi 677 678 echo "\n==== Installing IHV packages from $IA32_IHV_BINARY_PKGS ($LABEL) ====\n" \ 679 >> $LOGFILE 680 if [ -d "$IA32_IHV_BINARY_PKGS" ]; then 681 cd $IA32_IHV_BINARY_PKGS 682 tar -cf - * | \ 683 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 684 else 685 echo "$IA32_IHV_BINARY_PKGS: not found" >> $LOGFILE 686 fi 687} 688 689build_tools() { 690 691 if [ $# -ne 1 ]; then 692 echo "usage: build_tools DESTROOT" 693 exit 1; 694 fi 695 696 DESTROOT=$1 697 698 INSTALLOG=install-${MACH} 699 700 echo "\n==== Building tools at `date` ====\n" \ 701 >> $LOGFILE 702 703 rm -f ${TOOLS}/${INSTALLOG}.out 704 cd ${TOOLS} 705 /bin/time $MAKE ROOT=${DESTROOT} -e install 2>&1 | \ 706 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 707 708 echo "\n==== Tools build errors ====\n" >> $mail_msg_file 709 710 egrep ":" ${TOOLS}/${INSTALLOG}.out | 711 egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 712 egrep -v "Ignoring unknown host" | \ 713 egrep -v warning >> $mail_msg_file 714 if [ "$?" != "0" ]; then 715 STABS=${DESTROOT}/opt/onbld/bin/${MACH}/stabs 716 export STABS 717 CTFSTABS=${DESTROOT}/opt/onbld/bin/${MACH}/ctfstabs 718 export CTFSTABS 719 GENOFFSETS=${DESTROOT}/opt/onbld/bin/genoffsets 720 export GENOFFSETS 721 722 CTFCONVERT=${DESTROOT}/opt/onbld/bin/${MACH}/ctfconvert 723 export CTFCONVERT 724 CTFMERGE=${DESTROOT}/opt/onbld/bin/${MACH}/ctfmerge 725 export CTFMERGE 726 727 CTFCVTPTBL=${DESTROOT}/opt/onbld/bin/ctfcvtptbl 728 export CTFCVTPTBL 729 CTFFINDMOD=${DESTROOT}/opt/onbld/bin/ctffindmod 730 export CTFFINDMOD 731 732 if [ "$VERIFY_ELFSIGN" = "y" ]; then 733 ELFSIGN=${DESTROOT}/opt/onbld/bin/elfsigncmp 734 else 735 ELFSIGN=${DESTROOT}/opt/onbld/bin/${MACH}/elfsign 736 fi 737 export ELFSIGN 738 739 PATH="${DESTROOT}/opt/onbld/bin/${MACH}:${PATH}" 740 PATH="${DESTROOT}/opt/onbld/bin:${PATH}" 741 export PATH 742 743 echo "\n==== New environment settings. ====\n" >> $LOGFILE 744 echo "STABS=${STABS}" >> $LOGFILE 745 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 746 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 747 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 748 echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE 749 echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE 750 echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 751 echo "PATH=${PATH}" >> $LOGFILE 752 fi 753} 754 755staffer() { 756 if [ $ISUSER -ne 0 ]; then 757 "$@" 758 else 759 arg="\"$1\"" 760 shift 761 for i 762 do 763 arg="$arg \"$i\"" 764 done 765 eval su $STAFFER -c \'$arg\' 766 fi 767} 768 769# 770# Verify that the closed tree is present if it needs to be. 771# Sets CLOSED_IS_PRESENT for future use. 772# 773check_closed_tree() { 774 if [ -z "$CLOSED_IS_PRESENT" ]; then 775 if [ -d $SRC/../closed ]; then 776 CLOSED_IS_PRESENT="yes" 777 else 778 CLOSED_IS_PRESENT="no" 779 fi 780 export CLOSED_IS_PRESENT 781 fi 782 if [[ "$CLOSED_IS_PRESENT" = no && ! -d "$ON_CLOSED_BINS" ]]; then 783 # 784 # If it's an old (pre-split) tree or an empty 785 # workspace, don't complain. 786 # 787 if grep -s CLOSED_BUILD $SRC/Makefile.master > /dev/null; then 788 echo "If the closed sources are not present," \ 789 "ON_CLOSED_BINS" 790 echo "must point to the closed binaries tree." 791 exit 1 792 fi 793 fi 794} 795 796MACH=`uname -p` 797 798if [ "$OPTHOME" = "" ]; then 799 OPTHOME=/opt 800 export OPTHOME 801fi 802if [ "$TEAMWARE" = "" ]; then 803 TEAMWARE=$OPTHOME/teamware 804 export TEAMWARE 805fi 806 807USAGE='Usage: nightly [-in] [-V VERS ] [ -S E|D|H ] <env_file> 808 809Where: 810 -i Fast incremental options (no clobber, lint, check, gprof, trace) 811 -n Do not do a bringover 812 -V VERS set the build version string to VERS 813 -S Build a variant of the source product 814 E - build exportable source 815 D - build domestic source (exportable + crypt) 816 H - build hybrid source (binaries + deleted source) 817 818 <env_file> file in Bourne shell syntax that sets and exports 819 variables that configure the operation of this script and many of 820 the scripts this one calls. If <env_file> does not exist, 821 it will be looked for in $OPTHOME/onbld/env. 822 823non-DEBUG is the default build type. Build options can be set in the 824NIGHTLY_OPTIONS variable in the <env_file> as follows: 825 826 -A check for ABI differences in .so files 827 -C check for cstyle/hdrchk errors 828 -D do a build with DEBUG on 829 -F do _not_ do a non-DEBUG build 830 -G gate keeper default group of options (-au) 831 -I integration engineer default group of options (-ampu) 832 -M do not run pmodes (safe file permission checker) 833 -N do not run protocmp 834 -P do a build with GPROF on 835 -R default group of options for building a release (-mp) 836 -T do a build with TRACE on 837 -U update proto area in the parent 838 -V VERS set the build version string to VERS 839 -X copy x86 IHV proto area 840 -a create cpio archives 841 -d use Distributed Make (default uses Parallel Make) 842 -f find unreferenced files 843 -i do an incremental build (no "make clobber") 844 -l do "make lint" in $LINTDIRS (default: $SRC y) 845 -m send mail to $MAILTO at end of build 846 -n do not do a bringover 847 -o build using root privileges to set OWNER/GROUP (old style) 848 -p create packages 849 -r check ELF runtime attributes in the proto area 850 -t build and use the tools in $SRC/tools 851 -u update proto_list_$MACH and friends in the parent workspace; 852 when used with -f, also build an unrefmaster.out in the parent 853 -z compress cpio archives with gzip 854 -W Do not report warnings (freeware gate ONLY) 855 -S Build a variant of the source product 856 E - build exportable source 857 D - build domestic source (exportable + crypt) 858 H - build hybrid source (binaries + deleted source) 859' 860# 861# -x less public handling of xmod source for the source product 862# 863# A log file will be generated under the name $LOGFILE 864# for partially completed build and log.`date '+%m%d%y'` 865# in the same directory for fully completed builds. 866# 867 868# default values for low-level FLAGS; G I R are group FLAGS 869A_FLAG=n 870a_FLAG=n 871d_FLAG=n 872C_FLAG=n 873F_FLAG=n 874f_FLAG=n 875D_FLAG=n 876P_FLAG=n 877T_FLAG=n 878n_FLAG=n 879o_FLAG=n 880i_FLAG=n; i_CMD_LINE_FLAG=n 881l_FLAG=n 882m_FLAG=n 883p_FLAG=n 884r_FLAG=n 885t_FLAG=n 886u_FLAG=n 887U_FLAG=n 888V_FLAG=n 889M_FLAG=n 890N_FLAG=n 891z_FLAG=n 892W_FLAG=n 893SE_FLAG=n 894SD_FLAG=n 895SH_FLAG=n 896X_FLAG=n 897# 898XMOD_OPT= 899# 900build_ok=y 901# 902# examine arguments 903# 904 905OPTIND=1 906while getopts inV:S:t FLAG 907do 908 case $FLAG in 909 i ) i_FLAG=y; i_CMD_LINE_FLAG=y 910 ;; 911 n ) n_FLAG=y 912 ;; 913 V ) V_FLAG=y 914 V_ARG="$OPTARG" 915 ;; 916 S ) 917 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 918 echo "Can only build one source variant at a time." 919 exit 1 920 fi 921 if [ "${OPTARG}" = "E" ]; then 922 SE_FLAG=y 923 elif [ "${OPTARG}" = "D" ]; then 924 SD_FLAG=y 925 elif [ "${OPTARG}" = "H" ]; then 926 SH_FLAG=y 927 else 928 echo "$USAGE" 929 exit 1 930 fi 931 ;; 932 t ) t_FLAG=y 933 ;; 934 \? ) echo "$USAGE" 935 exit 1 936 ;; 937 esac 938done 939 940# correct argument count after options 941shift `expr $OPTIND - 1` 942 943# test that the path to the environment-setting file was given 944if [ $# -ne 1 ]; then 945 echo "$USAGE" 946 exit 1 947fi 948 949# check if user is running nightly as root 950# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 951# when root invokes nightly. 952/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 953ISUSER=$?; export ISUSER 954 955# 956# force locale to C 957LC_COLLATE=C; export LC_COLLATE 958LC_CTYPE=C; export LC_CTYPE 959LC_MESSAGES=C; export LC_MESSAGES 960LC_MONETARY=C; export LC_MONETARY 961LC_NUMERIC=C; export LC_NUMERIC 962LC_TIME=C; export LC_TIME 963 964# clear environment variables we know to be bad for the build 965unset LD_OPTIONS 966unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 967unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 968unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 969unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 970unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 971unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 972unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 973unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 974unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 975unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 976unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 977unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 978unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 979unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 980unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 981unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 982unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 983unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 984unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 985unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 986 987unset CONFIG 988unset GROUP 989unset OWNER 990unset REMOTE 991unset ENV 992unset ARCH 993unset CLASSPATH 994unset NAME 995 996# 997# Setup environmental variables 998# 999if [ -f $1 ]; then 1000 if [[ $1 = */* ]]; then 1001 . $1 1002 else 1003 . ./$1 1004 fi 1005else 1006 if [ -f $OPTHOME/onbld/env/$1 ]; then 1007 . $OPTHOME/onbld/env/$1 1008 else 1009 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 1010 exit 1 1011 fi 1012fi 1013 1014# 1015# place ourselves in a new task, respecting BUILD_PROJECT if set. 1016# 1017if [ -z "$BUILD_PROJECT" ]; then 1018 /usr/bin/newtask -c $$ 1019else 1020 /usr/bin/newtask -c $$ -p $BUILD_PROJECT 1021fi 1022 1023ps -o taskid= -p $$ | read build_taskid 1024ps -o project= -p $$ | read build_project 1025 1026# 1027# See if NIGHTLY_OPTIONS is set 1028# 1029if [ "$NIGHTLY_OPTIONS" = "" ]; then 1030 NIGHTLY_OPTIONS="-aBm" 1031fi 1032 1033# 1034# If BRINGOVER_WS was not specified, let it default to CLONE_WS 1035# 1036if [ "$BRINGOVER_WS" = "" ]; then 1037 BRINGOVER_WS=$CLONE_WS 1038fi 1039 1040# 1041# If BRINGOVER_FILES was not specified, default to usr 1042# 1043if [ "$BRINGOVER_FILES" = "" ]; then 1044 BRINGOVER_FILES="usr" 1045fi 1046 1047# 1048# If the closed sources are not present, the closed binaries must be 1049# present for the build to succeed. If there's no pointer to the 1050# closed binaries, flag that now, rather than forcing the user to wait 1051# a couple hours (or more) to find out. 1052# 1053orig_closed_is_present="$CLOSED_IS_PRESENT" 1054check_closed_tree 1055 1056# 1057# Note: changes to the option letters here should also be applied to the 1058# bldenv script. 1059# 1060OPTIND=1 1061while getopts ABDFNMPTCGIRafinlmoptuUxdrtzWS:X FLAG $NIGHTLY_OPTIONS 1062do 1063 case $FLAG in 1064 A ) A_FLAG=y 1065 ;; 1066 B ) D_FLAG=y 1067 ;; # old version of D 1068 F ) F_FLAG=y 1069 ;; 1070 D ) D_FLAG=y 1071 ;; 1072 P ) P_FLAG=y 1073 ;; 1074 T ) T_FLAG=y 1075 ;; 1076 C ) C_FLAG=y 1077 ;; 1078 M ) M_FLAG=y 1079 ;; 1080 N ) N_FLAG=y 1081 ;; 1082 G ) a_FLAG=y 1083 u_FLAG=y 1084 ;; 1085 I ) a_FLAG=y 1086 m_FLAG=y 1087 p_FLAG=y 1088 u_FLAG=y 1089 ;; 1090 R ) m_FLAG=y 1091 p_FLAG=y 1092 ;; 1093 a ) a_FLAG=y 1094 ;; 1095 d ) d_FLAG=y 1096 ;; 1097 f ) f_FLAG=y 1098 ;; 1099 i ) i_FLAG=y 1100 ;; 1101 n ) n_FLAG=y 1102 ;; 1103 o ) o_FLAG=y 1104 ;; 1105 l ) l_FLAG=y 1106 ;; 1107 m ) m_FLAG=y 1108 ;; 1109 p ) p_FLAG=y 1110 ;; 1111 r ) r_FLAG=y 1112 ;; 1113 t ) t_FLAG=y 1114 ;; 1115 u ) u_FLAG=y 1116 ;; 1117 z ) z_FLAG=y 1118 ;; 1119 U ) 1120 if [ -z "${PARENT_ROOT}" ]; then 1121 echo "PARENT_ROOT must be set if the U flag is" \ 1122 "present in NIGHTLY_OPTIONS." 1123 exit 1 1124 fi 1125 U_FLAG=y 1126 NIGHTLY_PARENT_ROOT=$PARENT_ROOT 1127 ;; 1128 x ) XMOD_OPT="-x" 1129 ;; 1130 W ) W_FLAG=y 1131 ;; 1132 S ) 1133 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1134 echo "Can only build one source variant at a time." 1135 exit 1 1136 fi 1137 if [ "${OPTARG}" = "E" ]; then 1138 SE_FLAG=y 1139 elif [ "${OPTARG}" = "D" ]; then 1140 SD_FLAG=y 1141 elif [ "${OPTARG}" = "H" ]; then 1142 SH_FLAG=y 1143 else 1144 echo "$USAGE" 1145 exit 1 1146 fi 1147 ;; 1148 X ) # now that we no longer need realmode builds, just 1149 # copy IHV packages. only meaningful on x86. 1150 if [ "$MACH" = "i386" ]; then 1151 X_FLAG=y 1152 fi 1153 ;; 1154 \? ) echo "$USAGE" 1155 exit 1 1156 ;; 1157 esac 1158done 1159 1160if [ $ISUSER -ne 0 ]; then 1161 if [ "$o_FLAG" = "y" ]; then 1162 echo "Old-style build requires root permission." 1163 exit 1 1164 fi 1165 1166 # Set default value for STAFFER, if needed. 1167 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 1168 STAFFER=`/usr/xpg4/bin/id -un` 1169 export STAFFER 1170 fi 1171fi 1172 1173if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 1174 MAILTO=$STAFFER 1175 export MAILTO 1176fi 1177 1178PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 1179PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb" 1180PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 1181export PATH 1182 1183# roots of source trees, both relative to $SRC and absolute. 1184relsrcdirs="." 1185if [[ -d $SRC/../closed && "$CLOSED_IS_PRESENT" != no ]]; then 1186 relsrcdirs="$relsrcdirs ../closed" 1187fi 1188abssrcdirs="" 1189for d in $relsrcdirs; do 1190 abssrcdirs="$abssrcdirs $SRC/$d" 1191done 1192 1193unset CH 1194if [ "$o_FLAG" = "y" ]; then 1195# root invoked old-style build -- make sure it works as it always has 1196# by exporting 'CH'. The current Makefile.master doesn't use this, but 1197# the old ones still do. 1198 PROTOCMPTERSE="protocmp.terse" 1199 CH= 1200 export CH 1201else 1202 PROTOCMPTERSE="protocmp.terse -gu" 1203fi 1204POUND_SIGN="#" 1205 1206# we export POUND_SIGN to speed up the build process -- prevents evaluation of 1207# the Makefile.master definitions. 1208export o_FLAG POUND_SIGN 1209 1210if [ "$d_FLAG" = "y" ]; then 1211 maketype="distributed" 1212 MAKE=dmake 1213 # get the dmake version string alone 1214 DMAKE_VERSION=$( $MAKE -v ) 1215 DMAKE_VERSION=${DMAKE_VERSION#*: } 1216 # focus in on just the dotted version number alone 1217 DMAKE_MAJOR=$( echo $DMAKE_VERSION | \ 1218 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' ) 1219 # extract the second (or final) integer 1220 DMAKE_MINOR=${DMAKE_MAJOR#*.} 1221 DMAKE_MINOR=${DMAKE_MINOR%%.*} 1222 # extract the first integer 1223 DMAKE_MAJOR=${DMAKE_MAJOR%%.*} 1224 CHECK_DMAKE=${CHECK_DMAKE:-y} 1225 # x86 was built on the 12th, sparc on the 13th. 1226 if [ "$CHECK_DMAKE" = "y" -a \ 1227 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \ 1228 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \ 1229 "$DMAKE_MAJOR" -lt 7 -o \ 1230 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then 1231 if [ -z "$DMAKE_VERSION" ]; then 1232 echo "$MAKE is missing." 1233 exit 1 1234 fi 1235 echo `whence $MAKE`" version is:" 1236 echo " ${DMAKE_VERSION}" 1237 cat <<EOF 1238 1239This version may not be safe for use. Either set TEAMWARE to a better 1240path or (if you really want to use this version of dmake anyway), add 1241the following to your environment to disable this check: 1242 1243 CHECK_DMAKE=n 1244EOF 1245 exit 1 1246 fi 1247else 1248 PATH="$TEAMWARE/ParallelMake/bin:$PATH" 1249 maketype="parallel" 1250 MAKE=make 1251fi 1252export PATH 1253export MAKE 1254 1255if [ "${SUNWSPRO}" != "" ]; then 1256 PATH="${SUNWSPRO}/bin:$PATH" 1257 export PATH 1258fi 1259 1260hostname=`uname -n` 1261if [ ! -f $HOME/.make.machines ]; then 1262 DMAKE_MAX_JOBS=4 1263else 1264 DMAKE_MAX_JOBS="`grep $hostname $HOME/.make.machines | \ 1265 tail -1 | awk -F= '{print $ 2;}'`" 1266 if [ "$DMAKE_MAX_JOBS" = "" ]; then 1267 DMAKE_MAX_JOBS=4 1268 fi 1269fi 1270DMAKE_MODE=parallel; 1271export DMAKE_MODE 1272export DMAKE_MAX_JOBS 1273 1274if [ -z "${ROOT}" ]; then 1275 echo "ROOT must be set." 1276 exit 1 1277fi 1278 1279if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" ]; then 1280 if [ -z "${EXPORT_SRC}" ]; then 1281 echo "EXPORT_SRC must be set for a source build." 1282 exit 1 1283 fi 1284 if [ -z "${CRYPT_SRC}" ]; then 1285 echo "CRYPT_SRC must be set for a source build." 1286 exit 1 1287 fi 1288fi 1289 1290if [ "$SH_FLAG" = "y" ]; then 1291 if [ -z "${EXPORT_SRC}" ]; then 1292 echo "EXPORT_SRC must be set for a source build." 1293 exit 1 1294 fi 1295fi 1296 1297# 1298# if -V flag was given, reset VERSION to V_ARG 1299# 1300if [ "$V_FLAG" = "y" ]; then 1301 VERSION=$V_ARG 1302fi 1303 1304# 1305# Check for IHV root for copying ihv proto area 1306# 1307if [ "$X_FLAG" = "y" ]; then 1308 if [ "$IA32_IHV_ROOT" = "" ]; then 1309 echo "IA32_IHV_ROOT: must be set for copying ihv proto" 1310 args_ok=n 1311 fi 1312 if [ ! -d "$IA32_IHV_ROOT" ]; then 1313 echo "$IA32_IHV_ROOT: not found" 1314 args_ok=n 1315 fi 1316fi 1317 1318# Append source version 1319if [ "$SE_FLAG" = "y" ]; then 1320 VERSION="${VERSION}:EXPORT" 1321fi 1322 1323if [ "$SD_FLAG" = "y" ]; then 1324 VERSION="${VERSION}:DOMESTIC" 1325fi 1326 1327if [ "$SH_FLAG" = "y" ]; then 1328 VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT" 1329fi 1330 1331TMPDIR="/tmp/nightly.tmpdir.$$" 1332export TMPDIR 1333rm -rf ${TMPDIR} 1334mkdir -p $TMPDIR || exit 1 1335 1336# 1337# Keep elfsign's use of pkcs11_softtoken from looking in the user home 1338# directory, which doesn't always work. Needed until all build machines 1339# have the fix for 6271754 1340# 1341SOFTTOKEN_DIR=$TMPDIR 1342export SOFTTOKEN_DIR 1343 1344TOOLS=${SRC}/tools 1345TOOLS_PROTO=${TOOLS}/proto 1346 1347unset CFLAGS LD_LIBRARY_PATH LDFLAGS 1348 1349# create directories that are automatically removed if the nightly script 1350# fails to start correctly 1351newdir() { 1352 dir=$1 1353 toadd= 1354 while [ ! -d $dir ]; do 1355 toadd="$dir $toadd" 1356 dir=`dirname $dir` 1357 done 1358 torm= 1359 newlist= 1360 for dir in $toadd; do 1361 if staffer mkdir $dir; then 1362 newlist="$ISUSER $dir $newlist" 1363 torm="$dir $torm" 1364 else 1365 [ -z "$torm" ] || staffer rmdir $torm 1366 return 1 1367 fi 1368 done 1369 newdirlist="$newlist $newdirlist" 1370 return 0 1371} 1372newdirlist= 1373 1374[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 1375 1376# since this script assumes the build is from full source, it nullifies 1377# variables likely to have been set by a "ws" script; nullification 1378# confines the search space for headers and libraries to the proto area 1379# built from this immediate source. 1380ENVLDLIBS1= 1381ENVLDLIBS2= 1382ENVLDLIBS3= 1383ENVCPPFLAGS1= 1384ENVCPPFLAGS2= 1385ENVCPPFLAGS3= 1386ENVCPPFLAGS4= 1387PARENT_ROOT= 1388 1389export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1390 PARENT_ROOT 1391 1392ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib" 1393ENVCPPFLAGS1="-I$ROOT/usr/include" 1394 1395export ENVLDLIBS1 ENVLDLIBS2 1396 1397CPIODIR_ORIG=$CPIODIR 1398PKGARCHIVE_ORIG=$PKGARCHIVE 1399IA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS 1400if [ "$SPARC_RM_PKGARCHIVE" ]; then 1401 SPARC_RM_PKGARCHIVE_ORIG=$SPARC_RM_PKGARCHIVE 1402fi 1403 1404# 1405# Juggle the logs and optionally send mail on completion. 1406# 1407 1408logshuffle() { 1409 LLOG="$ATLOG/log.`date '+%m%d'`" 1410 rm -rf $ATLOG/log.??`date '+%d'` 1411 if [ -f $LLOG -o -d $LLOG ]; then 1412 LLOG=$LLOG.$$ 1413 fi 1414 mkdir $LLOG 1415 1416 if [ "$build_ok" = "y" ]; then 1417 mv $ATLOG/proto_list_${MACH} $LLOG 1418 fi 1419 1420 # 1421 # Now that we're about to send mail, it's time to check the noise 1422 # file. In the event that an error occurs beyond this point, it will 1423 # be recorded in the nightly.log file, but nowhere else. This would 1424 # include only errors that cause the copying of the noise log to fail 1425 # or the mail itself not to be sent. 1426 # 1427 1428 exec >>$LOGFILE 2>&1 1429 if [ -s $build_noise_file ]; then 1430 echo "\n==== Nightly build noise ====\n" | 1431 tee -a $LOGFILE >>$mail_msg_file 1432 cat $build_noise_file >>$LOGFILE 1433 cat $build_noise_file >>$mail_msg_file 1434 echo | tee -a $LOGFILE >>$mail_msg_file 1435 fi 1436 rm -f $build_noise_file 1437 1438 case "$build_ok" in 1439 y) 1440 state=Completed 1441 ;; 1442 i) 1443 state=Interrupted 1444 ;; 1445 *) 1446 state=Failed 1447 ;; 1448 esac 1449 1450 cat $build_time_file $mail_msg_file > ${LLOG}/mail_msg 1451 if [ "$m_FLAG" = "y" ]; then 1452 cat $build_time_file $mail_msg_file | 1453 /usr/bin/mailx -s \ 1454 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 1455 ${MAILTO} 1456 fi 1457 1458 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1459 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 1460 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 1461 fi 1462 1463 mv $LOGFILE $LLOG 1464} 1465 1466# 1467# Remove the locks and temporary files on any exit 1468# 1469cleanup() { 1470 logshuffle 1471 1472 [ -z "$lockfile" ] || staffer rm -f $lockfile 1473 [ -z "$atloglockfile" ] || rm -f $atloglockfile 1474 [ -z "$ulockfile" ] || staffer rm -f $ulockfile 1475 [ -z "$Ulockfile" ] || rm -f $Ulockfile 1476 1477 set -- $newdirlist 1478 while [ $# -gt 0 ]; do 1479 ISUSER=$1 staffer rmdir $2 1480 shift; shift 1481 done 1482 rm -rf $TMPDIR 1483} 1484 1485cleanup_signal() { 1486 build_ok=i 1487 # this will trigger cleanup(), above. 1488 exit 1 1489} 1490 1491trap cleanup 0 1492trap cleanup_signal 1 2 3 15 1493 1494# 1495# Generic lock file processing -- make sure that the lock file doesn't 1496# exist. If it does, it should name the build host and PID. If it 1497# doesn't, then make sure we can create it. Clean up locks that are 1498# known to be stale (assumes host name is unique among build systems 1499# for the workspace). 1500create_lock() { 1501 lockf=$1 1502 lockvar=$2 1503 if [ -f $lockf ]; then 1504 basews=`basename $CODEMGR_WS` 1505 if read host user pid < $lockf; then 1506 if [ "$host" != "$hostname" ]; then 1507 echo "$MACH build of $basews apparently" \ 1508 "already started by $user on $host as $pid." 1509 elif kill -s 0 $pid 2>/dev/null; then 1510 echo "$MACH build of $basews already started" \ 1511 "by $user as $pid." 1512 else 1513 # stale lock; clear it out and continue 1514 rm -f $lockf 1515 fi 1516 else 1517 echo "$MACH build of $basews already running." 1518 fi 1519 fi 1520 if [ -f $lockf ]; then 1521 echo "Lock file is $lockf." 1522 exit 1 1523 fi 1524 ldir=`dirname $lockf` 1525 [ -d $ldir ] || newdir $ldir || exit 1 1526 eval $lockvar=$lockf 1527 staffer sh -c "echo $hostname $STAFFER $$ > $lockf" || exit 1 1528} 1529 1530# Ensure no other instance of this script is running on this host. 1531# LOCKNAME can be set in <env_file>, and is by default, but is not 1532# required due to the use of $ATLOG below. 1533if [ -n "$LOCKNAME" ]; then 1534 create_lock /tmp/$LOCKNAME "lockfile" 1535fi 1536# 1537# Create from one, two, or three other locks: 1538# $ATLOG/nightly.lock 1539# - protects against multiple builds in same workspace 1540# $PARENT_WS/usr/src/nightly.$MACH.lock 1541# - protects against multiple 'u' copy-backs 1542# $NIGHTLY_PARENT_ROOT/nightly.lock 1543# - protects against multiple 'U' copy-backs 1544# 1545# Overriding ISUSER to 1 causes the lock to be created as root if the 1546# script is run as root. The default is to create it as $STAFFER. 1547ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 1548if [ "$u_FLAG" = "y" ]; then 1549 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 1550fi 1551if [ "$U_FLAG" = "y" ]; then 1552 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 1553 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 1554fi 1555 1556# Locks have been taken, so we're doing a build and we're committed to 1557# the directories we may have created so far. 1558newdirlist= 1559 1560# 1561# Create mail_msg_file 1562# 1563mail_msg_file="${TMPDIR}/mail_msg" 1564touch $mail_msg_file 1565build_time_file="${TMPDIR}/build_time" 1566# 1567# Move old LOGFILE aside 1568# ATLOG directory already made by 'create_lock' above 1569# 1570if [ -f $LOGFILE ]; then 1571 mv -f $LOGFILE ${LOGFILE}- 1572fi 1573# 1574# Build OsNet source 1575# 1576START_DATE=`date` 1577SECONDS=0 1578echo "\n==== Nightly $maketype build started: $START_DATE ====" \ 1579 | tee -a $LOGFILE > $build_time_file 1580 1581# make sure we log only to the nightly build file 1582build_noise_file="${TMPDIR}/build_noise" 1583exec </dev/null >$build_noise_file 2>&1 1584 1585echo "\n==== list of environment variables ====\n" >> $LOGFILE 1586env >> $LOGFILE 1587 1588echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 1589 1590if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1591 if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then 1592 echo "WARNING: the -S flags do not support incremental" \ 1593 "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE 1594 i_FLAG=n 1595 i_CMD_LINE_FLAG=n 1596 fi 1597 if [ "$N_FLAG" = "n" ]; then 1598 echo "WARNING: the -S flags do not support protocmp;" \ 1599 "protocmp disabled\n" | \ 1600 tee -a $mail_msg_file >> $LOGFILE 1601 N_FLAG=y 1602 fi 1603 if [ "$l_FLAG" = "y" ]; then 1604 echo "WARNING: the -S flags do not support lint;" \ 1605 "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE 1606 l_FLAG=n 1607 fi 1608 if [ "$C_FLAG" = "y" ]; then 1609 echo "WARNING: the -S flags do not support cstyle;" \ 1610 "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE 1611 C_FLAG=n 1612 fi 1613else 1614 if [ "$N_FLAG" = "y" ]; then 1615 if [ "$p_FLAG" = "y" ]; then 1616 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1617WARNING: the p option (create packages) is set, but so is the N option (do 1618 not run protocmp); this is dangerous; you should unset the N option 1619EOF 1620 else 1621 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1622Warning: the N option (do not run protocmp) is set; it probably shouldn't be 1623EOF 1624 fi 1625 echo "" | tee -a $mail_msg_file >> $LOGFILE 1626 fi 1627fi 1628 1629if [ "$a_FLAG" = "y" -a "$D_FLAG" = "n" -a "$F_FLAG" = "y" ]; then 1630 echo "WARNING: Neither DEBUG nor non-DEBUG build requested, but the" \ 1631 "'a' option was set." | tee -a $mail_msg_file >> $LOGFILE 1632fi 1633 1634if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 1635 echo "WARNING: DEBUG build not requested, but lint will be with" \ 1636 "DEBUG enabled.\n" \ 1637 | tee -a $mail_msg_file >> $LOGFILE 1638fi 1639 1640if [ "$f_FLAG" = "y" ]; then 1641 if [ "$i_FLAG" = "y" ]; then 1642 echo "WARNING: the -f flag cannot be used during incremental" \ 1643 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1644 f_FLAG=n 1645 fi 1646 if [ "$p_FLAG" != "y" -o "$l_FLAG" != "y" ]; then 1647 echo "WARNING: the -f flag requires -l and -p; ignoring -f\n" | \ 1648 tee -a $mail_msg_file >> $LOGFILE 1649 f_FLAG=n 1650 fi 1651fi 1652 1653if [ "$T_FLAG" = "y" -a -d $SRC/uts/common/dtrace ]; then 1654 echo "WARNING: TRACE build requested but workspace contains DTrace;" \ 1655 "-T will have no effect\n" | tee -a $mail_msg_file >> $LOGFILE 1656fi 1657 1658if [ "$t_FLAG" = "n" ]; then 1659 # 1660 # We're not doing a tools build, so make sure elfsign(1) is 1661 # new enough to safely sign non-crypto binaries. We test 1662 # debugging output from elfsign to detect the old version. 1663 # 1664 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 1665 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 1666 | egrep algorithmOID` 1667 if [ -z "$newelfsigntest" ]; then 1668 echo "WARNING: /usr/bin/elfsign out of date;" \ 1669 "will only sign crypto modules\n" | \ 1670 tee -a $mail_msg_file >> $LOGFILE 1671 export ELFSIGN_OBJECT=true 1672 elif [ "$VERIFY_ELFSIGN" = "y" ]; then 1673 echo "WARNING: VERIFY_ELFSIGN=y requires" \ 1674 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 1675 tee -a $mail_msg_file >> $LOGFILE 1676 fi 1677fi 1678 1679# copy ihv proto area in addition to the build itself 1680 1681if [ "$X_FLAG" = "y" ]; then 1682 1683 # Install IA32 IHV proto area 1684 copy_ihv_proto 1685fi 1686 1687echo "==== Build environment ====\n" | tee -a $mail_msg_file >> $LOGFILE 1688 1689# System 1690whence uname | tee -a $mail_msg_file >> $LOGFILE 1691uname -a 2>&1 | tee -a $mail_msg_file >> $LOGFILE 1692echo | tee -a $mail_msg_file >> $LOGFILE 1693 1694# nightly (will fail in year 2100 due to SCCS flaw) 1695echo "$0 $@" | tee -a $mail_msg_file >> $LOGFILE 1696echo "%M% version %I% 20%E%\n" | tee -a $mail_msg_file >> $LOGFILE 1697 1698# make 1699whence $MAKE | tee -a $mail_msg_file >> $LOGFILE 1700if [ "$d_FLAG" = "y" ]; then 1701 $MAKE -v | tee -a $mail_msg_file >> $LOGFILE 1702fi 1703echo "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1704 tee -a $mail_msg_file >> $LOGFILE 1705 1706# 1707# Report the compiler versions. 1708# 1709if [ -f $SRC/Makefile ]; then 1710 srcroot=$SRC 1711elif [ -f $BRINGOVER_WS/usr/src/Makefile ]; then 1712 srcroot=$BRINGOVER_WS/usr/src 1713else 1714 echo "\nUnable to find \"Makefile\" in $BRINGOVER_WS/usr/src or $SRC." | 1715 tee -a $mail_msg_file >> $LOGFILE 1716 exit 1 1717fi 1718 1719( cd $srcroot 1720 for target in cc-version cc64-version java-version; do 1721 echo 1722 # 1723 # Put statefile somewhere we know we can write to rather than trip 1724 # over a read-only $srcroot. Use /usr/ccs/bin/make here because 1725 # it supports -K and ParallelMake doesn't. 1726 # 1727 rm -f $TMPDIR/make-state 1728 if /usr/ccs/bin/make -K $TMPDIR/make-state -e $target 2>/dev/null; then 1729 continue 1730 fi 1731 touch $TMPDIR/nocompiler 1732 done 1733 echo 1734) | tee -a $mail_msg_file >> $LOGFILE 1735 1736if [ -f $TMPDIR/nocompiler ]; then 1737 rm -f $TMPDIR/nocompiler 1738 build_ok=n 1739 echo "Aborting due to missing compiler." | 1740 tee -a $mail_msg_file >> $LOGFILE 1741 exit 1 1742fi 1743 1744# as 1745whence as | tee -a $mail_msg_file >> $LOGFILE 1746as -V 2>&1 | head -1 | tee -a $mail_msg_file >> $LOGFILE 1747echo | tee -a $mail_msg_file >> $LOGFILE 1748 1749# Check that we're running a capable link-editor 1750whence ld | tee -a $mail_msg_file >> $LOGFILE 1751LDVER=`ld -V 2>&1` 1752echo $LDVER | tee -a $mail_msg_file >> $LOGFILE 1753LDVER=`echo $LDVER | sed -e "s/.*-1\.//" -e "s/:.*//"` 1754if [ `expr $LDVER \< 422` -eq 1 ]; then 1755 echo "The link-editor needs to be at version 422 or higher to build" | \ 1756 tee -a $mail_msg_file >> $LOGFILE 1757 echo "the latest stuff, hope your build works." | \ 1758 tee -a $mail_msg_file >> $LOGFILE 1759fi 1760 1761echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1762 tee -a $mail_msg_file >> $LOGFILE 1763 1764echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 1765echo $VERSION | tee -a $mail_msg_file >> $LOGFILE 1766 1767# 1768# Decide whether to clobber 1769# 1770if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 1771 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 1772 1773 cd $SRC 1774 # remove old clobber file 1775 rm -f $SRC/clobber.out 1776 rm -f $SRC/clobber-${MACH}.out 1777 1778 # Remove all .make.state* files, just in case we are restarting 1779 # the build after having interrupted a previous 'make clobber'. 1780 find . \( -name SCCS -o -name 'interfaces.*' \) -prune \ 1781 -o -name '.make.*' -print | xargs rm -f 1782 1783 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 1784 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 1785 grep "$MAKE:" $SRC/clobber-${MACH}.out | 1786 egrep -v "Ignoring unknown host" \ 1787 >> $mail_msg_file 1788 1789 if [ "$t_FLAG" = "y" ]; then 1790 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 1791 cd ${TOOLS} 1792 rm -f ${TOOLS}/clobber-${MACH}.out 1793 $MAKE -ek clobber 2>&1 | \ 1794 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 1795 echo "\n==== Make tools clobber ERRORS ====\n" \ 1796 >> $mail_msg_file 1797 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1798 >> $mail_msg_file 1799 rm -rf ${TOOLS_PROTO} 1800 mkdir -p ${TOOLS_PROTO} 1801 fi 1802 rm -rf $ROOT 1803 1804 # Get back to a clean workspace as much as possible to catch 1805 # problems that only occur on fresh workspaces. 1806 # Remove all .make.state* files, libraries, and .o's that may 1807 # have been omitted from clobber. A couple of libraries are 1808 # under SCCS, so leave them alone. 1809 # We should probably blow away temporary directories too. 1810 cd $SRC 1811 find $relsrcdirs \( -name SCCS -o -name 'interfaces.*' \) -prune -o \ 1812 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1813 -name '*.o' \) -print | \ 1814 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 1815else 1816 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 1817fi 1818 1819# 1820# Decide whether to bringover to the codemgr workspace 1821# 1822if [ "$n_FLAG" = "n" ]; then 1823 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1824 # sleep on the parent workspace's lock 1825 while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks 1826 do 1827 sleep 120 1828 done 1829 1830 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1831 staffer $TEAMWARE/bin/bringover -c "nightly update" -p $BRINGOVER_WS \ 1832 -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 | \ 1833 tee -a $mail_msg_file >> $LOGFILE 1834 if [ $? -eq 1 ] 1835 then 1836 echo "trouble with bringover, quitting at `date`." >> $LOGFILE 1837 exit 1 1838 fi 1839 1840 # 1841 # Possible transition from pre-split workspace to split 1842 # workspace. See if the bringover changed anything. 1843 # 1844 CLOSED_IS_PRESENT="$orig_closed_is_present" 1845 check_closed_tree 1846else 1847 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 1848fi 1849 1850# 1851# Build tools if requested 1852# 1853if [ "$t_FLAG" = "y" ]; then 1854 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 1855 export RELEASE_BUILD ; RELEASE_BUILD= 1856 unset EXTRA_OPTIONS 1857 unset EXTRA_CFLAGS 1858 1859 export ONBLD_TOOLS=${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld} 1860 build_tools ${TOOLS_PROTO} 1861fi 1862 1863if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then 1864 echo "\n==== NOT Building base OS-Net source ====\n" | \ 1865 tee -a $LOGFILE >> $mail_msg_file 1866else 1867 normal_build 1868fi 1869 1870ORIG_SRC=$SRC 1871BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 1872 1873if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1874 save_binaries 1875 1876 echo "\n==== Retrieving SCCS files at `date` ====\n" >> $LOGFILE 1877 SCCSHELPER=${TMPDIR}/sccs-helper 1878 rm -f ${SCCSHELPER} 1879cat >${SCCSHELPER} <<EOF 1880#!/bin/ksh 1881cd \$1 1882cd .. 1883sccs get SCCS >/dev/null 2>&1 1884EOF 1885 cd $SRC 1886 chmod +x ${SCCSHELPER} 1887 find $relsrcdirs -name SCCS | xargs -L 1 ${SCCSHELPER} 1888 rm -f ${SCCSHELPER} 1889fi 1890 1891if [ "$SD_FLAG" = "y" ]; then 1892 clone_source ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC 1893fi 1894 1895# EXPORT_SRC comes after CRYPT_SRC since a domestic build will need 1896# $SRC pointing to the export_source usr/src. 1897if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1898 clone_source ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC 1899fi 1900 1901if [ "$SD_FLAG" = "y" ]; then 1902 # drop the crypt files in place. 1903 cd ${EXPORT_SRC} 1904 echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \ 1905 >> ${LOGFILE} 1906 zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \ 1907 cpio -idmucvB 2>/dev/null >> ${LOGFILE} 1908 if [ "$?" = "0" ]; then 1909 echo "\n==== DOMESTIC extraction succeeded ====\n" \ 1910 >> $mail_msg_file 1911 else 1912 echo "\n==== DOMESTIC extraction failed ====\n" \ 1913 >> $mail_msg_file 1914 fi 1915 1916fi 1917 1918if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1919 # remove proto area here, since we don't clobber 1920 rm -rf "$ROOT" 1921 if [ "$t_FLAG" = "y" ]; then 1922 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 1923 export RELEASE_BUILD ; RELEASE_BUILD= 1924 unset EXTRA_OPTIONS 1925 unset EXTRA_CFLAGS 1926 1927 build_tools ${EXPORT_SRC}/usr/src/tools/proto 1928 fi 1929 1930 export EXPORT_RELEASE_BUILD ; EXPORT_RELEASE_BUILD=# 1931 normal_build 1932fi 1933 1934if [ "$build_ok" = "y" ]; then 1935 echo "\n==== Creating protolist system file at `date` ====" \ 1936 >> $LOGFILE 1937 protolist $ROOT > $ATLOG/proto_list_${MACH} 1938 echo "==== protolist system file created at `date` ====\n" \ 1939 >> $LOGFILE 1940 1941 if [ "$N_FLAG" != "y" ]; then 1942 echo "\n==== Impact on packages ====\n" >> $mail_msg_file 1943 1944 # If there is a reference proto list, compare the build's proto 1945 # list with the reference to see changes in proto areas. 1946 # Use the current exception list. 1947 exc=etc/exception_list_$MACH 1948 if [ -f $SRC/pkgdefs/$exc ]; then 1949 ELIST="-e $SRC/pkgdefs/$exc" 1950 fi 1951 1952 if [ -f "$REF_PROTO_LIST" ]; then 1953 $PROTOCMPTERSE \ 1954 "Files in yesterday's proto area, but not today's:" \ 1955 "Files in today's proto area, but not yesterday's:" \ 1956 "Files that changed between yesterday and today:" \ 1957 ${ELIST} \ 1958 -d $REF_PROTO_LIST \ 1959 $ATLOG/proto_list_${MACH} \ 1960 >> $mail_msg_file 1961 fi 1962 # Compare the build's proto list with current package 1963 # definitions to audit the quality of package definitions 1964 # and makefile install targets. Use the current exception list. 1965 PKGDEFS_LIST="" 1966 for d in $abssrcdirs; do 1967 if [ -d $d/pkgdefs ]; then 1968 PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs" 1969 fi 1970 done 1971 1972 $PROTOCMPTERSE \ 1973 "Files missing from the proto area:" \ 1974 "Files missing from packages:" \ 1975 "Inconsistencies between pkgdefs and proto area:" \ 1976 ${ELIST} \ 1977 ${PKGDEFS_LIST} \ 1978 $ATLOG/proto_list_${MACH} \ 1979 >> $mail_msg_file 1980 fi 1981fi 1982 1983if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1984 staffer cp $ATLOG/proto_list_${MACH} \ 1985 $PARENT_WS/usr/src/proto_list_${MACH} 1986fi 1987 1988# Update parent proto area if necessary. This is done now 1989# so that the proto area has either DEBUG or non-DEBUG kernels. 1990# Note that this clears out the lock file, so we can dispense with 1991# the variable now. 1992if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 1993 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 1994 tee -a $LOGFILE >> $mail_msg_file 1995 # The rm -rf command below produces predictable errors if 1996 # nightly is invoked from the parent's $ROOT/opt/onbld/bin, 1997 # and that directory is accessed via NFS. This is because 1998 # deleted-but-still-open files don't actually disappear as 1999 # expected, but rather turn into .nfsXXXX junk files, leaving 2000 # the directory non-empty. Since this is a not-unusual usage 2001 # pattern, and we still want to catch other errors here, we 2002 # take the unusal step of moving aside 'nightly' from that 2003 # directory (if we're using it). 2004 mypath=${0##*/root_$MACH/} 2005 if [ "$mypath" = $0 ]; then 2006 mypath=opt/onbld/bin/${0##*/} 2007 fi 2008 if [ $0 -ef $PARENT_WS/proto/root_$MACH/$mypath ]; then 2009 mv -f $0 $PARENT_WS/proto/root_$MACH 2010 fi 2011 rm -rf $PARENT_WS/proto/root_$MACH/* 2012 unset Ulockfile 2013 mkdir -p $NIGHTLY_PARENT_ROOT 2014 cd $ROOT 2015 ( tar cf - . | ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 2016 tee -a $mail_msg_file >> $LOGFILE 2017fi 2018 2019# 2020# do shared library interface verification 2021# 2022 2023if [ "$A_FLAG" = "y" -a "$build_ok" = "y" ]; then 2024 echo "\n==== Check versioning and ABI information ====\n" | \ 2025 tee -a $LOGFILE >> $mail_msg_file 2026 2027 rm -rf $SRC/interfaces.ref 2028 if [ -d $SRC/interfaces.out ]; then 2029 mv $SRC/interfaces.out $SRC/interfaces.ref 2030 fi 2031 rm -rf $SRC/interfaces.out 2032 mkdir -p $SRC/interfaces.out 2033 2034 intf_check -V -m -o -b $SRC/tools/abi/etc \ 2035 -d $SRC/interfaces.out $ROOT 2>&1 | sort \ 2036 > $SRC/interfaces.out/log 2037 2038 # report any ERROR found in log file 2039 fgrep 'ERROR' $SRC/interfaces.out/log | sed 's/^ERROR: //' | \ 2040 tee -a $LOGFILE >> $mail_msg_file 2041 2042 if [ ! -d $SRC/interfaces.ref ] ; then 2043 mkdir -p $SRC/interfaces.ref 2044 if [ -d $SRC/interfaces.out ]; then 2045 cp -r $SRC/interfaces.out/* $SRC/interfaces.ref 2046 fi 2047 fi 2048 2049 echo "\n==== Diff versioning warnings (since last build) ====\n" | \ 2050 tee -a $LOGFILE >> $mail_msg_file 2051 2052 out_vers=`grep ^VERSION $SRC/interfaces.out/log`; 2053 ref_vers=`grep ^VERSION $SRC/interfaces.ref/log`; 2054 2055 # Report any differences in WARNING messages between last 2056 # and current build. 2057 if [ "$out_vers" = "$ref_vers" ]; then 2058 diff $SRC/interfaces.ref/log $SRC/interfaces.out/log | \ 2059 fgrep 'WARNING' | sed 's/WARNING: //' | \ 2060 tee -a $LOGFILE >> $mail_msg_file 2061 fi 2062fi 2063 2064if [ "$r_FLAG" = "y" -a "$build_ok" = "y" ]; then 2065 echo "\n==== Check ELF runtime attributes ====\n" | \ 2066 tee -a $LOGFILE >> $mail_msg_file 2067 2068 LDDUSAGE="^ldd: does not support -e" 2069 LDDWRONG="wrong class" 2070 CRLERROR="^crle:" 2071 CRLECONF="^crle: configuration file:" 2072 2073 rm -f $SRC/runtime.ref 2074 if [ -f $SRC/runtime.out ]; then 2075 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2076 $SRC/runtime.out > $SRC/runtime.ref 2077 fi 2078 2079 # If we're doing a debug build the proto area will be left with 2080 # debuggable objects, thus don't assert -s. 2081 if [ "$D_FLAG" = "y" ]; then 2082 rtime_sflag="" 2083 else 2084 rtime_sflag="-s" 2085 fi 2086 check_rtime -d $ROOT -i -m -o $rtime_sflag $ROOT 2>&1 | \ 2087 egrep -v ": unreferenced object=$ROOT/.*/lib(w|intl|thread|pthread).so" | \ 2088 egrep -v ": unused object=$ROOT/.*/lib(w|intl|thread|pthread).so" | \ 2089 sort >$SRC/runtime.out 2090 2091 # Determine any processing errors that will affect the final output 2092 # and display these first. 2093 grep -l "$LDDUSAGE" $SRC/runtime.out > /dev/null 2094 if [ $? -eq 0 ]; then 2095 echo "WARNING: ldd(1) does not support -e. The version of ldd(1)" | \ 2096 tee -a $LOGFILE >> $mail_msg_file 2097 echo "on your system is old - 4390308 (s81_30) is required.\n" | \ 2098 tee -a $LOGFILE >> $mail_msg_file 2099 fi 2100 grep -l "$LDDWRONG" $SRC/runtime.out > /dev/null 2101 if [ $? -eq 0 ]; then 2102 echo "WARNING: wrong class message detected. ldd(1) was unable" | \ 2103 tee -a $LOGFILE >> $mail_msg_file 2104 echo "to execute an object, thus it could not be checked fully." | \ 2105 tee -a $LOGFILE >> $mail_msg_file 2106 echo "Perhaps a 64-bit object was encountered on a 32-bit system," | \ 2107 tee -a $LOGFILE >> $mail_msg_file 2108 echo "or an i386 object was encountered on a sparc system?\n" | \ 2109 tee -a $LOGFILE >> $mail_msg_file 2110 fi 2111 grep -l "$CRLECONF" $SRC/runtime.out > /dev/null 2112 if [ $? -eq 0 ]; then 2113 echo "WARNING: creation of an alternative dependency cache failed." | \ 2114 tee -a $LOGFILE >> $mail_msg_file 2115 echo "Dependencies will bind to the base system libraries.\n" | \ 2116 tee -a $LOGFILE >> $mail_msg_file 2117 grep "$CRLECONF" $SRC/runtime.out | \ 2118 tee -a $LOGFILE >> $mail_msg_file 2119 grep "$CRLERROR" $SRC/runtime.out | grep -v "$CRLECONF" | \ 2120 tee -a $LOGFILE >> $mail_msg_file 2121 echo "\n" | tee -a $LOGFILE >> $mail_msg_file 2122 fi 2123 2124 egrep '<dependency no longer necessary>' $SRC/runtime.out | \ 2125 tee -a $LOGFILE >> $mail_msg_file 2126 2127 # NEEDED= and RPATH= are informational; report anything else that we 2128 # haven't already. 2129 egrep -v "NEEDED=|RPATH=|$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2130 $SRC/runtime.out | tee -a $LOGFILE >> $mail_msg_file 2131 2132 # probably should compare against a 'known ok runpaths' list 2133 if [ ! -f $SRC/runtime.ref ]; then 2134 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2135 $SRC/runtime.out > $SRC/runtime.ref 2136 fi 2137 2138 echo "\n==== Diff ELF runtime attributes (since last build) ====\n" \ 2139 >> $mail_msg_file 2140 2141 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" $SRC/runtime.out | \ 2142 diff $SRC/runtime.ref - >> $mail_msg_file 2143fi 2144 2145# For now, don't make archives or packages for GPROF/TRACE builds 2146a_FLAG=n 2147p_FLAG=n 2148 2149# GPROF build begins 2150 2151if [ "$i_CMD_LINE_FLAG" = "n" -a "$P_FLAG" = "y" ]; then 2152 2153 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 2154 export RELEASE_BUILD ; RELEASE_BUILD= 2155 export EXTRA_OPTIONS ; EXTRA_OPTIONS="-DGPROF" 2156 export EXTRA_CFLAGS ; EXTRA_CFLAGS="-xpg" 2157 2158 build GPROF -prof 2159 2160else 2161 echo "\n==== No GPROF build ====\n" >> $LOGFILE 2162fi 2163 2164# GPROF build ends 2165 2166# TRACE build begins 2167 2168if [ "$i_CMD_LINE_FLAG" = "n" -a "$T_FLAG" = "y" ]; then 2169 2170 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 2171 export RELEASE_BUILD ; RELEASE_BUILD= 2172 export EXTRA_OPTIONS ; EXTRA_OPTIONS="-DTRACE" 2173 unset EXTRA_CFLAGS 2174 2175 build TRACE -trace 2176 2177else 2178 echo "\n==== No TRACE build ====\n" >> $LOGFILE 2179fi 2180 2181# TRACE build ends 2182 2183# DEBUG lint of kernel begins 2184 2185if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 2186 if [ "$LINTDIRS" = "" ]; then 2187 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 2188 LINTDIRS="$SRC y" 2189 fi 2190 set $LINTDIRS 2191 while [ $# -gt 0 ]; do 2192 dolint $1 $2; shift; shift 2193 done 2194else 2195 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 2196fi 2197 2198# "make check" begins 2199 2200if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 2201 # remove old check.out 2202 rm -f $SRC/check.out 2203 2204 rm -f $SRC/check-${MACH}.out 2205 cd $SRC 2206 $MAKE -ek check 2>&1 | tee -a $SRC/check-${MACH}.out >> $LOGFILE 2207 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 2208 2209 grep ":" $SRC/check-${MACH}.out | 2210 egrep -v "Ignoring unknown host" | \ 2211 sort | uniq >> $mail_msg_file 2212else 2213 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 2214fi 2215 2216echo "\n==== Find core files ====\n" | \ 2217 tee -a $LOGFILE >> $mail_msg_file 2218 2219find $abssrcdirs -name core -a -type f -exec file {} \; | \ 2220 tee -a $LOGFILE >> $mail_msg_file 2221 2222if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2223 echo "\n==== Diff unreferenced files (since last build) ====\n" \ 2224 | tee -a $LOGFILE >>$mail_msg_file 2225 rm -f $SRC/unref-${MACH}.ref 2226 if [ -f $SRC/unref-${MACH}.out ]; then 2227 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2228 fi 2229 2230 findunref -t $SRC/.build.tstamp $SRC/.. \ 2231 ${TOOLS}/findunref/exception_list \ 2232 2>> $mail_msg_file | sort | \ 2233 sed -e s=^./src/=./= -e s=^./closed/=../closed/= \ 2234 > $SRC/unref-${MACH}.out 2235 2236 if [ ! -f $SRC/unref-${MACH}.ref ]; then 2237 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2238 fi 2239 2240 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 2241fi 2242 2243# Verify that the usual lists of files, such as exception lists, 2244# contain only valid references to files. If the build has failed, 2245# then don't check the proto area. 2246CHECK_PATHS=${CHECK_PATHS:-y} 2247if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 2248 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 2249 >>$mail_msg_file 2250 arg=-b 2251 [ "$build_ok" = y ] && arg= 2252 checkpaths $arg $ROOT 2>&1 | tee -a $LOGFILE >>$mail_msg_file 2253fi 2254 2255if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2256 echo "\n==== Impact on file permissions ====\n" \ 2257 >> $mail_msg_file 2258 # 2259 # Get pkginfo files from usr/src/pkgdefs 2260 # 2261 pmodes -qvdP \ 2262 `for d in $abssrcdirs; do 2263 if [ -d "$d/pkgdefs" ] 2264 then 2265 find $d/pkgdefs -name pkginfo.tmpl -print -o -name .del\* -prune 2266 fi 2267 done | sed -e 's:/pkginfo.tmpl$::' | sort -u ` >> $mail_msg_file 2268fi 2269 2270END_DATE=`date` 2271echo "==== Nightly $maketype build completed: $END_DATE ====" | \ 2272 tee -a $LOGFILE >> $build_time_file 2273 2274typeset -Z2 minutes 2275typeset -Z2 seconds 2276 2277elapsed_time=$SECONDS 2278((hours = elapsed_time / 3600 )) 2279((minutes = elapsed_time / 60 % 60)) 2280((seconds = elapsed_time % 60)) 2281 2282echo "\n==== Total build time ====" | \ 2283 tee -a $LOGFILE >> $build_time_file 2284echo "\nreal ${hours}:${minutes}:${seconds}" | \ 2285 tee -a $LOGFILE >> $build_time_file 2286 2287if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2288 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 2289 2290 # 2291 # Produce a master list of unreferenced files -- ideally, we'd 2292 # generate the master just once after all of the nightlies 2293 # have finished, but there's no simple way to know when that 2294 # will be. Instead, we assume that we're the last nightly to 2295 # finish and merge all of the unref-${MACH}.out files in 2296 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 2297 # finish, then this file will be the authoritative master 2298 # list. Otherwise, another ${MACH}'s nightly will eventually 2299 # overwrite ours with its own master, but in the meantime our 2300 # temporary "master" will be no worse than any older master 2301 # which was already on the parent. 2302 # 2303 2304 set -- $PARENT_WS/usr/src/unref-*.out 2305 cp "$1" ${TMPDIR}/unref.merge 2306 shift 2307 2308 for unreffile; do 2309 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 2310 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 2311 done 2312 2313 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 2314fi 2315 2316# 2317# All done save for the sweeping up. 2318# (whichever exit we hit here will trigger the "cleanup" trap which 2319# optionally sends mail on completion). 2320# 2321if [ "$build_ok" = "y" ]; then 2322 exit 0 2323fi 2324exit 1 2325