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 770MACH=`uname -p` 771 772if [ "$OPTHOME" = "" ]; then 773 OPTHOME=/opt 774 export OPTHOME 775fi 776if [ "$TEAMWARE" = "" ]; then 777 TEAMWARE=$OPTHOME/teamware 778 export TEAMWARE 779fi 780 781USAGE='Usage: nightly [-in] [-V VERS ] [ -S E|D|H ] <env_file> 782 783Where: 784 -i Fast incremental options (no clobber, lint, check, gprof, trace) 785 -n Do not do a bringover 786 -V VERS set the build version string to VERS 787 -S Build a variant of the source product 788 E - build exportable source 789 D - build domestic source (exportable + crypt) 790 H - build hybrid source (binaries + deleted source) 791 792 <env_file> file in Bourne shell syntax that sets and exports 793 variables that configure the operation of this script and many of 794 the scripts this one calls. If <env_file> does not exist, 795 it will be looked for in $OPTHOME/onbld/env. 796 797non-DEBUG is the default build type. Build options can be set in the 798NIGHTLY_OPTIONS variable in the <env_file> as follows: 799 800 -A check for ABI differences in .so files 801 -C check for cstyle/hdrchk errors 802 -D do a build with DEBUG on 803 -F do _not_ do a non-DEBUG build 804 -G gate keeper default group of options (-au) 805 -I integration engineer default group of options (-ampu) 806 -M do not run pmodes (safe file permission checker) 807 -N do not run protocmp 808 -P do a build with GPROF on 809 -R default group of options for building a release (-mp) 810 -T do a build with TRACE on 811 -U update proto area in the parent 812 -V VERS set the build version string to VERS 813 -X copy x86 IHV proto area 814 -a create cpio archives 815 -d use Distributed Make (default uses Parallel Make) 816 -f find unreferenced files 817 -i do an incremental build (no "make clobber") 818 -l do "make lint" in $LINTDIRS (default: $SRC y) 819 -m send mail to $MAILTO at end of build 820 -n do not do a bringover 821 -o build using root privileges to set OWNER/GROUP (old style) 822 -p create packages 823 -r check ELF runtime attributes in the proto area 824 -t build and use the tools in $SRC/tools 825 -u update proto_list_$MACH and friends in the parent workspace; 826 when used with -f, also build an unrefmaster.out in the parent 827 -z compress cpio archives with gzip 828 -W Do not report warnings (freeware gate ONLY) 829 -S Build a variant of the source product 830 E - build exportable source 831 D - build domestic source (exportable + crypt) 832 H - build hybrid source (binaries + deleted source) 833' 834# 835# -x less public handling of xmod source for the source product 836# 837# A log file will be generated under the name $LOGFILE 838# for partially completed build and log.`date '+%m%d%y'` 839# in the same directory for fully completed builds. 840# 841 842# default values for low-level FLAGS; G I R are group FLAGS 843A_FLAG=n 844a_FLAG=n 845d_FLAG=n 846C_FLAG=n 847F_FLAG=n 848f_FLAG=n 849D_FLAG=n 850P_FLAG=n 851T_FLAG=n 852n_FLAG=n 853o_FLAG=n 854i_FLAG=n; i_CMD_LINE_FLAG=n 855l_FLAG=n 856m_FLAG=n 857p_FLAG=n 858r_FLAG=n 859t_FLAG=n 860u_FLAG=n 861U_FLAG=n 862V_FLAG=n 863M_FLAG=n 864N_FLAG=n 865z_FLAG=n 866W_FLAG=n 867SE_FLAG=n 868SD_FLAG=n 869SH_FLAG=n 870X_FLAG=n 871# 872XMOD_OPT= 873# 874build_ok=y 875# 876# examine arguments 877# 878 879OPTIND=1 880while getopts inV:S:t FLAG 881do 882 case $FLAG in 883 i ) i_FLAG=y; i_CMD_LINE_FLAG=y 884 ;; 885 n ) n_FLAG=y 886 ;; 887 V ) V_FLAG=y 888 V_ARG="$OPTARG" 889 ;; 890 S ) 891 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 892 echo "Can only build one source variant at a time." 893 exit 1 894 fi 895 if [ "${OPTARG}" = "E" ]; then 896 SE_FLAG=y 897 elif [ "${OPTARG}" = "D" ]; then 898 SD_FLAG=y 899 elif [ "${OPTARG}" = "H" ]; then 900 SH_FLAG=y 901 else 902 echo "$USAGE" 903 exit 1 904 fi 905 ;; 906 t ) t_FLAG=y 907 ;; 908 \? ) echo "$USAGE" 909 exit 1 910 ;; 911 esac 912done 913 914# correct argument count after options 915shift `expr $OPTIND - 1` 916 917# test that the path to the environment-setting file was given 918if [ $# -ne 1 ]; then 919 echo "$USAGE" 920 exit 1 921fi 922 923# check if user is running nightly as root 924# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 925# when root invokes nightly. 926/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 927ISUSER=$?; export ISUSER 928 929# 930# force locale to C 931LC_COLLATE=C; export LC_COLLATE 932LC_CTYPE=C; export LC_CTYPE 933LC_MESSAGES=C; export LC_MESSAGES 934LC_MONETARY=C; export LC_MONETARY 935LC_NUMERIC=C; export LC_NUMERIC 936LC_TIME=C; export LC_TIME 937 938# clear environment variables we know to be bad for the build 939unset LD_OPTIONS 940unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 941unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 942unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 943unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 944unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 945unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 946unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 947unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 948unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 949unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 950unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 951unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 952unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 953unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 954unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 955unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 956unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 957unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 958unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 959unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 960 961unset CONFIG 962unset GROUP 963unset OWNER 964unset REMOTE 965unset ENV 966unset ARCH 967unset CLASSPATH 968unset NAME 969 970# 971# Setup environmental variables 972# 973if [ -f $1 ]; then 974 if [[ $1 = */* ]]; then 975 . $1 976 else 977 . ./$1 978 fi 979else 980 if [ -f $OPTHOME/onbld/env/$1 ]; then 981 . $OPTHOME/onbld/env/$1 982 else 983 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 984 exit 1 985 fi 986fi 987 988# 989# place ourselves in a new task, respecting BUILD_PROJECT if set. 990# 991if [ -z "$BUILD_PROJECT" ]; then 992 /usr/bin/newtask -c $$ 993else 994 /usr/bin/newtask -c $$ -p $BUILD_PROJECT 995fi 996 997ps -o taskid= -p $$ | read build_taskid 998ps -o project= -p $$ | read build_project 999 1000# 1001# See if NIGHTLY_OPTIONS is set 1002# 1003if [ "$NIGHTLY_OPTIONS" = "" ]; then 1004 NIGHTLY_OPTIONS="-aBm" 1005fi 1006 1007# 1008# If BRINGOVER_WS was not specified, let it default to CLONE_WS 1009# 1010if [ "$BRINGOVER_WS" = "" ]; then 1011 BRINGOVER_WS=$CLONE_WS 1012fi 1013 1014# 1015# If BRINGOVER_FILES was not specified, default to usr 1016# 1017if [ "$BRINGOVER_FILES" = "" ]; then 1018 BRINGOVER_FILES="usr" 1019fi 1020 1021if [ -z "$CLOSED_IS_PRESENT" ]; then 1022 # 1023 # See if the closed tree is present. If the current workspace 1024 # is empty, check the bringover workspace. (This is for 1025 # builds that start out with nothing but the environment 1026 # file.) 1027 # 1028 if [ -d $SRC/../closed ]; then 1029 CLOSED_IS_PRESENT="yes" 1030 elif [ -d $SRC ]; then 1031 CLOSED_IS_PRESENT="no" 1032 elif [ -d $CLONE_WS/usr/closed ]; then 1033 CLOSED_IS_PRESENT="yes" 1034 else 1035 CLOSED_IS_PRESENT="no" 1036 fi 1037 export CLOSED_IS_PRESENT 1038fi 1039 1040# 1041# If the closed sources are not present, the closed binaries must be 1042# present for the build to succeed. If there's no pointer to the 1043# closed binaries, flag that now, rather than forcing the user to wait 1044# a couple hours (or more) to find out. 1045# 1046if [[ "$CLOSED_IS_PRESENT" = no && ! -d "$ON_CLOSED_BINS" ]]; then 1047 # 1048 # If it's an old (pre-split) tree, don't complain. 1049 # 1050 if grep CLOSED_BUILD $SRC/Makefile.master > /dev/null; then 1051 echo "If the closed sources are not present, ON_CLOSED_BINS" 1052 echo "must point to the closed binaries tree." 1053 exit 1 1054 fi 1055fi 1056 1057# 1058# Note: changes to the option letters here should also be applied to the 1059# bldenv script. 1060# 1061OPTIND=1 1062while getopts ABDFNMPTCGIRafinlmoptuUxdrtzWS:X FLAG $NIGHTLY_OPTIONS 1063do 1064 case $FLAG in 1065 A ) A_FLAG=y 1066 ;; 1067 B ) D_FLAG=y 1068 ;; # old version of D 1069 F ) F_FLAG=y 1070 ;; 1071 D ) D_FLAG=y 1072 ;; 1073 P ) P_FLAG=y 1074 ;; 1075 T ) T_FLAG=y 1076 ;; 1077 C ) C_FLAG=y 1078 ;; 1079 M ) M_FLAG=y 1080 ;; 1081 N ) N_FLAG=y 1082 ;; 1083 G ) a_FLAG=y 1084 u_FLAG=y 1085 ;; 1086 I ) a_FLAG=y 1087 m_FLAG=y 1088 p_FLAG=y 1089 u_FLAG=y 1090 ;; 1091 R ) m_FLAG=y 1092 p_FLAG=y 1093 ;; 1094 a ) a_FLAG=y 1095 ;; 1096 d ) d_FLAG=y 1097 ;; 1098 f ) f_FLAG=y 1099 ;; 1100 i ) i_FLAG=y 1101 ;; 1102 n ) n_FLAG=y 1103 ;; 1104 o ) o_FLAG=y 1105 ;; 1106 l ) l_FLAG=y 1107 ;; 1108 m ) m_FLAG=y 1109 ;; 1110 p ) p_FLAG=y 1111 ;; 1112 r ) r_FLAG=y 1113 ;; 1114 t ) t_FLAG=y 1115 ;; 1116 u ) u_FLAG=y 1117 ;; 1118 z ) z_FLAG=y 1119 ;; 1120 U ) 1121 if [ -z "${PARENT_ROOT}" ]; then 1122 echo "PARENT_ROOT must be set if the U flag is" \ 1123 "present in NIGHTLY_OPTIONS." 1124 exit 1 1125 fi 1126 U_FLAG=y 1127 NIGHTLY_PARENT_ROOT=$PARENT_ROOT 1128 ;; 1129 x ) XMOD_OPT="-x" 1130 ;; 1131 W ) W_FLAG=y 1132 ;; 1133 S ) 1134 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1135 echo "Can only build one source variant at a time." 1136 exit 1 1137 fi 1138 if [ "${OPTARG}" = "E" ]; then 1139 SE_FLAG=y 1140 elif [ "${OPTARG}" = "D" ]; then 1141 SD_FLAG=y 1142 elif [ "${OPTARG}" = "H" ]; then 1143 SH_FLAG=y 1144 else 1145 echo "$USAGE" 1146 exit 1 1147 fi 1148 ;; 1149 X ) # now that we no longer need realmode builds, just 1150 # copy IHV packages. only meaningful on x86. 1151 if [ "$MACH" = "i386" ]; then 1152 X_FLAG=y 1153 fi 1154 ;; 1155 \? ) echo "$USAGE" 1156 exit 1 1157 ;; 1158 esac 1159done 1160 1161if [ $ISUSER -ne 0 ]; then 1162 if [ "$o_FLAG" = "y" ]; then 1163 echo "Old-style build requires root permission." 1164 exit 1 1165 fi 1166 1167 # Set default value for STAFFER, if needed. 1168 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 1169 STAFFER=`/usr/xpg4/bin/id -un` 1170 export STAFFER 1171 fi 1172fi 1173 1174if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 1175 MAILTO=$STAFFER 1176 export MAILTO 1177fi 1178 1179PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 1180PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb" 1181PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 1182export PATH 1183 1184# roots of source trees, both relative to $SRC and absolute. 1185relsrcdirs="." 1186if [[ -d $SRC/../closed && "$CLOSED_IS_PRESENT" != no ]]; then 1187 relsrcdirs="$relsrcdirs ../closed" 1188fi 1189abssrcdirs="" 1190for d in $relsrcdirs; do 1191 abssrcdirs="$abssrcdirs $SRC/$d" 1192done 1193 1194unset CH 1195if [ "$o_FLAG" = "y" ]; then 1196# root invoked old-style build -- make sure it works as it always has 1197# by exporting 'CH'. The current Makefile.master doesn't use this, but 1198# the old ones still do. 1199 PROTOCMPTERSE="protocmp.terse" 1200 CH= 1201 export CH 1202else 1203 PROTOCMPTERSE="protocmp.terse -gu" 1204fi 1205POUND_SIGN="#" 1206 1207# we export POUND_SIGN to speed up the build process -- prevents evaluation of 1208# the Makefile.master definitions. 1209export o_FLAG POUND_SIGN 1210 1211if [ "$d_FLAG" = "y" ]; then 1212 maketype="distributed" 1213 MAKE=dmake 1214 # get the dmake version string alone 1215 DMAKE_VERSION=$( $MAKE -v ) 1216 DMAKE_VERSION=${DMAKE_VERSION#*: } 1217 # focus in on just the dotted version number alone 1218 DMAKE_MAJOR=$( echo $DMAKE_VERSION | \ 1219 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' ) 1220 # extract the second (or final) integer 1221 DMAKE_MINOR=${DMAKE_MAJOR#*.} 1222 DMAKE_MINOR=${DMAKE_MINOR%%.*} 1223 # extract the first integer 1224 DMAKE_MAJOR=${DMAKE_MAJOR%%.*} 1225 CHECK_DMAKE=${CHECK_DMAKE:-y} 1226 # x86 was built on the 12th, sparc on the 13th. 1227 if [ "$CHECK_DMAKE" = "y" -a \ 1228 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \ 1229 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \ 1230 "$DMAKE_MAJOR" -lt 7 -o \ 1231 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then 1232 if [ -z "$DMAKE_VERSION" ]; then 1233 echo "$MAKE is missing." 1234 exit 1 1235 fi 1236 echo `whence $MAKE`" version is:" 1237 echo " ${DMAKE_VERSION}" 1238 cat <<EOF 1239 1240This version may not be safe for use. Either set TEAMWARE to a better 1241path or (if you really want to use this version of dmake anyway), add 1242the following to your environment to disable this check: 1243 1244 CHECK_DMAKE=n 1245EOF 1246 exit 1 1247 fi 1248else 1249 PATH="$TEAMWARE/ParallelMake/bin:$PATH" 1250 maketype="parallel" 1251 MAKE=make 1252fi 1253export PATH 1254export MAKE 1255 1256if [ "${SUNWSPRO}" != "" ]; then 1257 PATH="${SUNWSPRO}/bin:$PATH" 1258 export PATH 1259fi 1260 1261hostname=`uname -n` 1262if [ ! -f $HOME/.make.machines ]; then 1263 DMAKE_MAX_JOBS=4 1264else 1265 DMAKE_MAX_JOBS="`grep $hostname $HOME/.make.machines | \ 1266 tail -1 | awk -F= '{print $ 2;}'`" 1267 if [ "$DMAKE_MAX_JOBS" = "" ]; then 1268 DMAKE_MAX_JOBS=4 1269 fi 1270fi 1271DMAKE_MODE=parallel; 1272export DMAKE_MODE 1273export DMAKE_MAX_JOBS 1274 1275if [ -z "${ROOT}" ]; then 1276 echo "ROOT must be set." 1277 exit 1 1278fi 1279 1280if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" ]; then 1281 if [ -z "${EXPORT_SRC}" ]; then 1282 echo "EXPORT_SRC must be set for a source build." 1283 exit 1 1284 fi 1285 if [ -z "${CRYPT_SRC}" ]; then 1286 echo "CRYPT_SRC must be set for a source build." 1287 exit 1 1288 fi 1289fi 1290 1291if [ "$SH_FLAG" = "y" ]; then 1292 if [ -z "${EXPORT_SRC}" ]; then 1293 echo "EXPORT_SRC must be set for a source build." 1294 exit 1 1295 fi 1296fi 1297 1298# 1299# if -V flag was given, reset VERSION to V_ARG 1300# 1301if [ "$V_FLAG" = "y" ]; then 1302 VERSION=$V_ARG 1303fi 1304 1305# 1306# Check for IHV root for copying ihv proto area 1307# 1308if [ "$X_FLAG" = "y" ]; then 1309 if [ "$IA32_IHV_ROOT" = "" ]; then 1310 echo "IA32_IHV_ROOT: must be set for copying ihv proto" 1311 args_ok=n 1312 fi 1313 if [ ! -d "$IA32_IHV_ROOT" ]; then 1314 echo "$IA32_IHV_ROOT: not found" 1315 args_ok=n 1316 fi 1317fi 1318 1319# Append source version 1320if [ "$SE_FLAG" = "y" ]; then 1321 VERSION="${VERSION}:EXPORT" 1322fi 1323 1324if [ "$SD_FLAG" = "y" ]; then 1325 VERSION="${VERSION}:DOMESTIC" 1326fi 1327 1328if [ "$SH_FLAG" = "y" ]; then 1329 VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT" 1330fi 1331 1332TMPDIR="/tmp/nightly.tmpdir.$$" 1333export TMPDIR 1334rm -rf ${TMPDIR} 1335mkdir -p $TMPDIR || exit 1 1336 1337# 1338# Keep elfsign's use of pkcs11_softtoken from looking in the user home 1339# directory, which doesn't always work. Needed until all build machines 1340# have the fix for 6271754 1341# 1342SOFTTOKEN_DIR=$TMPDIR 1343export SOFTTOKEN_DIR 1344 1345TOOLS=${SRC}/tools 1346TOOLS_PROTO=${TOOLS}/proto 1347 1348unset CFLAGS LD_LIBRARY_PATH LDFLAGS 1349 1350# create directories that are automatically removed if the nightly script 1351# fails to start correctly 1352newdir() { 1353 dir=$1 1354 toadd= 1355 while [ ! -d $dir ]; do 1356 toadd="$dir $toadd" 1357 dir=`dirname $dir` 1358 done 1359 torm= 1360 newlist= 1361 for dir in $toadd; do 1362 if staffer mkdir $dir; then 1363 newlist="$ISUSER $dir $newlist" 1364 torm="$dir $torm" 1365 else 1366 [ -z "$torm" ] || staffer rmdir $torm 1367 return 1 1368 fi 1369 done 1370 newdirlist="$newlist $newdirlist" 1371 return 0 1372} 1373newdirlist= 1374 1375[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 1376 1377# since this script assumes the build is from full source, it nullifies 1378# variables likely to have been set by a "ws" script; nullification 1379# confines the search space for headers and libraries to the proto area 1380# built from this immediate source. 1381ENVLDLIBS1= 1382ENVLDLIBS2= 1383ENVLDLIBS3= 1384ENVCPPFLAGS1= 1385ENVCPPFLAGS2= 1386ENVCPPFLAGS3= 1387ENVCPPFLAGS4= 1388PARENT_ROOT= 1389 1390export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1391 PARENT_ROOT 1392 1393ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib" 1394ENVCPPFLAGS1="-I$ROOT/usr/include" 1395 1396export ENVLDLIBS1 ENVLDLIBS2 1397 1398CPIODIR_ORIG=$CPIODIR 1399PKGARCHIVE_ORIG=$PKGARCHIVE 1400IA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS 1401if [ "$SPARC_RM_PKGARCHIVE" ]; then 1402 SPARC_RM_PKGARCHIVE_ORIG=$SPARC_RM_PKGARCHIVE 1403fi 1404 1405# 1406# Juggle the logs and optionally send mail on completion. 1407# 1408 1409logshuffle() { 1410 LLOG="$ATLOG/log.`date '+%m%d'`" 1411 rm -rf $ATLOG/log.??`date '+%d'` 1412 if [ -f $LLOG -o -d $LLOG ]; then 1413 LLOG=$LLOG.$$ 1414 fi 1415 mkdir $LLOG 1416 1417 if [ "$build_ok" = "y" ]; then 1418 mv $ATLOG/proto_list_${MACH} $LLOG 1419 fi 1420 1421 # 1422 # Now that we're about to send mail, it's time to check the noise 1423 # file. In the event that an error occurs beyond this point, it will 1424 # be recorded in the nightly.log file, but nowhere else. This would 1425 # include only errors that cause the copying of the noise log to fail 1426 # or the mail itself not to be sent. 1427 # 1428 1429 exec >>$LOGFILE 2>&1 1430 if [ -s $build_noise_file ]; then 1431 echo "\n==== Nightly build noise ====\n" | 1432 tee -a $LOGFILE >>$mail_msg_file 1433 cat $build_noise_file >>$LOGFILE 1434 cat $build_noise_file >>$mail_msg_file 1435 echo | tee -a $LOGFILE >>$mail_msg_file 1436 fi 1437 rm -f $build_noise_file 1438 1439 case "$build_ok" in 1440 y) 1441 state=Completed 1442 ;; 1443 i) 1444 state=Interrupted 1445 ;; 1446 *) 1447 state=Failed 1448 ;; 1449 esac 1450 1451 cat $build_time_file $mail_msg_file > ${LLOG}/mail_msg 1452 if [ "$m_FLAG" = "y" ]; then 1453 cat $build_time_file $mail_msg_file | 1454 /usr/bin/mailx -s \ 1455 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \ 1456 ${MAILTO} 1457 fi 1458 1459 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1460 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH} 1461 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log 1462 fi 1463 1464 mv $LOGFILE $LLOG 1465} 1466 1467# 1468# Remove the locks and temporary files on any exit 1469# 1470cleanup() { 1471 logshuffle 1472 1473 [ -z "$lockfile" ] || staffer rm -f $lockfile 1474 [ -z "$atloglockfile" ] || rm -f $atloglockfile 1475 [ -z "$ulockfile" ] || staffer rm -f $ulockfile 1476 [ -z "$Ulockfile" ] || rm -f $Ulockfile 1477 1478 set -- $newdirlist 1479 while [ $# -gt 0 ]; do 1480 ISUSER=$1 staffer rmdir $2 1481 shift; shift 1482 done 1483 rm -rf $TMPDIR 1484} 1485 1486cleanup_signal() { 1487 build_ok=i 1488 # this will trigger cleanup(), above. 1489 exit 1 1490} 1491 1492trap cleanup 0 1493trap cleanup_signal 1 2 3 15 1494 1495# 1496# Generic lock file processing -- make sure that the lock file doesn't 1497# exist. If it does, it should name the build host and PID. If it 1498# doesn't, then make sure we can create it. Clean up locks that are 1499# known to be stale (assumes host name is unique among build systems 1500# for the workspace). 1501create_lock() { 1502 lockf=$1 1503 lockvar=$2 1504 if [ -f $lockf ]; then 1505 basews=`basename $CODEMGR_WS` 1506 if read host user pid < $lockf; then 1507 if [ "$host" != "$hostname" ]; then 1508 echo "$MACH build of $basews apparently" \ 1509 "already started by $user on $host as $pid." 1510 elif kill -s 0 $pid 2>/dev/null; then 1511 echo "$MACH build of $basews already started" \ 1512 "by $user as $pid." 1513 else 1514 # stale lock; clear it out and continue 1515 rm -f $lockf 1516 fi 1517 else 1518 echo "$MACH build of $basews already running." 1519 fi 1520 fi 1521 if [ -f $lockf ]; then 1522 echo "Lock file is $lockf." 1523 exit 1 1524 fi 1525 ldir=`dirname $lockf` 1526 [ -d $ldir ] || newdir $ldir || exit 1 1527 eval $lockvar=$lockf 1528 staffer sh -c "echo $hostname $STAFFER $$ > $lockf" || exit 1 1529} 1530 1531# Ensure no other instance of this script is running on this host. 1532# LOCKNAME can be set in <env_file>, and is by default, but is not 1533# required due to the use of $ATLOG below. 1534if [ -n "$LOCKNAME" ]; then 1535 create_lock /tmp/$LOCKNAME "lockfile" 1536fi 1537# 1538# Create from one, two, or three other locks: 1539# $ATLOG/nightly.lock 1540# - protects against multiple builds in same workspace 1541# $PARENT_WS/usr/src/nightly.$MACH.lock 1542# - protects against multiple 'u' copy-backs 1543# $NIGHTLY_PARENT_ROOT/nightly.lock 1544# - protects against multiple 'U' copy-backs 1545# 1546# Overriding ISUSER to 1 causes the lock to be created as root if the 1547# script is run as root. The default is to create it as $STAFFER. 1548ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile" 1549if [ "$u_FLAG" = "y" ]; then 1550 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile" 1551fi 1552if [ "$U_FLAG" = "y" ]; then 1553 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root. 1554 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile" 1555fi 1556 1557# Locks have been taken, so we're doing a build and we're committed to 1558# the directories we may have created so far. 1559newdirlist= 1560 1561# 1562# Create mail_msg_file 1563# 1564mail_msg_file="${TMPDIR}/mail_msg" 1565touch $mail_msg_file 1566build_time_file="${TMPDIR}/build_time" 1567# 1568# Move old LOGFILE aside 1569# ATLOG directory already made by 'create_lock' above 1570# 1571if [ -f $LOGFILE ]; then 1572 mv -f $LOGFILE ${LOGFILE}- 1573fi 1574# 1575# Build OsNet source 1576# 1577START_DATE=`date` 1578SECONDS=0 1579echo "\n==== Nightly $maketype build started: $START_DATE ====" \ 1580 | tee -a $LOGFILE > $build_time_file 1581 1582# make sure we log only to the nightly build file 1583build_noise_file="${TMPDIR}/build_noise" 1584exec </dev/null >$build_noise_file 2>&1 1585 1586echo "\n==== list of environment variables ====\n" >> $LOGFILE 1587env >> $LOGFILE 1588 1589echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE 1590 1591if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1592 if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then 1593 echo "WARNING: the -S flags do not support incremental" \ 1594 "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE 1595 i_FLAG=n 1596 i_CMD_LINE_FLAG=n 1597 fi 1598 if [ "$N_FLAG" = "n" ]; then 1599 echo "WARNING: the -S flags do not support protocmp;" \ 1600 "protocmp disabled\n" | \ 1601 tee -a $mail_msg_file >> $LOGFILE 1602 N_FLAG=y 1603 fi 1604 if [ "$l_FLAG" = "y" ]; then 1605 echo "WARNING: the -S flags do not support lint;" \ 1606 "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE 1607 l_FLAG=n 1608 fi 1609 if [ "$C_FLAG" = "y" ]; then 1610 echo "WARNING: the -S flags do not support cstyle;" \ 1611 "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE 1612 C_FLAG=n 1613 fi 1614else 1615 if [ "$N_FLAG" = "y" ]; then 1616 if [ "$p_FLAG" = "y" ]; then 1617 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1618WARNING: the p option (create packages) is set, but so is the N option (do 1619 not run protocmp); this is dangerous; you should unset the N option 1620EOF 1621 else 1622 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1623Warning: the N option (do not run protocmp) is set; it probably shouldn't be 1624EOF 1625 fi 1626 echo "" | tee -a $mail_msg_file >> $LOGFILE 1627 fi 1628fi 1629 1630if [ "$a_FLAG" = "y" -a "$D_FLAG" = "n" -a "$F_FLAG" = "y" ]; then 1631 echo "WARNING: Neither DEBUG nor non-DEBUG build requested, but the" \ 1632 "'a' option was set." | tee -a $mail_msg_file >> $LOGFILE 1633fi 1634 1635if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 1636 echo "WARNING: DEBUG build not requested, but lint will be with" \ 1637 "DEBUG enabled.\n" \ 1638 | tee -a $mail_msg_file >> $LOGFILE 1639fi 1640 1641if [ "$f_FLAG" = "y" ]; then 1642 if [ "$i_FLAG" = "y" ]; then 1643 echo "WARNING: the -f flag cannot be used during incremental" \ 1644 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1645 f_FLAG=n 1646 fi 1647 if [ "$p_FLAG" != "y" -o "$l_FLAG" != "y" ]; then 1648 echo "WARNING: the -f flag requires -l and -p; ignoring -f\n" | \ 1649 tee -a $mail_msg_file >> $LOGFILE 1650 f_FLAG=n 1651 fi 1652fi 1653 1654if [ "$T_FLAG" = "y" -a -d $SRC/uts/common/dtrace ]; then 1655 echo "WARNING: TRACE build requested but workspace contains DTrace;" \ 1656 "-T will have no effect\n" | tee -a $mail_msg_file >> $LOGFILE 1657fi 1658 1659if [ "$t_FLAG" = "n" ]; then 1660 # 1661 # We're not doing a tools build, so make sure elfsign(1) is 1662 # new enough to safely sign non-crypto binaries. We test 1663 # debugging output from elfsign to detect the old version. 1664 # 1665 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 1666 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 1667 | egrep algorithmOID` 1668 if [ -z "$newelfsigntest" ]; then 1669 echo "WARNING: /usr/bin/elfsign out of date;" \ 1670 "will only sign crypto modules\n" | \ 1671 tee -a $mail_msg_file >> $LOGFILE 1672 export ELFSIGN_OBJECT=true 1673 elif [ "$VERIFY_ELFSIGN" = "y" ]; then 1674 echo "WARNING: VERIFY_ELFSIGN=y requires" \ 1675 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 1676 tee -a $mail_msg_file >> $LOGFILE 1677 fi 1678fi 1679 1680# copy ihv proto area in addition to the build itself 1681 1682if [ "$X_FLAG" = "y" ]; then 1683 1684 # Install IA32 IHV proto area 1685 copy_ihv_proto 1686fi 1687 1688echo "==== Build environment ====\n" | tee -a $mail_msg_file >> $LOGFILE 1689 1690# System 1691whence uname | tee -a $mail_msg_file >> $LOGFILE 1692uname -a 2>&1 | tee -a $mail_msg_file >> $LOGFILE 1693echo | tee -a $mail_msg_file >> $LOGFILE 1694 1695# nightly (will fail in year 2100 due to SCCS flaw) 1696echo "$0 $@" | tee -a $mail_msg_file >> $LOGFILE 1697echo "%M% version %I% 20%E%\n" | tee -a $mail_msg_file >> $LOGFILE 1698 1699# make 1700whence $MAKE | tee -a $mail_msg_file >> $LOGFILE 1701if [ "$d_FLAG" = "y" ]; then 1702 $MAKE -v | tee -a $mail_msg_file >> $LOGFILE 1703fi 1704echo "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1705 tee -a $mail_msg_file >> $LOGFILE 1706 1707# 1708# Report the compiler versions. 1709# 1710if [ -f $SRC/Makefile ]; then 1711 srcroot=$SRC 1712elif [ -f $BRINGOVER_WS/usr/src/Makefile ]; then 1713 srcroot=$BRINGOVER_WS/usr/src 1714else 1715 echo "\nUnable to find \"Makefile\" in $BRINGOVER_WS/usr/src or $SRC." | 1716 tee -a $mail_msg_file >> $LOGFILE 1717 exit 1 1718fi 1719 1720( cd $srcroot 1721 for target in cc-version cc64-version java-version; do 1722 echo 1723 # 1724 # Put statefile somewhere we know we can write to rather than trip 1725 # over a read-only $srcroot. Use /usr/ccs/bin/make here because 1726 # it supports -K and ParallelMake doesn't. 1727 # 1728 rm -f $TMPDIR/make-state 1729 if /usr/ccs/bin/make -K $TMPDIR/make-state -e $target 2>/dev/null; then 1730 continue 1731 fi 1732 touch $TMPDIR/nocompiler 1733 done 1734 echo 1735) | tee -a $mail_msg_file >> $LOGFILE 1736 1737if [ -f $TMPDIR/nocompiler ]; then 1738 rm -f $TMPDIR/nocompiler 1739 build_ok=n 1740 echo "Aborting due to missing compiler." | 1741 tee -a $mail_msg_file >> $LOGFILE 1742 exit 1 1743fi 1744 1745# as 1746whence as | tee -a $mail_msg_file >> $LOGFILE 1747as -V 2>&1 | head -1 | tee -a $mail_msg_file >> $LOGFILE 1748echo | tee -a $mail_msg_file >> $LOGFILE 1749 1750# Check that we're running a capable link-editor 1751whence ld | tee -a $mail_msg_file >> $LOGFILE 1752LDVER=`ld -V 2>&1` 1753echo $LDVER | tee -a $mail_msg_file >> $LOGFILE 1754LDVER=`echo $LDVER | sed -e "s/.*-1\.//" -e "s/:.*//"` 1755if [ `expr $LDVER \< 422` -eq 1 ]; then 1756 echo "The link-editor needs to be at version 422 or higher to build" | \ 1757 tee -a $mail_msg_file >> $LOGFILE 1758 echo "the latest stuff, hope your build works." | \ 1759 tee -a $mail_msg_file >> $LOGFILE 1760fi 1761 1762echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1763 tee -a $mail_msg_file >> $LOGFILE 1764 1765echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 1766echo $VERSION | tee -a $mail_msg_file >> $LOGFILE 1767 1768# 1769# Decide whether to clobber 1770# 1771if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 1772 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 1773 1774 cd $SRC 1775 # remove old clobber file 1776 rm -f $SRC/clobber.out 1777 rm -f $SRC/clobber-${MACH}.out 1778 1779 # Remove all .make.state* files, just in case we are restarting 1780 # the build after having interrupted a previous 'make clobber'. 1781 find . \( -name SCCS -o -name 'interfaces.*' \) -prune \ 1782 -o -name '.make.*' -print | xargs rm -f 1783 1784 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 1785 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 1786 grep "$MAKE:" $SRC/clobber-${MACH}.out | 1787 egrep -v "Ignoring unknown host" \ 1788 >> $mail_msg_file 1789 1790 if [ "$t_FLAG" = "y" ]; then 1791 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 1792 cd ${TOOLS} 1793 rm -f ${TOOLS}/clobber-${MACH}.out 1794 $MAKE -ek clobber 2>&1 | \ 1795 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 1796 echo "\n==== Make tools clobber ERRORS ====\n" \ 1797 >> $mail_msg_file 1798 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1799 >> $mail_msg_file 1800 rm -rf ${TOOLS_PROTO} 1801 mkdir -p ${TOOLS_PROTO} 1802 fi 1803 rm -rf $ROOT 1804 1805 # Get back to a clean workspace as much as possible to catch 1806 # problems that only occur on fresh workspaces. 1807 # Remove all .make.state* files, libraries, and .o's that may 1808 # have been omitted from clobber. A couple of libraries are 1809 # under SCCS, so leave them alone. 1810 # We should probably blow away temporary directories too. 1811 cd $SRC 1812 find $relsrcdirs \( -name SCCS -o -name 'interfaces.*' \) -prune -o \ 1813 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1814 -name '*.o' \) -print | \ 1815 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 1816else 1817 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 1818fi 1819 1820# 1821# Decide whether to bringover to the codemgr workspace 1822# 1823if [ "$n_FLAG" = "n" ]; then 1824 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1825 # sleep on the parent workspace's lock 1826 while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks 1827 do 1828 sleep 120 1829 done 1830 1831 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1832 staffer $TEAMWARE/bin/bringover -c "nightly update" -p $BRINGOVER_WS \ 1833 -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 | \ 1834 tee -a $mail_msg_file >> $LOGFILE 1835 if [ $? -eq 1 ] 1836 then 1837 echo "trouble with bringover, quitting at `date`." >> $LOGFILE 1838 exit 1 1839 fi 1840else 1841 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 1842fi 1843 1844# 1845# Build tools if requested 1846# 1847if [ "$t_FLAG" = "y" ]; then 1848 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 1849 export RELEASE_BUILD ; RELEASE_BUILD= 1850 unset EXTRA_OPTIONS 1851 unset EXTRA_CFLAGS 1852 1853 export ONBLD_TOOLS=${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld} 1854 build_tools ${TOOLS_PROTO} 1855fi 1856 1857if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then 1858 echo "\n==== NOT Building base OS-Net source ====\n" | \ 1859 tee -a $LOGFILE >> $mail_msg_file 1860else 1861 normal_build 1862fi 1863 1864ORIG_SRC=$SRC 1865BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 1866 1867if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1868 save_binaries 1869 1870 echo "\n==== Retrieving SCCS files at `date` ====\n" >> $LOGFILE 1871 SCCSHELPER=${TMPDIR}/sccs-helper 1872 rm -f ${SCCSHELPER} 1873cat >${SCCSHELPER} <<EOF 1874#!/bin/ksh 1875cd \$1 1876cd .. 1877sccs get SCCS >/dev/null 2>&1 1878EOF 1879 cd $SRC 1880 chmod +x ${SCCSHELPER} 1881 find $relsrcdirs -name SCCS | xargs -L 1 ${SCCSHELPER} 1882 rm -f ${SCCSHELPER} 1883fi 1884 1885if [ "$SD_FLAG" = "y" ]; then 1886 clone_source ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC 1887fi 1888 1889# EXPORT_SRC comes after CRYPT_SRC since a domestic build will need 1890# $SRC pointing to the export_source usr/src. 1891if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1892 clone_source ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC 1893fi 1894 1895if [ "$SD_FLAG" = "y" ]; then 1896 # drop the crypt files in place. 1897 cd ${EXPORT_SRC} 1898 echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \ 1899 >> ${LOGFILE} 1900 zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \ 1901 cpio -idmucvB 2>/dev/null >> ${LOGFILE} 1902 if [ "$?" = "0" ]; then 1903 echo "\n==== DOMESTIC extraction succeeded ====\n" \ 1904 >> $mail_msg_file 1905 else 1906 echo "\n==== DOMESTIC extraction failed ====\n" \ 1907 >> $mail_msg_file 1908 fi 1909 1910fi 1911 1912if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1913 # remove proto area here, since we don't clobber 1914 rm -rf "$ROOT" 1915 if [ "$t_FLAG" = "y" ]; then 1916 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 1917 export RELEASE_BUILD ; RELEASE_BUILD= 1918 unset EXTRA_OPTIONS 1919 unset EXTRA_CFLAGS 1920 1921 build_tools ${EXPORT_SRC}/usr/src/tools/proto 1922 fi 1923 1924 export EXPORT_RELEASE_BUILD ; EXPORT_RELEASE_BUILD=# 1925 normal_build 1926fi 1927 1928if [ "$build_ok" = "y" ]; then 1929 echo "\n==== Creating protolist system file at `date` ====" \ 1930 >> $LOGFILE 1931 protolist $ROOT > $ATLOG/proto_list_${MACH} 1932 echo "==== protolist system file created at `date` ====\n" \ 1933 >> $LOGFILE 1934 1935 if [ "$N_FLAG" != "y" ]; then 1936 echo "\n==== Impact on packages ====\n" >> $mail_msg_file 1937 1938 # If there is a reference proto list, compare the build's proto 1939 # list with the reference to see changes in proto areas. 1940 # Use the current exception list. 1941 exc=etc/exception_list_$MACH 1942 if [ -f $SRC/pkgdefs/$exc ]; then 1943 ELIST="-e $SRC/pkgdefs/$exc" 1944 fi 1945 1946 if [ -f "$REF_PROTO_LIST" ]; then 1947 $PROTOCMPTERSE \ 1948 "Files in yesterday's proto area, but not today's:" \ 1949 "Files in today's proto area, but not yesterday's:" \ 1950 "Files that changed between yesterday and today:" \ 1951 ${ELIST} \ 1952 -d $REF_PROTO_LIST \ 1953 $ATLOG/proto_list_${MACH} \ 1954 >> $mail_msg_file 1955 fi 1956 # Compare the build's proto list with current package 1957 # definitions to audit the quality of package definitions 1958 # and makefile install targets. Use the current exception list. 1959 PKGDEFS_LIST="" 1960 for d in $abssrcdirs; do 1961 if [ -d $d/pkgdefs ]; then 1962 PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs" 1963 fi 1964 done 1965 1966 $PROTOCMPTERSE \ 1967 "Files missing from the proto area:" \ 1968 "Files missing from packages:" \ 1969 "Inconsistencies between pkgdefs and proto area:" \ 1970 ${ELIST} \ 1971 ${PKGDEFS_LIST} \ 1972 $ATLOG/proto_list_${MACH} \ 1973 >> $mail_msg_file 1974 fi 1975fi 1976 1977if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 1978 staffer cp $ATLOG/proto_list_${MACH} \ 1979 $PARENT_WS/usr/src/proto_list_${MACH} 1980fi 1981 1982# Update parent proto area if necessary. This is done now 1983# so that the proto area has either DEBUG or non-DEBUG kernels. 1984# Note that this clears out the lock file, so we can dispense with 1985# the variable now. 1986if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 1987 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 1988 tee -a $LOGFILE >> $mail_msg_file 1989 # The rm -rf command below produces predictable errors if 1990 # nightly is invoked from the parent's $ROOT/opt/onbld/bin, 1991 # and that directory is accessed via NFS. This is because 1992 # deleted-but-still-open files don't actually disappear as 1993 # expected, but rather turn into .nfsXXXX junk files, leaving 1994 # the directory non-empty. Since this is a not-unusual usage 1995 # pattern, and we still want to catch other errors here, we 1996 # take the unusal step of moving aside 'nightly' from that 1997 # directory (if we're using it). 1998 mypath=${0##*/root_$MACH/} 1999 if [ "$mypath" = $0 ]; then 2000 mypath=opt/onbld/bin/${0##*/} 2001 fi 2002 if [ $0 -ef $PARENT_WS/proto/root_$MACH/$mypath ]; then 2003 mv -f $0 $PARENT_WS/proto/root_$MACH 2004 fi 2005 rm -rf $PARENT_WS/proto/root_$MACH/* 2006 unset Ulockfile 2007 mkdir -p $NIGHTLY_PARENT_ROOT 2008 cd $ROOT 2009 ( tar cf - . | ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 2010 tee -a $mail_msg_file >> $LOGFILE 2011fi 2012 2013# 2014# do shared library interface verification 2015# 2016 2017if [ "$A_FLAG" = "y" -a "$build_ok" = "y" ]; then 2018 echo "\n==== Check versioning and ABI information ====\n" | \ 2019 tee -a $LOGFILE >> $mail_msg_file 2020 2021 rm -rf $SRC/interfaces.ref 2022 if [ -d $SRC/interfaces.out ]; then 2023 mv $SRC/interfaces.out $SRC/interfaces.ref 2024 fi 2025 rm -rf $SRC/interfaces.out 2026 mkdir -p $SRC/interfaces.out 2027 2028 intf_check -V -m -o -b $SRC/tools/abi/etc \ 2029 -d $SRC/interfaces.out $ROOT 2>&1 | sort \ 2030 > $SRC/interfaces.out/log 2031 2032 # report any ERROR found in log file 2033 fgrep 'ERROR' $SRC/interfaces.out/log | sed 's/^ERROR: //' | \ 2034 tee -a $LOGFILE >> $mail_msg_file 2035 2036 if [ ! -d $SRC/interfaces.ref ] ; then 2037 mkdir -p $SRC/interfaces.ref 2038 if [ -d $SRC/interfaces.out ]; then 2039 cp -r $SRC/interfaces.out/* $SRC/interfaces.ref 2040 fi 2041 fi 2042 2043 echo "\n==== Diff versioning warnings (since last build) ====\n" | \ 2044 tee -a $LOGFILE >> $mail_msg_file 2045 2046 out_vers=`grep ^VERSION $SRC/interfaces.out/log`; 2047 ref_vers=`grep ^VERSION $SRC/interfaces.ref/log`; 2048 2049 # Report any differences in WARNING messages between last 2050 # and current build. 2051 if [ "$out_vers" = "$ref_vers" ]; then 2052 diff $SRC/interfaces.ref/log $SRC/interfaces.out/log | \ 2053 fgrep 'WARNING' | sed 's/WARNING: //' | \ 2054 tee -a $LOGFILE >> $mail_msg_file 2055 fi 2056fi 2057 2058if [ "$r_FLAG" = "y" -a "$build_ok" = "y" ]; then 2059 echo "\n==== Check ELF runtime attributes ====\n" | \ 2060 tee -a $LOGFILE >> $mail_msg_file 2061 2062 LDDUSAGE="^ldd: does not support -e" 2063 LDDWRONG="wrong class" 2064 CRLERROR="^crle:" 2065 CRLECONF="^crle: configuration file:" 2066 2067 rm -f $SRC/runtime.ref 2068 if [ -f $SRC/runtime.out ]; then 2069 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2070 $SRC/runtime.out > $SRC/runtime.ref 2071 fi 2072 2073 # If we're doing a debug build the proto area will be left with 2074 # debuggable objects, thus don't assert -s. 2075 if [ "$D_FLAG" = "y" ]; then 2076 rtime_sflag="" 2077 else 2078 rtime_sflag="-s" 2079 fi 2080 check_rtime -d $ROOT -i -m -o $rtime_sflag $ROOT 2>&1 | \ 2081 egrep -v ": unreferenced object=$ROOT/.*/lib(w|intl|thread|pthread).so" | \ 2082 egrep -v ": unused object=$ROOT/.*/lib(w|intl|thread|pthread).so" | \ 2083 sort >$SRC/runtime.out 2084 2085 # Determine any processing errors that will affect the final output 2086 # and display these first. 2087 grep -l "$LDDUSAGE" $SRC/runtime.out > /dev/null 2088 if [ $? -eq 0 ]; then 2089 echo "WARNING: ldd(1) does not support -e. The version of ldd(1)" | \ 2090 tee -a $LOGFILE >> $mail_msg_file 2091 echo "on your system is old - 4390308 (s81_30) is required.\n" | \ 2092 tee -a $LOGFILE >> $mail_msg_file 2093 fi 2094 grep -l "$LDDWRONG" $SRC/runtime.out > /dev/null 2095 if [ $? -eq 0 ]; then 2096 echo "WARNING: wrong class message detected. ldd(1) was unable" | \ 2097 tee -a $LOGFILE >> $mail_msg_file 2098 echo "to execute an object, thus it could not be checked fully." | \ 2099 tee -a $LOGFILE >> $mail_msg_file 2100 echo "Perhaps a 64-bit object was encountered on a 32-bit system," | \ 2101 tee -a $LOGFILE >> $mail_msg_file 2102 echo "or an i386 object was encountered on a sparc system?\n" | \ 2103 tee -a $LOGFILE >> $mail_msg_file 2104 fi 2105 grep -l "$CRLECONF" $SRC/runtime.out > /dev/null 2106 if [ $? -eq 0 ]; then 2107 echo "WARNING: creation of an alternative dependency cache failed." | \ 2108 tee -a $LOGFILE >> $mail_msg_file 2109 echo "Dependencies will bind to the base system libraries.\n" | \ 2110 tee -a $LOGFILE >> $mail_msg_file 2111 grep "$CRLECONF" $SRC/runtime.out | \ 2112 tee -a $LOGFILE >> $mail_msg_file 2113 grep "$CRLERROR" $SRC/runtime.out | grep -v "$CRLECONF" | \ 2114 tee -a $LOGFILE >> $mail_msg_file 2115 echo "\n" | tee -a $LOGFILE >> $mail_msg_file 2116 fi 2117 2118 egrep '<dependency no longer necessary>' $SRC/runtime.out | \ 2119 tee -a $LOGFILE >> $mail_msg_file 2120 2121 # NEEDED= and RPATH= are informational; report anything else that we 2122 # haven't already. 2123 egrep -v "NEEDED=|RPATH=|$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2124 $SRC/runtime.out | tee -a $LOGFILE >> $mail_msg_file 2125 2126 # probably should compare against a 'known ok runpaths' list 2127 if [ ! -f $SRC/runtime.ref ]; then 2128 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2129 $SRC/runtime.out > $SRC/runtime.ref 2130 fi 2131 2132 echo "\n==== Diff ELF runtime attributes (since last build) ====\n" \ 2133 >> $mail_msg_file 2134 2135 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" $SRC/runtime.out | \ 2136 diff $SRC/runtime.ref - >> $mail_msg_file 2137fi 2138 2139# For now, don't make archives or packages for GPROF/TRACE builds 2140a_FLAG=n 2141p_FLAG=n 2142 2143# GPROF build begins 2144 2145if [ "$i_CMD_LINE_FLAG" = "n" -a "$P_FLAG" = "y" ]; then 2146 2147 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 2148 export RELEASE_BUILD ; RELEASE_BUILD= 2149 export EXTRA_OPTIONS ; EXTRA_OPTIONS="-DGPROF" 2150 export EXTRA_CFLAGS ; EXTRA_CFLAGS="-xpg" 2151 2152 build GPROF -prof 2153 2154else 2155 echo "\n==== No GPROF build ====\n" >> $LOGFILE 2156fi 2157 2158# GPROF build ends 2159 2160# TRACE build begins 2161 2162if [ "$i_CMD_LINE_FLAG" = "n" -a "$T_FLAG" = "y" ]; then 2163 2164 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 2165 export RELEASE_BUILD ; RELEASE_BUILD= 2166 export EXTRA_OPTIONS ; EXTRA_OPTIONS="-DTRACE" 2167 unset EXTRA_CFLAGS 2168 2169 build TRACE -trace 2170 2171else 2172 echo "\n==== No TRACE build ====\n" >> $LOGFILE 2173fi 2174 2175# TRACE build ends 2176 2177# DEBUG lint of kernel begins 2178 2179if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 2180 if [ "$LINTDIRS" = "" ]; then 2181 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 2182 LINTDIRS="$SRC y" 2183 fi 2184 set $LINTDIRS 2185 while [ $# -gt 0 ]; do 2186 dolint $1 $2; shift; shift 2187 done 2188else 2189 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 2190fi 2191 2192# "make check" begins 2193 2194if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 2195 # remove old check.out 2196 rm -f $SRC/check.out 2197 2198 rm -f $SRC/check-${MACH}.out 2199 cd $SRC 2200 $MAKE -ek check 2>&1 | tee -a $SRC/check-${MACH}.out >> $LOGFILE 2201 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 2202 2203 grep ":" $SRC/check-${MACH}.out | 2204 egrep -v "Ignoring unknown host" | \ 2205 sort | uniq >> $mail_msg_file 2206else 2207 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 2208fi 2209 2210echo "\n==== Find core files ====\n" | \ 2211 tee -a $LOGFILE >> $mail_msg_file 2212 2213find $abssrcdirs -name core -a -type f -exec file {} \; | \ 2214 tee -a $LOGFILE >> $mail_msg_file 2215 2216if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2217 echo "\n==== Diff unreferenced files (since last build) ====\n" \ 2218 | tee -a $LOGFILE >>$mail_msg_file 2219 rm -f $SRC/unref-${MACH}.ref 2220 if [ -f $SRC/unref-${MACH}.out ]; then 2221 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2222 fi 2223 2224 findunref -t $SRC/.build.tstamp $SRC/.. \ 2225 ${TOOLS}/findunref/exception_list \ 2226 2>> $mail_msg_file | sort | \ 2227 sed -e s=^./src/=./= -e s=^./closed/=../closed/= \ 2228 > $SRC/unref-${MACH}.out 2229 2230 if [ ! -f $SRC/unref-${MACH}.ref ]; then 2231 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2232 fi 2233 2234 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 2235fi 2236 2237# Verify that the usual lists of files, such as exception lists, 2238# contain only valid references to files. If the build has failed, 2239# then don't check the proto area. 2240CHECK_PATHS=${CHECK_PATHS:-y} 2241if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 2242 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 2243 >>$mail_msg_file 2244 arg=-b 2245 [ "$build_ok" = y ] && arg= 2246 checkpaths $arg $ROOT 2>&1 | tee -a $LOGFILE >>$mail_msg_file 2247fi 2248 2249if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2250 echo "\n==== Impact on file permissions ====\n" \ 2251 >> $mail_msg_file 2252 # 2253 # Get pkginfo files from usr/src/pkgdefs 2254 # 2255 pmodes -qvdP \ 2256 `for d in $abssrcdirs; do 2257 if [ -d "$d/pkgdefs" ] 2258 then 2259 find $d/pkgdefs -name pkginfo.tmpl -print -o -name .del\* -prune 2260 fi 2261 done | sed -e 's:/pkginfo.tmpl$::' | sort -u ` >> $mail_msg_file 2262fi 2263 2264END_DATE=`date` 2265echo "==== Nightly $maketype build completed: $END_DATE ====" | \ 2266 tee -a $LOGFILE >> $build_time_file 2267 2268typeset -Z2 minutes 2269typeset -Z2 seconds 2270 2271elapsed_time=$SECONDS 2272((hours = elapsed_time / 3600 )) 2273((minutes = elapsed_time / 60 % 60)) 2274((seconds = elapsed_time % 60)) 2275 2276echo "\n==== Total build time ====" | \ 2277 tee -a $LOGFILE >> $build_time_file 2278echo "\nreal ${hours}:${minutes}:${seconds}" | \ 2279 tee -a $LOGFILE >> $build_time_file 2280 2281if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2282 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 2283 2284 # 2285 # Produce a master list of unreferenced files -- ideally, we'd 2286 # generate the master just once after all of the nightlies 2287 # have finished, but there's no simple way to know when that 2288 # will be. Instead, we assume that we're the last nightly to 2289 # finish and merge all of the unref-${MACH}.out files in 2290 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 2291 # finish, then this file will be the authoritative master 2292 # list. Otherwise, another ${MACH}'s nightly will eventually 2293 # overwrite ours with its own master, but in the meantime our 2294 # temporary "master" will be no worse than any older master 2295 # which was already on the parent. 2296 # 2297 2298 set -- $PARENT_WS/usr/src/unref-*.out 2299 cp "$1" ${TMPDIR}/unref.merge 2300 shift 2301 2302 for unreffile; do 2303 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 2304 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 2305 done 2306 2307 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 2308fi 2309 2310# 2311# All done save for the sweeping up. 2312# (whichever exit we hit here will trigger the "cleanup" trap which 2313# optionally sends mail on completion). 2314# 2315if [ "$build_ok" = "y" ]; then 2316 exit 0 2317fi 2318exit 1 2319