Print this page
4029 remove tonic build bits
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/nightly.sh
+++ new/usr/src/tools/scripts/nightly.sh
1 1 #!/bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 # Copyright 2008, 2010, Richard Lowe
26 26 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
27 27 # Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
28 28 #
29 29 # Based on the nightly script from the integration folks,
30 30 # Mostly modified and owned by mike_s.
31 31 # Changes also by kjc, dmk.
32 32 #
33 33 # BRINGOVER_WS may be specified in the env file.
34 34 # The default is the old behavior of CLONE_WS
35 35 #
36 36 # -i on the command line, means fast options, so when it's on the
37 37 # command line (only), lint and check builds are skipped no matter what
38 38 # the setting of their individual flags are in NIGHTLY_OPTIONS.
39 39 #
40 40 # LINTDIRS can be set in the env file, format is a list of:
41 41 #
42 42 # /dirname-to-run-lint-on flag
43 43 #
44 44 # Where flag is: y - enable lint noise diff output
45 45 # n - disable lint noise diff output
46 46 #
47 47 # For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
48 48 #
49 49 # OPTHOME and TEAMWARE may be set in the environment to override /opt
50 50 # and /opt/teamware defaults.
51 51 #
52 52
53 53 #
54 54 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
55 55 # under certain circumstances, which can really screw things up; unset it.
56 56 #
57 57 unset CDPATH
58 58
59 59 # Get the absolute path of the nightly script that the user invoked. This
60 60 # may be a relative path, and we need to do this before changing directory.
61 61 nightly_path=`whence $0`
62 62
63 63 #
64 64 # Keep track of where we found nightly so we can invoke the matching
65 65 # which_scm script. If that doesn't work, don't go guessing, just rely
66 66 # on the $PATH settings, which will generally give us either /opt/onbld
67 67 # or the user's workspace.
68 68 #
69 69 WHICH_SCM=$(dirname $nightly_path)/which_scm
70 70 if [[ ! -x $WHICH_SCM ]]; then
71 71 WHICH_SCM=which_scm
72 72 fi
73 73
74 74 function fatal_error
75 75 {
76 76 print -u2 "nightly: $*"
77 77 exit 1
78 78 }
79 79
80 80 #
81 81 # Function to do a DEBUG and non-DEBUG build. Needed because we might
82 82 # need to do another for the source build, and since we only deliver DEBUG or
83 83 # non-DEBUG packages.
84 84 #
85 85 # usage: normal_build
86 86 #
87 87 function normal_build {
88 88
89 89 typeset orig_p_FLAG="$p_FLAG"
90 90 typeset crypto_signer="$CODESIGN_USER"
91 91
92 92 suffix=""
93 93
94 94 # non-DEBUG build begins
95 95
96 96 if [ "$F_FLAG" = "n" ]; then
97 97 set_non_debug_build_flags
98 98 CODESIGN_USER="$crypto_signer" \
99 99 build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
100 100 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \
101 101 "$p_FLAG" = "y" ]; then
102 102 copy_ihv_pkgs non-DEBUG -nd
103 103 fi
104 104 else
105 105 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
106 106 fi
107 107
108 108 # non-DEBUG build ends
109 109
110 110 # DEBUG build begins
111 111
112 112 if [ "$D_FLAG" = "y" ]; then
113 113 set_debug_build_flags
114 114 CODESIGN_USER="$crypto_signer" \
115 115 build "DEBUG" "$suffix" "" "$MULTI_PROTO"
116 116 if [ "$build_ok" = "y" -a "$X_FLAG" = "y" -a \
117 117 "$p_FLAG" = "y" ]; then
118 118 copy_ihv_pkgs DEBUG ""
119 119 fi
120 120 else
121 121 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
122 122 fi
123 123
124 124 # DEBUG build ends
125 125
126 126 p_FLAG="$orig_p_FLAG"
127 127 }
128 128
129 129 #
130 130 # usage: run_hook HOOKNAME ARGS...
131 131 #
132 132 # If variable "$HOOKNAME" is defined, insert a section header into
133 133 # our logs and then run the command with ARGS
134 134 #
135 135 function run_hook {
136 136 HOOKNAME=$1
137 137 eval HOOKCMD=\$$HOOKNAME
138 138 shift
139 139
140 140 if [ -n "$HOOKCMD" ]; then
141 141 (
142 142 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
143 143 ( $HOOKCMD "$@" 2>&1 )
144 144 if [ "$?" -ne 0 ]; then
145 145 # Let exit status propagate up
146 146 touch $TMPDIR/abort
147 147 fi
148 148 ) | tee -a $mail_msg_file >> $LOGFILE
149 149
150 150 if [ -f $TMPDIR/abort ]; then
151 151 build_ok=n
152 152 echo "\nAborting at request of $HOOKNAME" |
153 153 tee -a $mail_msg_file >> $LOGFILE
154 154 exit 1
155 155 fi
156 156 fi
157 157 }
158 158
159 159 #
160 160 # usage: filelist DESTDIR PATTERN
161 161 #
162 162 function filelist {
163 163 DEST=$1
164 164 PATTERN=$2
165 165 cd ${DEST}
166 166 }
167 167
168 168 # function to save off binaries after a full build for later
169 169 # restoration
170 170 function save_binaries {
171 171 # save off list of binaries
172 172 echo "\n==== Saving binaries from build at `date` ====\n" | \
173 173 tee -a $mail_msg_file >> $LOGFILE
174 174 rm -f ${BINARCHIVE}
175 175 cd ${CODEMGR_WS}
176 176 filelist ${CODEMGR_WS} '^preserve:' >> $LOGFILE
177 177 filelist ${CODEMGR_WS} '^preserve:' | \
178 178 cpio -ocB 2>/dev/null | compress \
179 179 > ${BINARCHIVE}
180 180 }
181 181
182 182 # delete files
183 183 # usage: hybridize_files DESTDIR MAKE_TARGET
184 184 function hybridize_files {
185 185 DEST=$1
186 186 MAKETARG=$2
187 187
188 188 echo "\n==== Hybridizing files at `date` ====\n" | \
189 189 tee -a $mail_msg_file >> $LOGFILE
190 190 for i in `filelist ${DEST} '^delete:'`
191 191 do
192 192 echo "removing ${i}." | tee -a $mail_msg_file >> $LOGFILE
193 193 rm -rf "${i}"
194 194 done
195 195 for i in `filelist ${DEST} '^hybridize:' `
196 196 do
197 197 echo "hybridizing ${i}." | tee -a $mail_msg_file >> $LOGFILE
198 198 rm -f ${i}+
199 199 sed -e "/^# HYBRID DELETE START/,/^# HYBRID DELETE END/d" \
200 200 < ${i} > ${i}+
201 201 mv ${i}+ ${i}
202 202 done
203 203 }
204 204
205 205 # restore binaries into the proper source tree.
206 206 # usage: restore_binaries DESTDIR MAKE_TARGET
207 207 function restore_binaries {
208 208 DEST=$1
209 209 MAKETARG=$2
210 210
211 211 echo "\n==== Restoring binaries to ${MAKETARG} at `date` ====\n" | \
212 212 tee -a $mail_msg_file >> $LOGFILE
213 213 cd ${DEST}
214 214 zcat ${BINARCHIVE} | \
215 215 cpio -idmucvB 2>/dev/null | tee -a $mail_msg_file >> ${LOGFILE}
216 216 }
217 217
218 218 # rename files we save binaries of
219 219 # usage: rename_files DESTDIR MAKE_TARGET
220 220 function rename_files {
221 221 DEST=$1
222 222 MAKETARG=$2
223 223 echo "\n==== Renaming source files in ${MAKETARG} at `date` ====\n" | \
224 224 tee -a $mail_msg_file >> $LOGFILE
225 225 for i in `filelist ${DEST} '^rename:'`
226 226 do
227 227 echo ${i} | tee -a $mail_msg_file >> ${LOGFILE}
228 228 rm -f ${i}.export
229 229 mv ${i} ${i}.export
230 230 done
231 231 }
232 232
233 233 #
234 234 # Copy some or all of the source tree.
235 235 #
236 236 # Returns 0 for success, non-zero for failure.
237 237 #
238 238 # usage: copy_source CODEMGR_WS DESTDIR LABEL SRCROOT
239 239 #
240 240 function copy_source {
241 241 WS=$1
242 242 DEST=$2
243 243 label=$3
244 244 srcroot=$4
245 245
246 246 printf "\n==== Creating %s source from %s (%s) ====\n\n" \
247 247 "$DEST" "$WS" "$label" | tee -a $mail_msg_file >> $LOGFILE
248 248
249 249 printf "cleaning out %s\n" "$DEST." >> $LOGFILE
250 250 rm -rf "$DEST" >> $LOGFILE 2>&1
251 251
252 252 printf "creating %s\n" "$DEST." >> $LOGFILE
253 253 mkdir -p "$DEST" 2>> $LOGFILE
254 254
255 255 if (( $? != 0 )) ; then
256 256 printf "failed to create %s\n" "$DEST" |
257 257 tee -a $mail_msg_file >> $LOGFILE
258 258 build_ok=n
259 259 return 1
260 260 fi
261 261 cd "$WS"
262 262
263 263 printf "populating %s\n" "$DEST." >> $LOGFILE
264 264
265 265 case "$SCM_TYPE" in
266 266 teamware)
267 267 find $srcroot -name 's\.*' -a -type f -print | \
268 268 sed -e 's,SCCS\/s.,,' | \
269 269 grep -v '/\.del-*' | \
270 270 cpio -pd $DEST >>$LOGFILE 2>&1
271 271 if (( $? != 0 )) ; then
272 272 printf "cpio failed for %s\n" "$DEST" |
273 273 tee -a $mail_msg_file >> $LOGFILE
274 274 build_ok=n
275 275 return 1
276 276 fi
277 277 ;;
278 278 mercurial)
279 279 copy_source_mercurial $DEST $srcroot
280 280 if (( $? != 0 )) ; then
281 281 build_ok=n
282 282 return 1
283 283 fi
284 284 ;;
285 285 *)
286 286 build_ok=n
287 287 echo "Tree copy is not supported for workspace type" \
288 288 "$SCM_TYPE" | tee -a $mail_msg_file >> $LOGFILE
289 289 return 1
290 290 ;;
291 291 esac
292 292
293 293 return 0
294 294 }
295 295
296 296 #
297 297 # Mercurial-specific copy code for copy_source().
298 298 #
299 299 # Returns 0 for success, non-zero for failure.
300 300 #
301 301 # usage: copy_source_mercurial destdir srcroot
302 302 #
303 303 function copy_source_mercurial {
304 304 typeset dest=$1
305 305 typeset srcroot=$2
306 306
307 307 hg locate -I "$srcroot" | cpio -pd "$dest" >>$LOGFILE 2>&1
308 308 if (( $? != 0 )) ; then
309 309 printf "cpio failed for %s\n" "$dest" |
310 310 tee -a $mail_msg_file >> $LOGFILE
311 311 return 1
312 312 fi
313 313
314 314 return 0
315 315 }
316 316
317 317 #
318 318 # function to create (but not build) the export/crypt source tree.
319 319 # usage: set_up_source_build CODEMGR_WS DESTDIR MAKE_TARGET
320 320 # Sets SRC to the modified source tree, for use by the caller when it
321 321 # builds the tree.
322 322 #
323 323 function set_up_source_build {
324 324 WS=$1
325 325 DEST=$2
326 326 MAKETARG=$3
327 327
328 328 copy_source $WS $DEST $MAKETARG usr
329 329 if (( $? != 0 )); then
330 330 echo "\nCould not copy source tree for source build." |
331 331 tee -a $mail_msg_file >> $LOGFILE
332 332 build_ok=n
333 333 return
334 334 fi
335 335
336 336 SRC=${DEST}/usr/src
337 337
338 338 cd $SRC
339 339 rm -f ${MAKETARG}.out
340 340 echo "making ${MAKETARG} in ${SRC}." >> $LOGFILE
341 341 /bin/time $MAKE -e ${MAKETARG} 2>&1 | \
342 342 tee -a $SRC/${MAKETARG}.out >> $LOGFILE
343 343 echo "\n==== ${MAKETARG} build errors ====\n" >> $mail_msg_file
344 344 egrep ":" $SRC/${MAKETARG}.out | \
345 345 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
346 346 egrep -v "Ignoring unknown host" | \
347 347 egrep -v "warning" >> $mail_msg_file
348 348
349 349 echo "clearing state files." >> $LOGFILE
350 350 find . -name '.make*' -exec rm -f {} \;
351 351 }
352 352
353 353 # Return library search directive as function of given root.
354 354 function myldlibs {
355 355 echo "-L$1/lib -L$1/usr/lib"
356 356 }
357 357
358 358 # Return header search directive as function of given root.
359 359 function myheaders {
360 360 echo "-I$1/usr/include"
361 361 }
362 362
363 363 #
364 364 # Function to do the build, including package generation.
365 365 # usage: build LABEL SUFFIX ND MULTIPROTO
366 366 # - LABEL is used to tag build output.
367 367 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
368 368 # open-only vs full tree).
369 369 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
370 370 # - If MULTIPROTO is "yes", it means to name the proto area according to
371 371 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
372 372 #
373 373 function build {
374 374 LABEL=$1
375 375 SUFFIX=$2
376 376 ND=$3
377 377 MULTIPROTO=$4
378 378 INSTALLOG=install${SUFFIX}-${MACH}
379 379 NOISE=noise${SUFFIX}-${MACH}
380 380 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
381 381
382 382 ORIGROOT=$ROOT
383 383 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
384 384
385 385 if [[ "$O_FLAG" = y ]]; then
386 386 echo "\nSetting CLOSEDROOT= ${ROOT}-closed\n" >> $LOGFILE
387 387 export CLOSEDROOT=${ROOT}-closed
388 388 fi
389 389
390 390 export ENVLDLIBS1=`myldlibs $ROOT`
391 391 export ENVCPPFLAGS1=`myheaders $ROOT`
392 392
393 393 this_build_ok=y
394 394 #
395 395 # Build OS-Networking source
396 396 #
397 397 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
398 398 >> $LOGFILE
399 399
400 400 rm -f $SRC/${INSTALLOG}.out
401 401 cd $SRC
402 402 /bin/time $MAKE -e install 2>&1 | \
403 403 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
404 404
405 405 if [[ "$SCM_TYPE" = teamware ]]; then
406 406 echo "\n==== SCCS Noise ($LABEL) ====\n" >> $mail_msg_file
407 407 egrep 'sccs(check:| *get)' $SRC/${INSTALLOG}.out >> \
408 408 $mail_msg_file
409 409 fi
410 410
411 411 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
412 412 egrep ":" $SRC/${INSTALLOG}.out |
413 413 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
414 414 egrep -v "Ignoring unknown host" | \
415 415 egrep -v "cc .* -o error " | \
416 416 egrep -v "warning" >> $mail_msg_file
417 417 if [ "$?" = "0" ]; then
418 418 build_ok=n
419 419 this_build_ok=n
420 420 fi
421 421 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
422 422 >> $mail_msg_file
423 423 if [ "$?" = "0" ]; then
424 424 build_ok=n
425 425 this_build_ok=n
426 426 fi
427 427
428 428 if [ "$W_FLAG" = "n" ]; then
429 429 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
430 430 egrep -i warning: $SRC/${INSTALLOG}.out \
431 431 | egrep -v '^tic:' \
432 432 | egrep -v "symbol (\`|')timezone' has differing types:" \
433 433 | egrep -v "parameter <PSTAMP> set to" \
434 434 | egrep -v "Ignoring unknown host" \
435 435 | egrep -v "redefining segment flags attribute for" \
436 436 >> $mail_msg_file
437 437 fi
438 438
439 439 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
440 440 >> $LOGFILE
441 441
442 442 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
443 443 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
444 444
445 445 if [ "$i_FLAG" = "n" -a "$W_FLAG" = "n" ]; then
446 446 rm -f $SRC/${NOISE}.ref
447 447 if [ -f $SRC/${NOISE}.out ]; then
448 448 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
449 449 fi
450 450 grep : $SRC/${INSTALLOG}.out \
451 451 | egrep -v '^/' \
452 452 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
453 453 | egrep -v '^tic:' \
454 454 | egrep -v '^mcs' \
455 455 | egrep -v '^LD_LIBRARY_PATH=' \
456 456 | egrep -v 'ar: creating' \
457 457 | egrep -v 'ar: writing' \
458 458 | egrep -v 'conflicts:' \
459 459 | egrep -v ':saved created' \
460 460 | egrep -v '^stty.*c:' \
461 461 | egrep -v '^mfgname.c:' \
462 462 | egrep -v '^uname-i.c:' \
463 463 | egrep -v '^volumes.c:' \
464 464 | egrep -v '^lint library construction:' \
465 465 | egrep -v 'tsort: INFORM:' \
466 466 | egrep -v 'stripalign:' \
467 467 | egrep -v 'chars, width' \
468 468 | egrep -v "symbol (\`|')timezone' has differing types:" \
469 469 | egrep -v 'PSTAMP' \
470 470 | egrep -v '|%WHOANDWHERE%|' \
471 471 | egrep -v '^Manifying' \
472 472 | egrep -v 'Ignoring unknown host' \
473 473 | egrep -v 'Processing method:' \
474 474 | egrep -v '^Writing' \
475 475 | egrep -v 'spellin1:' \
476 476 | egrep -v '^adding:' \
477 477 | egrep -v "^echo 'msgid" \
478 478 | egrep -v '^echo ' \
479 479 | egrep -v '\.c:$' \
480 480 | egrep -v '^Adding file:' \
481 481 | egrep -v 'CLASSPATH=' \
482 482 | egrep -v '\/var\/mail\/:saved' \
483 483 | egrep -v -- '-DUTS_VERSION=' \
484 484 | egrep -v '^Running Mkbootstrap' \
485 485 | egrep -v '^Applet length read:' \
486 486 | egrep -v 'bytes written:' \
487 487 | egrep -v '^File:SolarisAuthApplet.bin' \
488 488 | egrep -v -i 'jibversion' \
489 489 | egrep -v '^Output size:' \
490 490 | egrep -v '^Solo size statistics:' \
491 491 | egrep -v '^Using ROM API Version' \
492 492 | egrep -v '^Zero Signature length:' \
493 493 | egrep -v '^Note \(probably harmless\):' \
494 494 | egrep -v '::' \
495 495 | egrep -v -- '-xcache' \
496 496 | egrep -v '^\+' \
497 497 | egrep -v '^cc1: note: -fwritable-strings' \
498 498 | egrep -v 'svccfg-native -s svc:/' \
499 499 | sort | uniq >$SRC/${NOISE}.out
500 500 if [ ! -f $SRC/${NOISE}.ref ]; then
501 501 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref
502 502 fi
503 503 echo "\n==== Build noise differences ($LABEL) ====\n" \
504 504 >>$mail_msg_file
505 505 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file
506 506 fi
507 507
508 508 #
509 509 # Re-sign selected binaries using signing server
510 510 # (gatekeeper builds only)
511 511 #
512 512 if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then
513 513 echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE
514 514 signing_file="${TMPDIR}/signing"
515 515 rm -f ${signing_file}
516 516 export CODESIGN_USER
517 517 signproto $SRC/tools/codesign/creds 2>&1 | \
518 518 tee -a ${signing_file} >> $LOGFILE
519 519 echo "\n==== Finished signing proto area at `date` ====\n" \
520 520 >> $LOGFILE
521 521 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
522 522 >> $mail_msg_file
523 523 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
524 524 if (( $? == 0 )) ; then
525 525 build_ok=n
526 526 this_build_ok=n
527 527 fi
528 528 fi
529 529
530 530 #
531 531 # Building Packages
532 532 #
533 533 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
534 534 if [ -d $SRC/pkg -o -d $SRC/pkgdefs ]; then
535 535 echo "\n==== Creating $LABEL packages at `date` ====\n" \
536 536 >> $LOGFILE
537 537 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
538 538 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
539 539 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
540 540
541 541 for d in pkg pkgdefs; do
542 542 if [ ! -f "$SRC/$d/Makefile" ]; then
543 543 continue
544 544 fi
545 545 rm -f $SRC/$d/${INSTALLOG}.out
546 546 cd $SRC/$d
547 547 /bin/time $MAKE -e install 2>&1 | \
548 548 tee -a $SRC/$d/${INSTALLOG}.out >> $LOGFILE
549 549 done
550 550
551 551 echo "\n==== package build errors ($LABEL) ====\n" \
552 552 >> $mail_msg_file
553 553
554 554 for d in pkg pkgdefs; do
555 555 if [ ! -f "$SRC/$d/Makefile" ]; then
556 556 continue
557 557 fi
558 558
559 559 egrep "${MAKE}|ERROR|WARNING" $SRC/$d/${INSTALLOG}.out | \
560 560 grep ':' | \
561 561 grep -v PSTAMP | \
562 562 egrep -v "Ignoring unknown host" \
563 563 >> $mail_msg_file
564 564 done
565 565 else
566 566 #
567 567 # Handle it gracefully if -p was set but there are
568 568 # neither pkg nor pkgdefs directories.
569 569 #
570 570 echo "\n==== No $LABEL packages to build ====\n" \
571 571 >> $LOGFILE
572 572 fi
573 573 else
574 574 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
575 575 fi
576 576
577 577 ROOT=$ORIGROOT
578 578 }
579 579
580 580 # Usage: dolint /dir y|n
581 581 # Arg. 2 is a flag to turn on/off the lint diff output
582 582 function dolint {
583 583 if [ ! -d "$1" ]; then
584 584 echo "dolint error: $1 is not a directory"
585 585 exit 1
586 586 fi
587 587
588 588 if [ "$2" != "y" -a "$2" != "n" ]; then
589 589 echo "dolint internal error: $2 should be 'y' or 'n'"
590 590 exit 1
591 591 fi
592 592
593 593 lintdir=$1
594 594 dodiff=$2
595 595 base=`basename $lintdir`
596 596 LINTOUT=$lintdir/lint-${MACH}.out
597 597 LINTNOISE=$lintdir/lint-noise-${MACH}
598 598 export ENVLDLIBS1=`myldlibs $ROOT`
599 599 export ENVCPPFLAGS1=`myheaders $ROOT`
600 600
601 601 set_debug_build_flags
602 602
603 603 #
604 604 # '$MAKE lint' in $lintdir
605 605 #
606 606 echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
607 607
608 608 # remove old lint.out
609 609 rm -f $lintdir/lint.out $lintdir/lint-noise.out
610 610 if [ -f $lintdir/lint-noise.ref ]; then
611 611 mv $lintdir/lint-noise.ref ${LINTNOISE}.ref
612 612 fi
613 613
614 614 rm -f $LINTOUT
615 615 cd $lintdir
616 616 #
617 617 # Remove all .ln files to ensure a full reference file
618 618 #
619 619 rm -f Nothing_to_remove \
620 620 `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
621 621 -prune -o -type f -name '*.ln' -print `
622 622
623 623 /bin/time $MAKE -ek lint 2>&1 | \
624 624 tee -a $LINTOUT >> $LOGFILE
625 625 echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file
626 626 grep "$MAKE:" $LINTOUT |
627 627 egrep -v "Ignoring unknown host" \
628 628 >> $mail_msg_file
629 629
630 630 echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
631 631
632 632 echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
633 633 >>$mail_msg_file
634 634 tail -3 $LINTOUT >>$mail_msg_file
635 635
636 636 rm -f ${LINTNOISE}.ref
637 637 if [ -f ${LINTNOISE}.out ]; then
638 638 mv ${LINTNOISE}.out ${LINTNOISE}.ref
639 639 fi
640 640 grep : $LINTOUT | \
641 641 egrep -v '^(real|user|sys)' |
642 642 egrep -v '(library construction)' | \
643 643 egrep -v ': global crosschecks' | \
644 644 egrep -v 'Ignoring unknown host' | \
645 645 egrep -v '\.c:$' | \
646 646 sort | uniq > ${LINTNOISE}.out
647 647 if [ ! -f ${LINTNOISE}.ref ]; then
648 648 cp ${LINTNOISE}.out ${LINTNOISE}.ref
649 649 fi
650 650 if [ "$dodiff" != "n" ]; then
651 651 echo "\n==== lint warnings $base ====\n" \
652 652 >>$mail_msg_file
653 653 # should be none, though there are a few that were filtered out
654 654 # above
655 655 egrep -i '(warning|lint):' ${LINTNOISE}.out \
656 656 | sort | uniq >> $mail_msg_file
657 657 echo "\n==== lint noise differences $base ====\n" \
658 658 >> $mail_msg_file
659 659 diff ${LINTNOISE}.ref ${LINTNOISE}.out \
660 660 >> $mail_msg_file
661 661 fi
662 662 }
663 663
664 664 # Install proto area from IHV build
665 665
666 666 function copy_ihv_proto {
667 667
668 668 echo "\n==== Installing IHV proto area ====\n" \
669 669 >> $LOGFILE
670 670 if [ -d "$IA32_IHV_ROOT" ]; then
671 671 if [ ! -d "$ROOT" ]; then
672 672 echo "mkdir -p $ROOT" >> $LOGFILE
673 673 mkdir -p $ROOT
674 674 fi
675 675 echo "copying $IA32_IHV_ROOT to $ROOT\n" >> $LOGFILE
676 676 cd $IA32_IHV_ROOT
677 677 tar cf - . | (cd $ROOT; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
678 678 else
679 679 echo "$IA32_IHV_ROOT: not found" >> $LOGFILE
680 680 fi
681 681
682 682 if [ "$MULTI_PROTO" = yes ]; then
683 683 if [ ! -d "$ROOT-nd" ]; then
684 684 echo "mkdir -p $ROOT-nd" >> $LOGFILE
685 685 mkdir -p $ROOT-nd
686 686 fi
687 687 # If there's a non-DEBUG version of the IHV proto area,
688 688 # copy it, but copy something if there's not.
689 689 if [ -d "$IA32_IHV_ROOT-nd" ]; then
690 690 echo "copying $IA32_IHV_ROOT-nd to $ROOT-nd\n" >> $LOGFILE
691 691 cd $IA32_IHV_ROOT-nd
692 692 elif [ -d "$IA32_IHV_ROOT" ]; then
693 693 echo "copying $IA32_IHV_ROOT to $ROOT-nd\n" >> $LOGFILE
694 694 cd $IA32_IHV_ROOT
695 695 else
696 696 echo "$IA32_IHV_ROOT{-nd,}: not found" >> $LOGFILE
697 697 return
698 698 fi
699 699 tar cf - . | (cd $ROOT-nd; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
700 700 fi
701 701 }
702 702
703 703 # Install IHV packages in PKGARCHIVE
704 704 # usage: copy_ihv_pkgs LABEL SUFFIX
705 705 function copy_ihv_pkgs {
706 706 LABEL=$1
707 707 SUFFIX=$2
708 708 # always use non-DEBUG IHV packages
709 709 IA32_IHV_PKGS=${IA32_IHV_PKGS_ORIG}-nd
710 710 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
711 711
712 712 echo "\n==== Installing IHV packages from $IA32_IHV_PKGS ($LABEL) ====\n" \
713 713 >> $LOGFILE
714 714 if [ -d "$IA32_IHV_PKGS" ]; then
715 715 cd $IA32_IHV_PKGS
716 716 tar cf - * | \
717 717 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
718 718 else
719 719 echo "$IA32_IHV_PKGS: not found" >> $LOGFILE
720 720 fi
721 721
722 722 echo "\n==== Installing IHV packages from $IA32_IHV_BINARY_PKGS ($LABEL) ====\n" \
723 723 >> $LOGFILE
724 724 if [ -d "$IA32_IHV_BINARY_PKGS" ]; then
725 725 cd $IA32_IHV_BINARY_PKGS
726 726 tar cf - * | \
727 727 (cd $PKGARCHIVE; umask 0; tar xpf - ) 2>&1 >> $LOGFILE
728 728 else
729 729 echo "$IA32_IHV_BINARY_PKGS: not found" >> $LOGFILE
730 730 fi
731 731 }
732 732
733 733 #
734 734 # Build and install the onbld tools.
735 735 #
736 736 # usage: build_tools DESTROOT
737 737 #
738 738 # returns non-zero status if the build was successful.
739 739 #
740 740 function build_tools {
741 741 DESTROOT=$1
742 742
743 743 INSTALLOG=install-${MACH}
744 744
745 745 echo "\n==== Building tools at `date` ====\n" \
746 746 >> $LOGFILE
747 747
748 748 rm -f ${TOOLS}/${INSTALLOG}.out
749 749 cd ${TOOLS}
750 750 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
751 751 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
752 752
753 753 echo "\n==== Tools build errors ====\n" >> $mail_msg_file
754 754
755 755 egrep ":" ${TOOLS}/${INSTALLOG}.out |
756 756 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
757 757 egrep -v "Ignoring unknown host" | \
758 758 egrep -v warning >> $mail_msg_file
759 759 return $?
760 760 }
761 761
762 762 #
763 763 # Set up to use locally installed tools.
764 764 #
765 765 # usage: use_tools TOOLSROOT
766 766 #
767 767 function use_tools {
768 768 TOOLSROOT=$1
769 769
770 770 #
771 771 # If we're not building ON workspace, then the TOOLSROOT
772 772 # settings here are clearly ignored by the workspace
773 773 # makefiles, prepending nonexistent directories to PATH is
774 774 # harmless, and we clearly do not wish to override
775 775 # ONBLD_TOOLS.
776 776 #
777 777 # If we're building an ON workspace, then the prepended PATH
778 778 # elements should supercede the preexisting ONBLD_TOOLS paths,
779 779 # and we want to override ONBLD_TOOLS to catch the tools that
780 780 # don't have specific path env vars here.
781 781 #
782 782 # So the only conditional behavior is overriding ONBLD_TOOLS,
783 783 # and we check for "an ON workspace" by looking for
784 784 # ${TOOLSROOT}/opt/onbld.
785 785 #
786 786
787 787 STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs
788 788 export STABS
789 789 CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs
790 790 export CTFSTABS
791 791 GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets
792 792 export GENOFFSETS
793 793
794 794 CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert
795 795 export CTFCONVERT
796 796 CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge
797 797 export CTFMERGE
798 798
799 799 CTFCVTPTBL=${TOOLSROOT}/opt/onbld/bin/ctfcvtptbl
800 800 export CTFCVTPTBL
801 801 CTFFINDMOD=${TOOLSROOT}/opt/onbld/bin/ctffindmod
802 802 export CTFFINDMOD
803 803
804 804 if [ "$VERIFY_ELFSIGN" = "y" ]; then
805 805 ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp
806 806 else
807 807 ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign
808 808 fi
809 809 export ELFSIGN
810 810
811 811 PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}"
812 812 PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}"
813 813 export PATH
814 814
815 815 if [ -d "${TOOLSROOT}/opt/onbld" ]; then
816 816 ONBLD_TOOLS=${TOOLSROOT}/opt/onbld
817 817 export ONBLD_TOOLS
818 818 fi
819 819
820 820 echo "\n==== New environment settings. ====\n" >> $LOGFILE
821 821 echo "STABS=${STABS}" >> $LOGFILE
822 822 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
823 823 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
824 824 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
825 825 echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE
826 826 echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE
827 827 echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE
828 828 echo "PATH=${PATH}" >> $LOGFILE
829 829 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
830 830 }
831 831
832 832 function staffer {
833 833 if [ $ISUSER -ne 0 ]; then
834 834 "$@"
835 835 else
836 836 arg="\"$1\""
837 837 shift
838 838 for i
839 839 do
840 840 arg="$arg \"$i\""
841 841 done
842 842 eval su $STAFFER -c \'$arg\'
843 843 fi
844 844 }
845 845
846 846 #
847 847 # Verify that the closed tree is present if it needs to be.
848 848 #
849 849 function check_closed_tree {
850 850 if [[ ! -d "$ON_CLOSED_BINS" ]]; then
851 851 echo "ON_CLOSED_BINS must point to the closed binaries tree."
852 852 build_ok=n
853 853 exit 1
854 854 fi
855 855 }
856 856
857 857 function obsolete_build {
858 858 echo "WARNING: Obsolete $1 build requested; request will be ignored"
859 859 }
860 860
861 861 #
862 862 # wrapper over wsdiff.
863 863 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
864 864 #
865 865 function do_wsdiff {
866 866 label=$1
867 867 oldproto=$2
868 868 newproto=$3
869 869
870 870 wsdiff="wsdiff"
871 871 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
872 872
873 873 echo "\n==== Getting object changes since last build at `date`" \
874 874 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
875 875 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
876 876 tee -a $LOGFILE >> $mail_msg_file
877 877 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
878 878 tee -a $LOGFILE >> $mail_msg_file
879 879 }
880 880
881 881 #
882 882 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
883 883 # together.
884 884 #
885 885
886 886 function set_non_debug_build_flags {
887 887 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
888 888 export RELEASE_BUILD ; RELEASE_BUILD=
889 889 unset EXTRA_OPTIONS
890 890 unset EXTRA_CFLAGS
891 891 }
892 892
893 893 function set_debug_build_flags {
894 894 export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
895 895 unset RELEASE_BUILD
896 896 unset EXTRA_OPTIONS
897 897 unset EXTRA_CFLAGS
898 898 }
899 899
900 900
901 901 MACH=`uname -p`
902 902
903 903 if [ "$OPTHOME" = "" ]; then
904 904 OPTHOME=/opt
905 905 export OPTHOME
906 906 fi
907 907 if [ "$TEAMWARE" = "" ]; then
908 908 TEAMWARE=$OPTHOME/teamware
909 909 export TEAMWARE
910 910 fi
911 911
912 912 USAGE='Usage: nightly [-in] [+t] [-V VERS ] [ -S E|D|H|O ] <env_file>
913 913
914 914 Where:
915 915 -i Fast incremental options (no clobber, lint, check)
916 916 -n Do not do a bringover
917 917 +t Use the build tools in $ONBLD_TOOLS/bin
918 918 -V VERS set the build version string to VERS
919 919 -S Build a variant of the source product
920 920 E - build exportable source
921 921 D - build domestic source (exportable + crypt)
922 922 H - build hybrid source (binaries + deleted source)
923 923 O - build (only) open source
924 924
925 925 <env_file> file in Bourne shell syntax that sets and exports
926 926 variables that configure the operation of this script and many of
927 927 the scripts this one calls. If <env_file> does not exist,
928 928 it will be looked for in $OPTHOME/onbld/env.
929 929
930 930 non-DEBUG is the default build type. Build options can be set in the
931 931 NIGHTLY_OPTIONS variable in the <env_file> as follows:
932 932
933 933 -A check for ABI differences in .so files
934 934 -C check for cstyle/hdrchk errors
935 935 -D do a build with DEBUG on
936 936 -F do _not_ do a non-DEBUG build
937 937 -G gate keeper default group of options (-au)
938 938 -I integration engineer default group of options (-ampu)
939 939 -M do not run pmodes (safe file permission checker)
940 940 -N do not run protocmp
941 941 -O generate OpenSolaris deliverables
942 942 -R default group of options for building a release (-mp)
943 943 -U update proto area in the parent
944 944 -V VERS set the build version string to VERS
945 945 -X copy x86 IHV proto area
946 946 -f find unreferenced files
947 947 -i do an incremental build (no "make clobber")
948 948 -l do "make lint" in $LINTDIRS (default: $SRC y)
949 949 -m send mail to $MAILTO at end of build
950 950 -n do not do a bringover
951 951 -o build using root privileges to set OWNER/GROUP (old style)
952 952 -p create packages
953 953 -r check ELF runtime attributes in the proto area
954 954 -t build and use the tools in $SRC/tools (default setting)
955 955 +t Use the build tools in $ONBLD_TOOLS/bin
956 956 -u update proto_list_$MACH and friends in the parent workspace;
957 957 when used with -f, also build an unrefmaster.out in the parent
958 958 -w report on differences between previous and current proto areas
959 959 -z compress cpio archives with gzip
960 960 -W Do not report warnings (freeware gate ONLY)
961 961 -S Build a variant of the source product
962 962 E - build exportable source
963 963 D - build domestic source (exportable + crypt)
964 964 H - build hybrid source (binaries + deleted source)
965 965 O - build (only) open source
966 966 '
967 967 #
968 968 # A log file will be generated under the name $LOGFILE
969 969 # for partially completed build and log.`date '+%F'`
970 970 # in the same directory for fully completed builds.
971 971 #
972 972
973 973 # default values for low-level FLAGS; G I R are group FLAGS
974 974 A_FLAG=n
975 975 C_FLAG=n
976 976 D_FLAG=n
977 977 F_FLAG=n
978 978 f_FLAG=n
979 979 i_FLAG=n; i_CMD_LINE_FLAG=n
980 980 l_FLAG=n
981 981 M_FLAG=n
982 982 m_FLAG=n
983 983 N_FLAG=n
984 984 n_FLAG=n
985 985 O_FLAG=n
986 986 o_FLAG=n
987 987 P_FLAG=n
988 988 p_FLAG=n
989 989 r_FLAG=n
990 990 T_FLAG=n
991 991 t_FLAG=y
992 992 U_FLAG=n
993 993 u_FLAG=n
994 994 V_FLAG=n
995 995 W_FLAG=n
996 996 w_FLAG=n
997 997 X_FLAG=n
998 998 SD_FLAG=n
999 999 SE_FLAG=n
1000 1000 SH_FLAG=n
1001 1001 SO_FLAG=n
1002 1002 #
1003 1003 XMOD_OPT=
1004 1004 #
1005 1005 build_ok=y
1006 1006
1007 1007 function is_source_build {
1008 1008 [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o \
1009 1009 "$SH_FLAG" = "y" -o "$SO_FLAG" = "y" ]
1010 1010 return $?
1011 1011 }
1012 1012
1013 1013 #
1014 1014 # examine arguments
1015 1015 #
1016 1016
1017 1017 #
1018 1018 # single function for setting -S flag and doing error checking.
1019 1019 # usage: set_S_flag <type>
1020 1020 # where <type> is the source build type ("E", "D", ...).
1021 1021 #
1022 1022 function set_S_flag {
1023 1023 if is_source_build; then
1024 1024 echo "Can only build one source variant at a time."
1025 1025 exit 1
1026 1026 fi
1027 1027 if [ "$1" = "E" ]; then
1028 1028 SE_FLAG=y
1029 1029 elif [ "$1" = "D" ]; then
1030 1030 SD_FLAG=y
1031 1031 elif [ "$1" = "H" ]; then
1032 1032 SH_FLAG=y
1033 1033 elif [ "$1" = "O" ]; then
1034 1034 SO_FLAG=y
1035 1035 else
1036 1036 echo "$USAGE"
1037 1037 exit 1
1038 1038 fi
1039 1039 }
1040 1040
1041 1041 OPTIND=1
1042 1042 while getopts +inS:tV: FLAG
1043 1043 do
1044 1044 case $FLAG in
1045 1045 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
1046 1046 ;;
1047 1047 n ) n_FLAG=y
1048 1048 ;;
1049 1049 S )
1050 1050 set_S_flag $OPTARG
1051 1051 ;;
1052 1052 +t ) t_FLAG=n
1053 1053 ;;
1054 1054 V ) V_FLAG=y
1055 1055 V_ARG="$OPTARG"
1056 1056 ;;
1057 1057 \? ) echo "$USAGE"
1058 1058 exit 1
1059 1059 ;;
1060 1060 esac
1061 1061 done
1062 1062
1063 1063 # correct argument count after options
1064 1064 shift `expr $OPTIND - 1`
1065 1065
1066 1066 # test that the path to the environment-setting file was given
1067 1067 if [ $# -ne 1 ]; then
1068 1068 echo "$USAGE"
1069 1069 exit 1
1070 1070 fi
1071 1071
1072 1072 # check if user is running nightly as root
1073 1073 # ISUSER is set non-zero if an ordinary user runs nightly, or is zero
1074 1074 # when root invokes nightly.
1075 1075 /usr/bin/id | grep '^uid=0(' >/dev/null 2>&1
1076 1076 ISUSER=$?; export ISUSER
1077 1077
1078 1078 #
1079 1079 # force locale to C
1080 1080 LC_COLLATE=C; export LC_COLLATE
1081 1081 LC_CTYPE=C; export LC_CTYPE
1082 1082 LC_MESSAGES=C; export LC_MESSAGES
1083 1083 LC_MONETARY=C; export LC_MONETARY
1084 1084 LC_NUMERIC=C; export LC_NUMERIC
1085 1085 LC_TIME=C; export LC_TIME
1086 1086
1087 1087 # clear environment variables we know to be bad for the build
1088 1088 unset LD_OPTIONS
1089 1089 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
1090 1090 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
1091 1091 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
1092 1092 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
1093 1093 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
1094 1094 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
1095 1095 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
1096 1096 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
1097 1097 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
1098 1098 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
1099 1099 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
1100 1100 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
1101 1101 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
1102 1102 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
1103 1103 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
1104 1104 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
1105 1105 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
1106 1106 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
1107 1107 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
1108 1108 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
1109 1109
1110 1110 unset CONFIG
1111 1111 unset GROUP
1112 1112 unset OWNER
1113 1113 unset REMOTE
1114 1114 unset ENV
1115 1115 unset ARCH
1116 1116 unset CLASSPATH
1117 1117 unset NAME
1118 1118
1119 1119 #
1120 1120 # To get ONBLD_TOOLS from the environment, it must come from the env file.
1121 1121 # If it comes interactively, it is generally TOOLS_PROTO, which will be
1122 1122 # clobbered before the compiler version checks, which will therefore fail.
1123 1123 #
1124 1124 unset ONBLD_TOOLS
1125 1125
1126 1126 #
1127 1127 # Setup environmental variables
1128 1128 #
1129 1129 if [ -f /etc/nightly.conf ]; then
1130 1130 . /etc/nightly.conf
1131 1131 fi
1132 1132
1133 1133 if [ -f $1 ]; then
1134 1134 if [[ $1 = */* ]]; then
1135 1135 . $1
1136 1136 else
1137 1137 . ./$1
1138 1138 fi
1139 1139 else
1140 1140 if [ -f $OPTHOME/onbld/env/$1 ]; then
1141 1141 . $OPTHOME/onbld/env/$1
1142 1142 else
1143 1143 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1"
1144 1144 exit 1
1145 1145 fi
1146 1146 fi
1147 1147
1148 1148 # contents of stdenv.sh inserted after next line:
1149 1149 # STDENV_START
1150 1150 # STDENV_END
1151 1151
1152 1152 # Check if we have sufficient data to continue...
1153 1153 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1154 1154 if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
1155 1155 # Check if the gate data are valid if we don't do a "bringover" below
1156 1156 [[ -d "${CODEMGR_WS}" ]] || \
1157 1157 fatal_error "Error: ${CODEMGR_WS} is not a directory."
1158 1158 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
1159 1159 fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1160 1160 fi
1161 1161
1162 1162 #
1163 1163 # place ourselves in a new task, respecting BUILD_PROJECT if set.
1164 1164 #
1165 1165 if [ -z "$BUILD_PROJECT" ]; then
1166 1166 /usr/bin/newtask -c $$
1167 1167 else
1168 1168 /usr/bin/newtask -c $$ -p $BUILD_PROJECT
1169 1169 fi
1170 1170
1171 1171 ps -o taskid= -p $$ | read build_taskid
1172 1172 ps -o project= -p $$ | read build_project
1173 1173
1174 1174 #
1175 1175 # See if NIGHTLY_OPTIONS is set
1176 1176 #
1177 1177 if [ "$NIGHTLY_OPTIONS" = "" ]; then
1178 1178 NIGHTLY_OPTIONS="-aBm"
1179 1179 fi
1180 1180
1181 1181 #
1182 1182 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
1183 1183 #
1184 1184 if [ "$BRINGOVER_WS" = "" ]; then
1185 1185 BRINGOVER_WS=$CLONE_WS
1186 1186 fi
1187 1187
1188 1188 #
1189 1189 # If CLOSED_BRINGOVER_WS was not specified, let it default to CLOSED_CLONE_WS
1190 1190 #
1191 1191 if [ "$CLOSED_BRINGOVER_WS" = "" ]; then
1192 1192 CLOSED_BRINGOVER_WS=$CLOSED_CLONE_WS
1193 1193 fi
1194 1194
1195 1195 #
1196 1196 # If BRINGOVER_FILES was not specified, default to usr
1197 1197 #
1198 1198 if [ "$BRINGOVER_FILES" = "" ]; then
1199 1199 BRINGOVER_FILES="usr"
1200 1200 fi
1201 1201
1202 1202 check_closed_tree
1203 1203
1204 1204 #
1205 1205 # Note: changes to the option letters here should also be applied to the
1206 1206 # bldenv script. `d' is listed for backward compatibility.
1207 1207 #
1208 1208 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
1209 1209 OPTIND=1
1210 1210 while getopts +ABCDdFfGIilMmNnOoPpRrS:TtUuWwXxz FLAG $NIGHTLY_OPTIONS
1211 1211 do
1212 1212 case $FLAG in
1213 1213 A ) A_FLAG=y
1214 1214 ;;
1215 1215 B ) D_FLAG=y
1216 1216 ;; # old version of D
1217 1217 C ) C_FLAG=y
1218 1218 ;;
1219 1219 D ) D_FLAG=y
1220 1220 ;;
1221 1221 F ) F_FLAG=y
1222 1222 ;;
1223 1223 f ) f_FLAG=y
1224 1224 ;;
1225 1225 G ) u_FLAG=y
1226 1226 ;;
1227 1227 I ) m_FLAG=y
1228 1228 p_FLAG=y
1229 1229 u_FLAG=y
1230 1230 ;;
1231 1231 i ) i_FLAG=y
1232 1232 ;;
1233 1233 l ) l_FLAG=y
1234 1234 ;;
1235 1235 M ) M_FLAG=y
1236 1236 ;;
1237 1237 m ) m_FLAG=y
1238 1238 ;;
1239 1239 N ) N_FLAG=y
1240 1240 ;;
1241 1241 n ) n_FLAG=y
1242 1242 ;;
1243 1243 O ) O_FLAG=y
1244 1244 ;;
1245 1245 o ) o_FLAG=y
1246 1246 ;;
1247 1247 P ) P_FLAG=y
1248 1248 ;; # obsolete
1249 1249 p ) p_FLAG=y
1250 1250 ;;
1251 1251 R ) m_FLAG=y
1252 1252 p_FLAG=y
1253 1253 ;;
1254 1254 r ) r_FLAG=y
1255 1255 ;;
1256 1256 S )
1257 1257 set_S_flag $OPTARG
1258 1258 ;;
1259 1259 T ) T_FLAG=y
1260 1260 ;; # obsolete
1261 1261 +t ) t_FLAG=n
1262 1262 ;;
1263 1263 U ) if [ -z "${PARENT_ROOT}" ]; then
1264 1264 echo "PARENT_ROOT must be set if the U flag is" \
1265 1265 "present in NIGHTLY_OPTIONS."
1266 1266 exit 1
1267 1267 fi
1268 1268 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
1269 1269 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
1270 1270 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
1271 1271 fi
1272 1272 U_FLAG=y
1273 1273 ;;
1274 1274 u ) u_FLAG=y
1275 1275 ;;
1276 1276 W ) W_FLAG=y
1277 1277 ;;
1278 1278
1279 1279 w ) w_FLAG=y
1280 1280 ;;
1281 1281 X ) # now that we no longer need realmode builds, just
1282 1282 # copy IHV packages. only meaningful on x86.
1283 1283 if [ "$MACH" = "i386" ]; then
1284 1284 X_FLAG=y
1285 1285 fi
1286 1286 ;;
1287 1287 x ) XMOD_OPT="-x"
1288 1288 ;;
1289 1289 \? ) echo "$USAGE"
1290 1290 exit 1
1291 1291 ;;
1292 1292 esac
1293 1293 done
1294 1294
1295 1295 if [ $ISUSER -ne 0 ]; then
1296 1296 if [ "$o_FLAG" = "y" ]; then
1297 1297 echo "Old-style build requires root permission."
1298 1298 exit 1
1299 1299 fi
1300 1300
1301 1301 # Set default value for STAFFER, if needed.
1302 1302 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
1303 1303 STAFFER=`/usr/xpg4/bin/id -un`
1304 1304 export STAFFER
1305 1305 fi
1306 1306 fi
1307 1307
1308 1308 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
1309 1309 MAILTO=$STAFFER
1310 1310 export MAILTO
1311 1311 fi
1312 1312
1313 1313 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
1314 1314 PATH="$PATH:$OPTHOME/SUNWspro/bin:$TEAMWARE/bin:/usr/bin:/usr/sbin:/usr/ucb"
1315 1315 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
1316 1316 export PATH
1317 1317
1318 1318 # roots of source trees, both relative to $SRC and absolute.
1319 1319 relsrcdirs="."
1320 1320 abssrcdirs="$SRC"
1321 1321
1322 1322 unset CH
1323 1323 if [ "$o_FLAG" = "y" ]; then
1324 1324 # root invoked old-style build -- make sure it works as it always has
1325 1325 # by exporting 'CH'. The current Makefile.master doesn't use this, but
1326 1326 # the old ones still do.
1327 1327 PROTOCMPTERSE="protocmp.terse"
1328 1328 CH=
1329 1329 export CH
1330 1330 else
1331 1331 PROTOCMPTERSE="protocmp.terse -gu"
1332 1332 fi
1333 1333 POUND_SIGN="#"
1334 1334 # have we set RELEASE_DATE in our env file?
1335 1335 if [ -z "$RELEASE_DATE" ]; then
1336 1336 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
1337 1337 fi
1338 1338 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
1339 1339 BASEWSDIR=$(basename $CODEMGR_WS)
1340 1340 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
1341 1341
1342 1342 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
1343 1343 # by avoiding repeated shell invocations to evaluate Makefile.master definitions.
1344 1344 # we export o_FLAG and X_FLAG for use by makebfu, and by usr/src/pkg/Makefile
1345 1345 export o_FLAG X_FLAG POUND_SIGN RELEASE_DATE DEV_CM
1346 1346
1347 1347 maketype="distributed"
1348 1348 MAKE=dmake
1349 1349 # get the dmake version string alone
1350 1350 DMAKE_VERSION=$( $MAKE -v )
1351 1351 DMAKE_VERSION=${DMAKE_VERSION#*: }
1352 1352 # focus in on just the dotted version number alone
1353 1353 DMAKE_MAJOR=$( echo $DMAKE_VERSION | \
1354 1354 sed -e 's/.*\<\([^.]*\.[^ ]*\).*$/\1/' )
1355 1355 # extract the second (or final) integer
1356 1356 DMAKE_MINOR=${DMAKE_MAJOR#*.}
1357 1357 DMAKE_MINOR=${DMAKE_MINOR%%.*}
1358 1358 # extract the first integer
1359 1359 DMAKE_MAJOR=${DMAKE_MAJOR%%.*}
1360 1360 CHECK_DMAKE=${CHECK_DMAKE:-y}
1361 1361 # x86 was built on the 12th, sparc on the 13th.
1362 1362 if [ "$CHECK_DMAKE" = "y" -a \
1363 1363 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \
1364 1364 "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \
1365 1365 "$DMAKE_MAJOR" -lt 7 -o \
1366 1366 "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then
1367 1367 if [ -z "$DMAKE_VERSION" ]; then
1368 1368 echo "$MAKE is missing."
1369 1369 exit 1
1370 1370 fi
1371 1371 echo `whence $MAKE`" version is:"
1372 1372 echo " ${DMAKE_VERSION}"
1373 1373 cat <<EOF
1374 1374
1375 1375 This version may not be safe for use. Either set TEAMWARE to a better
↓ open down ↓ |
1375 lines elided |
↑ open up ↑ |
1376 1376 path or (if you really want to use this version of dmake anyway), add
1377 1377 the following to your environment to disable this check:
1378 1378
1379 1379 CHECK_DMAKE=n
1380 1380 EOF
1381 1381 exit 1
1382 1382 fi
1383 1383 export PATH
1384 1384 export MAKE
1385 1385
1386 -if [[ "$O_FLAG" = y ]]; then
1387 - export TONICBUILD=""
1388 -else
1389 - export TONICBUILD="#"
1390 -fi
1391 -
1392 1386 if [ "${SUNWSPRO}" != "" ]; then
1393 1387 PATH="${SUNWSPRO}/bin:$PATH"
1394 1388 export PATH
1395 1389 fi
1396 1390
1397 1391 hostname=$(uname -n)
1398 1392 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
1399 1393 then
1400 1394 maxjobs=
1401 1395 if [[ -f $HOME/.make.machines ]]
1402 1396 then
1403 1397 # Note: there is a hard tab and space character in the []s
1404 1398 # below.
1405 1399 egrep -i "^[ ]*$hostname[ \.]" \
1406 1400 $HOME/.make.machines | read host jobs
1407 1401 maxjobs=${jobs##*=}
1408 1402 fi
1409 1403
1410 1404 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
1411 1405 then
1412 1406 # default
1413 1407 maxjobs=4
1414 1408 fi
1415 1409
1416 1410 export DMAKE_MAX_JOBS=$maxjobs
1417 1411 fi
1418 1412
1419 1413 DMAKE_MODE=parallel;
1420 1414 export DMAKE_MODE
1421 1415
1422 1416 if [ -z "${ROOT}" ]; then
1423 1417 echo "ROOT must be set."
1424 1418 exit 1
1425 1419 fi
1426 1420
1427 1421 #
1428 1422 # if -V flag was given, reset VERSION to V_ARG
1429 1423 #
1430 1424 if [ "$V_FLAG" = "y" ]; then
1431 1425 VERSION=$V_ARG
1432 1426 fi
1433 1427
1434 1428 #
1435 1429 # Check for IHV root for copying ihv proto area
1436 1430 #
1437 1431 if [ "$X_FLAG" = "y" ]; then
1438 1432 if [ "$IA32_IHV_ROOT" = "" ]; then
1439 1433 echo "IA32_IHV_ROOT: must be set for copying ihv proto"
1440 1434 args_ok=n
1441 1435 fi
1442 1436 if [ ! -d "$IA32_IHV_ROOT" ]; then
1443 1437 echo "$IA32_IHV_ROOT: not found"
1444 1438 args_ok=n
1445 1439 fi
1446 1440 if [ "$IA32_IHV_WS" = "" ]; then
1447 1441 echo "IA32_IHV_WS: must be set for copying ihv proto"
1448 1442 args_ok=n
1449 1443 fi
1450 1444 if [ ! -d "$IA32_IHV_WS" ]; then
1451 1445 echo "$IA32_IHV_WS: not found"
1452 1446 args_ok=n
1453 1447 fi
1454 1448 fi
1455 1449
1456 1450 # Append source version
1457 1451 if [ "$SE_FLAG" = "y" ]; then
1458 1452 VERSION="${VERSION}:EXPORT"
1459 1453 fi
1460 1454
1461 1455 if [ "$SD_FLAG" = "y" ]; then
1462 1456 VERSION="${VERSION}:DOMESTIC"
1463 1457 fi
1464 1458
1465 1459 if [ "$SH_FLAG" = "y" ]; then
1466 1460 VERSION="${VERSION}:MODIFIED_SOURCE_PRODUCT"
1467 1461 fi
1468 1462
1469 1463 if [ "$SO_FLAG" = "y" ]; then
1470 1464 VERSION="${VERSION}:OPEN_ONLY"
1471 1465 fi
1472 1466
1473 1467 TMPDIR="/tmp/nightly.tmpdir.$$"
1474 1468 export TMPDIR
1475 1469 rm -rf ${TMPDIR}
1476 1470 mkdir -p $TMPDIR || exit 1
1477 1471 chmod 777 $TMPDIR
1478 1472
1479 1473 #
1480 1474 # Keep elfsign's use of pkcs11_softtoken from looking in the user home
1481 1475 # directory, which doesn't always work. Needed until all build machines
1482 1476 # have the fix for 6271754
1483 1477 #
1484 1478 SOFTTOKEN_DIR=$TMPDIR
1485 1479 export SOFTTOKEN_DIR
1486 1480
1487 1481 #
1488 1482 # Tools should only be built non-DEBUG. Keep track of the tools proto
1489 1483 # area path relative to $TOOLS, because the latter changes in an
1490 1484 # export build.
1491 1485 #
1492 1486 # TOOLS_PROTO is included below for builds other than usr/src/tools
1493 1487 # that look for this location. For usr/src/tools, this will be
1494 1488 # overridden on the $MAKE command line in build_tools().
1495 1489 #
1496 1490 TOOLS=${SRC}/tools
1497 1491 TOOLS_PROTO_REL=proto/root_${MACH}-nd
1498 1492 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
1499 1493
1500 1494 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
1501 1495
1502 1496 # create directories that are automatically removed if the nightly script
1503 1497 # fails to start correctly
1504 1498 function newdir {
1505 1499 dir=$1
1506 1500 toadd=
1507 1501 while [ ! -d $dir ]; do
1508 1502 toadd="$dir $toadd"
1509 1503 dir=`dirname $dir`
1510 1504 done
1511 1505 torm=
1512 1506 newlist=
1513 1507 for dir in $toadd; do
1514 1508 if staffer mkdir $dir; then
1515 1509 newlist="$ISUSER $dir $newlist"
1516 1510 torm="$dir $torm"
1517 1511 else
1518 1512 [ -z "$torm" ] || staffer rmdir $torm
1519 1513 return 1
1520 1514 fi
1521 1515 done
1522 1516 newdirlist="$newlist $newdirlist"
1523 1517 return 0
1524 1518 }
1525 1519 newdirlist=
1526 1520
1527 1521 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
1528 1522
1529 1523 # since this script assumes the build is from full source, it nullifies
1530 1524 # variables likely to have been set by a "ws" script; nullification
1531 1525 # confines the search space for headers and libraries to the proto area
1532 1526 # built from this immediate source.
1533 1527 ENVLDLIBS1=
1534 1528 ENVLDLIBS2=
1535 1529 ENVLDLIBS3=
1536 1530 ENVCPPFLAGS1=
1537 1531 ENVCPPFLAGS2=
1538 1532 ENVCPPFLAGS3=
1539 1533 ENVCPPFLAGS4=
1540 1534 PARENT_ROOT=
1541 1535
1542 1536 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1543 1537 PARENT_ROOT
1544 1538
1545 1539 PKGARCHIVE_ORIG=$PKGARCHIVE
1546 1540 IA32_IHV_PKGS_ORIG=$IA32_IHV_PKGS
1547 1541
1548 1542 #
1549 1543 # Juggle the logs and optionally send mail on completion.
1550 1544 #
1551 1545
1552 1546 function logshuffle {
1553 1547 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
1554 1548 if [ -f $LLOG -o -d $LLOG ]; then
1555 1549 LLOG=$LLOG.$$
1556 1550 fi
1557 1551 mkdir $LLOG
1558 1552 export LLOG
1559 1553
1560 1554 if [ "$build_ok" = "y" ]; then
1561 1555 mv $ATLOG/proto_list_${MACH} $LLOG
1562 1556
1563 1557 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
1564 1558 mv $ATLOG/proto_list_tools_${MACH} $LLOG
1565 1559 fi
1566 1560
1567 1561 if [ -f $TMPDIR/wsdiff.results ]; then
1568 1562 mv $TMPDIR/wsdiff.results $LLOG
1569 1563 fi
1570 1564
1571 1565 if [ -f $TMPDIR/wsdiff-nd.results ]; then
1572 1566 mv $TMPDIR/wsdiff-nd.results $LLOG
1573 1567 fi
1574 1568 fi
1575 1569
1576 1570 #
1577 1571 # Now that we're about to send mail, it's time to check the noise
1578 1572 # file. In the event that an error occurs beyond this point, it will
1579 1573 # be recorded in the nightly.log file, but nowhere else. This would
1580 1574 # include only errors that cause the copying of the noise log to fail
1581 1575 # or the mail itself not to be sent.
1582 1576 #
1583 1577
1584 1578 exec >>$LOGFILE 2>&1
1585 1579 if [ -s $build_noise_file ]; then
1586 1580 echo "\n==== Nightly build noise ====\n" |
1587 1581 tee -a $LOGFILE >>$mail_msg_file
1588 1582 cat $build_noise_file >>$LOGFILE
1589 1583 cat $build_noise_file >>$mail_msg_file
1590 1584 echo | tee -a $LOGFILE >>$mail_msg_file
1591 1585 fi
1592 1586 rm -f $build_noise_file
1593 1587
1594 1588 case "$build_ok" in
1595 1589 y)
1596 1590 state=Completed
1597 1591 ;;
1598 1592 i)
1599 1593 state=Interrupted
1600 1594 ;;
1601 1595 *)
1602 1596 state=Failed
1603 1597 ;;
1604 1598 esac
1605 1599 NIGHTLY_STATUS=$state
1606 1600 export NIGHTLY_STATUS
1607 1601
1608 1602 run_hook POST_NIGHTLY $state
1609 1603 run_hook SYS_POST_NIGHTLY $state
1610 1604
1611 1605 #
1612 1606 # mailx(1) sets From: based on the -r flag
1613 1607 # if it is given.
1614 1608 #
1615 1609 mailx_r=
1616 1610 if [[ -n "${MAILFROM}" ]]; then
1617 1611 mailx_r="-r ${MAILFROM}"
1618 1612 fi
1619 1613
1620 1614 cat $build_time_file $build_environ_file $mail_msg_file \
1621 1615 > ${LLOG}/mail_msg
1622 1616 if [ "$m_FLAG" = "y" ]; then
1623 1617 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1624 1618 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1625 1619 ${MAILTO}
1626 1620 fi
1627 1621
1628 1622 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1629 1623 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH}
1630 1624 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log
1631 1625 fi
1632 1626
1633 1627 mv $LOGFILE $LLOG
1634 1628 }
1635 1629
1636 1630 #
1637 1631 # Remove the locks and temporary files on any exit
1638 1632 #
1639 1633 function cleanup {
1640 1634 logshuffle
1641 1635
1642 1636 [ -z "$lockfile" ] || staffer rm -f $lockfile
1643 1637 [ -z "$atloglockfile" ] || rm -f $atloglockfile
1644 1638 [ -z "$ulockfile" ] || staffer rm -f $ulockfile
1645 1639 [ -z "$Ulockfile" ] || rm -f $Ulockfile
1646 1640
1647 1641 set -- $newdirlist
1648 1642 while [ $# -gt 0 ]; do
1649 1643 ISUSER=$1 staffer rmdir $2
1650 1644 shift; shift
1651 1645 done
1652 1646 rm -rf $TMPDIR
1653 1647 }
1654 1648
1655 1649 function cleanup_signal {
1656 1650 build_ok=i
1657 1651 # this will trigger cleanup(), above.
1658 1652 exit 1
1659 1653 }
1660 1654
1661 1655 trap cleanup 0
1662 1656 trap cleanup_signal 1 2 3 15
1663 1657
1664 1658 #
1665 1659 # Generic lock file processing -- make sure that the lock file doesn't
1666 1660 # exist. If it does, it should name the build host and PID. If it
1667 1661 # doesn't, then make sure we can create it. Clean up locks that are
1668 1662 # known to be stale (assumes host name is unique among build systems
1669 1663 # for the workspace).
1670 1664 #
1671 1665 function create_lock {
1672 1666 lockf=$1
1673 1667 lockvar=$2
1674 1668
1675 1669 ldir=`dirname $lockf`
1676 1670 [ -d $ldir ] || newdir $ldir || exit 1
1677 1671 eval $lockvar=$lockf
1678 1672
1679 1673 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1680 1674 basews=`basename $CODEMGR_WS`
1681 1675 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1682 1676 if [ "$host" != "$hostname" ]; then
1683 1677 echo "$MACH build of $basews apparently" \
1684 1678 "already started by $user on $host as $pid."
1685 1679 exit 1
1686 1680 elif kill -s 0 $pid 2>/dev/null; then
1687 1681 echo "$MACH build of $basews already started" \
1688 1682 "by $user as $pid."
1689 1683 exit 1
1690 1684 else
1691 1685 # stale lock; clear it out and try again
1692 1686 rm -f $lockf
1693 1687 fi
1694 1688 done
1695 1689 }
1696 1690
1697 1691 #
1698 1692 # Return the list of interesting proto areas, depending on the current
1699 1693 # options.
1700 1694 #
1701 1695 function allprotos {
1702 1696 typeset roots="$ROOT"
1703 1697
1704 1698 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1705 1699 roots="$roots $ROOT-nd"
1706 1700 fi
1707 1701
1708 1702 if [[ $O_FLAG = y ]]; then
1709 1703 roots="$roots $ROOT-closed"
1710 1704 [ $MULTI_PROTO = yes ] && roots="$roots $ROOT-nd-closed"
1711 1705 fi
1712 1706
1713 1707 echo $roots
1714 1708 }
1715 1709
1716 1710 # Ensure no other instance of this script is running on this host.
1717 1711 # LOCKNAME can be set in <env_file>, and is by default, but is not
1718 1712 # required due to the use of $ATLOG below.
1719 1713 if [ -n "$LOCKNAME" ]; then
1720 1714 create_lock /tmp/$LOCKNAME "lockfile"
1721 1715 fi
1722 1716 #
1723 1717 # Create from one, two, or three other locks:
1724 1718 # $ATLOG/nightly.lock
1725 1719 # - protects against multiple builds in same workspace
1726 1720 # $PARENT_WS/usr/src/nightly.$MACH.lock
1727 1721 # - protects against multiple 'u' copy-backs
1728 1722 # $NIGHTLY_PARENT_ROOT/nightly.lock
1729 1723 # - protects against multiple 'U' copy-backs
1730 1724 #
1731 1725 # Overriding ISUSER to 1 causes the lock to be created as root if the
1732 1726 # script is run as root. The default is to create it as $STAFFER.
1733 1727 ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile"
1734 1728 if [ "$u_FLAG" = "y" ]; then
1735 1729 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile"
1736 1730 fi
1737 1731 if [ "$U_FLAG" = "y" ]; then
1738 1732 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1739 1733 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile"
1740 1734 fi
1741 1735
1742 1736 # Locks have been taken, so we're doing a build and we're committed to
1743 1737 # the directories we may have created so far.
1744 1738 newdirlist=
1745 1739
1746 1740 #
1747 1741 # Create mail_msg_file
1748 1742 #
1749 1743 mail_msg_file="${TMPDIR}/mail_msg"
1750 1744 touch $mail_msg_file
1751 1745 build_time_file="${TMPDIR}/build_time"
1752 1746 build_environ_file="${TMPDIR}/build_environ"
1753 1747 touch $build_environ_file
1754 1748 #
1755 1749 # Move old LOGFILE aside
1756 1750 # ATLOG directory already made by 'create_lock' above
1757 1751 #
1758 1752 if [ -f $LOGFILE ]; then
1759 1753 mv -f $LOGFILE ${LOGFILE}-
1760 1754 fi
1761 1755 #
1762 1756 # Build OsNet source
1763 1757 #
1764 1758 START_DATE=`date`
1765 1759 SECONDS=0
1766 1760 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1767 1761 | tee -a $LOGFILE > $build_time_file
1768 1762
1769 1763 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1770 1764 tee -a $mail_msg_file >> $LOGFILE
1771 1765
1772 1766 # make sure we log only to the nightly build file
1773 1767 build_noise_file="${TMPDIR}/build_noise"
1774 1768 exec </dev/null >$build_noise_file 2>&1
1775 1769
1776 1770 run_hook SYS_PRE_NIGHTLY
1777 1771 run_hook PRE_NIGHTLY
1778 1772
1779 1773 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1780 1774 env >> $LOGFILE
1781 1775
1782 1776 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1783 1777
1784 1778 if [ "$P_FLAG" = "y" ]; then
1785 1779 obsolete_build GPROF | tee -a $mail_msg_file >> $LOGFILE
1786 1780 fi
1787 1781
1788 1782 if [ "$T_FLAG" = "y" ]; then
1789 1783 obsolete_build TRACE | tee -a $mail_msg_file >> $LOGFILE
1790 1784 fi
1791 1785
1792 1786 if is_source_build; then
1793 1787 if [ "$i_FLAG" = "y" -o "$i_CMD_LINE_FLAG" = "y" ]; then
1794 1788 echo "WARNING: the -S flags do not support incremental" \
1795 1789 "builds; forcing clobber\n" | tee -a $mail_msg_file >> $LOGFILE
1796 1790 i_FLAG=n
1797 1791 i_CMD_LINE_FLAG=n
1798 1792 fi
1799 1793 if [ "$N_FLAG" = "n" ]; then
1800 1794 echo "WARNING: the -S flags do not support protocmp;" \
1801 1795 "protocmp disabled\n" | \
1802 1796 tee -a $mail_msg_file >> $LOGFILE
1803 1797 N_FLAG=y
1804 1798 fi
1805 1799 if [ "$l_FLAG" = "y" ]; then
1806 1800 echo "WARNING: the -S flags do not support lint;" \
1807 1801 "lint disabled\n" | tee -a $mail_msg_file >> $LOGFILE
1808 1802 l_FLAG=n
1809 1803 fi
1810 1804 if [ "$C_FLAG" = "y" ]; then
1811 1805 echo "WARNING: the -S flags do not support cstyle;" \
1812 1806 "cstyle check disabled\n" | tee -a $mail_msg_file >> $LOGFILE
1813 1807 C_FLAG=n
1814 1808 fi
1815 1809 else
1816 1810 if [ "$N_FLAG" = "y" ]; then
1817 1811 if [ "$p_FLAG" = "y" ]; then
1818 1812 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1819 1813 WARNING: the p option (create packages) is set, but so is the N option (do
1820 1814 not run protocmp); this is dangerous; you should unset the N option
1821 1815 EOF
1822 1816 else
1823 1817 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1824 1818 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1825 1819 EOF
1826 1820 fi
1827 1821 echo "" | tee -a $mail_msg_file >> $LOGFILE
1828 1822 fi
1829 1823 fi
1830 1824
1831 1825 if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1832 1826 #
1833 1827 # In the past we just complained but went ahead with the lint
1834 1828 # pass, even though the proto area was built non-DEBUG. It's
1835 1829 # unlikely that non-DEBUG headers will make a difference, but
1836 1830 # rather than assuming it's a safe combination, force the user
1837 1831 # to specify a DEBUG build.
1838 1832 #
1839 1833 echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1840 1834 | tee -a $mail_msg_file >> $LOGFILE
1841 1835 l_FLAG=n
1842 1836 fi
1843 1837
1844 1838 if [ "$f_FLAG" = "y" ]; then
1845 1839 if [ "$i_FLAG" = "y" ]; then
1846 1840 echo "WARNING: the -f flag cannot be used during incremental" \
1847 1841 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1848 1842 f_FLAG=n
1849 1843 fi
1850 1844 if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then
1851 1845 echo "WARNING: the -f flag requires -l, and -p;" \
1852 1846 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1853 1847 f_FLAG=n
1854 1848 fi
1855 1849 fi
1856 1850
1857 1851 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1858 1852 echo "WARNING: -w specified, but $ROOT does not exist;" \
1859 1853 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE
1860 1854 w_FLAG=n
1861 1855 fi
1862 1856
1863 1857 if [ "$t_FLAG" = "n" ]; then
1864 1858 #
1865 1859 # We're not doing a tools build, so make sure elfsign(1) is
1866 1860 # new enough to safely sign non-crypto binaries. We test
1867 1861 # debugging output from elfsign to detect the old version.
1868 1862 #
1869 1863 newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \
1870 1864 -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \
1871 1865 | egrep algorithmOID`
1872 1866 if [ -z "$newelfsigntest" ]; then
1873 1867 echo "WARNING: /usr/bin/elfsign out of date;" \
1874 1868 "will only sign crypto modules\n" | \
1875 1869 tee -a $mail_msg_file >> $LOGFILE
1876 1870 export ELFSIGN_OBJECT=true
1877 1871 elif [ "$VERIFY_ELFSIGN" = "y" ]; then
1878 1872 echo "WARNING: VERIFY_ELFSIGN=y requires" \
1879 1873 "the -t flag; ignoring VERIFY_ELFSIGN\n" | \
1880 1874 tee -a $mail_msg_file >> $LOGFILE
1881 1875 fi
1882 1876 fi
1883 1877
1884 1878 [ "$O_FLAG" = y ] && MULTI_PROTO=yes
1885 1879
1886 1880 case $MULTI_PROTO in
1887 1881 yes|no) ;;
1888 1882 *)
1889 1883 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1890 1884 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1891 1885 echo "Setting MULTI_PROTO to \"no\".\n" | \
1892 1886 tee -a $mail_msg_file >> $LOGFILE
1893 1887 export MULTI_PROTO=no
1894 1888 ;;
1895 1889 esac
1896 1890
1897 1891 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1898 1892 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1899 1893
1900 1894 # Save the current proto area if we're comparing against the last build
1901 1895 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1902 1896 if [ -d "$ROOT.prev" ]; then
1903 1897 rm -rf $ROOT.prev
1904 1898 fi
1905 1899 mv $ROOT $ROOT.prev
1906 1900 fi
1907 1901
1908 1902 # Same for non-DEBUG proto area
1909 1903 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1910 1904 if [ -d "$ROOT-nd.prev" ]; then
1911 1905 rm -rf $ROOT-nd.prev
1912 1906 fi
1913 1907 mv $ROOT-nd $ROOT-nd.prev
1914 1908 fi
1915 1909
1916 1910 #
1917 1911 # Echo the SCM type of the parent workspace, this can't just be which_scm
1918 1912 # as that does not know how to identify various network repositories.
1919 1913 #
1920 1914 function parent_wstype {
1921 1915 typeset scm_type junk
1922 1916
1923 1917 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1924 1918 | read scm_type junk
1925 1919 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1926 1920 # Probe BRINGOVER_WS to determine its type
1927 1921 if [[ $BRINGOVER_WS == svn*://* ]]; then
1928 1922 scm_type="subversion"
1929 1923 elif [[ $BRINGOVER_WS == file://* ]] &&
1930 1924 egrep -s "This is a Subversion repository" \
1931 1925 ${BRINGOVER_WS#file://}/README.txt 2> /dev/null; then
1932 1926 scm_type="subversion"
1933 1927 elif [[ $BRINGOVER_WS == ssh://* ]]; then
1934 1928 scm_type="mercurial"
1935 1929 elif [[ $BRINGOVER_WS == http://* ]] && \
1936 1930 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1937 1931 egrep -s "application/mercurial" 2> /dev/null; then
1938 1932 scm_type="mercurial"
1939 1933 elif svn info $BRINGOVER_WS > /dev/null 2>&1; then
1940 1934 scm_type="subversion"
1941 1935 else
1942 1936 scm_type="none"
1943 1937 fi
1944 1938 fi
1945 1939
1946 1940 # fold both unsupported and unrecognized results into "none"
1947 1941 case "$scm_type" in
1948 1942 none|subversion|teamware|mercurial)
1949 1943 ;;
1950 1944 *) scm_type=none
1951 1945 ;;
1952 1946 esac
1953 1947
1954 1948 echo $scm_type
1955 1949 }
1956 1950
1957 1951 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1958 1952 function child_wstype {
1959 1953 typeset scm_type junk
1960 1954
1961 1955 # Probe CODEMGR_WS to determine its type
1962 1956 if [[ -d $CODEMGR_WS ]]; then
1963 1957 $WHICH_SCM | read scm_type junk || exit 1
1964 1958 fi
1965 1959
1966 1960 case "$scm_type" in
1967 1961 none|subversion|git|teamware|mercurial)
1968 1962 ;;
1969 1963 *) scm_type=none
1970 1964 ;;
1971 1965 esac
1972 1966
1973 1967 echo $scm_type
1974 1968 }
1975 1969
1976 1970 SCM_TYPE=$(child_wstype)
1977 1971
1978 1972 #
1979 1973 # Decide whether to clobber
1980 1974 #
1981 1975 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1982 1976 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1983 1977
1984 1978 cd $SRC
1985 1979 # remove old clobber file
1986 1980 rm -f $SRC/clobber.out
1987 1981 rm -f $SRC/clobber-${MACH}.out
1988 1982
1989 1983 # Remove all .make.state* files, just in case we are restarting
1990 1984 # the build after having interrupted a previous 'make clobber'.
1991 1985 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1992 1986 -o -name 'interfaces.*' \) -prune \
1993 1987 -o -name '.make.*' -print | xargs rm -f
1994 1988
1995 1989 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1996 1990 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1997 1991 grep "$MAKE:" $SRC/clobber-${MACH}.out |
1998 1992 egrep -v "Ignoring unknown host" \
1999 1993 >> $mail_msg_file
2000 1994
2001 1995 if [[ "$t_FLAG" = "y" || "$O_FLAG" = "y" ]]; then
2002 1996 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
2003 1997 cd ${TOOLS}
2004 1998 rm -f ${TOOLS}/clobber-${MACH}.out
2005 1999 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
2006 2000 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
2007 2001 echo "\n==== Make tools clobber ERRORS ====\n" \
2008 2002 >> $mail_msg_file
2009 2003 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
2010 2004 >> $mail_msg_file
2011 2005 rm -rf ${TOOLS_PROTO}
2012 2006 mkdir -p ${TOOLS_PROTO}
2013 2007 fi
2014 2008
2015 2009 typeset roots=$(allprotos)
2016 2010 echo "\n\nClearing $roots" >> "$LOGFILE"
2017 2011 rm -rf $roots
2018 2012
2019 2013 # Get back to a clean workspace as much as possible to catch
2020 2014 # problems that only occur on fresh workspaces.
2021 2015 # Remove all .make.state* files, libraries, and .o's that may
2022 2016 # have been omitted from clobber. A couple of libraries are
2023 2017 # under source code control, so leave them alone.
2024 2018 # We should probably blow away temporary directories too.
2025 2019 cd $SRC
2026 2020 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
2027 2021 -o -name .git -o -name 'interfaces.*' \) -prune -o \
2028 2022 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
2029 2023 -name '*.o' \) -print | \
2030 2024 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
2031 2025 else
2032 2026 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
2033 2027 fi
2034 2028
2035 2029 type bringover_teamware > /dev/null 2>&1 || function bringover_teamware {
2036 2030 # sleep on the parent workspace's lock
2037 2031 while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks
2038 2032 do
2039 2033 sleep 120
2040 2034 done
2041 2035
2042 2036 if [[ -z $BRINGOVER ]]; then
2043 2037 BRINGOVER=$TEAMWARE/bin/bringover
2044 2038 fi
2045 2039
2046 2040 staffer $BRINGOVER -c "nightly update" -p $BRINGOVER_WS \
2047 2041 -w $CODEMGR_WS $BRINGOVER_FILES < /dev/null 2>&1 ||
2048 2042 touch $TMPDIR/bringover_failed
2049 2043
2050 2044 staffer bringovercheck $CODEMGR_WS >$TMPDIR/bringovercheck.out 2>&1
2051 2045 if [ -s $TMPDIR/bringovercheck.out ]; then
2052 2046 echo "\n==== POST-BRINGOVER CLEANUP NOISE ====\n"
2053 2047 cat $TMPDIR/bringovercheck.out
2054 2048 fi
2055 2049 }
2056 2050
2057 2051 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
2058 2052 typeset -x PATH=$PATH
2059 2053
2060 2054 # If the repository doesn't exist yet, then we want to populate it.
2061 2055 if [[ ! -d $CODEMGR_WS/.hg ]]; then
2062 2056 staffer hg init $CODEMGR_WS
2063 2057 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
2064 2058 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
2065 2059 touch $TMPDIR/new_repository
2066 2060 fi
2067 2061
2068 2062 typeset -x HGMERGE="/bin/false"
2069 2063
2070 2064 #
2071 2065 # If the user has changes, regardless of whether those changes are
2072 2066 # committed, and regardless of whether those changes conflict, then
2073 2067 # we'll attempt to merge them either implicitly (uncommitted) or
2074 2068 # explicitly (committed).
2075 2069 #
2076 2070 # These are the messages we'll use to help clarify mercurial output
2077 2071 # in those cases.
2078 2072 #
2079 2073 typeset mergefailmsg="\
2080 2074 ***\n\
2081 2075 *** nightly was unable to automatically merge your changes. You should\n\
2082 2076 *** redo the full merge manually, following the steps outlined by mercurial\n\
2083 2077 *** above, then restart nightly.\n\
2084 2078 ***\n"
2085 2079 typeset mergepassmsg="\
2086 2080 ***\n\
2087 2081 *** nightly successfully merged your changes. This means that your working\n\
2088 2082 *** directory has been updated, but those changes are not yet committed.\n\
2089 2083 *** After nightly completes, you should validate the results of the merge,\n\
2090 2084 *** then use hg commit manually.\n\
2091 2085 ***\n"
2092 2086
2093 2087 #
2094 2088 # For each repository in turn:
2095 2089 #
2096 2090 # 1. Do the pull. If this fails, dump the output and bail out.
2097 2091 #
2098 2092 # 2. If the pull resulted in an extra head, do an explicit merge.
2099 2093 # If this fails, dump the output and bail out.
2100 2094 #
2101 2095 # Because we can't rely on Mercurial to exit with a failure code
2102 2096 # when a merge fails (Mercurial issue #186), we must grep the
2103 2097 # output of pull/merge to check for attempted and/or failed merges.
2104 2098 #
2105 2099 # 3. If a merge failed, set the message and fail the bringover.
2106 2100 #
2107 2101 # 4. Otherwise, if a merge succeeded, set the message
2108 2102 #
2109 2103 # 5. Dump the output, and any message from step 3 or 4.
2110 2104 #
2111 2105
2112 2106 typeset HG_SOURCE=$BRINGOVER_WS
2113 2107 if [ ! -f $TMPDIR/new_repository ]; then
2114 2108 HG_SOURCE=$TMPDIR/open_bundle.hg
2115 2109 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
2116 2110 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
2117 2111
2118 2112 #
2119 2113 # If there are no incoming changesets, then incoming will
2120 2114 # fail, and there will be no bundle file. Reset the source,
2121 2115 # to allow the remaining logic to complete with no false
2122 2116 # negatives. (Unlike incoming, pull will return success
2123 2117 # for the no-change case.)
2124 2118 #
2125 2119 if (( $? != 0 )); then
2126 2120 HG_SOURCE=$BRINGOVER_WS
2127 2121 fi
2128 2122 fi
2129 2123
2130 2124 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
2131 2125 > $TMPDIR/pull_open.out 2>&1
2132 2126 if (( $? != 0 )); then
2133 2127 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
2134 2128 cat $TMPDIR/pull_open.out
2135 2129 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then
2136 2130 printf "$mergefailmsg"
2137 2131 fi
2138 2132 touch $TMPDIR/bringover_failed
2139 2133 return
2140 2134 fi
2141 2135
2142 2136 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then
2143 2137 staffer hg --cwd $CODEMGR_WS merge \
2144 2138 >> $TMPDIR/pull_open.out 2>&1
2145 2139 if (( $? != 0 )); then
2146 2140 printf "%s: merge failed as follows:\n\n" \
2147 2141 "$CODEMGR_WS"
2148 2142 cat $TMPDIR/pull_open.out
2149 2143 if grep "^merging.*failed" $TMPDIR/pull_open.out \
2150 2144 > /dev/null 2>&1; then
2151 2145 printf "$mergefailmsg"
2152 2146 fi
2153 2147 touch $TMPDIR/bringover_failed
2154 2148 return
2155 2149 fi
2156 2150 fi
2157 2151
2158 2152 printf "updated %s with the following results:\n" "$CODEMGR_WS"
2159 2153 cat $TMPDIR/pull_open.out
2160 2154 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
2161 2155 printf "$mergepassmsg"
2162 2156 fi
2163 2157 printf "\n"
2164 2158
2165 2159 #
2166 2160 # Per-changeset output is neither useful nor manageable for a
2167 2161 # newly-created repository.
2168 2162 #
2169 2163 if [ -f $TMPDIR/new_repository ]; then
2170 2164 return
2171 2165 fi
2172 2166
2173 2167 printf "\nadded the following changesets to open repository:\n"
2174 2168 cat $TMPDIR/incoming_open.out
2175 2169
2176 2170 #
2177 2171 # The closed repository could have been newly created, even though
2178 2172 # the open one previously existed...
2179 2173 #
2180 2174 if [ -f $TMPDIR/new_closed ]; then
2181 2175 return
2182 2176 fi
2183 2177
2184 2178 if [ -f $TMPDIR/incoming_closed.out ]; then
2185 2179 printf "\nadded the following changesets to closed repository:\n"
2186 2180 cat $TMPDIR/incoming_closed.out
2187 2181 fi
2188 2182 }
2189 2183
2190 2184 type bringover_subversion > /dev/null 2>&1 || function bringover_subversion {
2191 2185 typeset -x PATH=$PATH
2192 2186
2193 2187 if [[ ! -d $CODEMGR_WS/.svn ]]; then
2194 2188 staffer svn checkout $BRINGOVER_WS $CODEMGR_WS ||
2195 2189 touch $TMPDIR/bringover_failed
2196 2190 else
2197 2191 typeset root
2198 2192 root=$(staffer svn info $CODEMGR_WS |
2199 2193 nawk '/^Repository Root:/ {print $NF}')
2200 2194 if [[ $root != $BRINGOVER_WS ]]; then
2201 2195 # We fail here because there's no way to update
2202 2196 # from a named repo.
2203 2197 cat <<-EOF
2204 2198 \$BRINGOVER_WS doesn't match repository root:
2205 2199 \$BRINGOVER_WS: $BRINGOVER_WS
2206 2200 Repository root: $root
2207 2201 EOF
2208 2202 touch $TMPDIR/bringover_failed
2209 2203 else
2210 2204 # If a conflict happens, svn still exits 0.
2211 2205 staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out ||
2212 2206 touch $TMPDIR/bringover_failed
2213 2207 if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then
2214 2208 touch $TMPDIR/bringover_failed
2215 2209 fi
2216 2210 fi
2217 2211 fi
2218 2212 }
2219 2213
2220 2214 type bringover_none > /dev/null 2>&1 || function bringover_none {
2221 2215 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
2222 2216 touch $TMPDIR/bringover_failed
2223 2217 }
2224 2218
2225 2219 #
2226 2220 # Decide whether to bringover to the codemgr workspace
2227 2221 #
2228 2222 if [ "$n_FLAG" = "n" ]; then
2229 2223 PARENT_SCM_TYPE=$(parent_wstype)
2230 2224
2231 2225 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
2232 2226 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
2233 2227 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
2234 2228 exit 1
2235 2229 fi
2236 2230
2237 2231 run_hook PRE_BRINGOVER
2238 2232
2239 2233 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
2240 2234 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
2241 2235
2242 2236 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
2243 2237 tee -a $mail_msg_file >> $LOGFILE
2244 2238
2245 2239 if [ -f $TMPDIR/bringover_failed ]; then
2246 2240 rm -f $TMPDIR/bringover_failed
2247 2241 build_ok=n
2248 2242 echo "trouble with bringover, quitting at `date`." |
2249 2243 tee -a $mail_msg_file >> $LOGFILE
2250 2244 exit 1
2251 2245 fi
2252 2246
2253 2247 #
2254 2248 # It's possible that we used the bringover above to create
2255 2249 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
2256 2250 # but should now be the same as $BRINGOVER_WS.
2257 2251 #
2258 2252 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
2259 2253
2260 2254 run_hook POST_BRINGOVER
2261 2255
2262 2256 check_closed_tree
2263 2257
2264 2258 else
2265 2259 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
2266 2260 fi
2267 2261
2268 2262 if [[ "$O_FLAG" = y ]]; then
2269 2263 build_ok=n
2270 2264 echo "OpenSolaris binary deliverables need usr/closed." \
2271 2265 | tee -a "$mail_msg_file" >> $LOGFILE
2272 2266 exit 1
2273 2267 fi
2274 2268
2275 2269 # Safeguards
2276 2270 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
2277 2271 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
2278 2272 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
2279 2273
2280 2274 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
2281 2275
2282 2276 # System
2283 2277 whence uname | tee -a $build_environ_file >> $LOGFILE
2284 2278 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
2285 2279 echo | tee -a $build_environ_file >> $LOGFILE
2286 2280
2287 2281 # make
2288 2282 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
2289 2283 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
2290 2284 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
2291 2285 tee -a $build_environ_file >> $LOGFILE
2292 2286
2293 2287 #
2294 2288 # Report the compiler versions.
2295 2289 #
2296 2290
2297 2291 if [[ ! -f $SRC/Makefile ]]; then
2298 2292 build_ok=n
2299 2293 echo "\nUnable to find \"Makefile\" in $SRC." | \
2300 2294 tee -a $build_environ_file >> $LOGFILE
2301 2295 exit 1
2302 2296 fi
2303 2297
2304 2298 ( cd $SRC
2305 2299 for target in cc-version cc64-version java-version; do
2306 2300 echo
2307 2301 #
2308 2302 # Put statefile somewhere we know we can write to rather than trip
2309 2303 # over a read-only $srcroot.
2310 2304 #
2311 2305 rm -f $TMPDIR/make-state
2312 2306 export SRC
2313 2307 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
2314 2308 continue
2315 2309 fi
2316 2310 touch $TMPDIR/nocompiler
2317 2311 done
2318 2312 echo
2319 2313 ) | tee -a $build_environ_file >> $LOGFILE
2320 2314
2321 2315 if [ -f $TMPDIR/nocompiler ]; then
2322 2316 rm -f $TMPDIR/nocompiler
2323 2317 build_ok=n
2324 2318 echo "Aborting due to missing compiler." |
2325 2319 tee -a $build_environ_file >> $LOGFILE
2326 2320 exit 1
2327 2321 fi
2328 2322
2329 2323 # as
2330 2324 whence as | tee -a $build_environ_file >> $LOGFILE
2331 2325 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
2332 2326 echo | tee -a $build_environ_file >> $LOGFILE
2333 2327
2334 2328 # Check that we're running a capable link-editor
2335 2329 whence ld | tee -a $build_environ_file >> $LOGFILE
2336 2330 LDVER=`ld -V 2>&1`
2337 2331 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
2338 2332 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
2339 2333 if [ `expr $LDVER \< 422` -eq 1 ]; then
2340 2334 echo "The link-editor needs to be at version 422 or higher to build" | \
2341 2335 tee -a $build_environ_file >> $LOGFILE
2342 2336 echo "the latest stuff. Hope your build works." | \
2343 2337 tee -a $build_environ_file >> $LOGFILE
2344 2338 fi
2345 2339
2346 2340 #
2347 2341 # Build and use the workspace's tools if requested
2348 2342 #
2349 2343 if [[ "$t_FLAG" = "y" || "$O_FLAG" = y ]]; then
2350 2344 set_non_debug_build_flags
2351 2345
2352 2346 build_tools ${TOOLS_PROTO}
2353 2347 if [[ $? != 0 && "$t_FLAG" = y ]]; then
2354 2348 use_tools $TOOLS_PROTO
2355 2349 fi
2356 2350 fi
2357 2351
2358 2352 #
2359 2353 # copy ihv proto area in addition to the build itself
2360 2354 #
2361 2355 if [ "$X_FLAG" = "y" ]; then
2362 2356 copy_ihv_proto
2363 2357 fi
2364 2358
2365 2359 if [ "$i_FLAG" = "y" -a "$SH_FLAG" = "y" ]; then
2366 2360 echo "\n==== NOT Building base OS-Net source ====\n" | \
2367 2361 tee -a $LOGFILE >> $mail_msg_file
2368 2362 else
2369 2363 # timestamp the start of the normal build; the findunref tool uses it.
2370 2364 touch $SRC/.build.tstamp
2371 2365
2372 2366 normal_build
2373 2367 fi
2374 2368
2375 2369 #
2376 2370 # Generate the THIRDPARTYLICENSE files if needed. This is done after
2377 2371 # the build, so that dynamically-created license files are there.
2378 2372 # It's done before findunref to help identify license files that need
2379 2373 # to be added to tools/opensolaris/license-list.
2380 2374 #
2381 2375 if [ "$O_FLAG" = y -a "$build_ok" = y ]; then
2382 2376 echo "\n==== Generating THIRDPARTYLICENSE files ====\n" |
2383 2377 tee -a "$mail_msg_file" >> "$LOGFILE"
2384 2378
2385 2379 if [ -d $ROOT/licenses/usr ]; then
2386 2380 ( cd $ROOT/licenses ; \
2387 2381 mktpl $SRC/pkg/license-list ) >> "$LOGFILE" 2>&1
2388 2382 if (( $? != 0 )) ; then
2389 2383 echo "Couldn't create THIRDPARTYLICENSE files" |
2390 2384 tee -a "$mail_msg_file" >> "$LOGFILE"
2391 2385 fi
2392 2386 else
2393 2387 echo "No licenses found under $ROOT/licenses" |
2394 2388 tee -a "$mail_msg_file" >> "$LOGFILE"
2395 2389 fi
2396 2390 fi
2397 2391
2398 2392 ORIG_SRC=$SRC
2399 2393 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
2400 2394
2401 2395 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
2402 2396 save_binaries
2403 2397 fi
2404 2398
2405 2399
2406 2400 # EXPORT_SRC comes after CRYPT_SRC since a domestic build will need
2407 2401 # $SRC pointing to the export_source usr/src.
2408 2402
2409 2403 if [ "$SE_FLAG" = "y" -o "$SD_FLAG" = "y" -o "$SH_FLAG" = "y" ]; then
2410 2404 if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
2411 2405 set_up_source_build ${CODEMGR_WS} ${CRYPT_SRC} CRYPT_SRC
2412 2406 fi
2413 2407
2414 2408 if [ $build_ok = y ]; then
2415 2409 set_up_source_build ${CODEMGR_WS} ${EXPORT_SRC} EXPORT_SRC
2416 2410 fi
2417 2411 fi
2418 2412
2419 2413 if [ "$SD_FLAG" = "y" -a $build_ok = y ]; then
2420 2414 # drop the crypt files in place.
2421 2415 cd ${EXPORT_SRC}
2422 2416 echo "\nextracting crypt_files.cpio.Z onto export_source.\n" \
2423 2417 >> ${LOGFILE}
2424 2418 zcat ${CODEMGR_WS}/crypt_files.cpio.Z | \
2425 2419 cpio -idmucvB 2>/dev/null >> ${LOGFILE}
2426 2420 if [ "$?" = "0" ]; then
2427 2421 echo "\n==== DOMESTIC extraction succeeded ====\n" \
2428 2422 >> $mail_msg_file
2429 2423 else
2430 2424 echo "\n==== DOMESTIC extraction failed ====\n" \
2431 2425 >> $mail_msg_file
2432 2426 fi
2433 2427
2434 2428 fi
2435 2429
2436 2430 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2437 2431 #
2438 2432 # Copy the open sources into their own tree.
2439 2433 # If copy_source fails, it will have already generated an
2440 2434 # error message and set build_ok=n, so we don't need to worry
2441 2435 # about that here.
2442 2436 #
2443 2437 copy_source $CODEMGR_WS $OPEN_SRCDIR OPEN_SOURCE usr/src
2444 2438 fi
2445 2439
2446 2440 if [ "$SO_FLAG" = "y" -a "$build_ok" = y ]; then
2447 2441 SRC=$OPEN_SRCDIR/usr/src
2448 2442 fi
2449 2443
2450 2444 if is_source_build && [ $build_ok = y ] ; then
2451 2445 # remove proto area(s) here, since we don't clobber
2452 2446 rm -rf `allprotos`
2453 2447 if [ "$t_FLAG" = "y" ]; then
2454 2448 set_non_debug_build_flags
2455 2449 ORIG_TOOLS=$TOOLS
2456 2450 #
2457 2451 # SRC was set earlier to point to the source build
2458 2452 # source tree (e.g., $EXPORT_SRC).
2459 2453 #
2460 2454 TOOLS=${SRC}/tools
2461 2455 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
2462 2456 build_tools ${TOOLS_PROTO}
2463 2457 if [[ $? != 0 ]]; then
2464 2458 use_tools ${TOOLS_PROTO}
2465 2459 fi
2466 2460 fi
2467 2461
2468 2462 normal_build
2469 2463 fi
2470 2464
2471 2465 #
2472 2466 # There are several checks that need to look at the proto area, but
2473 2467 # they only need to look at one, and they don't care whether it's
2474 2468 # DEBUG or non-DEBUG.
2475 2469 #
2476 2470 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
2477 2471 checkroot=$ROOT-nd
2478 2472 else
2479 2473 checkroot=$ROOT
2480 2474 fi
2481 2475
2482 2476 if [ "$build_ok" = "y" ]; then
2483 2477 echo "\n==== Creating protolist system file at `date` ====" \
2484 2478 >> $LOGFILE
2485 2479 protolist $checkroot > $ATLOG/proto_list_${MACH}
2486 2480 echo "==== protolist system file created at `date` ====\n" \
2487 2481 >> $LOGFILE
2488 2482
2489 2483 if [ "$N_FLAG" != "y" ]; then
2490 2484
2491 2485 E1=
2492 2486 f1=
2493 2487 if [ -d "$SRC/pkgdefs" ]; then
2494 2488 f1="$SRC/pkgdefs/etc/exception_list_$MACH"
2495 2489 if [ "$X_FLAG" = "y" ]; then
2496 2490 f1="$f1 $IA32_IHV_WS/usr/src/pkgdefs/etc/exception_list_$MACH"
2497 2491 fi
2498 2492 fi
2499 2493
2500 2494 for f in $f1; do
2501 2495 if [ -f "$f" ]; then
2502 2496 E1="$E1 -e $f"
2503 2497 fi
2504 2498 done
2505 2499
2506 2500 E2=
2507 2501 f2=
2508 2502 if [ -d "$SRC/pkg" ]; then
2509 2503 f2="$f2 exceptions/packaging"
2510 2504 fi
2511 2505
2512 2506 for f in $f2; do
2513 2507 if [ -f "$f" ]; then
2514 2508 E2="$E2 -e $f"
2515 2509 fi
2516 2510 done
2517 2511
2518 2512 if [ -f "$REF_PROTO_LIST" ]; then
2519 2513 #
2520 2514 # For builds that copy the IHV proto area (-X), add the
2521 2515 # IHV proto list to the reference list if the reference
2522 2516 # was built without -X.
2523 2517 #
2524 2518 # For builds that don't copy the IHV proto area, add the
2525 2519 # IHV proto list to the build's proto list if the
2526 2520 # reference was built with -X.
2527 2521 #
2528 2522 # Use the presence of the first file entry of the cached
2529 2523 # IHV proto list in the reference list to determine
2530 2524 # whether it was built with -X or not.
2531 2525 #
2532 2526 IHV_REF_PROTO_LIST=$SRC/pkg/proto_list_ihv_$MACH
2533 2527 grepfor=$(nawk '$1 == "f" { print $2; exit }' \
2534 2528 $IHV_REF_PROTO_LIST 2> /dev/null)
2535 2529 if [ $? = 0 -a -n "$grepfor" ]; then
2536 2530 if [ "$X_FLAG" = "y" ]; then
2537 2531 grep -w "$grepfor" \
2538 2532 $REF_PROTO_LIST > /dev/null
2539 2533 if [ ! "$?" = "0" ]; then
2540 2534 REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST"
2541 2535 fi
2542 2536 else
2543 2537 grep -w "$grepfor" \
2544 2538 $REF_PROTO_LIST > /dev/null
2545 2539 if [ "$?" = "0" ]; then
2546 2540 IHV_PROTO_LIST="$IHV_REF_PROTO_LIST"
2547 2541 fi
2548 2542 fi
2549 2543 fi
2550 2544 fi
2551 2545 fi
2552 2546
2553 2547 if [ "$N_FLAG" != "y" -a -f $SRC/pkgdefs/Makefile ]; then
2554 2548 echo "\n==== Impact on SVr4 packages ====\n" >> $mail_msg_file
2555 2549 #
2556 2550 # Compare the build's proto list with current package
2557 2551 # definitions to audit the quality of package
2558 2552 # definitions and makefile install targets. Use the
2559 2553 # current exception list.
2560 2554 #
2561 2555 PKGDEFS_LIST=""
2562 2556 for d in $abssrcdirs; do
2563 2557 if [ -d $d/pkgdefs ]; then
2564 2558 PKGDEFS_LIST="$PKGDEFS_LIST -d $d/pkgdefs"
2565 2559 fi
2566 2560 done
2567 2561 if [ "$X_FLAG" = "y" -a \
2568 2562 -d $IA32_IHV_WS/usr/src/pkgdefs ]; then
2569 2563 PKGDEFS_LIST="$PKGDEFS_LIST -d $IA32_IHV_WS/usr/src/pkgdefs"
2570 2564 fi
2571 2565 $PROTOCMPTERSE \
2572 2566 "Files missing from the proto area:" \
2573 2567 "Files missing from packages:" \
2574 2568 "Inconsistencies between pkgdefs and proto area:" \
2575 2569 ${E1} \
2576 2570 ${PKGDEFS_LIST} \
2577 2571 $ATLOG/proto_list_${MACH} \
2578 2572 >> $mail_msg_file
2579 2573 fi
2580 2574
2581 2575 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
2582 2576 echo "\n==== Validating manifests against proto area ====\n" \
2583 2577 >> $mail_msg_file
2584 2578 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) \
2585 2579 >> $mail_msg_file
2586 2580
2587 2581 fi
2588 2582
2589 2583 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
2590 2584 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
2591 2585 if [ -n "$E2" ]; then
2592 2586 ELIST=$E2
2593 2587 else
2594 2588 ELIST=$E1
2595 2589 fi
2596 2590 $PROTOCMPTERSE \
2597 2591 "Files in yesterday's proto area, but not today's:" \
2598 2592 "Files in today's proto area, but not yesterday's:" \
2599 2593 "Files that changed between yesterday and today:" \
2600 2594 ${ELIST} \
2601 2595 -d $REF_PROTO_LIST \
2602 2596 $REF_IHV_PROTO \
2603 2597 $ATLOG/proto_list_${MACH} \
2604 2598 $IHV_PROTO_LIST \
2605 2599 >> $mail_msg_file
2606 2600 fi
2607 2601 fi
2608 2602
2609 2603 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
2610 2604 staffer cp $ATLOG/proto_list_${MACH} \
2611 2605 $PARENT_WS/usr/src/proto_list_${MACH}
2612 2606 fi
2613 2607
2614 2608 # Update parent proto area if necessary. This is done now
2615 2609 # so that the proto area has either DEBUG or non-DEBUG kernels.
2616 2610 # Note that this clears out the lock file, so we can dispense with
2617 2611 # the variable now.
2618 2612 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
2619 2613 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
2620 2614 tee -a $LOGFILE >> $mail_msg_file
2621 2615 rm -rf $NIGHTLY_PARENT_ROOT/*
2622 2616 unset Ulockfile
2623 2617 mkdir -p $NIGHTLY_PARENT_ROOT
2624 2618 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2625 2619 ( cd $ROOT; tar cf - . |
2626 2620 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 |
2627 2621 tee -a $mail_msg_file >> $LOGFILE
2628 2622 fi
2629 2623 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2630 2624 rm -rf $NIGHTLY_PARENT_ROOT-nd/*
2631 2625 mkdir -p $NIGHTLY_PARENT_ROOT-nd
2632 2626 cd $ROOT-nd
2633 2627 ( tar cf - . |
2634 2628 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
2635 2629 tee -a $mail_msg_file >> $LOGFILE
2636 2630 fi
2637 2631 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
2638 2632 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
2639 2633 tee -a $LOGFILE >> $mail_msg_file
2640 2634 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
2641 2635 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
2642 2636 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2643 2637 ( cd $TOOLS_PROTO; tar cf - . |
2644 2638 ( cd $NIGHTLY_PARENT_TOOLS_ROOT;
2645 2639 umask 0; tar xpf - ) ) 2>&1 |
2646 2640 tee -a $mail_msg_file >> $LOGFILE
2647 2641 fi
2648 2642 fi
2649 2643 fi
2650 2644
2651 2645 #
2652 2646 # ELF verification: ABI (-A) and runtime (-r) checks
2653 2647 #
2654 2648 if [[ ($build_ok = y) && ( ($A_FLAG = y) || ($r_FLAG = y) ) ]]; then
2655 2649 # Directory ELF-data.$MACH holds the files produced by these tests.
2656 2650 elf_ddir=$SRC/ELF-data.$MACH
2657 2651
2658 2652 # If there is a previous ELF-data backup directory, remove it. Then,
2659 2653 # rotate current ELF-data directory into its place and create a new
2660 2654 # empty directory
2661 2655 rm -rf $elf_ddir.ref
2662 2656 if [[ -d $elf_ddir ]]; then
2663 2657 mv $elf_ddir $elf_ddir.ref
2664 2658 fi
2665 2659 mkdir -p $elf_ddir
2666 2660
2667 2661 # Call find_elf to produce a list of the ELF objects in the proto area.
2668 2662 # This list is passed to check_rtime and interface_check, preventing
2669 2663 # them from separately calling find_elf to do the same work twice.
2670 2664 find_elf -fr $checkroot > $elf_ddir/object_list
2671 2665
2672 2666 if [[ $A_FLAG = y ]]; then
2673 2667 echo "\n==== Check versioning and ABI information ====\n" | \
2674 2668 tee -a $LOGFILE >> $mail_msg_file
2675 2669
2676 2670 # Produce interface description for the proto. Report errors.
2677 2671 interface_check -o -w $elf_ddir -f object_list \
2678 2672 -i interface -E interface.err
2679 2673 if [[ -s $elf_ddir/interface.err ]]; then
2680 2674 tee -a $LOGFILE < $elf_ddir/interface.err \
2681 2675 >> $mail_msg_file
2682 2676 fi
2683 2677
2684 2678 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
2685 2679 # description file to that from the baseline gate. Issue a
2686 2680 # warning if the baseline is not present, and keep going.
2687 2681 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
2688 2682 base_ifile="$ELF_DATA_BASELINE_DIR/interface"
2689 2683
2690 2684 echo "\n==== Compare versioning and ABI information" \
2691 2685 "to baseline ====\n" | \
2692 2686 tee -a $LOGFILE >> $mail_msg_file
2693 2687 echo "Baseline: $base_ifile\n" >> $LOGFILE
2694 2688
2695 2689 if [[ -f $base_ifile ]]; then
2696 2690 interface_cmp -d -o $base_ifile \
2697 2691 $elf_ddir/interface > $elf_ddir/interface.cmp
2698 2692 if [[ -s $elf_ddir/interface.cmp ]]; then
2699 2693 echo | tee -a $LOGFILE >> $mail_msg_file
2700 2694 tee -a $LOGFILE < \
2701 2695 $elf_ddir/interface.cmp \
2702 2696 >> $mail_msg_file
2703 2697 fi
2704 2698 else
2705 2699 echo "baseline not available. comparison" \
2706 2700 "skipped" | \
2707 2701 tee -a $LOGFILE >> $mail_msg_file
2708 2702 fi
2709 2703
2710 2704 fi
2711 2705 fi
2712 2706
2713 2707 if [[ $r_FLAG = y ]]; then
2714 2708 echo "\n==== Check ELF runtime attributes ====\n" | \
2715 2709 tee -a $LOGFILE >> $mail_msg_file
2716 2710
2717 2711 # If we're doing a DEBUG build the proto area will be left
2718 2712 # with debuggable objects, thus don't assert -s.
2719 2713 if [[ $D_FLAG = y ]]; then
2720 2714 rtime_sflag=""
2721 2715 else
2722 2716 rtime_sflag="-s"
2723 2717 fi
2724 2718 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
2725 2719 -D object_list -f object_list -E runtime.err \
2726 2720 -I runtime.attr.raw
2727 2721
2728 2722 # check_rtime -I output needs to be sorted in order to
2729 2723 # compare it to that from previous builds.
2730 2724 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
2731 2725 rm $elf_ddir/runtime.attr.raw
2732 2726
2733 2727 # Report errors
2734 2728 if [[ -s $elf_ddir/runtime.err ]]; then
2735 2729 tee -a $LOGFILE < $elf_ddir/runtime.err \
2736 2730 >> $mail_msg_file
2737 2731 fi
2738 2732
2739 2733 # If there is an ELF-data directory from a previous build,
2740 2734 # then diff the attr files. These files contain information
2741 2735 # about dependencies, versioning, and runpaths. There is some
2742 2736 # overlap with the ABI checking done above, but this also
2743 2737 # flushes out non-ABI interface differences along with the
2744 2738 # other information.
2745 2739 echo "\n==== Diff ELF runtime attributes" \
2746 2740 "(since last build) ====\n" | \
2747 2741 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
2748 2742
2749 2743 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
2750 2744 diff $elf_ddir.ref/runtime.attr \
2751 2745 $elf_ddir/runtime.attr \
2752 2746 >> $mail_msg_file
2753 2747 fi
2754 2748 fi
2755 2749
2756 2750 # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
2757 2751 if [[ "$u_FLAG" = "y" ]]; then
2758 2752 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH
2759 2753
2760 2754 # If parent lacks the ELF-data.$MACH directory, create it
2761 2755 if [[ ! -d $p_elf_ddir ]]; then
2762 2756 staffer mkdir -p $p_elf_ddir
2763 2757 fi
2764 2758
2765 2759 # These files are used asynchronously by other builds for ABI
2766 2760 # verification, as above for the -A option. As such, we require
2767 2761 # the file replacement to be atomic. Copy the data to a temp
2768 2762 # file in the same filesystem and then rename into place.
2769 2763 (
2770 2764 cd $elf_ddir
2771 2765 for elf_dfile in *; do
2772 2766 staffer cp $elf_dfile \
2773 2767 ${p_elf_ddir}/${elf_dfile}.new
2774 2768 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
2775 2769 ${p_elf_ddir}/${elf_dfile}
2776 2770 done
2777 2771 )
2778 2772 fi
2779 2773 fi
2780 2774
2781 2775 # DEBUG lint of kernel begins
2782 2776
2783 2777 if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
2784 2778 if [ "$LINTDIRS" = "" ]; then
2785 2779 # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y"
2786 2780 LINTDIRS="$SRC y"
2787 2781 fi
2788 2782 set $LINTDIRS
2789 2783 while [ $# -gt 0 ]; do
2790 2784 dolint $1 $2; shift; shift
2791 2785 done
2792 2786 else
2793 2787 echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2794 2788 fi
2795 2789
2796 2790 # "make check" begins
2797 2791
2798 2792 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2799 2793 # remove old check.out
2800 2794 rm -f $SRC/check.out
2801 2795
2802 2796 rm -f $SRC/check-${MACH}.out
2803 2797 cd $SRC
2804 2798 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
2805 2799 >> $LOGFILE
2806 2800 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2807 2801
2808 2802 grep ":" $SRC/check-${MACH}.out |
2809 2803 egrep -v "Ignoring unknown host" | \
2810 2804 sort | uniq >> $mail_msg_file
2811 2805 else
2812 2806 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2813 2807 fi
2814 2808
2815 2809 echo "\n==== Find core files ====\n" | \
2816 2810 tee -a $LOGFILE >> $mail_msg_file
2817 2811
2818 2812 find $abssrcdirs -name core -a -type f -exec file {} \; | \
2819 2813 tee -a $LOGFILE >> $mail_msg_file
2820 2814
2821 2815 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2822 2816 echo "\n==== Diff unreferenced files (since last build) ====\n" \
2823 2817 | tee -a $LOGFILE >>$mail_msg_file
2824 2818 rm -f $SRC/unref-${MACH}.ref
2825 2819 if [ -f $SRC/unref-${MACH}.out ]; then
2826 2820 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2827 2821 fi
2828 2822
2829 2823 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2830 2824 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2831 2825 sort > $SRC/unref-${MACH}.out
2832 2826
2833 2827 if [ ! -f $SRC/unref-${MACH}.ref ]; then
2834 2828 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2835 2829 fi
2836 2830
2837 2831 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2838 2832 fi
2839 2833
2840 2834 #
2841 2835 # Generate the OpenSolaris deliverables if requested. Some of these
2842 2836 # steps need to come after findunref and are commented below.
2843 2837 #
2844 2838
2845 2839 # If we are doing an OpenSolaris _source_ build (-S O) then we do
2846 2840 # not have usr/closed available to us to generate closedbins from,
2847 2841 # so skip this part.
2848 2842 if [ "$SO_FLAG" = n -a "$O_FLAG" = y -a "$build_ok" = y ]; then
2849 2843 echo "\n==== Generating OpenSolaris tarballs ====\n" | \
2850 2844 tee -a $mail_msg_file >> $LOGFILE
2851 2845
2852 2846 cd $CODEMGR_WS
2853 2847
2854 2848 #
2855 2849 # This step grovels through the package manifests, so it
2856 2850 # must come after findunref.
2857 2851 #
2858 2852 # We assume no DEBUG vs non-DEBUG package content variation
2859 2853 # here; if that changes, then the "make all" in $SRC/pkg will
2860 2854 # need to be moved into the conditionals and repeated for each
2861 2855 # different build.
2862 2856 #
2863 2857 echo "Generating closed binaries tarball(s)..." >> $LOGFILE
2864 2858 closed_basename=on-closed-bins
2865 2859 if [ "$D_FLAG" = y ]; then
2866 2860 bindrop "$closed_basename" >>"$LOGFILE" 2>&1
2867 2861 if (( $? != 0 )) ; then
2868 2862 echo "Couldn't create DEBUG closed binaries." |
2869 2863 tee -a $mail_msg_file >> $LOGFILE
2870 2864 build_ok=n
2871 2865 fi
2872 2866 fi
2873 2867 if [ "$F_FLAG" = n ]; then
2874 2868 bindrop -n "$closed_basename-nd" >>"$LOGFILE" 2>&1
2875 2869 if (( $? != 0 )) ; then
2876 2870 echo "Couldn't create non-DEBUG closed binaries." |
2877 2871 tee -a $mail_msg_file >> $LOGFILE
2878 2872 build_ok=n
2879 2873 fi
2880 2874 fi
2881 2875
2882 2876 echo "Generating README.opensolaris..." >> $LOGFILE
2883 2877 cat $SRC/tools/opensolaris/README.opensolaris.tmpl | \
2884 2878 mkreadme_osol $CODEMGR_WS/README.opensolaris >> $LOGFILE 2>&1
2885 2879 if (( $? != 0 )) ; then
2886 2880 echo "Couldn't create README.opensolaris." |
2887 2881 tee -a $mail_msg_file >> $LOGFILE
2888 2882 build_ok=n
2889 2883 fi
2890 2884 fi
2891 2885
2892 2886 # Verify that the usual lists of files, such as exception lists,
2893 2887 # contain only valid references to files. If the build has failed,
2894 2888 # then don't check the proto area.
2895 2889 CHECK_PATHS=${CHECK_PATHS:-y}
2896 2890 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2897 2891 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2898 2892 >>$mail_msg_file
2899 2893 arg=-b
2900 2894 [ "$build_ok" = y ] && arg=
2901 2895 checkpaths $arg $checkroot 2>&1 | tee -a $LOGFILE >>$mail_msg_file
2902 2896 fi
2903 2897
2904 2898 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2905 2899 echo "\n==== Impact on file permissions ====\n" \
2906 2900 >> $mail_msg_file
2907 2901
2908 2902 abspkgdefs=
2909 2903 abspkg=
2910 2904 for d in $abssrcdirs; do
2911 2905 if [ -d "$d/pkgdefs" ]; then
2912 2906 abspkgdefs="$abspkgdefs $d"
2913 2907 fi
2914 2908 if [ -d "$d/pkg" ]; then
2915 2909 abspkg="$abspkg $d"
2916 2910 fi
2917 2911 done
2918 2912
2919 2913 if [ -n "$abspkgdefs" ]; then
2920 2914 pmodes -qvdP \
2921 2915 `find $abspkgdefs -name pkginfo.tmpl -print -o \
2922 2916 -name .del\* -prune | sed -e 's:/pkginfo.tmpl$::' | \
2923 2917 sort -u` >> $mail_msg_file
2924 2918 fi
2925 2919
2926 2920 if [ -n "$abspkg" ]; then
2927 2921 for d in "$abspkg"; do
2928 2922 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
2929 2923 done
2930 2924 fi
2931 2925 fi
2932 2926
2933 2927 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
2934 2928 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2935 2929 do_wsdiff DEBUG $ROOT.prev $ROOT
2936 2930 fi
2937 2931
2938 2932 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2939 2933 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2940 2934 fi
2941 2935 fi
2942 2936
2943 2937 END_DATE=`date`
2944 2938 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2945 2939 tee -a $LOGFILE >> $build_time_file
2946 2940
2947 2941 typeset -i10 hours
2948 2942 typeset -Z2 minutes
2949 2943 typeset -Z2 seconds
2950 2944
2951 2945 elapsed_time=$SECONDS
2952 2946 ((hours = elapsed_time / 3600 ))
2953 2947 ((minutes = elapsed_time / 60 % 60))
2954 2948 ((seconds = elapsed_time % 60))
2955 2949
2956 2950 echo "\n==== Total build time ====" | \
2957 2951 tee -a $LOGFILE >> $build_time_file
2958 2952 echo "\nreal ${hours}:${minutes}:${seconds}" | \
2959 2953 tee -a $LOGFILE >> $build_time_file
2960 2954
2961 2955 if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2962 2956 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
2963 2957
2964 2958 #
2965 2959 # Produce a master list of unreferenced files -- ideally, we'd
2966 2960 # generate the master just once after all of the nightlies
2967 2961 # have finished, but there's no simple way to know when that
2968 2962 # will be. Instead, we assume that we're the last nightly to
2969 2963 # finish and merge all of the unref-${MACH}.out files in
2970 2964 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
2971 2965 # finish, then this file will be the authoritative master
2972 2966 # list. Otherwise, another ${MACH}'s nightly will eventually
2973 2967 # overwrite ours with its own master, but in the meantime our
2974 2968 # temporary "master" will be no worse than any older master
2975 2969 # which was already on the parent.
2976 2970 #
2977 2971
2978 2972 set -- $PARENT_WS/usr/src/unref-*.out
2979 2973 cp "$1" ${TMPDIR}/unref.merge
2980 2974 shift
2981 2975
2982 2976 for unreffile; do
2983 2977 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2984 2978 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2985 2979 done
2986 2980
2987 2981 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2988 2982 fi
2989 2983
2990 2984 #
2991 2985 # All done save for the sweeping up.
2992 2986 # (whichever exit we hit here will trigger the "cleanup" trap which
2993 2987 # optionally sends mail on completion).
2994 2988 #
2995 2989 if [ "$build_ok" = "y" ]; then
2996 2990 exit 0
2997 2991 fi
2998 2992 exit 1
↓ open down ↓ |
1597 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX