Print this page
12313 nightly should check for ld guidance
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/nightly
+++ new/usr/src/tools/scripts/nightly
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 # Copyright (c) 2017 by Delphix. All rights reserved.
29 29 # Copyright 2020 Joyent, Inc.
30 30 # Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
31 31 # Copyright 2019 Peter Trible.
32 32 #
33 33 # Based on the nightly script from the integration folks,
34 34 # Mostly modified and owned by mike_s.
35 35 # Changes also by kjc, dmk.
36 36 #
37 37 # BRINGOVER_WS may be specified in the env file.
38 38 # The default is the old behavior of CLONE_WS
39 39 #
40 40 # -i on the command line, means fast options, so when it's on the
41 41 # command line (only), check builds are skipped no matter what
42 42 # the setting of their individual flags are in NIGHTLY_OPTIONS.
43 43 #
44 44 # OPTHOME may be set in the environment to override /opt
45 45 #
46 46
47 47 #
48 48 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
49 49 # under certain circumstances, which can really screw things up; unset it.
50 50 #
51 51 unset CDPATH
52 52
53 53 # Get the absolute path of the nightly script that the user invoked. This
54 54 # may be a relative path, and we need to do this before changing directory.
55 55 nightly_path=`whence $0`
56 56
57 57 #
58 58 # Keep track of where we found nightly so we can invoke the matching
59 59 # which_scm script. If that doesn't work, don't go guessing, just rely
60 60 # on the $PATH settings, which will generally give us either /opt/onbld
61 61 # or the user's workspace.
62 62 #
63 63 WHICH_SCM=$(dirname $nightly_path)/which_scm
64 64 if [[ ! -x $WHICH_SCM ]]; then
65 65 WHICH_SCM=which_scm
66 66 fi
67 67
68 68 function fatal_error
69 69 {
70 70 print -u2 "nightly: $*"
71 71 exit 1
72 72 }
73 73
74 74 #
75 75 # Function to do a DEBUG and non-DEBUG build. Needed because we might
76 76 # need to do another for the source build, and since we only deliver DEBUG or
77 77 # non-DEBUG packages.
78 78 #
79 79 # usage: normal_build
80 80 #
81 81 function normal_build {
82 82
83 83 typeset orig_p_FLAG="$p_FLAG"
84 84 typeset crypto_signer="$CODESIGN_USER"
85 85
86 86 suffix=""
87 87
88 88 # non-DEBUG build begins
89 89
90 90 if [ "$F_FLAG" = "n" ]; then
91 91 set_non_debug_build_flags
92 92 CODESIGN_USER="$crypto_signer" \
93 93 build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
94 94 else
95 95 echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
96 96 fi
97 97
98 98 # non-DEBUG build ends
99 99
100 100 # DEBUG build begins
101 101
102 102 if [ "$D_FLAG" = "y" ]; then
103 103 set_debug_build_flags
104 104 CODESIGN_USER="$crypto_signer" \
105 105 build "DEBUG" "$suffix" "" "$MULTI_PROTO"
106 106 else
107 107 echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
108 108 fi
109 109
110 110 # DEBUG build ends
111 111
112 112 p_FLAG="$orig_p_FLAG"
113 113 }
114 114
115 115 #
116 116 # usage: run_hook HOOKNAME ARGS...
117 117 #
118 118 # If variable "$HOOKNAME" is defined, insert a section header into
119 119 # our logs and then run the command with ARGS
120 120 #
121 121 function run_hook {
122 122 HOOKNAME=$1
123 123 eval HOOKCMD=\$$HOOKNAME
124 124 shift
125 125
126 126 if [ -n "$HOOKCMD" ]; then
127 127 (
128 128 echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
129 129 ( $HOOKCMD "$@" 2>&1 )
130 130 if [ "$?" -ne 0 ]; then
131 131 # Let exit status propagate up
132 132 touch $TMPDIR/abort
133 133 fi
134 134 ) | tee -a $mail_msg_file >> $LOGFILE
135 135
136 136 if [ -f $TMPDIR/abort ]; then
137 137 build_ok=n
138 138 echo "\nAborting at request of $HOOKNAME" |
139 139 tee -a $mail_msg_file >> $LOGFILE
140 140 exit 1
141 141 fi
142 142 fi
143 143 }
144 144
145 145 # Return library search directive as function of given root.
146 146 function myldlibs {
147 147 echo "-L$1/lib -L$1/usr/lib"
148 148 }
149 149
150 150 # Return header search directive as function of given root.
151 151 function myheaders {
152 152 echo "-I$1/usr/include"
153 153 }
154 154
155 155 #
156 156 # Function to do the build, including package generation.
157 157 # usage: build LABEL SUFFIX ND MULTIPROTO
158 158 # - LABEL is used to tag build output.
159 159 # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
160 160 # open-only vs full tree).
161 161 # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
162 162 # - If MULTIPROTO is "yes", it means to name the proto area according to
163 163 # SUFFIX. Otherwise ("no"), (re)use the standard proto area.
164 164 #
165 165 function build {
166 166 LABEL=$1
167 167 SUFFIX=$2
168 168 ND=$3
169 169 MULTIPROTO=$4
170 170 INSTALLOG=install${SUFFIX}-${MACH}
171 171 NOISE=noise${SUFFIX}-${MACH}
172 172 PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
173 173
174 174 ORIGROOT=$ROOT
175 175 [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
176 176
177 177 export ENVLDLIBS1=`myldlibs $ROOT`
178 178 export ENVCPPFLAGS1=`myheaders $ROOT`
179 179
180 180 this_build_ok=y
181 181 #
182 182 # Build OS-Networking source
183 183 #
↓ open down ↓ |
183 lines elided |
↑ open up ↑ |
184 184 echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
185 185 >> $LOGFILE
186 186
187 187 rm -f $SRC/${INSTALLOG}.out
188 188 cd $SRC
189 189 /bin/time $MAKE -e install 2>&1 | \
190 190 tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
191 191
192 192 echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
193 193 egrep ":" $SRC/${INSTALLOG}.out |
194 - egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
194 + egrep -e "(^${MAKE}:|[ ]error[: \n]|ld: guidance:)" | \
195 195 egrep -v "Ignoring unknown host" | \
196 196 egrep -v "cc .* -o error " | \
197 197 egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \
198 198 >> $mail_msg_file
199 199 sed -n "/^Undefined[ ]*first referenced$/,/^ld: fatal:/p" \
200 200 < $SRC/${INSTALLOG}.out >> $mail_msg_file
201 201 if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then
202 202 build_ok=n
203 203 this_build_ok=n
204 204 fi
205 205 grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
206 206 >> $mail_msg_file
207 207 if [ "$?" = "0" ]; then
208 208 build_ok=n
209 209 this_build_ok=n
210 210 fi
211 211
212 212 echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
213 213 egrep -i 'warn:|warning:' $SRC/${INSTALLOG}.out \
214 214 | egrep -v '^tic:' \
215 215 | egrep -v "symbol (\`|')timezone' has differing types:" \
216 216 | egrep -v "parameter <PSTAMP> set to" \
217 217 | egrep -v "Ignoring unknown host" \
218 218 | egrep -v "redefining segment flags attribute for" \
219 219 | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file
220 220 if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then
221 221 build_ok=n
222 222 this_build_ok=n
223 223 fi
224 224
225 225 echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
226 226 >> $LOGFILE
227 227
228 228 echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
229 229 tail -3 $SRC/${INSTALLOG}.out >>$mail_msg_file
230 230
231 231 if [ "$i_FLAG" = "n" ]; then
232 232 rm -f $SRC/${NOISE}.ref
233 233 if [ -f $SRC/${NOISE}.out ]; then
234 234 mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
235 235 fi
236 236 grep : $SRC/${INSTALLOG}.out \
237 237 | egrep -v '^/' \
238 238 | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
239 239 | egrep -v '^tic:' \
240 240 | egrep -v '^mcs' \
241 241 | egrep -v '^LD_LIBRARY_PATH=' \
242 242 | egrep -v 'ar: creating' \
243 243 | egrep -v 'ar: writing' \
244 244 | egrep -v 'conflicts:' \
245 245 | egrep -v ':saved created' \
246 246 | egrep -v '^stty.*c:' \
247 247 | egrep -v '^mfgname.c:' \
248 248 | egrep -v '^uname-i.c:' \
249 249 | egrep -v '^volumes.c:' \
250 250 | egrep -v '^lint library construction:' \
251 251 | egrep -v 'tsort: INFORM:' \
252 252 | egrep -v 'stripalign:' \
253 253 | egrep -v 'chars, width' \
254 254 | egrep -v "symbol (\`|')timezone' has differing types:" \
255 255 | egrep -v 'PSTAMP' \
256 256 | egrep -v '^Manifying' \
257 257 | egrep -v 'Ignoring unknown host' \
258 258 | egrep -v 'Processing method:' \
259 259 | egrep -v '^Writing' \
260 260 | egrep -v 'spellin1:' \
261 261 | egrep -v '^adding:' \
262 262 | egrep -v "^echo 'msgid" \
263 263 | egrep -v '^echo ' \
264 264 | egrep -v '\.c:$' \
265 265 | egrep -v '^Adding file:' \
266 266 | egrep -v 'CLASSPATH=' \
267 267 | egrep -v '\/var\/mail\/:saved' \
268 268 | egrep -v -- '-DUTS_VERSION=' \
269 269 | egrep -v '^Running Mkbootstrap' \
270 270 | egrep -v '^Applet length read:' \
271 271 | egrep -v 'bytes written:' \
272 272 | egrep -v '^File:SolarisAuthApplet.bin' \
273 273 | egrep -v -i 'jibversion' \
274 274 | egrep -v '^Output size:' \
275 275 | egrep -v '^Solo size statistics:' \
276 276 | egrep -v '^Using ROM API Version' \
277 277 | egrep -v '^Zero Signature length:' \
278 278 | egrep -v '^Note \(probably harmless\):' \
279 279 | egrep -v '::' \
280 280 | egrep -v '^\+' \
281 281 | egrep -v 'svccfg-native -s svc:/' \
282 282 | sort | uniq >$SRC/${NOISE}.out
283 283 if [ ! -f $SRC/${NOISE}.ref ]; then
284 284 cp $SRC/${NOISE}.out $SRC/${NOISE}.ref
285 285 fi
286 286 echo "\n==== Build noise differences ($LABEL) ====\n" \
287 287 >>$mail_msg_file
288 288 diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file
289 289 fi
290 290
291 291 #
292 292 # Re-sign selected binaries using signing server
293 293 # (gatekeeper builds only)
294 294 #
295 295 if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then
296 296 echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE
297 297 signing_file="${TMPDIR}/signing"
298 298 rm -f ${signing_file}
299 299 export CODESIGN_USER
300 300 signproto $SRC/tools/codesign/creds 2>&1 | \
301 301 tee -a ${signing_file} >> $LOGFILE
302 302 echo "\n==== Finished signing proto area at `date` ====\n" \
303 303 >> $LOGFILE
304 304 echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
305 305 >> $mail_msg_file
306 306 egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
307 307 if (( $? == 0 )) ; then
308 308 build_ok=n
309 309 this_build_ok=n
310 310 fi
311 311 fi
312 312
313 313 #
314 314 # Building Packages
315 315 #
316 316 if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
317 317 if [ -d $SRC/pkg ]; then
318 318 echo "\n==== Creating $LABEL packages at `date` ====\n" \
319 319 >> $LOGFILE
320 320 echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
321 321 rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
322 322 mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
323 323
324 324 rm -f $SRC/pkg/${INSTALLOG}.out
325 325 cd $SRC/pkg
326 326 /bin/time $MAKE -e install 2>&1 | \
327 327 tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE
328 328
329 329 echo "\n==== package build errors ($LABEL) ====\n" \
330 330 >> $mail_msg_file
331 331
332 332 egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \
333 333 grep ':' | \
334 334 grep -v PSTAMP | \
335 335 egrep -v "Ignoring unknown host" | \
336 336 tee $TMPDIR/package >> $mail_msg_file
337 337 if [[ -s $TMPDIR/package ]]; then
338 338 build_extras_ok=n
339 339 this_build_ok=n
340 340 fi
341 341 else
342 342 #
343 343 # Handle it gracefully if -p was set but there so
344 344 # no pkg directory.
345 345 #
346 346 echo "\n==== No $LABEL packages to build ====\n" \
347 347 >> $LOGFILE
348 348 fi
349 349 else
350 350 echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
351 351 fi
352 352
353 353 ROOT=$ORIGROOT
354 354 }
355 355
356 356 #
357 357 # Bootstrap build tools which are pre-requisites for the rest of the build.
358 358 #
359 359 function bootstrap_tools {
360 360 echo "\n==== Bootstrapping tools at `date` ====\n" >> $LOGFILE
361 361
362 362 typeset INSTALLOG=install-bootstrap-${MACH}
363 363
364 364 rm -f $TMPDIR/make-state ${TOOLS}/$INSTALLOG.out
365 365 cd ${TOOLS}
366 366 /bin/time $MAKE -K $TMPDIR/make-state -e TARGET=install bootstrap \
367 367 2>&1 | tee -a ${TOOLS}/$INSTALLOG.out >> $LOGFILE
368 368
369 369 echo "\n==== Bootstrap build errors ====\n" >> $mail_msg_file
370 370
371 371 egrep ":" ${TOOLS}/$INSTALLOG.out |
372 372 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
373 373 egrep -v warning | tee $TMPDIR/bootstrap_errors >> $mail_msg_file
374 374
375 375 [[ -s $TMPDIR/bootstrap_errors ]] && return 1
376 376 return 0
377 377 }
378 378
379 379 #
380 380 # Build and install the onbld tools.
381 381 #
382 382 # usage: build_tools DESTROOT
383 383 #
384 384 # returns non-zero status if the build was successful.
385 385 #
386 386 function build_tools {
387 387 DESTROOT=$1
388 388
389 389 INSTALLOG=install-${MACH}
390 390
391 391 echo "\n==== Building tools at `date` ====\n" \
392 392 >> $LOGFILE
393 393
394 394 rm -f ${TOOLS}/${INSTALLOG}.out
395 395 cd ${TOOLS}
396 396 /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
397 397 tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
398 398
399 399 echo "\n==== Tools build errors ====\n" >> $mail_msg_file
400 400
401 401 egrep ":" ${TOOLS}/${INSTALLOG}.out |
402 402 egrep -e "(${MAKE}:|[ ]error[: \n])" | \
403 403 egrep -v "Ignoring unknown host" | \
404 404 egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file
405 405
406 406 if [[ -s $TMPDIR/tools_errors ]]; then
407 407 return 1
408 408 fi
409 409 return 0
410 410 }
411 411
412 412 function staffer {
413 413 if [ $ISUSER -ne 0 ]; then
414 414 "$@"
415 415 else
416 416 arg="\"$1\""
417 417 shift
418 418 for i
419 419 do
420 420 arg="$arg \"$i\""
421 421 done
422 422 eval su $STAFFER -c \'$arg\'
423 423 fi
424 424 }
425 425
426 426 #
427 427 # Verify that the closed bins are present
428 428 #
429 429 function check_closed_bins {
430 430 if [[ -n "$ON_CLOSED_BINS" && ! -d "$ON_CLOSED_BINS" ]]; then
431 431 echo "ON_CLOSED_BINS must point to the closed binaries tree."
432 432 build_ok=n
433 433 exit 1
434 434 fi
435 435 }
436 436
437 437 #
438 438 # wrapper over wsdiff.
439 439 # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
440 440 #
441 441 function do_wsdiff {
442 442 label=$1
443 443 oldproto=$2
444 444 newproto=$3
445 445
446 446 wsdiff="wsdiff"
447 447 [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
448 448
449 449 echo "\n==== Getting object changes since last build at `date`" \
450 450 "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
451 451 $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
452 452 tee -a $LOGFILE >> $mail_msg_file
453 453 echo "\n==== Object changes determined at `date` ($label) ====\n" | \
454 454 tee -a $LOGFILE >> $mail_msg_file
455 455 }
456 456
457 457 #
458 458 # Functions for setting build flags (DEBUG/non-DEBUG). Keep them
459 459 # together.
460 460 #
461 461
462 462 function set_non_debug_build_flags {
463 463 export RELEASE_BUILD ; RELEASE_BUILD=
464 464 unset EXTRA_OPTIONS
465 465 unset EXTRA_CFLAGS
466 466 if [ -n "$RELEASE_CONSOLE_COLOR" ]; then
467 467 export DEFAULT_CONSOLE_COLOR="$RELEASE_CONSOLE_COLOR"
468 468 fi
469 469 }
470 470
471 471 function set_debug_build_flags {
472 472 unset RELEASE_BUILD
473 473 unset EXTRA_OPTIONS
474 474 unset EXTRA_CFLAGS
475 475
476 476 if [ -n "$DEBUG_CONSOLE_COLOR" ]; then
477 477 export DEFAULT_CONSOLE_COLOR="$DEBUG_CONSOLE_COLOR"
478 478 fi
479 479 }
480 480
481 481
482 482 MACH=`uname -p`
483 483
484 484 if [ "$OPTHOME" = "" ]; then
485 485 OPTHOME=/opt
486 486 export OPTHOME
487 487 fi
488 488
489 489 USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
490 490
491 491 Where:
492 492 -i Fast incremental options (no clobber, check)
493 493 -n Do not do a bringover
494 494 +t Use the build tools in $ONBLD_TOOLS/bin
495 495 -V VERS set the build version string to VERS
496 496
497 497 <env_file> file in Bourne shell syntax that sets and exports
498 498 variables that configure the operation of this script and many of
499 499 the scripts this one calls. If <env_file> does not exist,
500 500 it will be looked for in $OPTHOME/onbld/env.
501 501
502 502 non-DEBUG is the default build type. Build options can be set in the
503 503 NIGHTLY_OPTIONS variable in the <env_file> as follows:
504 504
505 505 -A check for ABI differences in .so files
506 506 -C check for cstyle/hdrchk errors
507 507 -D do a build with DEBUG on
508 508 -F do _not_ do a non-DEBUG build
509 509 -G gate keeper default group of options (-au)
510 510 -I integration engineer default group of options (-ampu)
511 511 -M do not run pmodes (safe file permission checker)
512 512 -N do not run protocmp
513 513 -R default group of options for building a release (-mp)
514 514 -U update proto area in the parent
515 515 -V VERS set the build version string to VERS
516 516 -f find unreferenced files
517 517 -i do an incremental build (no "make clobber")
518 518 -m send mail to $MAILTO at end of build
519 519 -n do not do a bringover
520 520 -p create packages
521 521 -r check ELF runtime attributes in the proto area
522 522 -t build and use the tools in $SRC/tools (default setting)
523 523 +t Use the build tools in $ONBLD_TOOLS/bin
524 524 -u update proto_list_$MACH and friends in the parent workspace;
525 525 when used with -f, also build an unrefmaster.out in the parent
526 526 -w report on differences between previous and current proto areas
527 527 '
528 528 #
529 529 # A log file will be generated under the name $LOGFILE
530 530 # for partially completed build and log.`date '+%F'`
531 531 # in the same directory for fully completed builds.
532 532 #
533 533
534 534 # default values for low-level FLAGS; G I R are group FLAGS
535 535 A_FLAG=n
536 536 C_FLAG=n
537 537 D_FLAG=n
538 538 F_FLAG=n
539 539 f_FLAG=n
540 540 i_FLAG=n; i_CMD_LINE_FLAG=n
541 541 M_FLAG=n
542 542 m_FLAG=n
543 543 N_FLAG=n
544 544 n_FLAG=n
545 545 p_FLAG=n
546 546 r_FLAG=n
547 547 t_FLAG=y
548 548 U_FLAG=n
549 549 u_FLAG=n
550 550 V_FLAG=n
551 551 w_FLAG=n
552 552 W_FLAG=n
553 553 #
554 554 build_ok=y
555 555 build_extras_ok=y
556 556
557 557 #
558 558 # examine arguments
559 559 #
560 560
561 561 OPTIND=1
562 562 while getopts +intV:W FLAG
563 563 do
564 564 case $FLAG in
565 565 i ) i_FLAG=y; i_CMD_LINE_FLAG=y
566 566 ;;
567 567 n ) n_FLAG=y
568 568 ;;
569 569 +t ) t_FLAG=n
570 570 ;;
571 571 V ) V_FLAG=y
572 572 V_ARG="$OPTARG"
573 573 ;;
574 574 W ) W_FLAG=y
575 575 ;;
576 576 \? ) echo "$USAGE"
577 577 exit 1
578 578 ;;
579 579 esac
580 580 done
581 581
582 582 # correct argument count after options
583 583 shift `expr $OPTIND - 1`
584 584
585 585 # test that the path to the environment-setting file was given
586 586 if [ $# -ne 1 ]; then
587 587 echo "$USAGE"
588 588 exit 1
589 589 fi
590 590
591 591 # check if user is running nightly as root
592 592 # ISUSER is set non-zero if an ordinary user runs nightly, or is zero
593 593 # when root invokes nightly.
594 594 /usr/bin/id | grep '^uid=0(' >/dev/null 2>&1
595 595 ISUSER=$?; export ISUSER
596 596
597 597 #
598 598 # force locale to C
599 599 LANG=C; export LANG
600 600 LC_ALL=C; export LC_ALL
601 601 LC_COLLATE=C; export LC_COLLATE
602 602 LC_CTYPE=C; export LC_CTYPE
603 603 LC_MESSAGES=C; export LC_MESSAGES
604 604 LC_MONETARY=C; export LC_MONETARY
605 605 LC_NUMERIC=C; export LC_NUMERIC
606 606 LC_TIME=C; export LC_TIME
607 607
608 608 # clear environment variables we know to be bad for the build
609 609 unset LD_OPTIONS
610 610 unset LD_AUDIT LD_AUDIT_32 LD_AUDIT_64
611 611 unset LD_BIND_NOW LD_BIND_NOW_32 LD_BIND_NOW_64
612 612 unset LD_BREADTH LD_BREADTH_32 LD_BREADTH_64
613 613 unset LD_CONFIG LD_CONFIG_32 LD_CONFIG_64
614 614 unset LD_DEBUG LD_DEBUG_32 LD_DEBUG_64
615 615 unset LD_DEMANGLE LD_DEMANGLE_32 LD_DEMANGLE_64
616 616 unset LD_FLAGS LD_FLAGS_32 LD_FLAGS_64
617 617 unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64
618 618 unset LD_LOADFLTR LD_LOADFLTR_32 LD_LOADFLTR_64
619 619 unset LD_NOAUDIT LD_NOAUDIT_32 LD_NOAUDIT_64
620 620 unset LD_NOAUXFLTR LD_NOAUXFLTR_32 LD_NOAUXFLTR_64
621 621 unset LD_NOCONFIG LD_NOCONFIG_32 LD_NOCONFIG_64
622 622 unset LD_NODIRCONFIG LD_NODIRCONFIG_32 LD_NODIRCONFIG_64
623 623 unset LD_NODIRECT LD_NODIRECT_32 LD_NODIRECT_64
624 624 unset LD_NOLAZYLOAD LD_NOLAZYLOAD_32 LD_NOLAZYLOAD_64
625 625 unset LD_NOOBJALTER LD_NOOBJALTER_32 LD_NOOBJALTER_64
626 626 unset LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64
627 627 unset LD_ORIGIN LD_ORIGIN_32 LD_ORIGIN_64
628 628 unset LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_64
629 629 unset LD_PROFILE LD_PROFILE_32 LD_PROFILE_64
630 630
631 631 unset CONFIG
632 632 unset GROUP
633 633 unset OWNER
634 634 unset REMOTE
635 635 unset ENV
636 636 unset ARCH
637 637 unset CLASSPATH
638 638 unset NAME
639 639
640 640 #
641 641 # To get ONBLD_TOOLS from the environment, it must come from the env file.
642 642 # If it comes interactively, it is generally TOOLS_PROTO, which will be
643 643 # clobbered before the compiler version checks, which will therefore fail.
644 644 #
645 645 unset ONBLD_TOOLS
646 646
647 647 #
648 648 # Setup environmental variables
649 649 #
650 650 if [ -f /etc/nightly.conf ]; then
651 651 . /etc/nightly.conf
652 652 fi
653 653
654 654 if [ -f $1 ]; then
655 655 if [[ $1 = */* ]]; then
656 656 . $1
657 657 else
658 658 . ./$1
659 659 fi
660 660 else
661 661 if [ -f $OPTHOME/onbld/env/$1 ]; then
662 662 . $OPTHOME/onbld/env/$1
663 663 else
664 664 echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1"
665 665 exit 1
666 666 fi
667 667 fi
668 668
669 669 # Check if we have sufficient data to continue...
670 670 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
671 671 if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
672 672 # Check if the gate data are valid if we don't do a "bringover" below
673 673 [[ -d "${CODEMGR_WS}" ]] || \
674 674 fatal_error "Error: ${CODEMGR_WS} is not a directory."
675 675 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
676 676 fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
677 677 fi
678 678
679 679 #
680 680 # place ourselves in a new task, respecting BUILD_PROJECT if set.
681 681 #
682 682 if [ -z "$BUILD_PROJECT" ]; then
683 683 /usr/bin/newtask -c $$
684 684 else
685 685 /usr/bin/newtask -c $$ -p $BUILD_PROJECT
686 686 fi
687 687
688 688 ps -o taskid= -p $$ | read build_taskid
689 689 ps -o project= -p $$ | read build_project
690 690
691 691 #
692 692 # See if NIGHTLY_OPTIONS is set
693 693 #
694 694 if [ "$NIGHTLY_OPTIONS" = "" ]; then
695 695 NIGHTLY_OPTIONS="-aBm"
696 696 fi
697 697
698 698 #
699 699 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
700 700 #
701 701 if [ "$BRINGOVER_WS" = "" ]; then
702 702 BRINGOVER_WS=$CLONE_WS
703 703 fi
704 704
705 705 #
706 706 # If BRINGOVER_FILES was not specified, default to usr
707 707 #
708 708 if [ "$BRINGOVER_FILES" = "" ]; then
709 709 BRINGOVER_FILES="usr"
710 710 fi
711 711
712 712 check_closed_bins
713 713
714 714 #
715 715 # Note: changes to the option letters here should also be applied to the
716 716 # bldenv script. `d' is listed for backward compatibility.
717 717 #
718 718 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
719 719 OPTIND=1
720 720 while getopts +ABCDdFfGIiMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS
721 721 do
722 722 case $FLAG in
723 723 A ) A_FLAG=y
724 724 ;;
725 725 B ) D_FLAG=y
726 726 ;; # old version of D
727 727 C ) C_FLAG=y
728 728 ;;
729 729 D ) D_FLAG=y
730 730 ;;
731 731 F ) F_FLAG=y
732 732 ;;
733 733 f ) f_FLAG=y
734 734 ;;
735 735 G ) u_FLAG=y
736 736 ;;
737 737 I ) m_FLAG=y
738 738 p_FLAG=y
739 739 u_FLAG=y
740 740 ;;
741 741 i ) i_FLAG=y
742 742 ;;
743 743 M ) M_FLAG=y
744 744 ;;
745 745 m ) m_FLAG=y
746 746 ;;
747 747 N ) N_FLAG=y
748 748 ;;
749 749 n ) n_FLAG=y
750 750 ;;
751 751 p ) p_FLAG=y
752 752 ;;
753 753 R ) m_FLAG=y
754 754 p_FLAG=y
755 755 ;;
756 756 r ) r_FLAG=y
757 757 ;;
758 758 +t ) t_FLAG=n
759 759 ;;
760 760 U ) if [ -z "${PARENT_ROOT}" ]; then
761 761 echo "PARENT_ROOT must be set if the U flag is" \
762 762 "present in NIGHTLY_OPTIONS."
763 763 exit 1
764 764 fi
765 765 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
766 766 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
767 767 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
768 768 fi
769 769 U_FLAG=y
770 770 ;;
771 771 u ) u_FLAG=y
772 772 ;;
773 773 w ) w_FLAG=y
774 774 ;;
775 775 W ) W_FLAG=y
776 776 ;;
777 777 \? ) echo "$USAGE"
778 778 exit 1
779 779 ;;
780 780 esac
781 781 done
782 782
783 783 if [ $ISUSER -ne 0 ]; then
784 784 # Set default value for STAFFER, if needed.
785 785 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
786 786 STAFFER=`/usr/xpg4/bin/id -un`
787 787 export STAFFER
788 788 fi
789 789 fi
790 790
791 791 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
792 792 MAILTO=$STAFFER
793 793 export MAILTO
794 794 fi
795 795
796 796 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
797 797 PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb"
798 798 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
799 799 export PATH
800 800
801 801 # roots of source trees, both relative to $SRC and absolute.
802 802 relsrcdirs="."
803 803 abssrcdirs="$SRC"
804 804
805 805 PROTOCMPTERSE="protocmp.terse -gu"
806 806 POUND_SIGN="#"
807 807 # have we set RELEASE_DATE in our env file?
808 808 if [ -z "$RELEASE_DATE" ]; then
809 809 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
810 810 fi
811 811 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
812 812 BASEWSDIR=$(basename $CODEMGR_WS)
813 813 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
814 814
815 815 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
816 816 # by avoiding repeated shell invocations to evaluate Makefile.master
817 817 # definitions.
818 818 export POUND_SIGN RELEASE_DATE DEV_CM
819 819
820 820 maketype="distributed"
821 821 if [[ -z "$MAKE" ]]; then
822 822 MAKE=dmake
823 823 elif [[ ! -x "$MAKE" ]]; then
824 824 echo "\$MAKE is set to garbage in the environment"
825 825 exit 1
826 826 fi
827 827 export PATH
828 828 export MAKE
829 829
830 830 if [ "${SUNWSPRO}" != "" ]; then
831 831 PATH="${SUNWSPRO}/bin:$PATH"
832 832 export PATH
833 833 fi
834 834
835 835 hostname=$(uname -n)
836 836 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
837 837 then
838 838 maxjobs=
839 839 if [[ -f $HOME/.make.machines ]]
840 840 then
841 841 # Note: there is a hard tab and space character in the []s
842 842 # below.
843 843 egrep -i "^[ ]*$hostname[ \.]" \
844 844 $HOME/.make.machines | read host jobs
845 845 maxjobs=${jobs##*=}
846 846 fi
847 847
848 848 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
849 849 then
850 850 # default
851 851 maxjobs=4
852 852 fi
853 853
854 854 export DMAKE_MAX_JOBS=$maxjobs
855 855 fi
856 856
857 857 DMAKE_MODE=parallel;
858 858 export DMAKE_MODE
859 859
860 860 if [ -z "${ROOT}" ]; then
861 861 echo "ROOT must be set."
862 862 exit 1
863 863 fi
864 864
865 865 #
866 866 # if -V flag was given, reset VERSION to V_ARG
867 867 #
868 868 if [ "$V_FLAG" = "y" ]; then
869 869 VERSION=$V_ARG
870 870 fi
871 871
872 872 TMPDIR="/tmp/nightly.tmpdir.$$"
873 873 export TMPDIR
874 874 rm -rf ${TMPDIR}
875 875 mkdir -p $TMPDIR || exit 1
876 876 chmod 777 $TMPDIR
877 877
878 878 #
879 879 # Work around folks who have historically used GCC_ROOT and convert it to
880 880 # GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could
881 881 # mess up the case where multiple different gcc versions are being used to
882 882 # shadow).
883 883 #
884 884 if [[ -n "${GCC_ROOT}" ]]; then
885 885 export GNUC_ROOT=${GCC_ROOT}
886 886 fi
887 887
888 888 #
889 889 # Tools should only be built non-DEBUG. Keep track of the tools proto
890 890 # area path relative to $TOOLS, because the latter changes in an
891 891 # export build.
892 892 #
893 893 # TOOLS_PROTO is included below for builds other than usr/src/tools
894 894 # that look for this location. For usr/src/tools, this will be
895 895 # overridden on the $MAKE command line in build_tools().
896 896 #
897 897 TOOLS=${SRC}/tools
898 898 TOOLS_PROTO_REL=proto/root_${MACH}-nd
899 899 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
900 900
901 901 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
902 902
903 903 # create directories that are automatically removed if the nightly script
904 904 # fails to start correctly
905 905 function newdir {
906 906 dir=$1
907 907 toadd=
908 908 while [ ! -d $dir ]; do
909 909 toadd="$dir $toadd"
910 910 dir=`dirname $dir`
911 911 done
912 912 torm=
913 913 newlist=
914 914 for dir in $toadd; do
915 915 if staffer mkdir $dir; then
916 916 newlist="$ISUSER $dir $newlist"
917 917 torm="$dir $torm"
918 918 else
919 919 [ -z "$torm" ] || staffer rmdir $torm
920 920 return 1
921 921 fi
922 922 done
923 923 newdirlist="$newlist $newdirlist"
924 924 return 0
925 925 }
926 926 newdirlist=
927 927
928 928 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
929 929
930 930 # since this script assumes the build is from full source, it nullifies
931 931 # variables likely to have been set by a "ws" script; nullification
932 932 # confines the search space for headers and libraries to the proto area
933 933 # built from this immediate source.
934 934 ENVLDLIBS1=
935 935 ENVLDLIBS2=
936 936 ENVLDLIBS3=
937 937 ENVCPPFLAGS1=
938 938 ENVCPPFLAGS2=
939 939 ENVCPPFLAGS3=
940 940 ENVCPPFLAGS4=
941 941 PARENT_ROOT=
942 942
943 943 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
944 944 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
945 945
946 946 PKGARCHIVE_ORIG=$PKGARCHIVE
947 947
948 948 #
949 949 # Juggle the logs and optionally send mail on completion.
950 950 #
951 951
952 952 function logshuffle {
953 953 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
954 954 if [ -f $LLOG -o -d $LLOG ]; then
955 955 LLOG=$LLOG.$$
956 956 fi
957 957
958 958 rm -f "$ATLOG/latest" 2>/dev/null
959 959 mkdir -p $LLOG
960 960 export LLOG
961 961
962 962 if [ "$build_ok" = "y" ]; then
963 963 mv $ATLOG/proto_list_${MACH} $LLOG
964 964
965 965 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
966 966 mv $ATLOG/proto_list_tools_${MACH} $LLOG
967 967 fi
968 968
969 969 if [ -f $TMPDIR/wsdiff.results ]; then
970 970 mv $TMPDIR/wsdiff.results $LLOG
971 971 fi
972 972
973 973 if [ -f $TMPDIR/wsdiff-nd.results ]; then
974 974 mv $TMPDIR/wsdiff-nd.results $LLOG
975 975 fi
976 976 fi
977 977
978 978 #
979 979 # Now that we're about to send mail, it's time to check the noise
980 980 # file. In the event that an error occurs beyond this point, it will
981 981 # be recorded in the nightly.log file, but nowhere else. This would
982 982 # include only errors that cause the copying of the noise log to fail
983 983 # or the mail itself not to be sent.
984 984 #
985 985
986 986 exec >>$LOGFILE 2>&1
987 987 if [ -s $build_noise_file ]; then
988 988 echo "\n==== Nightly build noise ====\n" |
989 989 tee -a $LOGFILE >>$mail_msg_file
990 990 cat $build_noise_file >>$LOGFILE
991 991 cat $build_noise_file >>$mail_msg_file
992 992 echo | tee -a $LOGFILE >>$mail_msg_file
993 993 fi
994 994 rm -f $build_noise_file
995 995
996 996 case "$build_ok" in
997 997 y)
998 998 state=Completed
999 999 ;;
1000 1000 i)
1001 1001 state=Interrupted
1002 1002 ;;
1003 1003 *)
1004 1004 state=Failed
1005 1005 ;;
1006 1006 esac
1007 1007
1008 1008 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
1009 1009 state=Failed
1010 1010 fi
1011 1011
1012 1012 NIGHTLY_STATUS=$state
1013 1013 export NIGHTLY_STATUS
1014 1014
1015 1015 run_hook POST_NIGHTLY $state
1016 1016 run_hook SYS_POST_NIGHTLY $state
1017 1017
1018 1018 #
1019 1019 # mailx(1) sets From: based on the -r flag
1020 1020 # if it is given.
1021 1021 #
1022 1022 mailx_r=
1023 1023 if [[ -n "${MAILFROM}" ]]; then
1024 1024 mailx_r="-r ${MAILFROM}"
1025 1025 fi
1026 1026
1027 1027 cat $build_time_file $build_environ_file $mail_msg_file \
1028 1028 > ${LLOG}/mail_msg
1029 1029 if [ "$m_FLAG" = "y" ]; then
1030 1030 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1031 1031 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1032 1032 ${MAILTO}
1033 1033 fi
1034 1034
1035 1035 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1036 1036 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH}
1037 1037 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log
1038 1038 fi
1039 1039
1040 1040 mv $LOGFILE $LLOG
1041 1041
1042 1042 ln -s "$LLOG" "$ATLOG/latest"
1043 1043 }
1044 1044
1045 1045 #
1046 1046 # Remove the locks and temporary files on any exit
1047 1047 #
1048 1048 function cleanup {
1049 1049 logshuffle
1050 1050
1051 1051 [ -z "$lockfile" ] || staffer rm -f $lockfile
1052 1052 [ -z "$atloglockfile" ] || rm -f $atloglockfile
1053 1053 [ -z "$ulockfile" ] || staffer rm -f $ulockfile
1054 1054 [ -z "$Ulockfile" ] || rm -f $Ulockfile
1055 1055
1056 1056 set -- $newdirlist
1057 1057 while [ $# -gt 0 ]; do
1058 1058 ISUSER=$1 staffer rmdir $2
1059 1059 shift; shift
1060 1060 done
1061 1061 rm -rf $TMPDIR
1062 1062 }
1063 1063
1064 1064 function cleanup_signal {
1065 1065 build_ok=i
1066 1066 # this will trigger cleanup(), above.
1067 1067 exit 1
1068 1068 }
1069 1069
1070 1070 trap cleanup 0
1071 1071 trap cleanup_signal 1 2 3 15
1072 1072
1073 1073 #
1074 1074 # Generic lock file processing -- make sure that the lock file doesn't
1075 1075 # exist. If it does, it should name the build host and PID. If it
1076 1076 # doesn't, then make sure we can create it. Clean up locks that are
1077 1077 # known to be stale (assumes host name is unique among build systems
1078 1078 # for the workspace).
1079 1079 #
1080 1080 function create_lock {
1081 1081 lockf=$1
1082 1082 lockvar=$2
1083 1083
1084 1084 ldir=`dirname $lockf`
1085 1085 [ -d $ldir ] || newdir $ldir || exit 1
1086 1086 eval $lockvar=$lockf
1087 1087
1088 1088 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1089 1089 basews=`basename $CODEMGR_WS`
1090 1090 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1091 1091 if [ "$host" != "$hostname" ]; then
1092 1092 echo "$MACH build of $basews apparently" \
1093 1093 "already started by $user on $host as $pid."
1094 1094 exit 1
1095 1095 elif kill -s 0 $pid 2>/dev/null; then
1096 1096 echo "$MACH build of $basews already started" \
1097 1097 "by $user as $pid."
1098 1098 exit 1
1099 1099 else
1100 1100 # stale lock; clear it out and try again
1101 1101 rm -f $lockf
1102 1102 fi
1103 1103 done
1104 1104 }
1105 1105
1106 1106 #
1107 1107 # Return the list of interesting proto areas, depending on the current
1108 1108 # options.
1109 1109 #
1110 1110 function allprotos {
1111 1111 typeset roots="$ROOT"
1112 1112
1113 1113 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1114 1114 roots="$roots $ROOT-nd"
1115 1115 fi
1116 1116
1117 1117 echo $roots
1118 1118 }
1119 1119
1120 1120 # Ensure no other instance of this script is running on this host.
1121 1121 # LOCKNAME can be set in <env_file>, and is by default, but is not
1122 1122 # required due to the use of $ATLOG below.
1123 1123 if [ -n "$LOCKNAME" ]; then
1124 1124 create_lock /tmp/$LOCKNAME "lockfile"
1125 1125 fi
1126 1126 #
1127 1127 # Create from one, two, or three other locks:
1128 1128 # $ATLOG/nightly.lock
1129 1129 # - protects against multiple builds in same workspace
1130 1130 # $PARENT_WS/usr/src/nightly.$MACH.lock
1131 1131 # - protects against multiple 'u' copy-backs
1132 1132 # $NIGHTLY_PARENT_ROOT/nightly.lock
1133 1133 # - protects against multiple 'U' copy-backs
1134 1134 #
1135 1135 # Overriding ISUSER to 1 causes the lock to be created as root if the
1136 1136 # script is run as root. The default is to create it as $STAFFER.
1137 1137 ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile"
1138 1138 if [ "$u_FLAG" = "y" ]; then
1139 1139 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile"
1140 1140 fi
1141 1141 if [ "$U_FLAG" = "y" ]; then
1142 1142 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1143 1143 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile"
1144 1144 fi
1145 1145
1146 1146 # Locks have been taken, so we're doing a build and we're committed to
1147 1147 # the directories we may have created so far.
1148 1148 newdirlist=
1149 1149
1150 1150 #
1151 1151 # Create mail_msg_file
1152 1152 #
1153 1153 mail_msg_file="${TMPDIR}/mail_msg"
1154 1154 touch $mail_msg_file
1155 1155 build_time_file="${TMPDIR}/build_time"
1156 1156 build_environ_file="${TMPDIR}/build_environ"
1157 1157 touch $build_environ_file
1158 1158 #
1159 1159 # Move old LOGFILE aside
1160 1160 # ATLOG directory already made by 'create_lock' above
1161 1161 #
1162 1162 if [ -f $LOGFILE ]; then
1163 1163 mv -f $LOGFILE ${LOGFILE}-
1164 1164 fi
1165 1165 #
1166 1166 # Build OsNet source
1167 1167 #
1168 1168 START_DATE=`date`
1169 1169 SECONDS=0
1170 1170 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1171 1171 | tee -a $LOGFILE > $build_time_file
1172 1172
1173 1173 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1174 1174 tee -a $mail_msg_file >> $LOGFILE
1175 1175
1176 1176 # make sure we log only to the nightly build file
1177 1177 build_noise_file="${TMPDIR}/build_noise"
1178 1178 exec </dev/null >$build_noise_file 2>&1
1179 1179
1180 1180 run_hook SYS_PRE_NIGHTLY
1181 1181 run_hook PRE_NIGHTLY
1182 1182
1183 1183 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1184 1184 env >> $LOGFILE
1185 1185
1186 1186 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1187 1187
1188 1188 if [ "$N_FLAG" = "y" ]; then
1189 1189 if [ "$p_FLAG" = "y" ]; then
1190 1190 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1191 1191 WARNING: the p option (create packages) is set, but so is the N option (do
1192 1192 not run protocmp); this is dangerous; you should unset the N option
1193 1193 EOF
1194 1194 else
1195 1195 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1196 1196 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1197 1197 EOF
1198 1198 fi
1199 1199 echo "" | tee -a $mail_msg_file >> $LOGFILE
1200 1200 fi
1201 1201
1202 1202 if [ "$f_FLAG" = "y" ]; then
1203 1203 if [ "$i_FLAG" = "y" ]; then
1204 1204 echo "WARNING: the -f flag cannot be used during incremental" \
1205 1205 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1206 1206 f_FLAG=n
1207 1207 fi
1208 1208 if [ "${p_FLAG}" != "y" ]; then
1209 1209 echo "WARNING: the -f flag requires -p;" \
1210 1210 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1211 1211 f_FLAG=n
1212 1212 fi
1213 1213 fi
1214 1214
1215 1215 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1216 1216 echo "WARNING: -w specified, but $ROOT does not exist;" \
1217 1217 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE
1218 1218 w_FLAG=n
1219 1219 fi
1220 1220
1221 1221 case $MULTI_PROTO in
1222 1222 yes|no) ;;
1223 1223 *)
1224 1224 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1225 1225 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1226 1226 echo "Setting MULTI_PROTO to \"no\".\n" | \
1227 1227 tee -a $mail_msg_file >> $LOGFILE
1228 1228 export MULTI_PROTO=no
1229 1229 ;;
1230 1230 esac
1231 1231
1232 1232 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1233 1233 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1234 1234
1235 1235 # Save the current proto area if we're comparing against the last build
1236 1236 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1237 1237 if [ -d "$ROOT.prev" ]; then
1238 1238 rm -rf $ROOT.prev
1239 1239 fi
1240 1240 mv $ROOT $ROOT.prev
1241 1241 fi
1242 1242
1243 1243 # Same for non-DEBUG proto area
1244 1244 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1245 1245 if [ -d "$ROOT-nd.prev" ]; then
1246 1246 rm -rf $ROOT-nd.prev
1247 1247 fi
1248 1248 mv $ROOT-nd $ROOT-nd.prev
1249 1249 fi
1250 1250
1251 1251 #
1252 1252 # Echo the SCM type of the parent workspace, this can't just be which_scm
1253 1253 # as that does not know how to identify various network repositories.
1254 1254 #
1255 1255 function parent_wstype {
1256 1256 typeset scm_type junk
1257 1257
1258 1258 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1259 1259 | read scm_type junk
1260 1260 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1261 1261 # Probe BRINGOVER_WS to determine its type
1262 1262 if [[ $BRINGOVER_WS == ssh://* ]]; then
1263 1263 scm_type="mercurial"
1264 1264 elif [[ $BRINGOVER_WS == http://* ]] && \
1265 1265 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1266 1266 egrep -s "application/mercurial" 2> /dev/null; then
1267 1267 scm_type="mercurial"
1268 1268 else
1269 1269 scm_type="none"
1270 1270 fi
1271 1271 fi
1272 1272
1273 1273 # fold both unsupported and unrecognized results into "none"
1274 1274 case "$scm_type" in
1275 1275 mercurial)
1276 1276 ;;
1277 1277 *) scm_type=none
1278 1278 ;;
1279 1279 esac
1280 1280
1281 1281 echo $scm_type
1282 1282 }
1283 1283
1284 1284 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1285 1285 function child_wstype {
1286 1286 typeset scm_type junk
1287 1287
1288 1288 # Probe CODEMGR_WS to determine its type
1289 1289 if [[ -d $CODEMGR_WS ]]; then
1290 1290 $WHICH_SCM | read scm_type junk || exit 1
1291 1291 fi
1292 1292
1293 1293 case "$scm_type" in
1294 1294 none|git|mercurial)
1295 1295 ;;
1296 1296 *) scm_type=none
1297 1297 ;;
1298 1298 esac
1299 1299
1300 1300 echo $scm_type
1301 1301 }
1302 1302
1303 1303 SCM_TYPE=$(child_wstype)
1304 1304
1305 1305 #
1306 1306 # Decide whether to clobber
1307 1307 #
1308 1308 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1309 1309 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1310 1310
1311 1311 cd $SRC
1312 1312 # remove old clobber file
1313 1313 rm -f $SRC/clobber.out
1314 1314 rm -f $SRC/clobber-${MACH}.out
1315 1315
1316 1316 # Remove all .make.state* files, just in case we are restarting
1317 1317 # the build after having interrupted a previous 'make clobber'.
1318 1318 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1319 1319 -o -name 'interfaces.*' \) -prune \
1320 1320 -o -name '.make.*' -print | xargs rm -f
1321 1321
1322 1322 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1323 1323 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1324 1324 grep "$MAKE:" $SRC/clobber-${MACH}.out |
1325 1325 egrep -v "Ignoring unknown host" | \
1326 1326 tee $TMPDIR/clobber_errs >> $mail_msg_file
1327 1327
1328 1328 if [[ -s $TMPDIR/clobber_errs ]]; then
1329 1329 build_extras_ok=n
1330 1330 fi
1331 1331
1332 1332 if [[ "$t_FLAG" = "y" ]]; then
1333 1333 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1334 1334 cd ${TOOLS}
1335 1335 rm -f ${TOOLS}/clobber-${MACH}.out
1336 1336 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1337 1337 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1338 1338 echo "\n==== Make tools clobber ERRORS ====\n" \
1339 1339 >> $mail_msg_file
1340 1340 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1341 1341 >> $mail_msg_file
1342 1342 if (( $? == 0 )); then
1343 1343 build_extras_ok=n
1344 1344 fi
1345 1345 rm -rf ${TOOLS_PROTO}
1346 1346 mkdir -p ${TOOLS_PROTO}
1347 1347 fi
1348 1348
1349 1349 typeset roots=$(allprotos)
1350 1350 echo "\n\nClearing $roots" >> "$LOGFILE"
1351 1351 rm -rf $roots
1352 1352
1353 1353 # Get back to a clean workspace as much as possible to catch
1354 1354 # problems that only occur on fresh workspaces.
1355 1355 # Remove all .make.state* files, libraries, and .o's that may
1356 1356 # have been omitted from clobber. A couple of libraries are
1357 1357 # under source code control, so leave them alone.
1358 1358 # We should probably blow away temporary directories too.
1359 1359 cd $SRC
1360 1360 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1361 1361 -o -name .git -o -name 'interfaces.*' \) -prune -o \
1362 1362 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1363 1363 -name '*.o' \) -print | \
1364 1364 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
1365 1365 else
1366 1366 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1367 1367 fi
1368 1368
1369 1369 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
1370 1370 typeset -x PATH=$PATH
1371 1371
1372 1372 # If the repository doesn't exist yet, then we want to populate it.
1373 1373 if [[ ! -d $CODEMGR_WS/.hg ]]; then
1374 1374 staffer hg init $CODEMGR_WS
1375 1375 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
1376 1376 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
1377 1377 touch $TMPDIR/new_repository
1378 1378 fi
1379 1379
1380 1380 typeset -x HGMERGE="/bin/false"
1381 1381
1382 1382 #
1383 1383 # If the user has changes, regardless of whether those changes are
1384 1384 # committed, and regardless of whether those changes conflict, then
1385 1385 # we'll attempt to merge them either implicitly (uncommitted) or
1386 1386 # explicitly (committed).
1387 1387 #
1388 1388 # These are the messages we'll use to help clarify mercurial output
1389 1389 # in those cases.
1390 1390 #
1391 1391 typeset mergefailmsg="\
1392 1392 ***\n\
1393 1393 *** nightly was unable to automatically merge your changes. You should\n\
1394 1394 *** redo the full merge manually, following the steps outlined by mercurial\n\
1395 1395 *** above, then restart nightly.\n\
1396 1396 ***\n"
1397 1397 typeset mergepassmsg="\
1398 1398 ***\n\
1399 1399 *** nightly successfully merged your changes. This means that your working\n\
1400 1400 *** directory has been updated, but those changes are not yet committed.\n\
1401 1401 *** After nightly completes, you should validate the results of the merge,\n\
1402 1402 *** then use hg commit manually.\n\
1403 1403 ***\n"
1404 1404
1405 1405 #
1406 1406 # For each repository in turn:
1407 1407 #
1408 1408 # 1. Do the pull. If this fails, dump the output and bail out.
1409 1409 #
1410 1410 # 2. If the pull resulted in an extra head, do an explicit merge.
1411 1411 # If this fails, dump the output and bail out.
1412 1412 #
1413 1413 # Because we can't rely on Mercurial to exit with a failure code
1414 1414 # when a merge fails (Mercurial issue #186), we must grep the
1415 1415 # output of pull/merge to check for attempted and/or failed merges.
1416 1416 #
1417 1417 # 3. If a merge failed, set the message and fail the bringover.
1418 1418 #
1419 1419 # 4. Otherwise, if a merge succeeded, set the message
1420 1420 #
1421 1421 # 5. Dump the output, and any message from step 3 or 4.
1422 1422 #
1423 1423
1424 1424 typeset HG_SOURCE=$BRINGOVER_WS
1425 1425 if [ ! -f $TMPDIR/new_repository ]; then
1426 1426 HG_SOURCE=$TMPDIR/open_bundle.hg
1427 1427 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
1428 1428 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
1429 1429
1430 1430 #
1431 1431 # If there are no incoming changesets, then incoming will
1432 1432 # fail, and there will be no bundle file. Reset the source,
1433 1433 # to allow the remaining logic to complete with no false
1434 1434 # negatives. (Unlike incoming, pull will return success
1435 1435 # for the no-change case.)
1436 1436 #
1437 1437 if (( $? != 0 )); then
1438 1438 HG_SOURCE=$BRINGOVER_WS
1439 1439 fi
1440 1440 fi
1441 1441
1442 1442 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
1443 1443 > $TMPDIR/pull_open.out 2>&1
1444 1444 if (( $? != 0 )); then
1445 1445 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
1446 1446 cat $TMPDIR/pull_open.out
1447 1447 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1448 1448 printf "$mergefailmsg"
1449 1449 fi
1450 1450 touch $TMPDIR/bringover_failed
1451 1451 return
1452 1452 fi
1453 1453
1454 1454 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1455 1455 staffer hg --cwd $CODEMGR_WS merge \
1456 1456 >> $TMPDIR/pull_open.out 2>&1
1457 1457 if (( $? != 0 )); then
1458 1458 printf "%s: merge failed as follows:\n\n" \
1459 1459 "$CODEMGR_WS"
1460 1460 cat $TMPDIR/pull_open.out
1461 1461 if grep "^merging.*failed" $TMPDIR/pull_open.out \
1462 1462 > /dev/null 2>&1; then
1463 1463 printf "$mergefailmsg"
1464 1464 fi
1465 1465 touch $TMPDIR/bringover_failed
1466 1466 return
1467 1467 fi
1468 1468 fi
1469 1469
1470 1470 printf "updated %s with the following results:\n" "$CODEMGR_WS"
1471 1471 cat $TMPDIR/pull_open.out
1472 1472 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
1473 1473 printf "$mergepassmsg"
1474 1474 fi
1475 1475 printf "\n"
1476 1476
1477 1477 #
1478 1478 # Per-changeset output is neither useful nor manageable for a
1479 1479 # newly-created repository.
1480 1480 #
1481 1481 if [ -f $TMPDIR/new_repository ]; then
1482 1482 return
1483 1483 fi
1484 1484
1485 1485 printf "\nadded the following changesets to open repository:\n"
1486 1486 cat $TMPDIR/incoming_open.out
1487 1487 }
1488 1488
1489 1489 type bringover_none > /dev/null 2>&1 || function bringover_none {
1490 1490 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1491 1491 touch $TMPDIR/bringover_failed
1492 1492 }
1493 1493
1494 1494 #
1495 1495 # Decide whether to bringover to the codemgr workspace
1496 1496 #
1497 1497 if [ "$n_FLAG" = "n" ]; then
1498 1498 PARENT_SCM_TYPE=$(parent_wstype)
1499 1499
1500 1500 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
1501 1501 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
1502 1502 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
1503 1503 exit 1
1504 1504 fi
1505 1505
1506 1506 run_hook PRE_BRINGOVER
1507 1507
1508 1508 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
1509 1509 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
1510 1510
1511 1511 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
1512 1512 tee -a $mail_msg_file >> $LOGFILE
1513 1513
1514 1514 if [ -f $TMPDIR/bringover_failed ]; then
1515 1515 rm -f $TMPDIR/bringover_failed
1516 1516 build_ok=n
1517 1517 echo "trouble with bringover, quitting at `date`." |
1518 1518 tee -a $mail_msg_file >> $LOGFILE
1519 1519 exit 1
1520 1520 fi
1521 1521
1522 1522 #
1523 1523 # It's possible that we used the bringover above to create
1524 1524 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
1525 1525 # but should now be the same as $BRINGOVER_WS.
1526 1526 #
1527 1527 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
1528 1528
1529 1529 run_hook POST_BRINGOVER
1530 1530
1531 1531 check_closed_bins
1532 1532
1533 1533 else
1534 1534 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
1535 1535 fi
1536 1536
1537 1537 # Safeguards
1538 1538 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1539 1539 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
1540 1540 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1541 1541
1542 1542 if [[ "$t_FLAG" = "y" ]]; then
1543 1543 set_non_debug_build_flags
1544 1544 bootstrap_tools || fatal_error "Error: could not bootstrap tools"
1545 1545
1546 1546 # Switch ONBLD_TOOLS early if -t is specified so that
1547 1547 # we could use bootstrapped cw for compiler checks.
1548 1548 ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld
1549 1549 export ONBLD_TOOLS
1550 1550 fi
1551 1551
1552 1552 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
1553 1553
1554 1554 # System
1555 1555 whence uname | tee -a $build_environ_file >> $LOGFILE
1556 1556 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
1557 1557 echo | tee -a $build_environ_file >> $LOGFILE
1558 1558
1559 1559 # make
1560 1560 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
1561 1561 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
1562 1562 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
1563 1563 tee -a $build_environ_file >> $LOGFILE
1564 1564
1565 1565 #
1566 1566 # Report the compiler versions.
1567 1567 #
1568 1568
1569 1569 if [[ ! -f $SRC/Makefile ]]; then
1570 1570 build_ok=n
1571 1571 echo "\nUnable to find \"Makefile\" in $SRC." | \
1572 1572 tee -a $build_environ_file >> $LOGFILE
1573 1573 exit 1
1574 1574 fi
1575 1575
1576 1576 ( cd $SRC
1577 1577 for target in cc-version java-version openssl-version; do
1578 1578 echo
1579 1579 #
1580 1580 # Put statefile somewhere we know we can write to rather than trip
1581 1581 # over a read-only $srcroot.
1582 1582 #
1583 1583 rm -f $TMPDIR/make-state
1584 1584 export SRC
1585 1585 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
1586 1586 continue
1587 1587 fi
1588 1588 touch $TMPDIR/nocompiler
1589 1589 done
1590 1590 echo
1591 1591 ) | tee -a $build_environ_file >> $LOGFILE
1592 1592
1593 1593 if [ -f $TMPDIR/nocompiler ]; then
1594 1594 rm -f $TMPDIR/nocompiler
1595 1595 build_ok=n
1596 1596 echo "Aborting due to missing compiler." |
1597 1597 tee -a $build_environ_file >> $LOGFILE
1598 1598 exit 1
1599 1599 fi
1600 1600
1601 1601 # as
1602 1602 whence as | tee -a $build_environ_file >> $LOGFILE
1603 1603 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
1604 1604 echo | tee -a $build_environ_file >> $LOGFILE
1605 1605
1606 1606 # Check that we're running a capable link-editor
1607 1607 whence ld | tee -a $build_environ_file >> $LOGFILE
1608 1608 LDVER=`ld -V 2>&1`
1609 1609 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
1610 1610 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1611 1611 if [ `expr $LDVER \< 422` -eq 1 ]; then
1612 1612 echo "The link-editor needs to be at version 422 or higher to build" | \
1613 1613 tee -a $build_environ_file >> $LOGFILE
1614 1614 echo "the latest stuff. Hope your build works." | \
1615 1615 tee -a $build_environ_file >> $LOGFILE
1616 1616 fi
1617 1617
1618 1618 #
1619 1619 # Build and use the workspace's tools if requested
1620 1620 #
1621 1621 if [[ "$t_FLAG" = "y" ]]; then
1622 1622 set_non_debug_build_flags
1623 1623
1624 1624 build_tools ${TOOLS_PROTO}
1625 1625 if (( $? != 0 )); then
1626 1626 build_ok=n
1627 1627 else
1628 1628 STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs
1629 1629 export STABS
1630 1630 CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs
1631 1631 export CTFSTABS
1632 1632 GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets
1633 1633 export GENOFFSETS
1634 1634
1635 1635 CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert
1636 1636 export CTFCONVERT
1637 1637 CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge
1638 1638 export CTFMERGE
1639 1639
1640 1640 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
1641 1641 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
1642 1642 export PATH
1643 1643
1644 1644 echo "\n==== New environment settings. ====\n" >> $LOGFILE
1645 1645 echo "STABS=${STABS}" >> $LOGFILE
1646 1646 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
1647 1647 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
1648 1648 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
1649 1649 echo "PATH=${PATH}" >> $LOGFILE
1650 1650 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
1651 1651 fi
1652 1652 fi
1653 1653
1654 1654 # timestamp the start of the normal build; the findunref tool uses it.
1655 1655 touch $SRC/.build.tstamp
1656 1656
1657 1657 normal_build
1658 1658
1659 1659 ORIG_SRC=$SRC
1660 1660 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
1661 1661
1662 1662
1663 1663 #
1664 1664 # There are several checks that need to look at the proto area, but
1665 1665 # they only need to look at one, and they don't care whether it's
1666 1666 # DEBUG or non-DEBUG.
1667 1667 #
1668 1668 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
1669 1669 checkroot=$ROOT-nd
1670 1670 else
1671 1671 checkroot=$ROOT
1672 1672 fi
1673 1673
1674 1674 if [ "$build_ok" = "y" ]; then
1675 1675 echo "\n==== Creating protolist system file at `date` ====" \
1676 1676 >> $LOGFILE
1677 1677 protolist $checkroot > $ATLOG/proto_list_${MACH}
1678 1678 echo "==== protolist system file created at `date` ====\n" \
1679 1679 >> $LOGFILE
1680 1680
1681 1681 if [ "$N_FLAG" != "y" ]; then
1682 1682
1683 1683 E1=
1684 1684 f1=
1685 1685 for f in $f1; do
1686 1686 if [ -f "$f" ]; then
1687 1687 E1="$E1 -e $f"
1688 1688 fi
1689 1689 done
1690 1690
1691 1691 E2=
1692 1692 f2=
1693 1693 if [ -d "$SRC/pkg" ]; then
1694 1694 f2="$f2 exceptions/packaging"
1695 1695 fi
1696 1696
1697 1697 for f in $f2; do
1698 1698 if [ -f "$f" ]; then
1699 1699 E2="$E2 -e $f"
1700 1700 fi
1701 1701 done
1702 1702 fi
1703 1703
1704 1704 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
1705 1705 echo "\n==== Validating manifests against proto area ====\n" \
1706 1706 >> $mail_msg_file
1707 1707 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \
1708 1708 tee $TMPDIR/protocmp_noise >> $mail_msg_file
1709 1709 if [[ -s $TMPDIR/protocmp_noise ]]; then
1710 1710 build_extras_ok=n
1711 1711 fi
1712 1712 fi
1713 1713
1714 1714 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1715 1715 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1716 1716 if [ -n "$E2" ]; then
1717 1717 ELIST=$E2
1718 1718 else
1719 1719 ELIST=$E1
1720 1720 fi
1721 1721 $PROTOCMPTERSE \
1722 1722 "Files in yesterday's proto area, but not today's:" \
1723 1723 "Files in today's proto area, but not yesterday's:" \
1724 1724 "Files that changed between yesterday and today:" \
1725 1725 ${ELIST} \
1726 1726 -d $REF_PROTO_LIST \
1727 1727 $ATLOG/proto_list_${MACH} \
1728 1728 >> $mail_msg_file
1729 1729 fi
1730 1730 fi
1731 1731
1732 1732 if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \
1733 1733 "$build_extras_ok" == "y" ]]; then
1734 1734 staffer cp $ATLOG/proto_list_${MACH} \
1735 1735 $PARENT_WS/usr/src/proto_list_${MACH}
1736 1736 fi
1737 1737
1738 1738 # Update parent proto area if necessary. This is done now
1739 1739 # so that the proto area has either DEBUG or non-DEBUG kernels.
1740 1740 # Note that this clears out the lock file, so we can dispense with
1741 1741 # the variable now.
1742 1742 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1743 1743 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1744 1744 tee -a $LOGFILE >> $mail_msg_file
1745 1745 rm -rf $NIGHTLY_PARENT_ROOT/*
1746 1746 unset Ulockfile
1747 1747 mkdir -p $NIGHTLY_PARENT_ROOT
1748 1748 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1749 1749 ( cd $ROOT; tar cf - . |
1750 1750 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 |
1751 1751 tee -a $mail_msg_file >> $LOGFILE
1752 1752 fi
1753 1753 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
1754 1754 rm -rf $NIGHTLY_PARENT_ROOT-nd/*
1755 1755 mkdir -p $NIGHTLY_PARENT_ROOT-nd
1756 1756 cd $ROOT-nd
1757 1757 ( tar cf - . |
1758 1758 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
1759 1759 tee -a $mail_msg_file >> $LOGFILE
1760 1760 fi
1761 1761 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1762 1762 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1763 1763 tee -a $LOGFILE >> $mail_msg_file
1764 1764 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1765 1765 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
1766 1766 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1767 1767 ( cd $TOOLS_PROTO; tar cf - . |
1768 1768 ( cd $NIGHTLY_PARENT_TOOLS_ROOT;
1769 1769 umask 0; tar xpf - ) ) 2>&1 |
1770 1770 tee -a $mail_msg_file >> $LOGFILE
1771 1771 fi
1772 1772 fi
1773 1773 fi
1774 1774
1775 1775 #
1776 1776 # ELF verification: ABI (-A) and runtime (-r) checks
1777 1777 #
1778 1778 if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then
1779 1779 # Directory ELF-data.$MACH holds the files produced by these tests.
1780 1780 elf_ddir=$SRC/ELF-data.$MACH
1781 1781
1782 1782 # If there is a previous ELF-data backup directory, remove it. Then,
1783 1783 # rotate current ELF-data directory into its place and create a new
1784 1784 # empty directory
1785 1785 rm -rf $elf_ddir.ref
1786 1786 if [[ -d $elf_ddir ]]; then
1787 1787 mv $elf_ddir $elf_ddir.ref
1788 1788 fi
1789 1789 mkdir -p $elf_ddir
1790 1790
1791 1791 # Call find_elf to produce a list of the ELF objects in the proto area.
1792 1792 # This list is passed to check_rtime and interface_check, preventing
1793 1793 # them from separately calling find_elf to do the same work twice.
1794 1794 find_elf -fr $checkroot > $elf_ddir/object_list
1795 1795
1796 1796 if [[ $A_FLAG = y ]]; then
1797 1797 echo "\n==== Check versioning and ABI information ====\n" | \
1798 1798 tee -a $LOGFILE >> $mail_msg_file
1799 1799
1800 1800 # Produce interface description for the proto. Report errors.
1801 1801 interface_check -o -w $elf_ddir -f object_list \
1802 1802 -i interface -E interface.err
1803 1803 if [[ -s $elf_ddir/interface.err ]]; then
1804 1804 tee -a $LOGFILE < $elf_ddir/interface.err \
1805 1805 >> $mail_msg_file
1806 1806 build_extras_ok=n
1807 1807 fi
1808 1808
1809 1809 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1810 1810 # description file to that from the baseline gate. Issue a
1811 1811 # warning if the baseline is not present, and keep going.
1812 1812 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1813 1813 base_ifile="$ELF_DATA_BASELINE_DIR/interface"
1814 1814
1815 1815 echo "\n==== Compare versioning and ABI information" \
1816 1816 "to baseline ====\n" | \
1817 1817 tee -a $LOGFILE >> $mail_msg_file
1818 1818 echo "Baseline: $base_ifile\n" >> $LOGFILE
1819 1819
1820 1820 if [[ -f $base_ifile ]]; then
1821 1821 interface_cmp -d -o $base_ifile \
1822 1822 $elf_ddir/interface > $elf_ddir/interface.cmp
1823 1823 if [[ -s $elf_ddir/interface.cmp ]]; then
1824 1824 echo | tee -a $LOGFILE >> $mail_msg_file
1825 1825 tee -a $LOGFILE < \
1826 1826 $elf_ddir/interface.cmp \
1827 1827 >> $mail_msg_file
1828 1828 build_extras_ok=n
1829 1829 fi
1830 1830 else
1831 1831 echo "baseline not available. comparison" \
1832 1832 "skipped" | \
1833 1833 tee -a $LOGFILE >> $mail_msg_file
1834 1834 fi
1835 1835
1836 1836 fi
1837 1837 fi
1838 1838
1839 1839 if [[ $r_FLAG = y ]]; then
1840 1840 echo "\n==== Check ELF runtime attributes ====\n" | \
1841 1841 tee -a $LOGFILE >> $mail_msg_file
1842 1842
1843 1843 # If we're doing a DEBUG build the proto area will be left
1844 1844 # with debuggable objects, thus don't assert -s.
1845 1845 if [[ $D_FLAG = y ]]; then
1846 1846 rtime_sflag=""
1847 1847 else
1848 1848 rtime_sflag="-s"
1849 1849 fi
1850 1850 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
1851 1851 -D object_list -f object_list -E runtime.err \
1852 1852 -I runtime.attr.raw
1853 1853 if (( $? != 0 )); then
1854 1854 build_extras_ok=n
1855 1855 fi
1856 1856
1857 1857 # check_rtime -I output needs to be sorted in order to
1858 1858 # compare it to that from previous builds.
1859 1859 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
1860 1860 rm $elf_ddir/runtime.attr.raw
1861 1861
1862 1862 # Report errors
1863 1863 if [[ -s $elf_ddir/runtime.err ]]; then
1864 1864 tee -a $LOGFILE < $elf_ddir/runtime.err \
1865 1865 >> $mail_msg_file
1866 1866 build_extras_ok=n
1867 1867 fi
1868 1868
1869 1869 # If there is an ELF-data directory from a previous build,
1870 1870 # then diff the attr files. These files contain information
1871 1871 # about dependencies, versioning, and runpaths. There is some
1872 1872 # overlap with the ABI checking done above, but this also
1873 1873 # flushes out non-ABI interface differences along with the
1874 1874 # other information.
1875 1875 echo "\n==== Diff ELF runtime attributes" \
1876 1876 "(since last build) ====\n" | \
1877 1877 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
1878 1878
1879 1879 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
1880 1880 diff $elf_ddir.ref/runtime.attr \
1881 1881 $elf_ddir/runtime.attr \
1882 1882 >> $mail_msg_file
1883 1883 fi
1884 1884 fi
1885 1885
1886 1886 # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
1887 1887 if [[ "$u_FLAG" = "y" ]]; then
1888 1888 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH
1889 1889
1890 1890 # If parent lacks the ELF-data.$MACH directory, create it
1891 1891 if [[ ! -d $p_elf_ddir ]]; then
1892 1892 staffer mkdir -p $p_elf_ddir
1893 1893 fi
1894 1894
1895 1895 # These files are used asynchronously by other builds for ABI
1896 1896 # verification, as above for the -A option. As such, we require
1897 1897 # the file replacement to be atomic. Copy the data to a temp
1898 1898 # file in the same filesystem and then rename into place.
1899 1899 (
1900 1900 cd $elf_ddir
1901 1901 for elf_dfile in *; do
1902 1902 staffer cp $elf_dfile \
1903 1903 ${p_elf_ddir}/${elf_dfile}.new
1904 1904 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
1905 1905 ${p_elf_ddir}/${elf_dfile}
1906 1906 done
1907 1907 )
1908 1908 fi
1909 1909 fi
1910 1910
1911 1911 # "make check" begins
1912 1912
1913 1913 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
1914 1914 # remove old check.out
1915 1915 rm -f $SRC/check.out
1916 1916
1917 1917 rm -f $SRC/check-${MACH}.out
1918 1918 cd $SRC
1919 1919 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
1920 1920 >> $LOGFILE
1921 1921 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
1922 1922
1923 1923 grep ":" $SRC/check-${MACH}.out |
1924 1924 egrep -v "Ignoring unknown host" | \
1925 1925 sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file
1926 1926
1927 1927 if [[ -s $TMPDIR/check_errors ]]; then
1928 1928 build_extras_ok=n
1929 1929 fi
1930 1930 else
1931 1931 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
1932 1932 fi
1933 1933
1934 1934 echo "\n==== Find core files ====\n" | \
1935 1935 tee -a $LOGFILE >> $mail_msg_file
1936 1936
1937 1937 find $abssrcdirs -name core -a -type f -exec file {} \; | \
1938 1938 tee -a $LOGFILE >> $mail_msg_file
1939 1939
1940 1940 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
1941 1941 echo "\n==== Diff unreferenced files (since last build) ====\n" \
1942 1942 | tee -a $LOGFILE >>$mail_msg_file
1943 1943 rm -f $SRC/unref-${MACH}.ref
1944 1944 if [ -f $SRC/unref-${MACH}.out ]; then
1945 1945 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
1946 1946 fi
1947 1947
1948 1948 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
1949 1949 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
1950 1950 sort > $SRC/unref-${MACH}.out
1951 1951
1952 1952 if [ ! -f $SRC/unref-${MACH}.ref ]; then
1953 1953 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
1954 1954 fi
1955 1955
1956 1956 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
1957 1957 fi
1958 1958
1959 1959 # Verify that the usual lists of files, such as exception lists,
1960 1960 # contain only valid references to files. If the build has failed,
1961 1961 # then don't check the proto area.
1962 1962 CHECK_PATHS=${CHECK_PATHS:-y}
1963 1963 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
1964 1964 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
1965 1965 >>$mail_msg_file
1966 1966 arg=-b
1967 1967 [ "$build_ok" = y ] && arg=
1968 1968 checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1
1969 1969 if [[ -s $SRC/check-paths.out ]]; then
1970 1970 tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file
1971 1971 build_extras_ok=n
1972 1972 fi
1973 1973 fi
1974 1974
1975 1975 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
1976 1976 echo "\n==== Impact on file permissions ====\n" \
1977 1977 >> $mail_msg_file
1978 1978
1979 1979 abspkg=
1980 1980 for d in $abssrcdirs; do
1981 1981 if [ -d "$d/pkg" ]; then
1982 1982 abspkg="$abspkg $d"
1983 1983 fi
1984 1984 done
1985 1985
1986 1986 if [ -n "$abspkg" ]; then
1987 1987 for d in "$abspkg"; do
1988 1988 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
1989 1989 done
1990 1990 fi
1991 1991 fi
1992 1992
1993 1993 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
1994 1994 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1995 1995 do_wsdiff DEBUG $ROOT.prev $ROOT
1996 1996 fi
1997 1997
1998 1998 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
1999 1999 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2000 2000 fi
2001 2001 fi
2002 2002
2003 2003 END_DATE=`date`
2004 2004 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2005 2005 tee -a $LOGFILE >> $build_time_file
2006 2006
2007 2007 typeset -i10 hours
2008 2008 typeset -Z2 minutes
2009 2009 typeset -Z2 seconds
2010 2010
2011 2011 elapsed_time=$SECONDS
2012 2012 ((hours = elapsed_time / 3600 ))
2013 2013 ((minutes = elapsed_time / 60 % 60))
2014 2014 ((seconds = elapsed_time % 60))
2015 2015
2016 2016 echo "\n==== Total build time ====" | \
2017 2017 tee -a $LOGFILE >> $build_time_file
2018 2018 echo "\nreal ${hours}:${minutes}:${seconds}" | \
2019 2019 tee -a $LOGFILE >> $build_time_file
2020 2020
2021 2021 if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2022 2022 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
2023 2023
2024 2024 #
2025 2025 # Produce a master list of unreferenced files -- ideally, we'd
2026 2026 # generate the master just once after all of the nightlies
2027 2027 # have finished, but there's no simple way to know when that
2028 2028 # will be. Instead, we assume that we're the last nightly to
2029 2029 # finish and merge all of the unref-${MACH}.out files in
2030 2030 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
2031 2031 # finish, then this file will be the authoritative master
2032 2032 # list. Otherwise, another ${MACH}'s nightly will eventually
2033 2033 # overwrite ours with its own master, but in the meantime our
2034 2034 # temporary "master" will be no worse than any older master
2035 2035 # which was already on the parent.
2036 2036 #
2037 2037
2038 2038 set -- $PARENT_WS/usr/src/unref-*.out
2039 2039 cp "$1" ${TMPDIR}/unref.merge
2040 2040 shift
2041 2041
2042 2042 for unreffile; do
2043 2043 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2044 2044 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2045 2045 done
2046 2046
2047 2047 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2048 2048 fi
2049 2049
2050 2050 #
2051 2051 # All done save for the sweeping up.
2052 2052 # (whichever exit we hit here will trigger the "cleanup" trap which
2053 2053 # optionally sends mail on completion).
2054 2054 #
2055 2055 if [[ "$build_ok" == "y" ]]; then
2056 2056 if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then
2057 2057 exit 0
2058 2058 fi
2059 2059 fi
2060 2060
2061 2061 exit 1
↓ open down ↓ |
1857 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX