Print this page
11224 nightly and bldenv should be usable directly
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/nightly.sh
+++ 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]
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
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 -# Copyright 2019 Joyent, Inc.
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 #
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 194 egrep -e "(^${MAKE}:|[ ]error[: \n])" | \
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
↓ open down ↓ |
619 lines elided |
↑ open up ↑ |
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 -# contents of stdenv.sh inserted after next line:
670 -# STDENV_START
671 -# STDENV_END
672 -
673 669 # Check if we have sufficient data to continue...
674 670 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
675 671 if [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
676 672 # Check if the gate data are valid if we don't do a "bringover" below
677 673 [[ -d "${CODEMGR_WS}" ]] || \
678 674 fatal_error "Error: ${CODEMGR_WS} is not a directory."
679 675 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
680 676 fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
681 677 fi
682 678
683 679 #
684 680 # place ourselves in a new task, respecting BUILD_PROJECT if set.
685 681 #
686 682 if [ -z "$BUILD_PROJECT" ]; then
687 683 /usr/bin/newtask -c $$
688 684 else
689 685 /usr/bin/newtask -c $$ -p $BUILD_PROJECT
690 686 fi
691 687
692 688 ps -o taskid= -p $$ | read build_taskid
693 689 ps -o project= -p $$ | read build_project
694 690
695 691 #
696 692 # See if NIGHTLY_OPTIONS is set
697 693 #
698 694 if [ "$NIGHTLY_OPTIONS" = "" ]; then
699 695 NIGHTLY_OPTIONS="-aBm"
700 696 fi
701 697
702 698 #
703 699 # If BRINGOVER_WS was not specified, let it default to CLONE_WS
704 700 #
705 701 if [ "$BRINGOVER_WS" = "" ]; then
706 702 BRINGOVER_WS=$CLONE_WS
707 703 fi
708 704
709 705 #
710 706 # If BRINGOVER_FILES was not specified, default to usr
711 707 #
712 708 if [ "$BRINGOVER_FILES" = "" ]; then
713 709 BRINGOVER_FILES="usr"
714 710 fi
715 711
716 712 check_closed_bins
717 713
718 714 #
719 715 # Note: changes to the option letters here should also be applied to the
720 716 # bldenv script. `d' is listed for backward compatibility.
721 717 #
722 718 NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
723 719 OPTIND=1
724 720 while getopts +ABCDdFfGIiMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS
725 721 do
726 722 case $FLAG in
727 723 A ) A_FLAG=y
728 724 ;;
729 725 B ) D_FLAG=y
730 726 ;; # old version of D
731 727 C ) C_FLAG=y
732 728 ;;
733 729 D ) D_FLAG=y
734 730 ;;
735 731 F ) F_FLAG=y
736 732 ;;
737 733 f ) f_FLAG=y
738 734 ;;
739 735 G ) u_FLAG=y
740 736 ;;
741 737 I ) m_FLAG=y
742 738 p_FLAG=y
743 739 u_FLAG=y
744 740 ;;
745 741 i ) i_FLAG=y
746 742 ;;
747 743 M ) M_FLAG=y
748 744 ;;
749 745 m ) m_FLAG=y
750 746 ;;
751 747 N ) N_FLAG=y
752 748 ;;
753 749 n ) n_FLAG=y
754 750 ;;
755 751 p ) p_FLAG=y
756 752 ;;
757 753 R ) m_FLAG=y
758 754 p_FLAG=y
759 755 ;;
760 756 r ) r_FLAG=y
761 757 ;;
762 758 +t ) t_FLAG=n
763 759 ;;
764 760 U ) if [ -z "${PARENT_ROOT}" ]; then
765 761 echo "PARENT_ROOT must be set if the U flag is" \
766 762 "present in NIGHTLY_OPTIONS."
767 763 exit 1
768 764 fi
769 765 NIGHTLY_PARENT_ROOT=$PARENT_ROOT
770 766 if [ -n "${PARENT_TOOLS_ROOT}" ]; then
771 767 NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
772 768 fi
773 769 U_FLAG=y
774 770 ;;
775 771 u ) u_FLAG=y
776 772 ;;
777 773 w ) w_FLAG=y
778 774 ;;
779 775 W ) W_FLAG=y
780 776 ;;
781 777 \? ) echo "$USAGE"
782 778 exit 1
783 779 ;;
784 780 esac
785 781 done
786 782
787 783 if [ $ISUSER -ne 0 ]; then
788 784 # Set default value for STAFFER, if needed.
789 785 if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
790 786 STAFFER=`/usr/xpg4/bin/id -un`
791 787 export STAFFER
792 788 fi
793 789 fi
794 790
795 791 if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
796 792 MAILTO=$STAFFER
797 793 export MAILTO
798 794 fi
799 795
800 796 PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
801 797 PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb"
802 798 PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
803 799 export PATH
804 800
805 801 # roots of source trees, both relative to $SRC and absolute.
806 802 relsrcdirs="."
807 803 abssrcdirs="$SRC"
808 804
809 805 PROTOCMPTERSE="protocmp.terse -gu"
810 806 POUND_SIGN="#"
811 807 # have we set RELEASE_DATE in our env file?
812 808 if [ -z "$RELEASE_DATE" ]; then
813 809 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
814 810 fi
815 811 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
816 812 BASEWSDIR=$(basename $CODEMGR_WS)
817 813 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
818 814
819 815 # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
820 816 # by avoiding repeated shell invocations to evaluate Makefile.master
821 817 # definitions.
822 818 export POUND_SIGN RELEASE_DATE DEV_CM
823 819
824 820 maketype="distributed"
825 821 if [[ -z "$MAKE" ]]; then
826 822 MAKE=dmake
827 823 elif [[ ! -x "$MAKE" ]]; then
828 824 echo "\$MAKE is set to garbage in the environment"
829 825 exit 1
830 826 fi
831 827 export PATH
832 828 export MAKE
833 829
834 830 if [ "${SUNWSPRO}" != "" ]; then
835 831 PATH="${SUNWSPRO}/bin:$PATH"
836 832 export PATH
837 833 fi
838 834
839 835 hostname=$(uname -n)
840 836 if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
841 837 then
842 838 maxjobs=
843 839 if [[ -f $HOME/.make.machines ]]
844 840 then
845 841 # Note: there is a hard tab and space character in the []s
846 842 # below.
847 843 egrep -i "^[ ]*$hostname[ \.]" \
848 844 $HOME/.make.machines | read host jobs
849 845 maxjobs=${jobs##*=}
850 846 fi
851 847
852 848 if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
853 849 then
854 850 # default
855 851 maxjobs=4
856 852 fi
857 853
858 854 export DMAKE_MAX_JOBS=$maxjobs
859 855 fi
860 856
861 857 DMAKE_MODE=parallel;
862 858 export DMAKE_MODE
863 859
864 860 if [ -z "${ROOT}" ]; then
865 861 echo "ROOT must be set."
866 862 exit 1
867 863 fi
868 864
869 865 #
870 866 # if -V flag was given, reset VERSION to V_ARG
871 867 #
872 868 if [ "$V_FLAG" = "y" ]; then
873 869 VERSION=$V_ARG
874 870 fi
875 871
876 872 TMPDIR="/tmp/nightly.tmpdir.$$"
877 873 export TMPDIR
878 874 rm -rf ${TMPDIR}
879 875 mkdir -p $TMPDIR || exit 1
880 876 chmod 777 $TMPDIR
881 877
882 878 #
883 879 # Work around folks who have historically used GCC_ROOT and convert it to
884 880 # GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could
885 881 # mess up the case where multiple different gcc versions are being used to
886 882 # shadow).
887 883 #
888 884 if [[ -n "${GCC_ROOT}" ]]; then
889 885 export GNUC_ROOT=${GCC_ROOT}
890 886 fi
891 887
892 888 #
893 889 # Tools should only be built non-DEBUG. Keep track of the tools proto
894 890 # area path relative to $TOOLS, because the latter changes in an
895 891 # export build.
896 892 #
897 893 # TOOLS_PROTO is included below for builds other than usr/src/tools
898 894 # that look for this location. For usr/src/tools, this will be
899 895 # overridden on the $MAKE command line in build_tools().
900 896 #
901 897 TOOLS=${SRC}/tools
902 898 TOOLS_PROTO_REL=proto/root_${MACH}-nd
903 899 TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL}; export TOOLS_PROTO
904 900
905 901 unset CFLAGS LD_LIBRARY_PATH LDFLAGS
906 902
907 903 # create directories that are automatically removed if the nightly script
908 904 # fails to start correctly
909 905 function newdir {
910 906 dir=$1
911 907 toadd=
912 908 while [ ! -d $dir ]; do
913 909 toadd="$dir $toadd"
914 910 dir=`dirname $dir`
915 911 done
916 912 torm=
917 913 newlist=
918 914 for dir in $toadd; do
919 915 if staffer mkdir $dir; then
920 916 newlist="$ISUSER $dir $newlist"
921 917 torm="$dir $torm"
922 918 else
923 919 [ -z "$torm" ] || staffer rmdir $torm
924 920 return 1
925 921 fi
926 922 done
927 923 newdirlist="$newlist $newdirlist"
928 924 return 0
929 925 }
930 926 newdirlist=
931 927
932 928 [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
933 929
934 930 # since this script assumes the build is from full source, it nullifies
935 931 # variables likely to have been set by a "ws" script; nullification
936 932 # confines the search space for headers and libraries to the proto area
937 933 # built from this immediate source.
938 934 ENVLDLIBS1=
939 935 ENVLDLIBS2=
940 936 ENVLDLIBS3=
941 937 ENVCPPFLAGS1=
942 938 ENVCPPFLAGS2=
943 939 ENVCPPFLAGS3=
944 940 ENVCPPFLAGS4=
945 941 PARENT_ROOT=
946 942
947 943 export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
948 944 ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
949 945
950 946 PKGARCHIVE_ORIG=$PKGARCHIVE
951 947
952 948 #
953 949 # Juggle the logs and optionally send mail on completion.
954 950 #
955 951
956 952 function logshuffle {
957 953 LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
958 954 if [ -f $LLOG -o -d $LLOG ]; then
959 955 LLOG=$LLOG.$$
960 956 fi
961 957
962 958 rm -f "$ATLOG/latest" 2>/dev/null
963 959 mkdir -p $LLOG
964 960 export LLOG
965 961
966 962 if [ "$build_ok" = "y" ]; then
967 963 mv $ATLOG/proto_list_${MACH} $LLOG
968 964
969 965 if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
970 966 mv $ATLOG/proto_list_tools_${MACH} $LLOG
971 967 fi
972 968
973 969 if [ -f $TMPDIR/wsdiff.results ]; then
974 970 mv $TMPDIR/wsdiff.results $LLOG
975 971 fi
976 972
977 973 if [ -f $TMPDIR/wsdiff-nd.results ]; then
978 974 mv $TMPDIR/wsdiff-nd.results $LLOG
979 975 fi
980 976 fi
981 977
982 978 #
983 979 # Now that we're about to send mail, it's time to check the noise
984 980 # file. In the event that an error occurs beyond this point, it will
985 981 # be recorded in the nightly.log file, but nowhere else. This would
986 982 # include only errors that cause the copying of the noise log to fail
987 983 # or the mail itself not to be sent.
988 984 #
989 985
990 986 exec >>$LOGFILE 2>&1
991 987 if [ -s $build_noise_file ]; then
992 988 echo "\n==== Nightly build noise ====\n" |
993 989 tee -a $LOGFILE >>$mail_msg_file
994 990 cat $build_noise_file >>$LOGFILE
995 991 cat $build_noise_file >>$mail_msg_file
996 992 echo | tee -a $LOGFILE >>$mail_msg_file
997 993 fi
998 994 rm -f $build_noise_file
999 995
1000 996 case "$build_ok" in
1001 997 y)
1002 998 state=Completed
1003 999 ;;
1004 1000 i)
1005 1001 state=Interrupted
1006 1002 ;;
1007 1003 *)
1008 1004 state=Failed
1009 1005 ;;
1010 1006 esac
1011 1007
1012 1008 if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
1013 1009 state=Failed
1014 1010 fi
1015 1011
1016 1012 NIGHTLY_STATUS=$state
1017 1013 export NIGHTLY_STATUS
1018 1014
1019 1015 run_hook POST_NIGHTLY $state
1020 1016 run_hook SYS_POST_NIGHTLY $state
1021 1017
1022 1018 #
1023 1019 # mailx(1) sets From: based on the -r flag
1024 1020 # if it is given.
1025 1021 #
1026 1022 mailx_r=
1027 1023 if [[ -n "${MAILFROM}" ]]; then
1028 1024 mailx_r="-r ${MAILFROM}"
1029 1025 fi
1030 1026
1031 1027 cat $build_time_file $build_environ_file $mail_msg_file \
1032 1028 > ${LLOG}/mail_msg
1033 1029 if [ "$m_FLAG" = "y" ]; then
1034 1030 cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1035 1031 "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1036 1032 ${MAILTO}
1037 1033 fi
1038 1034
1039 1035 if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1040 1036 staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH}
1041 1037 staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log
1042 1038 fi
1043 1039
1044 1040 mv $LOGFILE $LLOG
1045 1041
1046 1042 ln -s "$LLOG" "$ATLOG/latest"
1047 1043 }
1048 1044
1049 1045 #
1050 1046 # Remove the locks and temporary files on any exit
1051 1047 #
1052 1048 function cleanup {
1053 1049 logshuffle
1054 1050
1055 1051 [ -z "$lockfile" ] || staffer rm -f $lockfile
1056 1052 [ -z "$atloglockfile" ] || rm -f $atloglockfile
1057 1053 [ -z "$ulockfile" ] || staffer rm -f $ulockfile
1058 1054 [ -z "$Ulockfile" ] || rm -f $Ulockfile
1059 1055
1060 1056 set -- $newdirlist
1061 1057 while [ $# -gt 0 ]; do
1062 1058 ISUSER=$1 staffer rmdir $2
1063 1059 shift; shift
1064 1060 done
1065 1061 rm -rf $TMPDIR
1066 1062 }
1067 1063
1068 1064 function cleanup_signal {
1069 1065 build_ok=i
1070 1066 # this will trigger cleanup(), above.
1071 1067 exit 1
1072 1068 }
1073 1069
1074 1070 trap cleanup 0
1075 1071 trap cleanup_signal 1 2 3 15
1076 1072
1077 1073 #
1078 1074 # Generic lock file processing -- make sure that the lock file doesn't
1079 1075 # exist. If it does, it should name the build host and PID. If it
1080 1076 # doesn't, then make sure we can create it. Clean up locks that are
1081 1077 # known to be stale (assumes host name is unique among build systems
1082 1078 # for the workspace).
1083 1079 #
1084 1080 function create_lock {
1085 1081 lockf=$1
1086 1082 lockvar=$2
1087 1083
1088 1084 ldir=`dirname $lockf`
1089 1085 [ -d $ldir ] || newdir $ldir || exit 1
1090 1086 eval $lockvar=$lockf
1091 1087
1092 1088 while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1093 1089 basews=`basename $CODEMGR_WS`
1094 1090 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1095 1091 if [ "$host" != "$hostname" ]; then
1096 1092 echo "$MACH build of $basews apparently" \
1097 1093 "already started by $user on $host as $pid."
1098 1094 exit 1
1099 1095 elif kill -s 0 $pid 2>/dev/null; then
1100 1096 echo "$MACH build of $basews already started" \
1101 1097 "by $user as $pid."
1102 1098 exit 1
1103 1099 else
1104 1100 # stale lock; clear it out and try again
1105 1101 rm -f $lockf
1106 1102 fi
1107 1103 done
1108 1104 }
1109 1105
1110 1106 #
1111 1107 # Return the list of interesting proto areas, depending on the current
1112 1108 # options.
1113 1109 #
1114 1110 function allprotos {
1115 1111 typeset roots="$ROOT"
1116 1112
1117 1113 if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1118 1114 roots="$roots $ROOT-nd"
1119 1115 fi
1120 1116
1121 1117 echo $roots
1122 1118 }
1123 1119
1124 1120 # Ensure no other instance of this script is running on this host.
1125 1121 # LOCKNAME can be set in <env_file>, and is by default, but is not
1126 1122 # required due to the use of $ATLOG below.
1127 1123 if [ -n "$LOCKNAME" ]; then
1128 1124 create_lock /tmp/$LOCKNAME "lockfile"
1129 1125 fi
1130 1126 #
1131 1127 # Create from one, two, or three other locks:
1132 1128 # $ATLOG/nightly.lock
1133 1129 # - protects against multiple builds in same workspace
1134 1130 # $PARENT_WS/usr/src/nightly.$MACH.lock
1135 1131 # - protects against multiple 'u' copy-backs
1136 1132 # $NIGHTLY_PARENT_ROOT/nightly.lock
1137 1133 # - protects against multiple 'U' copy-backs
1138 1134 #
1139 1135 # Overriding ISUSER to 1 causes the lock to be created as root if the
1140 1136 # script is run as root. The default is to create it as $STAFFER.
1141 1137 ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile"
1142 1138 if [ "$u_FLAG" = "y" ]; then
1143 1139 create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile"
1144 1140 fi
1145 1141 if [ "$U_FLAG" = "y" ]; then
1146 1142 # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1147 1143 ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile"
1148 1144 fi
1149 1145
1150 1146 # Locks have been taken, so we're doing a build and we're committed to
1151 1147 # the directories we may have created so far.
1152 1148 newdirlist=
1153 1149
1154 1150 #
1155 1151 # Create mail_msg_file
1156 1152 #
1157 1153 mail_msg_file="${TMPDIR}/mail_msg"
1158 1154 touch $mail_msg_file
1159 1155 build_time_file="${TMPDIR}/build_time"
1160 1156 build_environ_file="${TMPDIR}/build_environ"
1161 1157 touch $build_environ_file
1162 1158 #
1163 1159 # Move old LOGFILE aside
1164 1160 # ATLOG directory already made by 'create_lock' above
1165 1161 #
1166 1162 if [ -f $LOGFILE ]; then
1167 1163 mv -f $LOGFILE ${LOGFILE}-
1168 1164 fi
1169 1165 #
1170 1166 # Build OsNet source
1171 1167 #
1172 1168 START_DATE=`date`
1173 1169 SECONDS=0
1174 1170 echo "\n==== Nightly $maketype build started: $START_DATE ====" \
1175 1171 | tee -a $LOGFILE > $build_time_file
1176 1172
1177 1173 echo "\nBuild project: $build_project\nBuild taskid: $build_taskid" | \
1178 1174 tee -a $mail_msg_file >> $LOGFILE
1179 1175
1180 1176 # make sure we log only to the nightly build file
1181 1177 build_noise_file="${TMPDIR}/build_noise"
1182 1178 exec </dev/null >$build_noise_file 2>&1
1183 1179
1184 1180 run_hook SYS_PRE_NIGHTLY
1185 1181 run_hook PRE_NIGHTLY
1186 1182
1187 1183 echo "\n==== list of environment variables ====\n" >> $LOGFILE
1188 1184 env >> $LOGFILE
1189 1185
1190 1186 echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1191 1187
1192 1188 if [ "$N_FLAG" = "y" ]; then
1193 1189 if [ "$p_FLAG" = "y" ]; then
1194 1190 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1195 1191 WARNING: the p option (create packages) is set, but so is the N option (do
1196 1192 not run protocmp); this is dangerous; you should unset the N option
1197 1193 EOF
1198 1194 else
1199 1195 cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1200 1196 Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1201 1197 EOF
1202 1198 fi
1203 1199 echo "" | tee -a $mail_msg_file >> $LOGFILE
1204 1200 fi
1205 1201
1206 1202 if [ "$f_FLAG" = "y" ]; then
1207 1203 if [ "$i_FLAG" = "y" ]; then
1208 1204 echo "WARNING: the -f flag cannot be used during incremental" \
1209 1205 "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1210 1206 f_FLAG=n
1211 1207 fi
1212 1208 if [ "${p_FLAG}" != "y" ]; then
1213 1209 echo "WARNING: the -f flag requires -p;" \
1214 1210 "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1215 1211 f_FLAG=n
1216 1212 fi
1217 1213 fi
1218 1214
1219 1215 if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1220 1216 echo "WARNING: -w specified, but $ROOT does not exist;" \
1221 1217 "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE
1222 1218 w_FLAG=n
1223 1219 fi
1224 1220
1225 1221 case $MULTI_PROTO in
1226 1222 yes|no) ;;
1227 1223 *)
1228 1224 echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1229 1225 "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1230 1226 echo "Setting MULTI_PROTO to \"no\".\n" | \
1231 1227 tee -a $mail_msg_file >> $LOGFILE
1232 1228 export MULTI_PROTO=no
1233 1229 ;;
1234 1230 esac
1235 1231
1236 1232 echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1237 1233 echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1238 1234
1239 1235 # Save the current proto area if we're comparing against the last build
1240 1236 if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1241 1237 if [ -d "$ROOT.prev" ]; then
1242 1238 rm -rf $ROOT.prev
1243 1239 fi
1244 1240 mv $ROOT $ROOT.prev
1245 1241 fi
1246 1242
1247 1243 # Same for non-DEBUG proto area
1248 1244 if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1249 1245 if [ -d "$ROOT-nd.prev" ]; then
1250 1246 rm -rf $ROOT-nd.prev
1251 1247 fi
1252 1248 mv $ROOT-nd $ROOT-nd.prev
1253 1249 fi
1254 1250
1255 1251 #
1256 1252 # Echo the SCM type of the parent workspace, this can't just be which_scm
1257 1253 # as that does not know how to identify various network repositories.
1258 1254 #
1259 1255 function parent_wstype {
1260 1256 typeset scm_type junk
1261 1257
1262 1258 CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1263 1259 | read scm_type junk
1264 1260 if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1265 1261 # Probe BRINGOVER_WS to determine its type
1266 1262 if [[ $BRINGOVER_WS == ssh://* ]]; then
1267 1263 scm_type="mercurial"
1268 1264 elif [[ $BRINGOVER_WS == http://* ]] && \
1269 1265 wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1270 1266 egrep -s "application/mercurial" 2> /dev/null; then
1271 1267 scm_type="mercurial"
1272 1268 else
1273 1269 scm_type="none"
1274 1270 fi
1275 1271 fi
1276 1272
1277 1273 # fold both unsupported and unrecognized results into "none"
1278 1274 case "$scm_type" in
1279 1275 mercurial)
1280 1276 ;;
1281 1277 *) scm_type=none
1282 1278 ;;
1283 1279 esac
1284 1280
1285 1281 echo $scm_type
1286 1282 }
1287 1283
1288 1284 # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1289 1285 function child_wstype {
1290 1286 typeset scm_type junk
1291 1287
1292 1288 # Probe CODEMGR_WS to determine its type
1293 1289 if [[ -d $CODEMGR_WS ]]; then
1294 1290 $WHICH_SCM | read scm_type junk || exit 1
1295 1291 fi
1296 1292
1297 1293 case "$scm_type" in
1298 1294 none|git|mercurial)
1299 1295 ;;
1300 1296 *) scm_type=none
1301 1297 ;;
1302 1298 esac
1303 1299
1304 1300 echo $scm_type
1305 1301 }
1306 1302
1307 1303 SCM_TYPE=$(child_wstype)
1308 1304
1309 1305 #
1310 1306 # Decide whether to clobber
1311 1307 #
1312 1308 if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1313 1309 echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1314 1310
1315 1311 cd $SRC
1316 1312 # remove old clobber file
1317 1313 rm -f $SRC/clobber.out
1318 1314 rm -f $SRC/clobber-${MACH}.out
1319 1315
1320 1316 # Remove all .make.state* files, just in case we are restarting
1321 1317 # the build after having interrupted a previous 'make clobber'.
1322 1318 find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1323 1319 -o -name 'interfaces.*' \) -prune \
1324 1320 -o -name '.make.*' -print | xargs rm -f
1325 1321
1326 1322 $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1327 1323 echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1328 1324 grep "$MAKE:" $SRC/clobber-${MACH}.out |
1329 1325 egrep -v "Ignoring unknown host" | \
1330 1326 tee $TMPDIR/clobber_errs >> $mail_msg_file
1331 1327
1332 1328 if [[ -s $TMPDIR/clobber_errs ]]; then
1333 1329 build_extras_ok=n
1334 1330 fi
1335 1331
1336 1332 if [[ "$t_FLAG" = "y" ]]; then
1337 1333 echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1338 1334 cd ${TOOLS}
1339 1335 rm -f ${TOOLS}/clobber-${MACH}.out
1340 1336 $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1341 1337 tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1342 1338 echo "\n==== Make tools clobber ERRORS ====\n" \
1343 1339 >> $mail_msg_file
1344 1340 grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1345 1341 >> $mail_msg_file
1346 1342 if (( $? == 0 )); then
1347 1343 build_extras_ok=n
1348 1344 fi
1349 1345 rm -rf ${TOOLS_PROTO}
1350 1346 mkdir -p ${TOOLS_PROTO}
1351 1347 fi
1352 1348
1353 1349 typeset roots=$(allprotos)
1354 1350 echo "\n\nClearing $roots" >> "$LOGFILE"
1355 1351 rm -rf $roots
1356 1352
1357 1353 # Get back to a clean workspace as much as possible to catch
1358 1354 # problems that only occur on fresh workspaces.
1359 1355 # Remove all .make.state* files, libraries, and .o's that may
1360 1356 # have been omitted from clobber. A couple of libraries are
1361 1357 # under source code control, so leave them alone.
1362 1358 # We should probably blow away temporary directories too.
1363 1359 cd $SRC
1364 1360 find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1365 1361 -o -name .git -o -name 'interfaces.*' \) -prune -o \
1366 1362 \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1367 1363 -name '*.o' \) -print | \
1368 1364 grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
1369 1365 else
1370 1366 echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1371 1367 fi
1372 1368
1373 1369 type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
1374 1370 typeset -x PATH=$PATH
1375 1371
1376 1372 # If the repository doesn't exist yet, then we want to populate it.
1377 1373 if [[ ! -d $CODEMGR_WS/.hg ]]; then
1378 1374 staffer hg init $CODEMGR_WS
1379 1375 staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
1380 1376 staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
1381 1377 touch $TMPDIR/new_repository
1382 1378 fi
1383 1379
1384 1380 typeset -x HGMERGE="/bin/false"
1385 1381
1386 1382 #
1387 1383 # If the user has changes, regardless of whether those changes are
1388 1384 # committed, and regardless of whether those changes conflict, then
1389 1385 # we'll attempt to merge them either implicitly (uncommitted) or
1390 1386 # explicitly (committed).
1391 1387 #
1392 1388 # These are the messages we'll use to help clarify mercurial output
1393 1389 # in those cases.
1394 1390 #
1395 1391 typeset mergefailmsg="\
1396 1392 ***\n\
1397 1393 *** nightly was unable to automatically merge your changes. You should\n\
1398 1394 *** redo the full merge manually, following the steps outlined by mercurial\n\
1399 1395 *** above, then restart nightly.\n\
1400 1396 ***\n"
1401 1397 typeset mergepassmsg="\
1402 1398 ***\n\
1403 1399 *** nightly successfully merged your changes. This means that your working\n\
1404 1400 *** directory has been updated, but those changes are not yet committed.\n\
1405 1401 *** After nightly completes, you should validate the results of the merge,\n\
1406 1402 *** then use hg commit manually.\n\
1407 1403 ***\n"
1408 1404
1409 1405 #
1410 1406 # For each repository in turn:
1411 1407 #
1412 1408 # 1. Do the pull. If this fails, dump the output and bail out.
1413 1409 #
1414 1410 # 2. If the pull resulted in an extra head, do an explicit merge.
1415 1411 # If this fails, dump the output and bail out.
1416 1412 #
1417 1413 # Because we can't rely on Mercurial to exit with a failure code
1418 1414 # when a merge fails (Mercurial issue #186), we must grep the
1419 1415 # output of pull/merge to check for attempted and/or failed merges.
1420 1416 #
1421 1417 # 3. If a merge failed, set the message and fail the bringover.
1422 1418 #
1423 1419 # 4. Otherwise, if a merge succeeded, set the message
1424 1420 #
1425 1421 # 5. Dump the output, and any message from step 3 or 4.
1426 1422 #
1427 1423
1428 1424 typeset HG_SOURCE=$BRINGOVER_WS
1429 1425 if [ ! -f $TMPDIR/new_repository ]; then
1430 1426 HG_SOURCE=$TMPDIR/open_bundle.hg
1431 1427 staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
1432 1428 -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
1433 1429
1434 1430 #
1435 1431 # If there are no incoming changesets, then incoming will
1436 1432 # fail, and there will be no bundle file. Reset the source,
1437 1433 # to allow the remaining logic to complete with no false
1438 1434 # negatives. (Unlike incoming, pull will return success
1439 1435 # for the no-change case.)
1440 1436 #
1441 1437 if (( $? != 0 )); then
1442 1438 HG_SOURCE=$BRINGOVER_WS
1443 1439 fi
1444 1440 fi
1445 1441
1446 1442 staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
1447 1443 > $TMPDIR/pull_open.out 2>&1
1448 1444 if (( $? != 0 )); then
1449 1445 printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
1450 1446 cat $TMPDIR/pull_open.out
1451 1447 if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1452 1448 printf "$mergefailmsg"
1453 1449 fi
1454 1450 touch $TMPDIR/bringover_failed
1455 1451 return
1456 1452 fi
1457 1453
1458 1454 if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1459 1455 staffer hg --cwd $CODEMGR_WS merge \
1460 1456 >> $TMPDIR/pull_open.out 2>&1
1461 1457 if (( $? != 0 )); then
1462 1458 printf "%s: merge failed as follows:\n\n" \
1463 1459 "$CODEMGR_WS"
1464 1460 cat $TMPDIR/pull_open.out
1465 1461 if grep "^merging.*failed" $TMPDIR/pull_open.out \
1466 1462 > /dev/null 2>&1; then
1467 1463 printf "$mergefailmsg"
1468 1464 fi
1469 1465 touch $TMPDIR/bringover_failed
1470 1466 return
1471 1467 fi
1472 1468 fi
1473 1469
1474 1470 printf "updated %s with the following results:\n" "$CODEMGR_WS"
1475 1471 cat $TMPDIR/pull_open.out
1476 1472 if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
1477 1473 printf "$mergepassmsg"
1478 1474 fi
1479 1475 printf "\n"
1480 1476
1481 1477 #
1482 1478 # Per-changeset output is neither useful nor manageable for a
1483 1479 # newly-created repository.
1484 1480 #
1485 1481 if [ -f $TMPDIR/new_repository ]; then
1486 1482 return
1487 1483 fi
1488 1484
1489 1485 printf "\nadded the following changesets to open repository:\n"
1490 1486 cat $TMPDIR/incoming_open.out
1491 1487 }
1492 1488
1493 1489 type bringover_none > /dev/null 2>&1 || function bringover_none {
1494 1490 echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1495 1491 touch $TMPDIR/bringover_failed
1496 1492 }
1497 1493
1498 1494 #
1499 1495 # Decide whether to bringover to the codemgr workspace
1500 1496 #
1501 1497 if [ "$n_FLAG" = "n" ]; then
1502 1498 PARENT_SCM_TYPE=$(parent_wstype)
1503 1499
1504 1500 if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
1505 1501 echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
1506 1502 "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
1507 1503 exit 1
1508 1504 fi
1509 1505
1510 1506 run_hook PRE_BRINGOVER
1511 1507
1512 1508 echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
1513 1509 echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
1514 1510
1515 1511 eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
1516 1512 tee -a $mail_msg_file >> $LOGFILE
1517 1513
1518 1514 if [ -f $TMPDIR/bringover_failed ]; then
1519 1515 rm -f $TMPDIR/bringover_failed
1520 1516 build_ok=n
1521 1517 echo "trouble with bringover, quitting at `date`." |
1522 1518 tee -a $mail_msg_file >> $LOGFILE
1523 1519 exit 1
1524 1520 fi
1525 1521
1526 1522 #
1527 1523 # It's possible that we used the bringover above to create
1528 1524 # $CODEMGR_WS. If so, then SCM_TYPE was previously "none,"
1529 1525 # but should now be the same as $BRINGOVER_WS.
1530 1526 #
1531 1527 [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
1532 1528
1533 1529 run_hook POST_BRINGOVER
1534 1530
1535 1531 check_closed_bins
1536 1532
1537 1533 else
1538 1534 echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
1539 1535 fi
1540 1536
1541 1537 # Safeguards
1542 1538 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1543 1539 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
1544 1540 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1545 1541
1546 1542 if [[ "$t_FLAG" = "y" ]]; then
1547 1543 set_non_debug_build_flags
1548 1544 bootstrap_tools || fatal_error "Error: could not bootstrap tools"
1549 1545
1550 1546 # Switch ONBLD_TOOLS early if -t is specified so that
1551 1547 # we could use bootstrapped cw for compiler checks.
1552 1548 ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld
1553 1549 export ONBLD_TOOLS
1554 1550 fi
1555 1551
1556 1552 echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
1557 1553
1558 1554 # System
1559 1555 whence uname | tee -a $build_environ_file >> $LOGFILE
1560 1556 uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
1561 1557 echo | tee -a $build_environ_file >> $LOGFILE
1562 1558
1563 1559 # make
1564 1560 whence $MAKE | tee -a $build_environ_file >> $LOGFILE
1565 1561 $MAKE -v | tee -a $build_environ_file >> $LOGFILE
1566 1562 echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
1567 1563 tee -a $build_environ_file >> $LOGFILE
1568 1564
1569 1565 #
1570 1566 # Report the compiler versions.
1571 1567 #
1572 1568
1573 1569 if [[ ! -f $SRC/Makefile ]]; then
1574 1570 build_ok=n
1575 1571 echo "\nUnable to find \"Makefile\" in $SRC." | \
1576 1572 tee -a $build_environ_file >> $LOGFILE
1577 1573 exit 1
1578 1574 fi
1579 1575
1580 1576 ( cd $SRC
1581 1577 for target in cc-version java-version openssl-version; do
1582 1578 echo
1583 1579 #
1584 1580 # Put statefile somewhere we know we can write to rather than trip
1585 1581 # over a read-only $srcroot.
1586 1582 #
1587 1583 rm -f $TMPDIR/make-state
1588 1584 export SRC
1589 1585 if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
1590 1586 continue
1591 1587 fi
1592 1588 touch $TMPDIR/nocompiler
1593 1589 done
1594 1590 echo
1595 1591 ) | tee -a $build_environ_file >> $LOGFILE
1596 1592
1597 1593 if [ -f $TMPDIR/nocompiler ]; then
1598 1594 rm -f $TMPDIR/nocompiler
1599 1595 build_ok=n
1600 1596 echo "Aborting due to missing compiler." |
1601 1597 tee -a $build_environ_file >> $LOGFILE
1602 1598 exit 1
1603 1599 fi
1604 1600
1605 1601 # as
1606 1602 whence as | tee -a $build_environ_file >> $LOGFILE
1607 1603 as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
1608 1604 echo | tee -a $build_environ_file >> $LOGFILE
1609 1605
1610 1606 # Check that we're running a capable link-editor
1611 1607 whence ld | tee -a $build_environ_file >> $LOGFILE
1612 1608 LDVER=`ld -V 2>&1`
1613 1609 echo $LDVER | tee -a $build_environ_file >> $LOGFILE
1614 1610 LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1615 1611 if [ `expr $LDVER \< 422` -eq 1 ]; then
1616 1612 echo "The link-editor needs to be at version 422 or higher to build" | \
1617 1613 tee -a $build_environ_file >> $LOGFILE
1618 1614 echo "the latest stuff. Hope your build works." | \
1619 1615 tee -a $build_environ_file >> $LOGFILE
1620 1616 fi
1621 1617
1622 1618 #
1623 1619 # Build and use the workspace's tools if requested
1624 1620 #
1625 1621 if [[ "$t_FLAG" = "y" ]]; then
1626 1622 set_non_debug_build_flags
1627 1623
1628 1624 build_tools ${TOOLS_PROTO}
1629 1625 if (( $? != 0 )); then
1630 1626 build_ok=n
1631 1627 else
1632 1628 STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs
1633 1629 export STABS
1634 1630 CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs
1635 1631 export CTFSTABS
1636 1632 GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets
1637 1633 export GENOFFSETS
1638 1634
1639 1635 CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert
1640 1636 export CTFCONVERT
1641 1637 CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge
1642 1638 export CTFMERGE
1643 1639
1644 1640 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
1645 1641 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
1646 1642 export PATH
1647 1643
1648 1644 echo "\n==== New environment settings. ====\n" >> $LOGFILE
1649 1645 echo "STABS=${STABS}" >> $LOGFILE
1650 1646 echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
1651 1647 echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
1652 1648 echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
1653 1649 echo "PATH=${PATH}" >> $LOGFILE
1654 1650 echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
1655 1651 fi
1656 1652 fi
1657 1653
1658 1654 # timestamp the start of the normal build; the findunref tool uses it.
1659 1655 touch $SRC/.build.tstamp
1660 1656
1661 1657 normal_build
1662 1658
1663 1659 ORIG_SRC=$SRC
1664 1660 BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
1665 1661
1666 1662
1667 1663 #
1668 1664 # There are several checks that need to look at the proto area, but
1669 1665 # they only need to look at one, and they don't care whether it's
1670 1666 # DEBUG or non-DEBUG.
1671 1667 #
1672 1668 if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
1673 1669 checkroot=$ROOT-nd
1674 1670 else
1675 1671 checkroot=$ROOT
1676 1672 fi
1677 1673
1678 1674 if [ "$build_ok" = "y" ]; then
1679 1675 echo "\n==== Creating protolist system file at `date` ====" \
1680 1676 >> $LOGFILE
1681 1677 protolist $checkroot > $ATLOG/proto_list_${MACH}
1682 1678 echo "==== protolist system file created at `date` ====\n" \
1683 1679 >> $LOGFILE
1684 1680
1685 1681 if [ "$N_FLAG" != "y" ]; then
1686 1682
1687 1683 E1=
1688 1684 f1=
1689 1685 for f in $f1; do
1690 1686 if [ -f "$f" ]; then
1691 1687 E1="$E1 -e $f"
1692 1688 fi
1693 1689 done
1694 1690
1695 1691 E2=
1696 1692 f2=
1697 1693 if [ -d "$SRC/pkg" ]; then
1698 1694 f2="$f2 exceptions/packaging"
1699 1695 fi
1700 1696
1701 1697 for f in $f2; do
1702 1698 if [ -f "$f" ]; then
1703 1699 E2="$E2 -e $f"
1704 1700 fi
1705 1701 done
1706 1702 fi
1707 1703
1708 1704 if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
1709 1705 echo "\n==== Validating manifests against proto area ====\n" \
1710 1706 >> $mail_msg_file
1711 1707 ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \
1712 1708 tee $TMPDIR/protocmp_noise >> $mail_msg_file
1713 1709 if [[ -s $TMPDIR/protocmp_noise ]]; then
1714 1710 build_extras_ok=n
1715 1711 fi
1716 1712 fi
1717 1713
1718 1714 if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1719 1715 echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1720 1716 if [ -n "$E2" ]; then
1721 1717 ELIST=$E2
1722 1718 else
1723 1719 ELIST=$E1
1724 1720 fi
1725 1721 $PROTOCMPTERSE \
1726 1722 "Files in yesterday's proto area, but not today's:" \
1727 1723 "Files in today's proto area, but not yesterday's:" \
1728 1724 "Files that changed between yesterday and today:" \
1729 1725 ${ELIST} \
1730 1726 -d $REF_PROTO_LIST \
1731 1727 $ATLOG/proto_list_${MACH} \
1732 1728 >> $mail_msg_file
1733 1729 fi
1734 1730 fi
1735 1731
1736 1732 if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \
1737 1733 "$build_extras_ok" == "y" ]]; then
1738 1734 staffer cp $ATLOG/proto_list_${MACH} \
1739 1735 $PARENT_WS/usr/src/proto_list_${MACH}
1740 1736 fi
1741 1737
1742 1738 # Update parent proto area if necessary. This is done now
1743 1739 # so that the proto area has either DEBUG or non-DEBUG kernels.
1744 1740 # Note that this clears out the lock file, so we can dispense with
1745 1741 # the variable now.
1746 1742 if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1747 1743 echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1748 1744 tee -a $LOGFILE >> $mail_msg_file
1749 1745 rm -rf $NIGHTLY_PARENT_ROOT/*
1750 1746 unset Ulockfile
1751 1747 mkdir -p $NIGHTLY_PARENT_ROOT
1752 1748 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1753 1749 ( cd $ROOT; tar cf - . |
1754 1750 ( cd $NIGHTLY_PARENT_ROOT; umask 0; tar xpf - ) ) 2>&1 |
1755 1751 tee -a $mail_msg_file >> $LOGFILE
1756 1752 fi
1757 1753 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
1758 1754 rm -rf $NIGHTLY_PARENT_ROOT-nd/*
1759 1755 mkdir -p $NIGHTLY_PARENT_ROOT-nd
1760 1756 cd $ROOT-nd
1761 1757 ( tar cf - . |
1762 1758 ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
1763 1759 tee -a $mail_msg_file >> $LOGFILE
1764 1760 fi
1765 1761 if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1766 1762 echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1767 1763 tee -a $LOGFILE >> $mail_msg_file
1768 1764 rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1769 1765 mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
1770 1766 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1771 1767 ( cd $TOOLS_PROTO; tar cf - . |
1772 1768 ( cd $NIGHTLY_PARENT_TOOLS_ROOT;
1773 1769 umask 0; tar xpf - ) ) 2>&1 |
1774 1770 tee -a $mail_msg_file >> $LOGFILE
1775 1771 fi
1776 1772 fi
1777 1773 fi
1778 1774
1779 1775 #
1780 1776 # ELF verification: ABI (-A) and runtime (-r) checks
1781 1777 #
1782 1778 if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then
1783 1779 # Directory ELF-data.$MACH holds the files produced by these tests.
1784 1780 elf_ddir=$SRC/ELF-data.$MACH
1785 1781
1786 1782 # If there is a previous ELF-data backup directory, remove it. Then,
1787 1783 # rotate current ELF-data directory into its place and create a new
1788 1784 # empty directory
1789 1785 rm -rf $elf_ddir.ref
1790 1786 if [[ -d $elf_ddir ]]; then
1791 1787 mv $elf_ddir $elf_ddir.ref
1792 1788 fi
1793 1789 mkdir -p $elf_ddir
1794 1790
1795 1791 # Call find_elf to produce a list of the ELF objects in the proto area.
1796 1792 # This list is passed to check_rtime and interface_check, preventing
1797 1793 # them from separately calling find_elf to do the same work twice.
1798 1794 find_elf -fr $checkroot > $elf_ddir/object_list
1799 1795
1800 1796 if [[ $A_FLAG = y ]]; then
1801 1797 echo "\n==== Check versioning and ABI information ====\n" | \
1802 1798 tee -a $LOGFILE >> $mail_msg_file
1803 1799
1804 1800 # Produce interface description for the proto. Report errors.
1805 1801 interface_check -o -w $elf_ddir -f object_list \
1806 1802 -i interface -E interface.err
1807 1803 if [[ -s $elf_ddir/interface.err ]]; then
1808 1804 tee -a $LOGFILE < $elf_ddir/interface.err \
1809 1805 >> $mail_msg_file
1810 1806 build_extras_ok=n
1811 1807 fi
1812 1808
1813 1809 # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1814 1810 # description file to that from the baseline gate. Issue a
1815 1811 # warning if the baseline is not present, and keep going.
1816 1812 if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1817 1813 base_ifile="$ELF_DATA_BASELINE_DIR/interface"
1818 1814
1819 1815 echo "\n==== Compare versioning and ABI information" \
1820 1816 "to baseline ====\n" | \
1821 1817 tee -a $LOGFILE >> $mail_msg_file
1822 1818 echo "Baseline: $base_ifile\n" >> $LOGFILE
1823 1819
1824 1820 if [[ -f $base_ifile ]]; then
1825 1821 interface_cmp -d -o $base_ifile \
1826 1822 $elf_ddir/interface > $elf_ddir/interface.cmp
1827 1823 if [[ -s $elf_ddir/interface.cmp ]]; then
1828 1824 echo | tee -a $LOGFILE >> $mail_msg_file
1829 1825 tee -a $LOGFILE < \
1830 1826 $elf_ddir/interface.cmp \
1831 1827 >> $mail_msg_file
1832 1828 build_extras_ok=n
1833 1829 fi
1834 1830 else
1835 1831 echo "baseline not available. comparison" \
1836 1832 "skipped" | \
1837 1833 tee -a $LOGFILE >> $mail_msg_file
1838 1834 fi
1839 1835
1840 1836 fi
1841 1837 fi
1842 1838
1843 1839 if [[ $r_FLAG = y ]]; then
1844 1840 echo "\n==== Check ELF runtime attributes ====\n" | \
1845 1841 tee -a $LOGFILE >> $mail_msg_file
1846 1842
1847 1843 # If we're doing a DEBUG build the proto area will be left
1848 1844 # with debuggable objects, thus don't assert -s.
1849 1845 if [[ $D_FLAG = y ]]; then
1850 1846 rtime_sflag=""
1851 1847 else
1852 1848 rtime_sflag="-s"
1853 1849 fi
1854 1850 check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
1855 1851 -D object_list -f object_list -E runtime.err \
1856 1852 -I runtime.attr.raw
1857 1853 if (( $? != 0 )); then
1858 1854 build_extras_ok=n
1859 1855 fi
1860 1856
1861 1857 # check_rtime -I output needs to be sorted in order to
1862 1858 # compare it to that from previous builds.
1863 1859 sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
1864 1860 rm $elf_ddir/runtime.attr.raw
1865 1861
1866 1862 # Report errors
1867 1863 if [[ -s $elf_ddir/runtime.err ]]; then
1868 1864 tee -a $LOGFILE < $elf_ddir/runtime.err \
1869 1865 >> $mail_msg_file
1870 1866 build_extras_ok=n
1871 1867 fi
1872 1868
1873 1869 # If there is an ELF-data directory from a previous build,
1874 1870 # then diff the attr files. These files contain information
1875 1871 # about dependencies, versioning, and runpaths. There is some
1876 1872 # overlap with the ABI checking done above, but this also
1877 1873 # flushes out non-ABI interface differences along with the
1878 1874 # other information.
1879 1875 echo "\n==== Diff ELF runtime attributes" \
1880 1876 "(since last build) ====\n" | \
1881 1877 tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
1882 1878
1883 1879 if [[ -f $elf_ddir.ref/runtime.attr ]]; then
1884 1880 diff $elf_ddir.ref/runtime.attr \
1885 1881 $elf_ddir/runtime.attr \
1886 1882 >> $mail_msg_file
1887 1883 fi
1888 1884 fi
1889 1885
1890 1886 # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
1891 1887 if [[ "$u_FLAG" = "y" ]]; then
1892 1888 p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH
1893 1889
1894 1890 # If parent lacks the ELF-data.$MACH directory, create it
1895 1891 if [[ ! -d $p_elf_ddir ]]; then
1896 1892 staffer mkdir -p $p_elf_ddir
1897 1893 fi
1898 1894
1899 1895 # These files are used asynchronously by other builds for ABI
1900 1896 # verification, as above for the -A option. As such, we require
1901 1897 # the file replacement to be atomic. Copy the data to a temp
1902 1898 # file in the same filesystem and then rename into place.
1903 1899 (
1904 1900 cd $elf_ddir
1905 1901 for elf_dfile in *; do
1906 1902 staffer cp $elf_dfile \
1907 1903 ${p_elf_ddir}/${elf_dfile}.new
1908 1904 staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
1909 1905 ${p_elf_ddir}/${elf_dfile}
1910 1906 done
1911 1907 )
1912 1908 fi
1913 1909 fi
1914 1910
1915 1911 # "make check" begins
1916 1912
1917 1913 if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
1918 1914 # remove old check.out
1919 1915 rm -f $SRC/check.out
1920 1916
1921 1917 rm -f $SRC/check-${MACH}.out
1922 1918 cd $SRC
1923 1919 $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
1924 1920 >> $LOGFILE
1925 1921 echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
1926 1922
1927 1923 grep ":" $SRC/check-${MACH}.out |
1928 1924 egrep -v "Ignoring unknown host" | \
1929 1925 sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file
1930 1926
1931 1927 if [[ -s $TMPDIR/check_errors ]]; then
1932 1928 build_extras_ok=n
1933 1929 fi
1934 1930 else
1935 1931 echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
1936 1932 fi
1937 1933
1938 1934 echo "\n==== Find core files ====\n" | \
1939 1935 tee -a $LOGFILE >> $mail_msg_file
1940 1936
1941 1937 find $abssrcdirs -name core -a -type f -exec file {} \; | \
1942 1938 tee -a $LOGFILE >> $mail_msg_file
1943 1939
1944 1940 if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
1945 1941 echo "\n==== Diff unreferenced files (since last build) ====\n" \
1946 1942 | tee -a $LOGFILE >>$mail_msg_file
1947 1943 rm -f $SRC/unref-${MACH}.ref
1948 1944 if [ -f $SRC/unref-${MACH}.out ]; then
1949 1945 mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
1950 1946 fi
1951 1947
1952 1948 findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
1953 1949 ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
1954 1950 sort > $SRC/unref-${MACH}.out
1955 1951
1956 1952 if [ ! -f $SRC/unref-${MACH}.ref ]; then
1957 1953 cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
1958 1954 fi
1959 1955
1960 1956 diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
1961 1957 fi
1962 1958
1963 1959 # Verify that the usual lists of files, such as exception lists,
1964 1960 # contain only valid references to files. If the build has failed,
1965 1961 # then don't check the proto area.
1966 1962 CHECK_PATHS=${CHECK_PATHS:-y}
1967 1963 if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
1968 1964 echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
1969 1965 >>$mail_msg_file
1970 1966 arg=-b
1971 1967 [ "$build_ok" = y ] && arg=
1972 1968 checkpaths $arg $checkroot > $SRC/check-paths.out 2>&1
1973 1969 if [[ -s $SRC/check-paths.out ]]; then
1974 1970 tee -a $LOGFILE < $SRC/check-paths.out >> $mail_msg_file
1975 1971 build_extras_ok=n
1976 1972 fi
1977 1973 fi
1978 1974
1979 1975 if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
1980 1976 echo "\n==== Impact on file permissions ====\n" \
1981 1977 >> $mail_msg_file
1982 1978
1983 1979 abspkg=
1984 1980 for d in $abssrcdirs; do
1985 1981 if [ -d "$d/pkg" ]; then
1986 1982 abspkg="$abspkg $d"
1987 1983 fi
1988 1984 done
1989 1985
1990 1986 if [ -n "$abspkg" ]; then
1991 1987 for d in "$abspkg"; do
1992 1988 ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
1993 1989 done
1994 1990 fi
1995 1991 fi
1996 1992
1997 1993 if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
1998 1994 if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1999 1995 do_wsdiff DEBUG $ROOT.prev $ROOT
2000 1996 fi
2001 1997
2002 1998 if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2003 1999 do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2004 2000 fi
2005 2001 fi
2006 2002
2007 2003 END_DATE=`date`
2008 2004 echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2009 2005 tee -a $LOGFILE >> $build_time_file
2010 2006
2011 2007 typeset -i10 hours
2012 2008 typeset -Z2 minutes
2013 2009 typeset -Z2 seconds
2014 2010
2015 2011 elapsed_time=$SECONDS
2016 2012 ((hours = elapsed_time / 3600 ))
2017 2013 ((minutes = elapsed_time / 60 % 60))
2018 2014 ((seconds = elapsed_time % 60))
2019 2015
2020 2016 echo "\n==== Total build time ====" | \
2021 2017 tee -a $LOGFILE >> $build_time_file
2022 2018 echo "\nreal ${hours}:${minutes}:${seconds}" | \
2023 2019 tee -a $LOGFILE >> $build_time_file
2024 2020
2025 2021 if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2026 2022 staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
2027 2023
2028 2024 #
2029 2025 # Produce a master list of unreferenced files -- ideally, we'd
2030 2026 # generate the master just once after all of the nightlies
2031 2027 # have finished, but there's no simple way to know when that
2032 2028 # will be. Instead, we assume that we're the last nightly to
2033 2029 # finish and merge all of the unref-${MACH}.out files in
2034 2030 # $PARENT_WS/usr/src/. If we are in fact the final ${MACH} to
2035 2031 # finish, then this file will be the authoritative master
2036 2032 # list. Otherwise, another ${MACH}'s nightly will eventually
2037 2033 # overwrite ours with its own master, but in the meantime our
2038 2034 # temporary "master" will be no worse than any older master
2039 2035 # which was already on the parent.
2040 2036 #
2041 2037
2042 2038 set -- $PARENT_WS/usr/src/unref-*.out
2043 2039 cp "$1" ${TMPDIR}/unref.merge
2044 2040 shift
2045 2041
2046 2042 for unreffile; do
2047 2043 comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2048 2044 mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2049 2045 done
2050 2046
2051 2047 staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2052 2048 fi
2053 2049
2054 2050 #
2055 2051 # All done save for the sweeping up.
2056 2052 # (whichever exit we hit here will trigger the "cleanup" trap which
2057 2053 # optionally sends mail on completion).
2058 2054 #
2059 2055 if [[ "$build_ok" == "y" ]]; then
2060 2056 if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then
2061 2057 exit 0
2062 2058 fi
2063 2059 fi
2064 2060
2065 2061 exit 1
↓ open down ↓ |
1383 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX