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