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 2006 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 and check builds are skipped no matter what 37# 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 352 echo "\n==== SCCS Noise ($LABEL) ====\n" >> $mail_msg_file 353 354 egrep 'sccs(check| get)' $SRC/${INSTALLOG}.out >> $mail_msg_file 355 356 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file 357 egrep ":" $SRC/${INSTALLOG}.out | 358 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ 359 egrep -v "Ignoring unknown host" | \ 360 egrep -v "cc .* -o error " | \ 361 egrep -v "warning" >> $mail_msg_file 362 if [ "$?" = "0" ]; then 363 build_ok=n 364 this_build_ok=n 365 fi 366 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \ 367 >> $mail_msg_file 368 if [ "$?" = "0" ]; then 369 build_ok=n 370 this_build_ok=n 371 fi 372 373 if [ "$W_FLAG" = "n" ]; then 374 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file 375 egrep -i warning: $SRC/${INSTALLOG}.out \ 376 | egrep -v '^tic:' \ 377 | egrep -v "symbol \`timezone' has differing types:" \ 378 | egrep -v "parameter <PSTAMP> set to" \ 379 | egrep -v "Ignoring unknown host" \ 380 | egrep -v "redefining segment flags attribute for" \ 381 >> $mail_msg_file 382 fi 383 384 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \ 385 >> $LOGFILE 386 387 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file 388 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file 389 390 if [ "$i_FLAG" = "n" -a "$W_FLAG" = "n" ]; then 391 rm -f $SRC/${NOISE}.ref 392 if [ -f $SRC/${NOISE}.out ]; then 393 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref 394 fi 395 grep : $SRC/${INSTALLOG}.out \ 396 | egrep -v '^/' \ 397 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \ 398 | egrep -v '^tic:' \ 399 | egrep -v '^mcs' \ 400 | egrep -v '^LD_LIBRARY_PATH=' \ 401 | egrep -v 'ar: creating' \ 402 | egrep -v 'ar: writing' \ 403 | egrep -v 'conflicts:' \ 404 | egrep -v ':saved created' \ 405 | egrep -v '^stty.*c:' \ 406 | egrep -v '^mfgname.c:' \ 407 | egrep -v '^uname-i.c:' \ 408 | egrep -v '^volumes.c:' \ 409 | egrep -v '^lint library construction:' \ 410 | egrep -v 'tsort: INFORM:' \ 411 | egrep -v 'stripalign:' \ 412 | egrep -v 'chars, width' \ 413 | egrep -v "symbol \`timezone' has differing types:" \ 414 | egrep -v 'PSTAMP' \ 415 | egrep -v '|%WHOANDWHERE%|' \ 416 | egrep -v '^Manifying' \ 417 | egrep -v 'Ignoring unknown host' \ 418 | egrep -v 'Processing method:' \ 419 | egrep -v '^Writing' \ 420 | egrep -v 'spellin1:' \ 421 | egrep -v '^adding:' \ 422 | egrep -v "^echo 'msgid" \ 423 | egrep -v '^echo ' \ 424 | egrep -v '\.c:$' \ 425 | egrep -v '^Adding file:' \ 426 | egrep -v 'CLASSPATH=' \ 427 | egrep -v '\/var\/mail\/:saved' \ 428 | egrep -v -- '-DUTS_VERSION=' \ 429 | egrep -v '^Running Mkbootstrap' \ 430 | egrep -v '^Applet length read:' \ 431 | egrep -v 'bytes written:' \ 432 | egrep -v '^File:SolarisAuthApplet.bin' \ 433 | egrep -v -i 'jibversion' \ 434 | egrep -v '^Output size:' \ 435 | egrep -v '^Solo size statistics:' \ 436 | egrep -v '^Using ROM API Version' \ 437 | egrep -v '^Zero Signature length:' \ 438 | egrep -v '^Note \(probably harmless\):' \ 439 | egrep -v '::' \ 440 | egrep -v -- '-xcache' \ 441 | egrep -v '^\+' \ 442 | egrep -v '^cc1: note: -fwritable-strings' \ 443 | egrep -v 'svccfg-native -s svc:/' \ 444 | sort | uniq >$SRC/${NOISE}.out 445 if [ ! -f $SRC/${NOISE}.ref ]; then 446 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref 447 fi 448 echo "\n==== Build noise differences ($LABEL) ====\n" \ 449 >>$mail_msg_file 450 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file 451 fi 452 453 # 454 # Create cpio archives for preintegration testing (PIT) 455 # 456 if [ "$a_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 457 echo "\n==== Creating $LABEL cpio archives at `date` ====\n" \ 458 >> $LOGFILE 459 makebfu_file="${TMPDIR}/makebfu" 460 rm -f ${makebfu_file} 461 makebfu 2>&1 | \ 462 tee -a ${makebfu_file} >> $LOGFILE 463 echo "\n==== cpio archives build errors ($LABEL) ====\n" \ 464 >> $mail_msg_file 465 grep -v "^Creating .* archive:" ${makebfu_file} | \ 466 grep -v "^Making" | \ 467 grep -v "^$" | \ 468 sort | uniq >> $mail_msg_file 469 rm -f ${makebfu_file} 470 # hack for test folks 471 if [ -z "`echo $PARENT_WS|egrep '^\/ws\/'`" ]; then 472 X=/net/`uname -n`${CPIODIR} 473 else 474 X=${CPIODIR} 475 fi 476 echo "Archive_directory: ${X}" >${TMPDIR}/f 477 cp ${TMPDIR}/f ${CPIODIR}/../../.${MACH}_wgtrun 478 rm -f ${TMPDIR}/f 479 480 else 481 echo "\n==== Not creating $LABEL cpio archives ====\n" \ 482 >> $LOGFILE 483 fi 484 485 # 486 # Building Packages 487 # 488 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then 489 echo "\n==== Creating $LABEL packages at `date` ====\n" \ 490 >> $LOGFILE 491 rm -f $SRC/pkgdefs/${INSTALLOG}.out 492 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE 493 rm -rf $PKGARCHIVE 494 mkdir -p $PKGARCHIVE 495 496 # 497 # Optional build of sparc realmode on i386 498 # 499 if [ "$MACH" = "i386" ] && [ "${SPARC_RM_PKGARCHIVE}" ]; then 500 echo "Clearing out ${SPARC_RM_PKGARCHIVE} ..." \ 501 >> $LOGFILE 502 rm -rf ${SPARC_RM_PKGARCHIVE} 503 mkdir -p ${SPARC_RM_PKGARCHIVE} 504 fi 505 506 cd $SRC/pkgdefs 507 $MAKE -e install 2>&1 | \ 508 tee -a $SRC/pkgdefs/${INSTALLOG}.out >> $LOGFILE 509 echo "\n==== Package build errors ($LABEL) ====\n" \ 510 >> $mail_msg_file 511 egrep "${MAKE}|ERROR|WARNING" $SRC/pkgdefs/${INSTALLOG}.out | \ 512 grep ':' | \ 513 grep -v PSTAMP | \ 514 egrep -v "Ignoring unknown host" \ 515 >> $mail_msg_file 516 else 517 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE 518 fi 519} 520 521dolint() { 522 523 # 524 # Arg. 2 is a flag to turn on/off the lint diff output 525 # 526 dl_usage="Usage: dolint /dir y|n" 527 528 if [ $# -ne 2 ]; then 529 echo $dl_usage 530 exit 1 531 fi 532 533 if [ ! -d "$1" ]; then 534 echo $dl_usage 535 exit 1 536 fi 537 538 if [ "$2" != "y" -a "$2" != "n" ]; then 539 echo $dl_usage 540 exit 1 541 fi 542 543 lintdir=$1 544 dodiff=$2 545 base=`basename $lintdir` 546 LINTOUT=$lintdir/lint-${MACH}.out 547 LINTNOISE=$lintdir/lint-noise-${MACH} 548 549 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 550 unset RELEASE_BUILD 551 unset EXTRA_OPTIONS 552 unset EXTRA_CFLAGS 553 554 # 555 # '$MAKE lint' in $lintdir 556 # 557 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 558 559 # remove old lint.out 560 rm -f $lintdir/lint.out $lintdir/lint-noise.out 561 if [ -f $lintdir/lint-noise.ref ]; then 562 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref 563 fi 564 565 rm -f $LINTOUT 566 cd $lintdir 567 # 568 # Remove all .ln files to ensure a full reference file 569 # 570 rm -f Nothing_to_remove \ 571 `find . -name SCCS -prune -o -type f -name '*.ln' -print ` 572 573 /bin/time $MAKE -ek lint 2>&1 | \ 574 tee -a $LINTOUT >> $LOGFILE 575 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file 576 grep "$MAKE:" $LINTOUT | 577 egrep -v "Ignoring unknown host" \ 578 >> $mail_msg_file 579 580 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE 581 582 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \ 583 >>$mail_msg_file 584 tail -3 $LINTOUT >>$mail_msg_file 585 586 rm -f ${LINTNOISE}.ref 587 if [ -f ${LINTNOISE}.out ]; then 588 mv ${LINTNOISE}.out ${LINTNOISE}.ref 589 fi 590 grep : $LINTOUT | \ 591 egrep -v '^(real|user|sys)' | 592 egrep -v '(library construction)' | \ 593 egrep -v ': global crosschecks' | \ 594 egrep -v 'Ignoring unknown host' | \ 595 egrep -v '\.c:$' | \ 596 sort | uniq > ${LINTNOISE}.out 597 if [ ! -f ${LINTNOISE}.ref ]; then 598 cp ${LINTNOISE}.out ${LINTNOISE}.ref 599 fi 600 if [ "$dodiff" != "n" ]; then 601 echo "\n==== lint warnings $base ====\n" \ 602 >>$mail_msg_file 603 # should be none, though there are a few that were filtered out 604 # above 605 egrep -i '(warning|lint):' ${LINTNOISE}.out \ 606 | sort | uniq >> $mail_msg_file 607 echo "\n==== lint noise differences $base ====\n" \ 608 >> $mail_msg_file 609 diff ${LINTNOISE}.ref ${LINTNOISE}.out \ 610 >> $mail_msg_file 611 fi 612} 613 614# Install proto area from IHV build 615 616copy_ihv_proto() { 617 618 echo "\n==== Installing IHV proto area ====\n" \ 619 >> $LOGFILE 620 if [ -d "$IA32_IHV_ROOT" ]; then 621 if [ ! -d "$ROOT" ]; then 622 echo "mkdir -p $ROOT" >> $LOGFILE 623 mkdir -p $ROOT 624 fi 625 echo "copying $IA32_IHV_ROOT to $ROOT\n" >> $LOGFILE 626 cd $IA32_IHV_ROOT 627 tar -cf - . | (cd $ROOT; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 628 else 629 echo "$IA32_IHV_ROOT: not found" >> $LOGFILE 630 fi 631} 632 633# Install IHV packages in PKGARCHIVE 634 635copy_ihv_pkgs() { 636 637 if [ $# -ne 2 ]; then 638 echo "usage: copy_ihv_pkgs LABEL SUFFIX" 639 exit 1; 640 fi 641 642 LABEL=$1 643 SUFFIX=$2 644 # always use non-DEBUG IHV packages 645 IA32_IHV_PKGS=${IA32_IHV_PKGS_ORIG}-nd 646 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX} 647 648 echo "\n==== Installing IHV packages from $IA32_IHV_PKGS ($LABEL) ====\n" \ 649 >> $LOGFILE 650 if [ -d "$IA32_IHV_PKGS" ]; then 651 cd $IA32_IHV_PKGS 652 tar -cf - * | \ 653 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 654 else 655 echo "$IA32_IHV_PKGS: not found" >> $LOGFILE 656 fi 657 658 echo "\n==== Installing IHV packages from $IA32_IHV_BINARY_PKGS ($LABEL) ====\n" \ 659 >> $LOGFILE 660 if [ -d "$IA32_IHV_BINARY_PKGS" ]; then 661 cd $IA32_IHV_BINARY_PKGS 662 tar -cf - * | \ 663 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE 664 else 665 echo "$IA32_IHV_BINARY_PKGS: not found" >> $LOGFILE 666 fi 667} 668 669build_tools() { 670 671 if [ $# -ne 1 ]; then 672 echo "usage: build_tools DESTROOT" 673 exit 1; 674 fi 675 676 DESTROOT=$1 677 678 INSTALLOG=install-${MACH} 679 680 echo "\n==== Building tools at `date` ====\n" \ 681 >> $LOGFILE 682 683 rm -f ${TOOLS}/${INSTALLOG}.out 684 cd ${TOOLS} 685 /bin/time $MAKE ROOT=${DESTROOT} -e install 2>&1 | \ 686 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE 687 688 echo "\n==== Tools build errors ====\n" >> $mail_msg_file 689 690 egrep ":" ${TOOLS}/${INSTALLOG}.out | 691 egrep -e "(${MAKE}:|[ ]error[: \n])" | \ 692 egrep -v "Ignoring unknown host" | \ 693 egrep -v warning >> $mail_msg_file 694 if [ "$?" != "0" ]; then 695 STABS=${DESTROOT}/opt/onbld/bin/${MACH}/stabs 696 export STABS 697 CTFSTABS=${DESTROOT}/opt/onbld/bin/${MACH}/ctfstabs 698 export CTFSTABS 699 GENOFFSETS=${DESTROOT}/opt/onbld/bin/genoffsets 700 export GENOFFSETS 701 702 CTFCONVERT=${DESTROOT}/opt/onbld/bin/${MACH}/ctfconvert 703 export CTFCONVERT 704 CTFMERGE=${DESTROOT}/opt/onbld/bin/${MACH}/ctfmerge 705 export CTFMERGE 706 707 CTFCVTPTBL=${DESTROOT}/opt/onbld/bin/ctfcvtptbl 708 export CTFCVTPTBL 709 CTFFINDMOD=${DESTROOT}/opt/onbld/bin/ctffindmod 710 export CTFFINDMOD 711 712 if [ "$VERIFY_ELFSIGN" = "y" ]; then 713 ELFSIGN=${DESTROOT}/opt/onbld/bin/elfsigncmp 714 else 715 ELFSIGN=${DESTROOT}/opt/onbld/bin/${MACH}/elfsign 716 fi 717 export ELFSIGN 718 719 PATH="${DESTROOT}/opt/onbld/bin/${MACH}:${PATH}" 720 PATH="${DESTROOT}/opt/onbld/bin:${PATH}" 721 export PATH 722 723 echo "\n==== New environment settings. ====\n" >> $LOGFILE 724 echo "STABS=${STABS}" >> $LOGFILE 725 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE 726 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE 727 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE 728 echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE 729 echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE 730 echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE 731 echo "PATH=${PATH}" >> $LOGFILE 732 fi 733} 734 735staffer() { 736 if [ $ISUSER -ne 0 ]; then 737 "$@" 738 else 739 arg="\"$1\"" 740 shift 741 for i 742 do 743 arg="$arg \"$i\"" 744 done 745 eval su $STAFFER -c \'$arg\' 746 fi 747} 748 749# 750# Verify that the closed tree is present if it needs to be. 751# Sets CLOSED_IS_PRESENT for future use. 752# 753check_closed_tree() { 754 if [ -z "$CLOSED_IS_PRESENT" ]; then 755 if [ -d $SRC/../closed ]; then 756 CLOSED_IS_PRESENT="yes" 757 else 758 CLOSED_IS_PRESENT="no" 759 fi 760 export CLOSED_IS_PRESENT 761 fi 762 if [[ "$CLOSED_IS_PRESENT" = no && ! -d "$ON_CLOSED_BINS" ]]; then 763 # 764 # If it's an old (pre-split) tree or an empty 765 # workspace, don't complain. 766 # 767 if grep -s CLOSED_BUILD $SRC/Makefile.master > /dev/null; then 768 echo "If the closed sources are not present," \ 769 "ON_CLOSED_BINS" 770 echo "must point to the closed binaries tree." 771 exit 1 772 fi 773 fi 774} 775 776obsolete_build() { 777 echo "WARNING: Obsolete $1 build requested; request will be ignored" 778} 779 780 781MACH=`uname -p` 782 783if [ "$OPTHOME" = "" ]; then 784 OPTHOME=/opt 785 export OPTHOME 786fi 787if [ "$TEAMWARE" = "" ]; then 788 TEAMWARE=$OPTHOME/teamware 789 export TEAMWARE 790fi 791 792USAGE='Usage: nightly [-in] [-V VERS ] [ -S E|D|H ] <env_file> 793 794Where: 795 -i Fast incremental options (no clobber, lint, check) 796 -n Do not do a bringover 797 -V VERS set the build version string to VERS 798 -S Build a variant of the source product 799 E - build exportable source 800 D - build domestic source (exportable + crypt) 801 H - build hybrid source (binaries + deleted source) 802 803 <env_file> file in Bourne shell syntax that sets and exports 804 variables that configure the operation of this script and many of 805 the scripts this one calls. If <env_file> does not exist, 806 it will be looked for in $OPTHOME/onbld/env. 807 808non-DEBUG is the default build type. Build options can be set in the 809NIGHTLY_OPTIONS variable in the <env_file> as follows: 810 811 -A check for ABI differences in .so files 812 -C check for cstyle/hdrchk errors 813 -D do a build with DEBUG on 814 -F do _not_ do a non-DEBUG build 815 -G gate keeper default group of options (-au) 816 -I integration engineer default group of options (-ampu) 817 -M do not run pmodes (safe file permission checker) 818 -N do not run protocmp 819 -R default group of options for building a release (-mp) 820 -U update proto area in the parent 821 -V VERS set the build version string to VERS 822 -X copy x86 IHV proto area 823 -a create cpio archives 824 -f find unreferenced files 825 -i do an incremental build (no "make clobber") 826 -l do "make lint" in $LINTDIRS (default: $SRC y) 827 -m send mail to $MAILTO at end of build 828 -n do not do a bringover 829 -o build using root privileges to set OWNER/GROUP (old style) 830 -p create packages 831 -r check ELF runtime attributes in the proto area 832 -t build and use the tools in $SRC/tools 833 -u update proto_list_$MACH and friends in the parent workspace; 834 when used with -f, also build an unrefmaster.out in the parent 835 -w report on differences between previous and current proto areas 836 -z compress cpio archives with gzip 837 -W Do not report warnings (freeware gate ONLY) 838 -S Build a variant of the source product 839 E - build exportable source 840 D - build domestic source (exportable + crypt) 841 H - build hybrid source (binaries + deleted source) 842' 843# 844# -x less public handling of xmod source for the source product 845# 846# A log file will be generated under the name $LOGFILE 847# for partially completed build and log.`date '+%F'` 848# in the same directory for fully completed builds. 849# 850 851# default values for low-level FLAGS; G I R are group FLAGS 852A_FLAG=n 853a_FLAG=n 854C_FLAG=n 855F_FLAG=n 856f_FLAG=n 857D_FLAG=n 858P_FLAG=n 859T_FLAG=n 860n_FLAG=n 861o_FLAG=n 862i_FLAG=n; i_CMD_LINE_FLAG=n 863l_FLAG=n 864m_FLAG=n 865p_FLAG=n 866r_FLAG=n 867t_FLAG=n 868u_FLAG=n 869U_FLAG=n 870V_FLAG=n 871M_FLAG=n 872N_FLAG=n 873z_FLAG=n 874w_FLAG=n 875W_FLAG=n 876SE_FLAG=n 877SD_FLAG=n 878SH_FLAG=n 879X_FLAG=n 880# 881XMOD_OPT= 882# 883build_ok=y 884# 885# examine arguments 886# 887 888OPTIND=1 889while getopts inV:S:t FLAG 890do 891 case $FLAG in 892 i ) i_FLAG=y; i_CMD_LINE_FLAG=y 893 ;; 894 n ) n_FLAG=y 895 ;; 896 V ) V_FLAG=y 897 V_ARG="$OPTARG" 898 ;; 899 S ) 900 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 901 echo "Can only build one source variant at a time." 902 exit 1 903 fi 904 if [ "${OPTARG}" = "E" ]; then 905 SE_FLAG=y 906 elif [ "${OPTARG}" = "D" ]; then 907 SD_FLAG=y 908 elif [ "${OPTARG}" = "H" ]; then 909 SH_FLAG=y 910 else 911 echo "$USAGE" 912 exit 1 913 fi 914 ;; 915 t ) t_FLAG=y 916 ;; 917 \? ) echo "$USAGE" 918 exit 1 919 ;; 920 esac 921done 922 923# correct argument count after options 924shift `expr $OPTIND - 1` 925 926# test that the path to the environment-setting file was given 927if [ $# -ne 1 ]; then 928 echo "$USAGE" 929 exit 1 930fi 931 932# check if user is running nightly as root 933# ISUSER is set non-zero if an ordinary user runs nightly, or is zero 934# when root invokes nightly. 935/usr/bin/id | grep '^uid=0(' >/dev/null 2>&1 936ISUSER=$?; export ISUSER 937 938# 939# force locale to C 940LC_COLLATE=C; export LC_COLLATE 941LC_CTYPE=C; export LC_CTYPE 942LC_MESSAGES=C; export LC_MESSAGES 943LC_MONETARY=C; export LC_MONETARY 944LC_NUMERIC=C; export LC_NUMERIC 945LC_TIME=C; export LC_TIME 946 947# clear environment variables we know to be bad for the build 948unset LD_OPTIONS 949unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64 950unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64 951unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64 952unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64 953unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64 954unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64 955unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64 956unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 957unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64 958unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64 959unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64 960unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64 961unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64 962unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64 963unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64 964unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64 965unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64 966unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64 967unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64 968unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64 969 970unset CONFIG 971unset GROUP 972unset OWNER 973unset REMOTE 974unset ENV 975unset ARCH 976unset CLASSPATH 977unset NAME 978 979# 980# Setup environmental variables 981# 982if [ -f $1 ]; then 983 if [[ $1 = */* ]]; then 984 . $1 985 else 986 . ./$1 987 fi 988else 989 if [ -f $OPTHOME/onbld/env/$1 ]; then 990 . $OPTHOME/onbld/env/$1 991 else 992 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1" 993 exit 1 994 fi 995fi 996 997# 998# place ourselves in a new task, respecting BUILD_PROJECT if set. 999# 1000if [ -z "$BUILD_PROJECT" ]; then 1001 /usr/bin/newtask -c $$ 1002else 1003 /usr/bin/newtask -c $$ -p $BUILD_PROJECT 1004fi 1005 1006ps -o taskid= -p $$ | read build_taskid 1007ps -o project= -p $$ | read build_project 1008 1009# 1010# See if NIGHTLY_OPTIONS is set 1011# 1012if [ "$NIGHTLY_OPTIONS" = "" ]; then 1013 NIGHTLY_OPTIONS="-aBm" 1014fi 1015 1016# 1017# If BRINGOVER_WS was not specified, let it default to CLONE_WS 1018# 1019if [ "$BRINGOVER_WS" = "" ]; then 1020 BRINGOVER_WS=$CLONE_WS 1021fi 1022 1023# 1024# If BRINGOVER_FILES was not specified, default to usr 1025# 1026if [ "$BRINGOVER_FILES" = "" ]; then 1027 BRINGOVER_FILES="usr" 1028fi 1029 1030# 1031# If the closed sources are not present, the closed binaries must be 1032# present for the build to succeed. If there's no pointer to the 1033# closed binaries, flag that now, rather than forcing the user to wait 1034# a couple hours (or more) to find out. 1035# 1036orig_closed_is_present="$CLOSED_IS_PRESENT" 1037check_closed_tree 1038 1039# 1040# Note: changes to the option letters here should also be applied to the 1041# bldenv script. `d' is listed for backward compatibility. 1042# 1043NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-} 1044OPTIND=1 1045while getopts ABDFNMPTCGIRafinlmoptuUxdrtwzWS:X FLAG $NIGHTLY_OPTIONS 1046do 1047 case $FLAG in 1048 A ) A_FLAG=y 1049 ;; 1050 B ) D_FLAG=y 1051 ;; # old version of D 1052 F ) F_FLAG=y 1053 ;; 1054 D ) D_FLAG=y 1055 ;; 1056 P ) P_FLAG=y 1057 ;; # obsolete 1058 T ) T_FLAG=y 1059 ;; # obsolete 1060 C ) C_FLAG=y 1061 ;; 1062 M ) M_FLAG=y 1063 ;; 1064 N ) N_FLAG=y 1065 ;; 1066 G ) a_FLAG=y 1067 u_FLAG=y 1068 ;; 1069 I ) a_FLAG=y 1070 m_FLAG=y 1071 p_FLAG=y 1072 u_FLAG=y 1073 ;; 1074 R ) m_FLAG=y 1075 p_FLAG=y 1076 ;; 1077 a ) a_FLAG=y 1078 ;; 1079 f ) f_FLAG=y 1080 ;; 1081 i ) i_FLAG=y 1082 ;; 1083 n ) n_FLAG=y 1084 ;; 1085 o ) o_FLAG=y 1086 ;; 1087 l ) l_FLAG=y 1088 ;; 1089 m ) m_FLAG=y 1090 ;; 1091 p ) p_FLAG=y 1092 ;; 1093 r ) r_FLAG=y 1094 ;; 1095 t ) t_FLAG=y 1096 ;; 1097 u ) u_FLAG=y 1098 ;; 1099 w ) w_FLAG=y 1100 ;; 1101 z ) z_FLAG=y 1102 ;; 1103 U ) 1104 if [ -z "${PARENT_ROOT}" ]; then 1105 echo "PARENT_ROOT must be set if the U flag is" \ 1106 "present in NIGHTLY_OPTIONS." 1107 exit 1 1108 fi 1109 U_FLAG=y 1110 NIGHTLY_PARENT_ROOT=$PARENT_ROOT 1111 ;; 1112 x ) XMOD_OPT="-x" 1113 ;; 1114 W ) W_FLAG=y 1115 ;; 1116 S ) 1117 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1118 echo "Can only build one source variant at a time." 1119 exit 1 1120 fi 1121 if [ "${OPTARG}" = "E" ]; then 1122 SE_FLAG=y 1123 elif [ "${OPTARG}" = "D" ]; then 1124 SD_FLAG=y 1125 elif [ "${OPTARG}" = "H" ]; then 1126 SH_FLAG=y 1127 else 1128 echo "$USAGE" 1129 exit 1 1130 fi 1131 ;; 1132 X ) # now that we no longer need realmode builds, just 1133 # copy IHV packages. only meaningful on x86. 1134 if [ "$MACH" = "i386" ]; then 1135 X_FLAG=y 1136 fi 1137 ;; 1138 \? ) echo "$USAGE" 1139 exit 1 1140 ;; 1141 esac 1142done 1143 1144if [ $ISUSER -ne 0 ]; then 1145 if [ "$o_FLAG" = "y" ]; then 1146 echo "Old-style build requires root permission." 1147 exit 1 1148 fi 1149 1150 # Set default value for STAFFER, if needed. 1151 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then 1152 STAFFER=`/usr/xpg4/bin/id -un` 1153 export STAFFER 1154 fi 1155fi 1156 1157if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then 1158 MAILTO=$STAFFER 1159 export MAILTO 1160fi 1161 1162PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin" 1163PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb" 1164PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:." 1165export PATH 1166 1167# roots of source trees, both relative to $SRC and absolute. 1168relsrcdirs="." 1169if [[ -d $SRC/../closed && "$CLOSED_IS_PRESENT" != no ]]; then 1170 relsrcdirs="$relsrcdirs ../closed" 1171fi 1172abssrcdirs="" 1173for d in $relsrcdirs; do 1174 abssrcdirs="$abssrcdirs $SRC/$d" 1175done 1176 1177unset CH 1178if [ "$o_FLAG" = "y" ]; then 1179# root invoked old-style build -- make sure it works as it always has 1180# by exporting 'CH'. The current Makefile.master doesn't use this, but 1181# the old ones still do. 1182 PROTOCMPTERSE="protocmp.terse" 1183 CH= 1184 export CH 1185else 1186 PROTOCMPTERSE="protocmp.terse -gu" 1187fi 1188POUND_SIGN="#" 1189 1190# we export POUND_SIGN to speed up the build process -- prevents evaluation of 1191# the Makefile.master definitions. 1192export o_FLAG X_FLAG POUND_SIGN 1193 1194maketype="distributed" 1195MAKE=dmake 1196# get the dmake version string alone 1197DMAKE_VERSION=$( $MAKE -v ) 1198DMAKE_VERSION=${DMAKE_VERSION#*: } 1199# focus in on just the dotted version number alone 1200DMAKE_MAJOR=$( echo $DMAKE_VERSION | \ 1201 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' ) 1202# extract the second (or final) integer 1203DMAKE_MINOR=${DMAKE_MAJOR#*.} 1204DMAKE_MINOR=${DMAKE_MINOR%%.*} 1205# extract the first integer 1206DMAKE_MAJOR=${DMAKE_MAJOR%%.*} 1207CHECK_DMAKE=${CHECK_DMAKE:-y} 1208# x86 was built on the 12th, sparc on the 13th. 1209if [ "$CHECK_DMAKE" = "y" -a \ 1210 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \ 1211 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \ 1212 "$DMAKE_MAJOR" -lt 7 -o \ 1213 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then 1214 if [ -z "$DMAKE_VERSION" ]; then 1215 echo "$MAKE is missing." 1216 exit 1 1217 fi 1218 echo `whence $MAKE`" version is:" 1219 echo " ${DMAKE_VERSION}" 1220 cat <<EOF 1221 1222This version may not be safe for use. Either set TEAMWARE to a better 1223path or (if you really want to use this version of dmake anyway), add 1224the following to your environment to disable this check: 1225 1226 CHECK_DMAKE=n 1227EOF 1228 exit 1 1229fi 1230export PATH 1231export MAKE 1232 1233if [ "${SUNWSPRO}" != "" ]; then 1234 PATH="${SUNWSPRO}/bin:$PATH" 1235 export PATH 1236fi 1237 1238hostname=`uname -n` 1239if [ ! -f $HOME/.make.machines ]; then 1240 DMAKE_MAX_JOBS=4 1241else 1242 DMAKE_MAX_JOBS="`grep $hostname $HOME/.make.machines | \ 1243 tail -1 | awk -F= '{print $ 2;}'`" 1244 if [ "$DMAKE_MAX_JOBS" = "" ]; then 1245 DMAKE_MAX_JOBS=4 1246 fi 1247fi 1248DMAKE_MODE=parallel; 1249export DMAKE_MODE 1250export DMAKE_MAX_JOBS 1251 1252if [ -z "${ROOT}" ]; then 1253 echo "ROOT must be set." 1254 exit 1 1255fi 1256 1257if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" ]; then 1258 if [ -z "${EXPORT_SRC}" ]; then 1259 echo "EXPORT_SRC must be set for a source build." 1260 exit 1 1261 fi 1262 if [ -z "${CRYPT_SRC}" ]; then 1263 echo "CRYPT_SRC must be set for a source build." 1264 exit 1 1265 fi 1266fi 1267 1268if [ "$SH_FLAG" = "y" ]; then 1269 if [ -z "${EXPORT_SRC}" ]; then 1270 echo "EXPORT_SRC must be set for a source build." 1271 exit 1 1272 fi 1273fi 1274 1275# 1276# if -V flag was given, reset VERSION to V_ARG 1277# 1278if [ "$V_FLAG" = "y" ]; then 1279 VERSION=$V_ARG 1280fi 1281 1282# 1283# Check for IHV root for copying ihv proto area 1284# 1285if [ "$X_FLAG" = "y" ]; then 1286 if [ "$IA32_IHV_ROOT" = "" ]; then 1287 echo "IA32_IHV_ROOT: must be set for copying ihv proto" 1288 args_ok=n 1289 fi 1290 if [ ! -d "$IA32_IHV_ROOT" ]; then 1291 echo "$IA32_IHV_ROOT: not found" 1292 args_ok=n 1293 fi 1294 if [ "$IA32_IHV_WS" = "" ]; then 1295 echo "IA32_IHV_WS: must be set for copying ihv proto" 1296 args_ok=n 1297 fi 1298 if [ ! -d "$IA32_IHV_WS" ]; then 1299 echo "$IA32_IHV_WS: not found" 1300 args_ok=n 1301 fi 1302fi 1303 1304# Append source version 1305if [ "$SE_FLAG" = "y" ]; then 1306 VERSION="${VERSION}:EXPORT" 1307fi 1308 1309if [ "$SD_FLAG" = "y" ]; then 1310 VERSION="${VERSION}:DOMESTIC" 1311fi 1312 1313if [ "$SH_FLAG" = "y" ]; then 1314 VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT" 1315fi 1316 1317TMPDIR="/tmp/nightly.tmpdir.$$" 1318export TMPDIR 1319rm -rf ${TMPDIR} 1320mkdir -p $TMPDIR || exit 1 1321 1322# 1323# Keep elfsign's use of pkcs11_softtoken from looking in the user home 1324# directory, which doesn't always work. Needed until all build machines 1325# have the fix for 6271754 1326# 1327SOFTTOKEN_DIR=$TMPDIR 1328export SOFTTOKEN_DIR 1329 1330TOOLS=${SRC}/tools 1331TOOLS_PROTO=${TOOLS}/proto 1332 1333unset CFLAGS LD_LIBRARY_PATH LDFLAGS 1334 1335# create directories that are automatically removed if the nightly script 1336# fails to start correctly 1337newdir() { 1338 dir=$1 1339 toadd= 1340 while [ ! -d $dir ]; do 1341 toadd="$dir $toadd" 1342 dir=`dirname $dir` 1343 done 1344 torm= 1345 newlist= 1346 for dir in $toadd; do 1347 if staffer mkdir $dir; then 1348 newlist="$ISUSER $dir $newlist" 1349 torm="$dir $torm" 1350 else 1351 [ -z "$torm" ] || staffer rmdir $torm 1352 return 1 1353 fi 1354 done 1355 newdirlist="$newlist $newdirlist" 1356 return 0 1357} 1358newdirlist= 1359 1360[ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1 1361 1362# since this script assumes the build is from full source, it nullifies 1363# variables likely to have been set by a "ws" script; nullification 1364# confines the search space for headers and libraries to the proto area 1365# built from this immediate source. 1366ENVLDLIBS1= 1367ENVLDLIBS2= 1368ENVLDLIBS3= 1369ENVCPPFLAGS1= 1370ENVCPPFLAGS2= 1371ENVCPPFLAGS3= 1372ENVCPPFLAGS4= 1373PARENT_ROOT= 1374 1375export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \ 1376 PARENT_ROOT 1377 1378ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib" 1379ENVCPPFLAGS1="-I$ROOT/usr/include" 1380 1381export ENVLDLIBS1 ENVLDLIBS2 1382 1383CPIODIR_ORIG=$CPIODIR 1384PKGARCHIVE_ORIG=$PKGARCHIVE 1385IA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS 1386if [ "$SPARC_RM_PKGARCHIVE" ]; then 1387 SPARC_RM_PKGARCHIVE_ORIG=$SPARC_RM_PKGARCHIVE 1388fi 1389 1390# 1391# Juggle the logs and optionally send mail on completion. 1392# 1393 1394logshuffle() { 1395 LLOG="$ATLOG/log.`date '+%F'`" 1396 rm -rf $ATLOG/log.??`date '+%d'` 1397 rm -rf $ATLOG/log.????-??-`date '+%d'` 1398 if [ -f $LLOG -o -d $LLOG ]; then 1399 LLOG=$LLOG.$$ 1400 fi 1401 mkdir $LLOG 1402 export LLOG 1403 1404 if [ "$build_ok" = "y" ]; then 1405 mv $ATLOG/proto_list_${MACH} $LLOG 1406 1407 if [ -f $TMPDIR/wsdiff.results ]; then 1408 mv $TMPDIR/wsdiff.results $LLOG 1409 fi 1410 fi 1411 1412 # 1413 # Now that we're about to send mail, it's time to check the noise 1414 # file. In the event that an error occurs beyond this point, it will 1415 # be recorded in the nightly.log file, but nowhere else. This would 1416 # include only errors that cause the copying of the noise log to fail 1417 # or the mail itself not to be sent. 1418 # 1419 1420 exec >>$LOGFILE 2>&1 1421 if [ -s $build_noise_file ]; then 1422 echo "\n==== Nightly build noise ====\n" | 1423 tee -a $LOGFILE >>$mail_msg_file 1424 cat $build_noise_file >>$LOGFILE 1425 cat $build_noise_file >>$mail_msg_file 1426 echo | tee -a $LOGFILE >>$mail_msg_file 1427 fi 1428 rm -f $build_noise_file 1429 1430 case "$build_ok" in 1431 y) 1432 state=Completed 1433 ;; 1434 i) 1435 state=Interrupted 1436 ;; 1437 *) 1438 state=Failed 1439 ;; 1440 esac 1441 NIGHTLY_STATUS=$state 1442 export NIGHTLY_STATUS 1443 1444 if [ -n "$POST_NIGHTLY" ]; then 1445 echo "\n==== Running POST_NIGHTLY command:" \ 1446 "$POST_NIGHTLY ====\n" | tee -a $mail_msg_file >> $LOGFILE 1447 $POST_NIGHTLY $state 2>&1 | tee -a $mail_msg_file >> $LOGFILE 1448 fi 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 [ "$P_FLAG" = "y" ]; then 1591 obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE 1592fi 1593 1594if [ "$T_FLAG" = "y" ]; then 1595 obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE 1596fi 1597 1598if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1599 if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then 1600 echo "WARNING: the -S flags do not support incremental" \ 1601 "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE 1602 i_FLAG=n 1603 i_CMD_LINE_FLAG=n 1604 fi 1605 if [ "$N_FLAG" = "n" ]; then 1606 echo "WARNING: the -S flags do not support protocmp;" \ 1607 "protocmp disabled\n" | \ 1608 tee -a $mail_msg_file >> $LOGFILE 1609 N_FLAG=y 1610 fi 1611 if [ "$l_FLAG" = "y" ]; then 1612 echo "WARNING: the -S flags do not support lint;" \ 1613 "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE 1614 l_FLAG=n 1615 fi 1616 if [ "$C_FLAG" = "y" ]; then 1617 echo "WARNING: the -S flags do not support cstyle;" \ 1618 "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE 1619 C_FLAG=n 1620 fi 1621else 1622 if [ "$N_FLAG" = "y" ]; then 1623 if [ "$p_FLAG" = "y" ]; then 1624 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1625WARNING: the p option (create packages) is set, but so is the N option (do 1626 not run protocmp); this is dangerous; you should unset the N option 1627EOF 1628 else 1629 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE 1630Warning: the N option (do not run protocmp) is set; it probably shouldn't be 1631EOF 1632 fi 1633 echo "" | tee -a $mail_msg_file >> $LOGFILE 1634 fi 1635fi 1636 1637if [ "$a_FLAG" = "y" -a "$D_FLAG" = "n" -a "$F_FLAG" = "y" ]; then 1638 echo "WARNING: Neither DEBUG nor non-DEBUG build requested, but the" \ 1639 "'a' option was set." | tee -a $mail_msg_file >> $LOGFILE 1640fi 1641 1642if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 1643 echo "WARNING: DEBUG build not requested, but lint will be with" \ 1644 "DEBUG enabled.\n" \ 1645 | tee -a $mail_msg_file >> $LOGFILE 1646fi 1647 1648if [ "$f_FLAG" = "y" ]; then 1649 if [ "$i_FLAG" = "y" ]; then 1650 echo "WARNING: the -f flag cannot be used during incremental" \ 1651 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE 1652 f_FLAG=n 1653 fi 1654 if [ "$p_FLAG" != "y" -o "$l_FLAG" != "y" ]; then 1655 echo "WARNING: the -f flag requires -l and -p; ignoring -f\n" | \ 1656 tee -a $mail_msg_file >> $LOGFILE 1657 f_FLAG=n 1658 fi 1659fi 1660 1661if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then 1662 echo "WARNING: -w specified, but no pre-existing proto area found;" \ 1663 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE 1664 w_FLAG=n 1665fi 1666 1667if [ "$t_FLAG" = "n" ]; then 1668 # 1669 # We're not doing a tools build, so make sure elfsign(1) is 1670 # new enough to safely sign non-crypto binaries. We test 1671 # debugging output from elfsign to detect the old version. 1672 # 1673 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \ 1674 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \ 1675 | egrep algorithmOID` 1676 if [ -z "$newelfsigntest" ]; then 1677 echo "WARNING: /usr/bin/elfsign out of date;" \ 1678 "will only sign crypto modules\n" | \ 1679 tee -a $mail_msg_file >> $LOGFILE 1680 export ELFSIGN_OBJECT=true 1681 elif [ "$VERIFY_ELFSIGN" = "y" ]; then 1682 echo "WARNING: VERIFY_ELFSIGN=y requires" \ 1683 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \ 1684 tee -a $mail_msg_file >> $LOGFILE 1685 fi 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 1701$MAKE -v | tee -a $mail_msg_file >> $LOGFILE 1702echo "number of concurrent jobs = $DMAKE_MAX_JOBS" | 1703 tee -a $mail_msg_file >> $LOGFILE 1704 1705# 1706# Report the compiler versions. 1707# 1708if [ -f $SRC/Makefile ]; then 1709 srcroot=$SRC 1710elif [ -f $BRINGOVER_WS/usr/src/Makefile ]; then 1711 srcroot=$BRINGOVER_WS/usr/src 1712else 1713 echo "\nUnable to find \"Makefile\" in $BRINGOVER_WS/usr/src or $SRC." | 1714 tee -a $mail_msg_file >> $LOGFILE 1715 exit 1 1716fi 1717 1718( cd $srcroot 1719 for target in cc-version cc64-version java-version; do 1720 echo 1721 # 1722 # Put statefile somewhere we know we can write to rather than trip 1723 # over a read-only $srcroot. 1724 # 1725 rm -f $TMPDIR/make-state 1726 export SRC=$srcroot 1727 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then 1728 continue 1729 fi 1730 touch $TMPDIR/nocompiler 1731 done 1732 echo 1733) | tee -a $mail_msg_file >> $LOGFILE 1734 1735if [ -f $TMPDIR/nocompiler ]; then 1736 rm -f $TMPDIR/nocompiler 1737 build_ok=n 1738 echo "Aborting due to missing compiler." | 1739 tee -a $mail_msg_file >> $LOGFILE 1740 exit 1 1741fi 1742 1743# as 1744whence as | tee -a $mail_msg_file >> $LOGFILE 1745as -V 2>&1 | head -1 | tee -a $mail_msg_file >> $LOGFILE 1746echo | tee -a $mail_msg_file >> $LOGFILE 1747 1748# Check that we're running a capable link-editor 1749whence ld | tee -a $mail_msg_file >> $LOGFILE 1750LDVER=`ld -V 2>&1` 1751echo $LDVER | tee -a $mail_msg_file >> $LOGFILE 1752LDVER=`echo $LDVER | sed -e "s/.*-1\.//" -e "s/:.*//"` 1753if [ `expr $LDVER \< 422` -eq 1 ]; then 1754 echo "The link-editor needs to be at version 422 or higher to build" | \ 1755 tee -a $mail_msg_file >> $LOGFILE 1756 echo "the latest stuff, hope your build works." | \ 1757 tee -a $mail_msg_file >> $LOGFILE 1758fi 1759 1760echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \ 1761 tee -a $mail_msg_file >> $LOGFILE 1762 1763echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE 1764echo $VERSION | tee -a $mail_msg_file >> $LOGFILE 1765 1766# Save the current proto area if we're comparing against the last build 1767if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then 1768 if [ -d "$ROOT.prev" ]; then 1769 rm -rf $ROOT.prev 1770 fi 1771 mv $ROOT $ROOT.prev 1772fi 1773 1774# 1775# Decide whether to clobber 1776# 1777if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then 1778 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE 1779 1780 cd $SRC 1781 # remove old clobber file 1782 rm -f $SRC/clobber.out 1783 rm -f $SRC/clobber-${MACH}.out 1784 1785 # Remove all .make.state* files, just in case we are restarting 1786 # the build after having interrupted a previous 'make clobber'. 1787 find . \( -name SCCS -o -name 'interfaces.*' \) -prune \ 1788 -o -name '.make.*' -print | xargs rm -f 1789 1790 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE 1791 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file 1792 grep "$MAKE:" $SRC/clobber-${MACH}.out | 1793 egrep -v "Ignoring unknown host" \ 1794 >> $mail_msg_file 1795 1796 if [ "$t_FLAG" = "y" ]; then 1797 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE 1798 cd ${TOOLS} 1799 rm -f ${TOOLS}/clobber-${MACH}.out 1800 $MAKE -ek clobber 2>&1 | \ 1801 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE 1802 echo "\n==== Make tools clobber ERRORS ====\n" \ 1803 >> $mail_msg_file 1804 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \ 1805 >> $mail_msg_file 1806 rm -rf ${TOOLS_PROTO} 1807 mkdir -p ${TOOLS_PROTO} 1808 fi 1809 1810 rm -rf $ROOT 1811 1812 # Get back to a clean workspace as much as possible to catch 1813 # problems that only occur on fresh workspaces. 1814 # Remove all .make.state* files, libraries, and .o's that may 1815 # have been omitted from clobber. A couple of libraries are 1816 # under SCCS, so leave them alone. 1817 # We should probably blow away temporary directories too. 1818 cd $SRC 1819 find $relsrcdirs \( -name SCCS -o -name 'interfaces.*' \) -prune -o \ 1820 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \ 1821 -name '*.o' \) -print | \ 1822 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f 1823else 1824 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE 1825fi 1826 1827# 1828# Decide whether to bringover to the codemgr workspace 1829# 1830if [ "$n_FLAG" = "n" ]; then 1831 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE 1832 # sleep on the parent workspace's lock 1833 while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks 1834 do 1835 sleep 120 1836 done 1837 1838 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file 1839 1840 (staffer $TEAMWARE/bin/bringover -c "nightly update" -p $BRINGOVER_WS \ 1841 -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 || 1842 touch $TMPDIR/bringover_failed 1843 1844 staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1 1845 1846 if [ -s $TMPDIR/bringovercheck.out ]; then 1847 echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n" 1848 cat $TMPDIR/bringovercheck.out 1849 fi 1850 1851 ) | tee -a $mail_msg_file >> $LOGFILE 1852 1853 if [ -f $TMPDIR/bringover_failed ]; then 1854 rm -f $TMPDIR/bringover_failed 1855 build_ok=n 1856 echo "trouble with bringover, quitting at `date`." | 1857 tee -a $mail_msg_file >> $LOGFILE 1858 exit 1 1859 fi 1860 1861 # 1862 # Possible transition from pre-split workspace to split 1863 # workspace. See if the bringover changed anything. 1864 # 1865 CLOSED_IS_PRESENT="$orig_closed_is_present" 1866 check_closed_tree 1867else 1868 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE 1869fi 1870 1871# 1872# Build tools if requested 1873# 1874if [ "$t_FLAG" = "y" ]; then 1875 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 1876 export RELEASE_BUILD ; RELEASE_BUILD= 1877 unset EXTRA_OPTIONS 1878 unset EXTRA_CFLAGS 1879 1880 export ONBLD_TOOLS=${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld} 1881 build_tools ${TOOLS_PROTO} 1882fi 1883 1884# 1885# copy ihv proto area in addition to the build itself 1886# 1887if [ "$X_FLAG" = "y" ]; then 1888 copy_ihv_proto 1889fi 1890 1891if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then 1892 echo "\n==== NOT Building base OS-Net source ====\n" | \ 1893 tee -a $LOGFILE >> $mail_msg_file 1894else 1895 normal_build 1896fi 1897 1898ORIG_SRC=$SRC 1899BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z 1900 1901if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1902 save_binaries 1903 1904 echo "\n==== Retrieving SCCS files at `date` ====\n" >> $LOGFILE 1905 SCCSHELPER=${TMPDIR}/sccs-helper 1906 rm -f ${SCCSHELPER} 1907cat >${SCCSHELPER} <<EOF 1908#!/bin/ksh 1909cd \$1 1910cd .. 1911sccs get SCCS >/dev/null 2>&1 1912EOF 1913 cd $SRC 1914 chmod +x ${SCCSHELPER} 1915 find $relsrcdirs -name SCCS | xargs -L 1 ${SCCSHELPER} 1916 rm -f ${SCCSHELPER} 1917fi 1918 1919if [ "$SD_FLAG" = "y" ]; then 1920 clone_source ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC 1921fi 1922 1923# EXPORT_SRC comes after CRYPT_SRC since a domestic build will need 1924# $SRC pointing to the export_source usr/src. 1925if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1926 clone_source ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC 1927fi 1928 1929if [ "$SD_FLAG" = "y" ]; then 1930 # drop the crypt files in place. 1931 cd ${EXPORT_SRC} 1932 echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \ 1933 >> ${LOGFILE} 1934 zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \ 1935 cpio -idmucvB 2>/dev/null >> ${LOGFILE} 1936 if [ "$?" = "0" ]; then 1937 echo "\n==== DOMESTIC extraction succeeded ====\n" \ 1938 >> $mail_msg_file 1939 else 1940 echo "\n==== DOMESTIC extraction failed ====\n" \ 1941 >> $mail_msg_file 1942 fi 1943 1944fi 1945 1946if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then 1947 # remove proto area here, since we don't clobber 1948 rm -rf "$ROOT" 1949 if [ "$t_FLAG" = "y" ]; then 1950 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD= 1951 export RELEASE_BUILD ; RELEASE_BUILD= 1952 unset EXTRA_OPTIONS 1953 unset EXTRA_CFLAGS 1954 ORIG_TOOLS=$TOOLS 1955 TOOLS=${EXPORT_SRC}/usr/src/tools 1956 build_tools ${EXPORT_SRC}/usr/src/tools/proto 1957 TOOLS=$ORIG_TOOLS 1958 fi 1959 1960 export EXPORT_RELEASE_BUILD ; EXPORT_RELEASE_BUILD=# 1961 normal_build 1962fi 1963 1964if [ "$build_ok" = "y" ]; then 1965 echo "\n==== Creating protolist system file at `date` ====" \ 1966 >> $LOGFILE 1967 protolist $ROOT > $ATLOG/proto_list_${MACH} 1968 echo "==== protolist system file created at `date` ====\n" \ 1969 >> $LOGFILE 1970 1971 if [ "$N_FLAG" != "y" ]; then 1972 echo "\n==== Impact on packages ====\n" >> $mail_msg_file 1973 1974 # If there is a reference proto list, compare the build's proto 1975 # list with the reference to see changes in proto areas. 1976 # Use the current exception list. 1977 exc=etc/exception_list_$MACH 1978 if [ -f $SRC/pkgdefs/$exc ]; then 1979 ELIST="-e $SRC/pkgdefs/$exc" 1980 fi 1981 if [ "$X_FLAG" = "y" -a -f $IA32_IHV_WS/usr/src/pkgdefs/$exc ]; then 1982 ELIST="$ELIST -e $IA32_IHV_WS/usr/src/pkgdefs/$exc" 1983 fi 1984 1985 if [ -f "$REF_PROTO_LIST" ]; then 1986 # For builds that copy the IHV proto area (-X), add the 1987 # IHV proto list to the reference list if the reference 1988 # was built without -X. 1989 # 1990 # For builds that don't copy the IHV proto area, add the 1991 # IHV proto list to the build's proto list if the 1992 # reference was built with -X. 1993 # 1994 # Use the presence of the first file entry of the cached 1995 # IHV proto list in the reference list to determine 1996 # whether it was build with -X or not. 1997 IHV_REF_PROTO_LIST=$SRC/pkgdefs/etc/proto_list_ihv_$MACH 1998 grepfor=$(nawk '$1 == "f" { print $2; exit }' \ 1999 $IHV_REF_PROTO_LIST 2> /dev/null) 2000 if [ $? = 0 -a -n "$grepfor" ]; then 2001 if [ "$X_FLAG" = "y" ]; then 2002 grep -w "$grepfor" \ 2003 $REF_PROTO_LIST > /dev/null 2004 if [ ! "$?" = "0" ]; then 2005 REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST" 2006 fi 2007 else 2008 grep -w "$grepfor" \ 2009 $REF_PROTO_LIST > /dev/null 2010 if [ "$?" = "0" ]; then 2011 IHV_PROTO_LIST="$IHV_REF_PROTO_LIST" 2012 fi 2013 fi 2014 fi 2015 2016 $PROTOCMPTERSE \ 2017 "Files in yesterday's proto area, but not today's:" \ 2018 "Files in today's proto area, but not yesterday's:" \ 2019 "Files that changed between yesterday and today:" \ 2020 ${ELIST} \ 2021 -d $REF_PROTO_LIST \ 2022 $REF_IHV_PROTO \ 2023 $ATLOG/proto_list_${MACH} \ 2024 $IHV_PROTO_LIST \ 2025 >> $mail_msg_file 2026 fi 2027 # Compare the build's proto list with current package 2028 # definitions to audit the quality of package definitions 2029 # and makefile install targets. Use the current exception list. 2030 PKGDEFS_LIST="" 2031 for d in $abssrcdirs; do 2032 if [ -d $d/pkgdefs ]; then 2033 PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs" 2034 fi 2035 done 2036 if [ "$X_FLAG" = "y" -a -d $IA32_IHV_WS/usr/src/pkgdefs ]; then 2037 PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs" 2038 fi 2039 2040 $PROTOCMPTERSE \ 2041 "Files missing from the proto area:" \ 2042 "Files missing from packages:" \ 2043 "Inconsistencies between pkgdefs and proto area:" \ 2044 ${ELIST} \ 2045 ${PKGDEFS_LIST} \ 2046 $ATLOG/proto_list_${MACH} \ 2047 >> $mail_msg_file 2048 fi 2049fi 2050 2051if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then 2052 staffer cp $ATLOG/proto_list_${MACH} \ 2053 $PARENT_WS/usr/src/proto_list_${MACH} 2054fi 2055 2056# Update parent proto area if necessary. This is done now 2057# so that the proto area has either DEBUG or non-DEBUG kernels. 2058# Note that this clears out the lock file, so we can dispense with 2059# the variable now. 2060if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then 2061 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \ 2062 tee -a $LOGFILE >> $mail_msg_file 2063 # The rm -rf command below produces predictable errors if 2064 # nightly is invoked from the parent's $ROOT/opt/onbld/bin, 2065 # and that directory is accessed via NFS. This is because 2066 # deleted-but-still-open files don't actually disappear as 2067 # expected, but rather turn into .nfsXXXX junk files, leaving 2068 # the directory non-empty. Since this is a not-unusual usage 2069 # pattern, and we still want to catch other errors here, we 2070 # take the unusal step of moving aside 'nightly' from that 2071 # directory (if we're using it). 2072 mypath=${0##*/root_$MACH/} 2073 if [ "$mypath" = $0 ]; then 2074 mypath=opt/onbld/bin/${0##*/} 2075 fi 2076 if [ $0 -ef $PARENT_WS/proto/root_$MACH/$mypath ]; then 2077 mv -f $0 $PARENT_WS/proto/root_$MACH 2078 fi 2079 rm -rf $PARENT_WS/proto/root_$MACH/* 2080 unset Ulockfile 2081 mkdir -p $NIGHTLY_PARENT_ROOT 2082 cd $ROOT 2083 ( tar cf - . | ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 | 2084 tee -a $mail_msg_file >> $LOGFILE 2085fi 2086 2087# 2088# do shared library interface verification 2089# 2090 2091if [ "$A_FLAG" = "y" -a "$build_ok" = "y" ]; then 2092 echo "\n==== Check versioning and ABI information ====\n" | \ 2093 tee -a $LOGFILE >> $mail_msg_file 2094 2095 rm -rf $SRC/interfaces.ref 2096 if [ -d $SRC/interfaces.out ]; then 2097 mv $SRC/interfaces.out $SRC/interfaces.ref 2098 fi 2099 rm -rf $SRC/interfaces.out 2100 mkdir -p $SRC/interfaces.out 2101 2102 intf_check -V -m -o -b $SRC/tools/abi/etc \ 2103 -d $SRC/interfaces.out $ROOT 2>&1 | sort \ 2104 > $SRC/interfaces.out/log 2105 2106 # report any ERROR found in log file 2107 fgrep 'ERROR' $SRC/interfaces.out/log | sed 's/^ERROR: //' | \ 2108 tee -a $LOGFILE >> $mail_msg_file 2109 2110 if [ ! -d $SRC/interfaces.ref ] ; then 2111 mkdir -p $SRC/interfaces.ref 2112 if [ -d $SRC/interfaces.out ]; then 2113 cp -r $SRC/interfaces.out/* $SRC/interfaces.ref 2114 fi 2115 fi 2116 2117 echo "\n==== Diff versioning warnings (since last build) ====\n" | \ 2118 tee -a $LOGFILE >> $mail_msg_file 2119 2120 out_vers=`grep ^VERSION $SRC/interfaces.out/log`; 2121 ref_vers=`grep ^VERSION $SRC/interfaces.ref/log`; 2122 2123 # Report any differences in WARNING messages between last 2124 # and current build. 2125 if [ "$out_vers" = "$ref_vers" ]; then 2126 diff $SRC/interfaces.ref/log $SRC/interfaces.out/log | \ 2127 fgrep 'WARNING' | sed 's/WARNING: //' | \ 2128 tee -a $LOGFILE >> $mail_msg_file 2129 fi 2130fi 2131 2132if [ "$r_FLAG" = "y" -a "$build_ok" = "y" ]; then 2133 echo "\n==== Check ELF runtime attributes ====\n" | \ 2134 tee -a $LOGFILE >> $mail_msg_file 2135 2136 LDDUSAGE="^ldd: does not support -e" 2137 LDDWRONG="wrong class" 2138 CRLERROR="^crle:" 2139 CRLECONF="^crle: configuration file:" 2140 2141 rm -f $SRC/runtime.ref 2142 if [ -f $SRC/runtime.out ]; then 2143 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2144 $SRC/runtime.out > $SRC/runtime.ref 2145 fi 2146 2147 # If we're doing a debug build the proto area will be left with 2148 # debuggable objects, thus don't assert -s. 2149 if [ "$D_FLAG" = "y" ]; then 2150 rtime_sflag="" 2151 else 2152 rtime_sflag="-s" 2153 fi 2154 check_rtime -d $ROOT -i -m -o $rtime_sflag $ROOT 2>&1 | \ 2155 egrep -v ": unreferenced object=$ROOT/.*/lib(w|intl|thread|pthread).so" | \ 2156 egrep -v ": unused object=$ROOT/.*/lib(w|intl|thread|pthread).so" | \ 2157 sort >$SRC/runtime.out 2158 2159 # Determine any processing errors that will affect the final output 2160 # and display these first. 2161 grep -l "$LDDUSAGE" $SRC/runtime.out > /dev/null 2162 if [ $? -eq 0 ]; then 2163 echo "WARNING: ldd(1) does not support -e. The version of ldd(1)" | \ 2164 tee -a $LOGFILE >> $mail_msg_file 2165 echo "on your system is old - 4390308 (s81_30) is required.\n" | \ 2166 tee -a $LOGFILE >> $mail_msg_file 2167 fi 2168 grep -l "$LDDWRONG" $SRC/runtime.out > /dev/null 2169 if [ $? -eq 0 ]; then 2170 echo "WARNING: wrong class message detected. ldd(1) was unable" | \ 2171 tee -a $LOGFILE >> $mail_msg_file 2172 echo "to execute an object, thus it could not be checked fully." | \ 2173 tee -a $LOGFILE >> $mail_msg_file 2174 echo "Perhaps a 64-bit object was encountered on a 32-bit system," | \ 2175 tee -a $LOGFILE >> $mail_msg_file 2176 echo "or an i386 object was encountered on a sparc system?\n" | \ 2177 tee -a $LOGFILE >> $mail_msg_file 2178 fi 2179 grep -l "$CRLECONF" $SRC/runtime.out > /dev/null 2180 if [ $? -eq 0 ]; then 2181 echo "WARNING: creation of an alternative dependency cache failed." | \ 2182 tee -a $LOGFILE >> $mail_msg_file 2183 echo "Dependencies will bind to the base system libraries.\n" | \ 2184 tee -a $LOGFILE >> $mail_msg_file 2185 grep "$CRLECONF" $SRC/runtime.out | \ 2186 tee -a $LOGFILE >> $mail_msg_file 2187 grep "$CRLERROR" $SRC/runtime.out | grep -v "$CRLECONF" | \ 2188 tee -a $LOGFILE >> $mail_msg_file 2189 echo "\n" | tee -a $LOGFILE >> $mail_msg_file 2190 fi 2191 2192 egrep '<dependency no longer necessary>' $SRC/runtime.out | \ 2193 tee -a $LOGFILE >> $mail_msg_file 2194 2195 # NEEDED= and RPATH= are informational; report anything else that we 2196 # haven't already. 2197 egrep -v "NEEDED=|RPATH=|$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2198 $SRC/runtime.out | tee -a $LOGFILE >> $mail_msg_file 2199 2200 # probably should compare against a 'known ok runpaths' list 2201 if [ ! -f $SRC/runtime.ref ]; then 2202 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" \ 2203 $SRC/runtime.out > $SRC/runtime.ref 2204 fi 2205 2206 echo "\n==== Diff ELF runtime attributes (since last build) ====\n" \ 2207 >> $mail_msg_file 2208 2209 egrep -v "$LDDUSAGE|$LDDWRONG|$CRLERROR|$CRLECONF" $SRC/runtime.out | \ 2210 diff $SRC/runtime.ref - >> $mail_msg_file 2211fi 2212 2213# DEBUG lint of kernel begins 2214 2215if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then 2216 if [ "$LINTDIRS" = "" ]; then 2217 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y" 2218 LINTDIRS="$SRC y" 2219 fi 2220 set $LINTDIRS 2221 while [ $# -gt 0 ]; do 2222 dolint $1 $2; shift; shift 2223 done 2224else 2225 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE 2226fi 2227 2228# "make check" begins 2229 2230if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then 2231 # remove old check.out 2232 rm -f $SRC/check.out 2233 2234 rm -f $SRC/check-${MACH}.out 2235 cd $SRC 2236 $MAKE -ek check 2>&1 | tee -a $SRC/check-${MACH}.out >> $LOGFILE 2237 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file 2238 2239 grep ":" $SRC/check-${MACH}.out | 2240 egrep -v "Ignoring unknown host" | \ 2241 sort | uniq >> $mail_msg_file 2242else 2243 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE 2244fi 2245 2246echo "\n==== Find core files ====\n" | \ 2247 tee -a $LOGFILE >> $mail_msg_file 2248 2249find $abssrcdirs -name core -a -type f -exec file {} \; | \ 2250 tee -a $LOGFILE >> $mail_msg_file 2251 2252if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2253 echo "\n==== Diff unreferenced files (since last build) ====\n" \ 2254 | tee -a $LOGFILE >>$mail_msg_file 2255 rm -f $SRC/unref-${MACH}.ref 2256 if [ -f $SRC/unref-${MACH}.out ]; then 2257 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2258 fi 2259 2260 findunref -t $SRC/.build.tstamp $SRC/.. \ 2261 ${TOOLS}/findunref/exception_list \ 2262 2>> $mail_msg_file | sort | \ 2263 sed -e s=^./src/=./= -e s=^./closed/=../closed/= \ 2264 > $SRC/unref-${MACH}.out 2265 2266 if [ ! -f $SRC/unref-${MACH}.ref ]; then 2267 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref 2268 fi 2269 2270 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file 2271fi 2272 2273# Verify that the usual lists of files, such as exception lists, 2274# contain only valid references to files. If the build has failed, 2275# then don't check the proto area. 2276CHECK_PATHS=${CHECK_PATHS:-y} 2277if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then 2278 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \ 2279 >>$mail_msg_file 2280 arg=-b 2281 [ "$build_ok" = y ] && arg= 2282 checkpaths $arg $ROOT 2>&1 | tee -a $LOGFILE >>$mail_msg_file 2283fi 2284 2285if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then 2286 echo "\n==== Impact on file permissions ====\n" \ 2287 >> $mail_msg_file 2288 # 2289 # Get pkginfo files from usr/src/pkgdefs 2290 # 2291 pmodes -qvdP \ 2292 `for d in $abssrcdirs; do 2293 if [ -d "$d/pkgdefs" ] 2294 then 2295 find $d/pkgdefs -name pkginfo.tmpl -print -o -name .del\* -prune 2296 fi 2297 done | sed -e 's:/pkginfo.tmpl$::' | sort -u ` >> $mail_msg_file 2298fi 2299 2300if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then 2301 echo "\n==== Objects that differ since last build ====\n" | \ 2302 tee -a $LOGFILE >> $mail_msg_file 2303 2304 if [ "$t_FLAG" = "y" ]; then 2305 wsdiff -t -r ${TMPDIR}/wsdiff.results $ROOT.prev $ROOT | \ 2306 tee -a $LOGFILE >> $mail_msg_file 2307 else 2308 wsdiff -r ${TMPDIR}/wsdiff.results $ROOT.prev $ROOT | \ 2309 tee -a $LOGFILE >> $mail_msg_file 2310 fi 2311fi 2312 2313END_DATE=`date` 2314echo "==== Nightly $maketype build completed: $END_DATE ====" | \ 2315 tee -a $LOGFILE >> $build_time_file 2316 2317typeset -Z2 minutes 2318typeset -Z2 seconds 2319 2320elapsed_time=$SECONDS 2321((hours = elapsed_time / 3600 )) 2322((minutes = elapsed_time / 60 % 60)) 2323((seconds = elapsed_time % 60)) 2324 2325echo "\n==== Total build time ====" | \ 2326 tee -a $LOGFILE >> $build_time_file 2327echo "\nreal ${hours}:${minutes}:${seconds}" | \ 2328 tee -a $LOGFILE >> $build_time_file 2329 2330if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then 2331 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/ 2332 2333 # 2334 # Produce a master list of unreferenced files -- ideally, we'd 2335 # generate the master just once after all of the nightlies 2336 # have finished, but there's no simple way to know when that 2337 # will be. Instead, we assume that we're the last nightly to 2338 # finish and merge all of the unref-${MACH}.out files in 2339 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to 2340 # finish, then this file will be the authoritative master 2341 # list. Otherwise, another ${MACH}'s nightly will eventually 2342 # overwrite ours with its own master, but in the meantime our 2343 # temporary "master" will be no worse than any older master 2344 # which was already on the parent. 2345 # 2346 2347 set -- $PARENT_WS/usr/src/unref-*.out 2348 cp "$1" ${TMPDIR}/unref.merge 2349 shift 2350 2351 for unreffile; do 2352 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$ 2353 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge 2354 done 2355 2356 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out 2357fi 2358 2359# 2360# All done save for the sweeping up. 2361# (whichever exit we hit here will trigger the "cleanup" trap which 2362# optionally sends mail on completion). 2363# 2364if [ "$build_ok" = "y" ]; then 2365 exit 0 2366fi 2367exit 1 2368