Print this page
4526 nightly contains a great deal of effectively dead code
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/Install.sh
+++ new/usr/src/tools/scripts/Install.sh
1 1 #!/bin/ksh
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 # Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 #
25 25 # Author: Jeff Bonwick
26 26 #
27 27 # Please report any bugs to bonwick@eng.
28 28 #
29 29 # How Install works:
30 30 #
31 31 # Install performs the following steps:
32 32 #
33 33 # 1. Get the list of modules, configuration files, and links
34 34 # that are desired.
35 35 #
36 36 # 2. Create the requested subset of /kernel in Install's temp space
37 37 # (/tmp/Install.username by default.)
38 38 #
39 39 # 3. Create a tar file (/tmp/Install.username/Install.tar) based on (3).
40 40 #
41 41 # 4. If -n was specified, exit. If a target was specified using -T,
42 42 # rcp the tarfile to the target and exit. If a target was specified
43 43 # using -t, rsh to the target machine and untar the tarfile in the
44 44 # target directory.
45 45 #
46 46 # If any of these steps fail, Install will give you an error message and,
47 47 # in most cases, suggest corrective measures. Then, you can recover the
48 48 # install with "Install -R". (This is not required; it's just faster than
49 49 # starting from scratch.)
50 50 #
51 51 # One final comment: Unfortunately, tar and I disagree on what
52 52 # constitutes a fatal error. (tar -x will exit 0 even if it can't write
53 53 # anything in the current directory.) Thus, I am reduced to grepping stderr
54 54 # for (what I consider) fatal and nonfatal error messages. If you run into
55 55 # a situation where this doesn't behave the way you think it should (either
56 56 # an "Install failed" message after a successful install, or an "Install
57 57 # complete" message after it bombs), please let me know.
58 58
59 59 #
60 60 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
61 61 # under certain circumstances, which can really screw things up; unset it.
62 62 #
63 63 unset CDPATH
64 64
65 65 INSTALL=`basename $0`
66 66 DOT=`pwd`
67 67
68 68 TRAILER="Install.$LOGNAME"
69 69 INSTALL_STATE=${INSTALL_STATE-$HOME/.Install.state}
70 70 export INSTALL_STATE
71 71 INSTALL_DIR=${INSTALL_DIR-/tmp/$TRAILER}
72 72 if [ "`basename $INSTALL_DIR`" != "$TRAILER" ]; then
73 73 INSTALL_DIR="$INSTALL_DIR/$TRAILER"
74 74 fi
75 75 export INSTALL_DIR
76 76 INSTALL_LIB=${INSTALL_LIB-$HOME/LibInstall}
77 77 export INSTALL_LIB
78 78 INSTALL_RC=${INSTALL_RC-$HOME/.Installrc}
79 79 export INSTALL_RC
80 80 INSTALL_CP=${INSTALL_CP-"cp -p"}
81 81 export INSTALL_CP
82 82 INSTALL_RCP=${INSTALL_RCP-"rcp -p"}
83 83 export INSTALL_RCP
84 84
85 85 STATE=0
86 86
87 87 DEFAULT_OPTIONS="-naq"
88 88 GLOM=no
89 89 GLOMNAME=kernel
90 90 IMPL="default"
91 91 WANT32="yes"
92 92 WANT64="yes"
93 93
94 94 modlist=/tmp/modlist$$
95 95 # dummy directory for make state files.
96 96 modstatedir=/tmp/modstate$$
97 97
98 98 trap 'fail "User Interrupt" "You can resume by typing \"$INSTALL -R\""' 1 2 3 15
99 99
100 100 function usage {
101 101 echo ""
102 102 echo $1
103 103 echo '
104 104 Usage: Install [ -w workspace ]
105 105 [ -s srcdir (default: usr/src/uts) ]
106 106 [ -k karch (e.g. sun4u; required if not deducible from pwd) ]
107 107 [ -t target (extract tar file on target, e.g. user@machine:/) ]
108 108 [ -T target (copy tar file to target, e.g. user@machine:/tmp) ]
109 109 [ -n (no target, just create tar file in /tmp (default)) ]
110 110 [ -u (install unix only) ]
111 111 [ -m (install modules only) ]
112 112 [ -a (install everything, i.e. unix + modules (default)) ]
113 113 [ -v (verbose output) ]
114 114 [ -V (REALLY verbose output) ]
115 115 [ -q (quiet (default)) ]
116 116 [ -c (clean up (remove temp files) when done (default) ]
117 117 [ -p (preserve temp files -- useful for debugging) ]
118 118 [ -L (library create: put tarfile in $INSTALL_LIB/env.karch) ]
119 119 [ -l lib (library extract: use $INSTALL_LIB/lib as source) ]
120 120 [ -D libdir (default: $HOME/LibInstall) ]
121 121 [ -d tempdir (Install work area (default: /tmp)) ]
122 122 [ -G glomname (put all files under platform/karch/glomname) ]
123 123 [ -i impl (e.g. sunfire; recommended with -G) ]
124 124 [ -x (update /etc/name_to_major et al) ]
125 125 [ -X (do not update /etc/name_to_major et al (default)) ]
126 126 [ -P (update /etc/path_to_inst -- generally not advisable) ]
127 127 [ -h (help -- prints this message) ]
128 128 [ -R (recover a previous Install) ]
129 129 [ -o objdir (object directory - either obj or debug (the default)) ]
130 130 [ -K (do not copy kmdb) ]
131 131 [ -3 32-bit modules only ]
132 132 [ -6 64-bit modules only ]
133 133 [ list of modules to install ]
134 134
135 135 For full details:
136 136
137 137 man -M /ws/on297-gate/public/docs Install
138 138 '
139 139 exit 1
140 140 }
141 141
142 142 #
143 143 # Save the current state of Install
144 144 #
145 145
146 146 function save_state {
147 147 rm -f $INSTALL_STATE
148 148 (echo "# State of previous Install
149 149 TARGET=$TARGET
150 150 ENV_PATH=$ENV_PATH
151 151 ENV_NAME=$ENV_NAME
152 152 KARCH=$KARCH
153 153 UTS=$UTS
154 154 INSTALL_DIR=$INSTALL_DIR
155 155 INSTALL_LIB=$INSTALL_LIB
156 156 IMODE=$IMODE
157 157 LIBCREATE=$LIBCREATE
158 158 LIBSRC=$LIBSRC
159 159 VERBOSE=$VERBOSE
160 160 CLEANUP=$CLEANUP
161 161 GLOM=$GLOM
162 162 GLOMNAME=$GLOMNAME
163 163 KMDB=$KMDB
164 164 files='$files'
165 165 STATE=$STATE" >$INSTALL_STATE) || verbose "Warning: cannot save state"
166 166 }
167 167
168 168 #
169 169 # Restore the previous state of Install
170 170 #
171 171
172 172 function restore_state {
173 173 test -s $INSTALL_STATE || fail "Can't find $INSTALL_STATE"
174 174 eval "`cat $INSTALL_STATE`"
175 175 }
176 176
177 177 #
178 178 # Install failed -- print error messages and exit 2
179 179 #
180 180
181 181 function fail {
182 182 save_state
183 183 #
184 184 # We might have gotten here via a trap. So wait for any
185 185 # children (especially "make modlist") to exit before giving
186 186 # the error message or cleaning up.
187 187 #
188 188 wait
189 189 while [ $# -gt 0 ]
190 190 do
191 191 echo $1
192 192 shift
193 193 done
194 194 rm -rf $modstatedir
195 195 rm -f $modlist
196 196 echo "Install failed"
197 197 exit 2
198 198 }
199 199
200 200 #
201 201 # Echo a string in verbose mode only
202 202 #
203 203
204 204 function verbose {
205 205 test "$VERBOSE" != "q" && echo $1
206 206 }
207 207
208 208 #
209 209 # hack for tmpfs bug -- remove files gradually
210 210 #
211 211
212 212 function remove_dir {
213 213 test -d $1 || return
214 214 local_dot=`pwd`
215 215 cd $1
216 216 touch foo
217 217 rm -f `find . -type f -print`
218 218 cd $local_dot
219 219 rm -rf $1
220 220 }
221 221
222 222 #
223 223 # Create a directory if it doesn't already exist.
224 224 # mkdir will provide an error message, so don't provide an additional
225 225 # message.
226 226 #
227 227
228 228 function tstmkdir {
229 229 [ -d $1 ] || mkdir -p $1 || fail
230 230 }
231 231
232 232 #
233 233 # Patch up target directories for glommed kernel.
234 234 # usage: fixglom listfile glomname
235 235 #
236 236
237 237 function fixglom {
238 238 nawk \
239 239 -v glomname=$2 \
240 240 -v karch=$KARCH '
241 241 $1 == "MOD" || $1 == "SYMLINK" {
242 242 sub(/^platform.*kernel/, "platform/" karch "/" glomname, $4)
243 243 sub(/^kernel/, "platform/" karch "/" glomname, $4)
244 244 sub(/^usr.kernel/, "platform/" karch "/" glomname, $4)
245 245 print
246 246 }
247 247 $1 == "LINK" {
248 248 sub(/^platform.*kernel/, "platform/" karch "/" glomname, $3)
249 249 sub(/^kernel/, "platform/" karch "/" glomname, $3)
250 250 sub(/^usr.kernel/, "platform/" karch "/" glomname, $3)
251 251 sub(/^platform.*kernel/, "platform/" karch "/" glomname, $5)
252 252 sub(/^kernel/, "platform/" karch "/" glomname, $5)
253 253 sub(/^usr.kernel/, "platform/" karch "/" glomname, $5)
254 254 print
255 255 }
256 256 $1 == "CONF" {
257 257 sub(/^platform.*kernel/, "platform/" karch "/" glomname, $3)
258 258 sub(/^kernel/, "platform/" karch "/" glomname, $3)
259 259 sub(/^usr.kernel/, "platform/" karch "/" glomname, $3)
260 260 print
261 261 }
262 262 ' $1 > $1.new
263 263 mv $1.new $1
264 264 }
265 265
266 266 #
267 267 # Filter out implementation-specific modules, unless that
268 268 # implementation was requested by the user.
269 269 # usage: filtimpl listfile implname
270 270 #
271 271
272 272 function filtimpl {
273 273 nawk \
274 274 -v impl=$2 '
275 275 $1 == "MOD" || $1 == "SYMLINK" {
276 276 if ($6 == "all" || $6 == impl)
277 277 print
278 278 }
279 279 $1 == "CONF" {
280 280 if ($5 == "all" || $5 == impl)
281 281 print
282 282 }
283 283 $1 == "LINK" {
284 284 if ($7 == "all" || $7 == impl)
285 285 print
286 286 }
287 287 ' $1 > $1.new
288 288 mv $1.new $1
289 289 }
290 290
291 291 #
292 292 # Filter the module list to match the user's request.
293 293 # Usage: filtmod listfile modules
294 294 #
295 295 function filtmod {
296 296 nawk -v reqstring="$2" '
297 297 function modmatch(modname) {
298 298 if (reqstring == "All") {
299 299 return (1)
300 300 } else if (reqstring == "Modules") {
301 301 if (modname != "unix" && modname != "genunix")
302 302 return (1)
303 303 } else {
304 304 if (modname in reqmods)
305 305 return (1)
306 306 }
307 307 return (0)
308 308 }
309 309 BEGIN {
310 310 #
311 311 # The split call creates indexes 1, 2, 3, ... We want
312 312 # the module names as indexes.
313 313 #
314 314 split(reqstring, tmpmods)
315 315 for (i in tmpmods)
316 316 reqmods[tmpmods[i]] = 1
317 317 }
318 318 $1 == "MOD" {
319 319 if (modmatch($3))
320 320 print
321 321 }
322 322 $1 == "CONF" {
323 323 if (modmatch($6))
324 324 print
325 325 }
326 326 $1 == "SYMLINK" {
327 327 if (modmatch($7))
328 328 print
329 329 }
330 330 $1 == "LINK" {
331 331 if (modmatch($4))
332 332 print
333 333 }
334 334 ' $1 > $1.new
335 335 mv $1.new $1
336 336 }
337 337
338 338 #
339 339 # Unpack the crypto tarball into the given tree, then massage the
340 340 # tree so that the binaries are all in objNN or debugNN directories.
341 341 #
342 342 function unpack_crypto {
343 343 typeset tarfile=$1
344 344 typeset ctop=$2
345 345 [ -d "$ctop" ] || fail "Can't create tree for crypto modules."
346 346
347 347 [ "$VERBOSE" = "V" ] && echo "unpacking crypto tarball into $ctop..."
348 348 bzcat "$tarfile" | (cd "$ctop"; tar xf -)
349 349
350 350 typeset root="$ctop/proto/root_$MACH"
351 351 [ $OBJD = obj ] && root="$ctop/proto/root_$MACH-nd"
352 352 [ -d "$root" ] || fail "Can't unpack crypto tarball."
353 353
354 354 (cd "$root"; for d in platform kernel usr/kernel; do
355 355 [ ! -d $d ] && continue
356 356 find $d -type f -print
357 357 done) | while read file; do
358 358 typeset dir=$(dirname "$file")
359 359 typeset base=$(basename "$file")
360 360 typeset type=$(basename "$dir")
361 361 if [ "$type" = amd64 ]; then
362 362 newdir="$dir/${OBJD}64"
363 363 elif [ "$type" = sparcv9 ]; then
364 364 newdir="$dir/${OBJD}64"
↓ open down ↓ |
364 lines elided |
↑ open up ↑ |
365 365 else
366 366 newdir="$dir/${OBJD}32"
367 367 fi
368 368 mkdir -p "$root/$newdir"
369 369 [ "$VERBOSE" = "V" ] && echo "mv $file $newdir"
370 370 mv "$root/$file" "$root/$newdir"
371 371 done
372 372 }
373 373
374 374 #
375 -# usage: fixcrypto listfile ctop
376 -# Massage entries in listfile for crypto modules, so that they point
377 -# into ctop.
378 -#
379 -function fixcrypto {
380 - typeset listfile=$1
381 - typeset ctop=$2
382 -
383 - typeset ccontents=/tmp/crypto-toc$$
384 - find "$ctop" -type f -print > $ccontents
385 - typeset root=root_$MACH
386 - [ "$OBJD" = obj ] && root=root_$MACH-nd
387 -
388 - grep -v ^MOD $listfile > $listfile.no-mod
389 - grep ^MOD $listfile | while read tag srcdir module targdir size impl; do
390 - #
391 - # We don't just grep for ${OBJD}$size/$module because
392 - # there can be generic and platform-dependent versions
393 - # of a module.
394 - #
395 - newsrcfile=$(grep -w $root/$targdir/${OBJD}$size/$module $ccontents)
396 - if [ -n "$newsrcfile" ]; then
397 - # srcdir doesn't include final objNN or debugNN
398 - echo $tag $module $targdir $size $impl \
399 - $(dirname $(dirname "$newsrcfile"))
400 - else
401 - echo $tag $module $targdir $size $impl $srcdir
402 - fi
403 - done > $listfile.mod
404 - cat $listfile.mod $listfile.no-mod > $listfile
405 -
406 - rm -f $listfile.mod
407 - rm -f $listfile.no-mod
408 - rm -f $ccontents
409 -}
410 -
411 -#
412 375 # Copy a module, or create a link, as needed.
413 376 #
414 -
415 377 function copymod {
416 378 case $1 in
417 379 MOD)
418 380 targdir=$INSTALL_FILES/$4
419 381 tstmkdir $targdir
420 382 target=$targdir/$3
421 383 verbose "$INSTALL_CP $2/${OBJD}$5/$3 $target"
422 384 $INSTALL_CP $2/${OBJD}$5/$3 $target || \
423 385 fail "can't create $target"
424 386 ;;
425 387 SYMLINK)
426 388 targdir=$INSTALL_FILES/$4
427 389 tstmkdir $targdir
428 390 target=$targdir/$5
429 391 rm -f $target
430 392 verbose "ln -s $3 $target"
431 393 ln -s $3 $target || fail "can't create $target"
432 394 ;;
433 395 LINK)
434 396 targdir=$INSTALL_FILES/$5
435 397 tstmkdir $targdir
436 398 target=$targdir/$6
437 399 rm -f $target
438 400 verbose "ln $INSTALL_FILES/$3/$4 $target"
439 401 ln $INSTALL_FILES/$3/$4 $target || fail "can't create $target"
440 402 ;;
441 403 CONF)
442 404 target=$INSTALL_FILES/$3
443 405 tstmkdir `dirname $target`
444 406 conffile=`basename $3`
445 407 verbose "$INSTALL_CP $4/$conffile $target"
446 408 $INSTALL_CP $4/$conffile $target
447 409 ;;
448 410 *)
449 411 fail "unrecognized modlist entry: $*"
450 412 ;;
451 413 esac
452 414 }
453 415
454 416 # Sanity-check the given module list.
455 417 function check_modlist {
456 418 nawk '
457 419 BEGIN {
458 420 nfields["MOD"] = 6
459 421 nfields["CONF"] = 6
460 422 nfields["LINK"] = 7
461 423 nfields["SYMLINK"] = 7
462 424 }
463 425 {
464 426 # This also catches unknown tags.
465 427 if (nfields[$1] != NF) {
466 428 print "error: invalid modlist record:"
467 429 print $0
468 430 print "expected", nfields[$1], "fields, found", NF
469 431 status=1
470 432 }
471 433 }
472 434 END {
473 435 exit status
474 436 }
475 437 ' $1 || fail "Errors in kernel module list"
476 438 }
477 439
478 440 #
479 441 # Copy kernel modules to $INSTALL_DIR
480 442 #
481 443
482 444 function copy_kernel {
483 445
484 446 case $KARCH in
485 447 sun4*) ISA=sparc; MACH=sparc ;;
486 448 i86*) ISA=intel; MACH=i386 ;;
487 449 *) fail "${KARCH}: invalid kernel architecture";;
488 450 esac
489 451 export MACH
490 452
491 453 if [ "$GLOM" = "no" ]; then
492 454 verbose "Source = $UTS, ISA = $ISA, kernel = $KARCH"
493 455 else
494 456 verbose "Source = $UTS, ISA = $ISA, kernel = $KARCH, impl = $IMPL"
495 457 fi
496 458
497 459 test -d $KARCH || fail "${KARCH}: invalid kernel architecture"
498 460 test -d $ISA || fail "${ISA}: invalid instruction set architecture"
499 461
500 462 tstmkdir $INSTALL_FILES
501 463 rm -rf $modstatedir
502 464 tstmkdir $modstatedir
503 465 export MODSTATE=$modstatedir/state
504 466
505 467 #
506 468 # Figure out which "make" to use. dmake is faster than serial
507 469 # make, but dmake 7.3 has a bug that causes it to lose log
508 470 # output, which means the modlist might be incomplete.
509 471 #
510 472 make=dmake
511 473 dmvers=`$make -version`
512 474 if [ $? -ne 0 ]; then
513 475 make=/usr/ccs/bin/make
514 476 elif [[ $dmvers = *Distributed?Make?7.3* ]]; then
515 477 unset make
516 478 searchpath="/ws/onnv-tools/SUNWspro/SOS10/bin
517 479 /opt/SUNWspro/SOS10/bin
518 480 /opt/SUNWspro/bin"
519 481 for dmpath in $searchpath; do
520 482 verbose "Trying $dmpath/dmake"
521 483 if [ -x $dmpath/dmake ]; then
522 484 dmvers=`$dmpath/dmake -version`
523 485 if [[ $dmvers != *Distributed?Make?7.3* ]]; then
524 486 make="$dmpath/dmake"
525 487 break;
526 488 fi
527 489 fi
528 490 done
529 491 if [ -z $make ]; then
530 492 make=/usr/ccs/bin/make
531 493 echo "Warning: dmake 7.3 doesn't work with Install;" \
532 494 "using $make"
533 495 fi
534 496 fi
↓ open down ↓ |
110 lines elided |
↑ open up ↑ |
535 497
536 498 #
537 499 # Get a list of all modules, configuration files, and links
538 500 # that we might want to install.
539 501 #
540 502 verbose "Building module list..."
541 503 (cd $KARCH; MAKEFLAGS=e $make -K $MODSTATE modlist.karch) | \
542 504 egrep "^MOD|^CONF|^LINK|^SYMLINK" > $modlist
543 505 [ "$VERBOSE" = "V" ] && cat $modlist
544 506 check_modlist $modlist
545 - if [ -n "$ON_CRYPTO_BINS" ]; then
546 - cryptotar="$ON_CRYPTO_BINS"
547 - if [ "$OBJD" = obj ]; then
548 - isa=$(uname -p)
549 - cryptotar=$(echo "$ON_CRYPTO_BINS" |
550 - sed -e s/.$isa.tar.bz2/-nd.$isa.tar.bz2/)
551 - fi
552 - [ -f "$cryptotar" ] || fail "crypto ($cryptotar) doesn't exist"
553 - cryptotree=$(mktemp -d /tmp/crypto.XXXXXX)
554 - [ -n "$cryptotree" ] || fail "can't create tree for crypto"
555 - unpack_crypto "$cryptotar" "$cryptotree"
556 - #
557 - # fixcrypto must come before fixglom, because
558 - # fixcrypto uses the unglommed path to find things in
559 - # the unpacked crypto.
560 - #
561 - fixcrypto $modlist "$cryptotree"
562 - fi
563 507 if [ "$GLOM" = "yes" ]; then
564 508 fixglom $modlist $GLOMNAME
565 509 filtimpl $modlist $IMPL
566 510 fi
567 511 if [[ -n "$files" && "$files" != All ]]; then
568 512 filtmod $modlist "$files"
569 513 fi
570 514
571 515 #
572 516 # Copy modules and create links. For architectures with both
573 517 # 32- and 64-bit modules, we'll likely have duplicate
574 518 # configuration files, so do those after filtering out the
575 519 # duplicates.
576 520 #
577 521 verbose "Copying files to ${INSTALL_FILES}..."
578 522
579 523 #
580 524 # The IFS is reset to the newline character so we can buffer the
581 525 # output of grep without piping it directly to copymod, otherwise
582 526 # if fail() is called, then it will deadlock in fail()'s wait call
583 527 #
584 528 OIFS="$IFS"
585 529 IFS="
586 530 "
587 531 set -- `grep -v "^CONF" $modlist`;
588 532 IFS="$OIFS"
589 533 for onemod in "$@"; do
590 534 copymod $onemod
591 535 done
592 536
593 537 OIFS="$IFS"
594 538 IFS="
595 539 "
596 540 set -- `grep "^CONF" $modlist | sort | uniq`;
597 541 IFS="$OIFS"
598 542 for onemod in "$@"; do
599 543 copymod $onemod
600 544 done
601 545
602 546 #
603 547 # Add the glommed kernel name to the root archive
604 548 #
605 549 if [[ $GLOM == "yes" ]];
606 550 then
607 551 filelist="$INSTALL_FILES/etc/boot/solaris/filelist.ramdisk"
608 552 mkdir -p `dirname $filelist`
609 553 echo "platform/$KARCH/$GLOMNAME" >$filelist
610 554 fi
611 555
612 556 STATE=1 # all kernel modules copied correctly
613 557 save_state
614 558 }
615 559
616 560 function kmdb_copy {
617 561 typeset src="$1"
618 562 typeset destdir="$2"
619 563
620 564 if [[ ! -d $dest ]] ; then
621 565 [[ "$VERBOSE" != "q" ]] && echo "mkdir -p $destdir"
622 566
623 567 mkdir -p $destdir || fail "failed to create $destdir"
624 568 fi
625 569
626 570 [[ "$VERBOSE" != "q" ]] && echo "cp $src $destdir"
627 571
628 572 cp $src $destdir || fail "failed to copy $src to $destdir"
629 573 }
630 574
631 575 function kmdb_copy_machkmods {
632 576 typeset modbase="$1"
633 577 typeset destdir="$2"
634 578 typeset dir=
635 579 typeset kmod=
636 580
637 581 [[ ! -d $modbase ]] && return
638 582
639 583 for dir in $(find $modbase -name kmod) ; do
640 584 set -- $(echo $dir |tr '/' ' ')
641 585
642 586 [[ $# -lt 2 ]] && fail "invalid mach kmod dir $dir"
643 587
644 588 shift $(($# - 2))
645 589 kmod=$1
646 590
647 591 [[ ! -f $dir/$kmod ]] && continue
648 592
649 593 kmdb_copy $dir/$kmod $destdir
650 594 done
651 595 }
652 596
653 597 function kmdb_copy_karchkmods {
654 598 typeset modbase="$1"
655 599 typeset destdir="$2"
656 600 typeset bitdir="$3"
657 601 typeset dir=
658 602 typeset kmod=
659 603 typeset karch=
660 604
661 605 [[ ! -d $modbase ]] && return
662 606
663 607 for dir in $(find $modbase -name kmod) ; do
664 608 set -- $(echo $dir | tr '/' ' ')
665 609
666 610 [[ $# -lt 3 ]] && fail "invalid karch kmod dir $dir"
667 611
668 612 shift $(($# - 3))
669 613 kmod=$1
670 614 bdir=$2
671 615
672 616 [[ $bdir != $bitdir ]] && continue
673 617 [[ ! -f $dir/$1 ]] && continue
674 618
675 619 kmdb_copy $dir/$kmod $destdir
676 620 done
677 621 }
678 622
679 623 function kmdb_copy_kmdbmod {
680 624 typeset kmdbpath="$1"
681 625 typeset destdir="$2"
682 626
683 627 [[ ! -f $kmdbpath ]] && return 1
684 628
685 629 kmdb_copy $kmdbpath $destdir
686 630
687 631 return 0
688 632 }
689 633
690 634 function copy_kmdb {
691 635 typeset kmdbtgtdir=$INSTALL_FILES/platform/$KARCH/$GLOMNAME/misc
692 636 typeset bitdirs=
693 637 typeset isadir=
694 638 typeset b64srcdir=
695 639 typeset b64tgtdir=
696 640 typeset b32srcdir=
697 641 typeset b32tgtdir=
698 642 typeset machdir=
699 643 typeset platdir=
700 644
701 645 if [[ $KMDB = "no" || ! -d $SRC/cmd/mdb ]] ; then
702 646 # The kmdb copy was suppressed or the workspace doesn't contain
703 647 # the mdb subtree. Either way, there's nothing to do.
704 648 STATE=2
705 649 save_state
706 650 return
707 651 fi
708 652
709 653 if [[ $(mach) = "i386" ]] ; then
710 654 isadir="intel"
711 655 b64srcdir="amd64"
712 656 b64tgtdir="amd64"
713 657 b32srcdir="ia32"
714 658 b32tgtdir="."
715 659 else
716 660 isadir="sparc"
717 661 b64srcdir="v9"
718 662 b64tgtdir="sparcv9"
719 663 b32srcdir="v7"
720 664 b32tgtdir="."
721 665 fi
722 666
723 667 typeset foundkmdb=no
724 668 typeset kmdbpath=
↓ open down ↓ |
152 lines elided |
↑ open up ↑ |
725 669 typeset destdir=
726 670
727 671 platdir=$INSTALL_FILES/platform/$KARCH/$GLOMNAME
728 672 if [[ $GLOM = "yes" ]] ; then
729 673 machdir=$platdir
730 674 else
731 675 machdir=$INSTALL_FILES/kernel
732 676 fi
733 677
734 678 srctrees=$SRC
735 - if [ -z "$ON_CRYPTO_BINS" ]; then
736 - echo "Warning: ON_CRYPTO_BINS not set; pre-signed" \
737 - "crypto not provided."
738 - fi
739 679 if [[ $WANT64 = "yes" ]] ; then
740 680 # kmdbmod for sparc and x86 are built and installed
741 681 # in different places
742 682 if [[ $(mach) = "i386" ]] ; then
743 683 kmdbpath=$SRC/cmd/mdb/$isadir/$b64srcdir/kmdb/kmdbmod
744 684 destdir=$machdir/misc/$b64tgtdir
745 685 else
746 686 kmdbpath=$SRC/cmd/mdb/$KARCH/$b64srcdir/kmdb/kmdbmod
747 687 destdir=$platdir/misc/$b64tgtdir
748 688 fi
749 689
750 690 if kmdb_copy_kmdbmod $kmdbpath $destdir ; then
751 691 foundkmdb="yes"
752 692
753 693 for tree in $srctrees; do
754 694 kmdb_copy_machkmods \
755 695 $tree/cmd/mdb/$isadir/$b64srcdir \
756 696 $machdir/kmdb/$b64tgtdir
757 697 kmdb_copy_karchkmods $tree/cmd/mdb/$KARCH \
758 698 $platdir/kmdb/$b64tgtdir $b64srcdir
759 699 done
760 700 fi
761 701 fi
762 702
763 703 if [[ $WANT32 = "yes" ]] ; then
764 704 kmdbpath=$SRC/cmd/mdb/$isadir/$b32srcdir/kmdb/kmdbmod
765 705 destdir=$machdir/misc/$b32tgtdir
766 706
767 707 if kmdb_copy_kmdbmod $kmdbpath $destdir ; then
768 708 foundkmdb="yes"
769 709
770 710 for tree in $srctrees; do
771 711 kmdb_copy_machkmods \
772 712 $tree/cmd/mdb/$isadir/$b32srcdir \
773 713 $machdir/kmdb/$b32tgtdir
774 714 kmdb_copy_karchkmods $tree/cmd/mdb/$KARCH \
775 715 $platdir/kmdb/$b32tgtdir $b32srcdir
776 716 done
777 717 fi
778 718 fi
779 719
780 720 # A kmdb-less workspace isn't fatal, but it is potentially problematic,
781 721 # as the changes made to uts may have altered something upon which kmdb
782 722 # depends. We will therefore remind the user that they haven't built it
783 723 # yet.
784 724 if [[ $foundkmdb != "yes" ]] ; then
785 725 echo "WARNING: kmdb isn't built, and won't be included"
786 726 fi
787 727
788 728 STATE=2
789 729 save_state
790 730 return
791 731 }
792 732
793 733 #
794 734 # Make tarfile
795 735 #
796 736
797 737 function make_tarfile {
798 738 echo "Creating tarfile $TARFILE"
799 739 test -d $INSTALL_FILES || fail "Can't find $INSTALL_FILES"
800 740 cd $INSTALL_FILES
801 741 rm -f $TARFILE files
802 742
803 743 # We don't want to change the permissions or ownership of pre-existing
804 744 # directories on the target machine, so we're going to take care to
805 745 # avoid including directories in the tarfile. On extraction, tar won't
806 746 # modify pre-existing directories, and will create non-existent ones as
807 747 # the user doing the extraction.
808 748 find . ! -type d -print |fgrep -vx './files' >files
809 749 tar cf $TARFILE -I files || fail "Couldn't create tarfile $TARFILE"
810 750 STATE=3
811 751 }
812 752
813 753 #
814 754 # Routines to copy files to the target machine
815 755 #
816 756
817 757 function remote_fail {
818 758 fail "" "$1" "" \
819 759 "Make sure that $TARGET_MACHINE is up." \
820 760 "Check .rhosts in the home directory of user $TARGET_USER on $TARGET_MACHINE." \
821 761 "Check /etc/hosts.equiv, /etc/passwd, and /etc/shadow." \
822 762 "Change permissions on $TARGET_MACHINE as necessary." \
823 763 "Then, use \"$INSTALL -R\" to resume the install." ""
824 764 }
825 765
826 766 function remote_install {
827 767 if [ "$IMODE" = "n" ]; then
828 768 STATE=4
829 769 return 0
830 770 fi
831 771 test -s $TARFILE || fail "$TARFILE missing or empty"
832 772 verbose "Installing system on $TARGET"
833 773 test -d $INSTALL_DIR || fail "Can't find $INSTALL_DIR"
834 774 cd $INSTALL_DIR
835 775 rm -f errors fatal nonfatal
836 776 if [ "$IMODE" = "T" ]; then
837 777 EMESG="Can't rcp to $TARGET"
838 778 touch errors
839 779 sh -e${SHV}c "$INSTALL_RCP $TARFILE $TARGET/Install.tar"
840 780 else
841 781 EMESG="Can't rsh to $TARGET_MACHINE"
842 782 rsh -l $TARGET_USER $TARGET_MACHINE \
843 783 "(cd $TARGET_DIR; /usr/bin/tar x${V}f -)" \
844 784 <$TARFILE 2>errors
845 785 fi
846 786 test $? -ne 0 && remote_fail "$EMESG"
847 787 cd $INSTALL_DIR
848 788 egrep "set time|warning|blocksize" errors >nonfatal
849 789 egrep -v "set time|warning|blocksize" errors >fatal
850 790 if [ -s fatal ]; then
851 791 echo "Fatal errors from rsh:"
852 792 cat fatal
853 793 remote_fail "Can't install on $TARGET_MACHINE"
854 794 fi
855 795 if [ -s nonfatal -a "$VERBOSE" != "q" ]; then
856 796 echo "Non-fatal errors from rsh:"
857 797 cat nonfatal
858 798 fi
859 799 rm -f fatal nonfatal errors
860 800 test "$IMODE" = "T" && echo "Files can be extracted on \
861 801 $TARGET_MACHINE using 'tar xvf $TARGET_DIR/Install.tar'"
862 802 STATE=4
863 803 }
864 804
865 805 function okexit {
866 806 cd /tmp
867 807 test "$CLEANUP" = c && remove_dir $INSTALL_DIR
868 808 save_state
869 809 rm -rf $modstatedir
870 810 rm -f $modlist
871 811 [ -n "$cryptotree" ] && rm -rf "$cryptotree"
872 812 verbose "Install complete"
873 813 exit 0
874 814 }
875 815
876 816 #
877 817 # Process options
878 818 #
879 819
880 820 RCOPTS=""
881 821 LIBCREATE="no"
882 822 LIBSRC=""
883 823 ENV_PATH=$CODEMGR_WS
884 824 OBJD="debug"
885 825 KMDB="yes"
886 826
887 827 test -s $INSTALL_RC && RCOPTS=`cat $INSTALL_RC`
888 828 set $INSTALL $DEFAULT_OPTIONS $RCOPTS $*
889 829 shift
890 830
891 831 while getopts acd:D:G:hi:k:Kl:Lmno:pPqRs:t:T:uvVw:xX36 opt
892 832 do
893 833 case $opt in
894 834 w) ENV_PATH="$OPTARG"; SRC="$ENV_PATH/usr/src";;
895 835 s) UTS="$OPTARG";;
896 836 k) KARCH="$OPTARG";;
897 837 t|T) TARGET="$OPTARG"; IMODE=$opt; CLEANUP="c";;
898 838 n) TARGET=""; IMODE="n"; CLEANUP="p";;
899 839 u) files="unix genunix";;
900 840 m) files="Modules";;
901 841 a) files="All";;
902 842 v|V|q) VERBOSE=$opt;;
903 843 c|p) CLEANUP=$opt;;
904 844 L) LIBCREATE="yes"; CLEANUP="c";;
905 845 l) LIBSRC="$OPTARG";;
906 846 D) INSTALL_LIB="$OPTARG";;
907 847 d) INSTALL_DIR="$OPTARG/$TRAILER";;
908 848 G) GLOM=yes; GLOMNAME="$OPTARG";;
909 849 P|X|x) echo "-$opt is obsolete; ignored";;
910 850 h) usage "${INSTALL}: installs unix and modules";;
911 851 R) x=$OPTIND; restore_state; OPTIND=$x;;
912 852 i) IMPL="$OPTARG";;
913 853 o) OBJD="$OPTARG";;
914 854 K) KMDB="no";;
915 855 3) WANT64="no";;
916 856 6) WANT32="no";;
917 857 \?) usage "Illegal option";;
918 858 esac
919 859 done
920 860 shift `expr $OPTIND - 1`
921 861
922 862 ENV_NAME=`basename $ENV_PATH`
923 863
924 864 #
925 865 # The rest of the command line is a list of individual files to copy.
926 866 # If non-null, this list overrides the -uma options.
927 867 #
928 868
929 869 if [[ $# -gt 0 ]] ; then
930 870 files="$*"
931 871 KMDB="no"
932 872 fi
933 873
934 874 case "$VERBOSE" in
935 875 v) V="v"; SHV="x";;
936 876 V) V="v"; SHV="x"; set -x;;
937 877 q) V=""; SHV="";;
938 878 esac
939 879
940 880 #
941 881 # Create temp directory for Install's files
942 882 #
943 883
944 884 tstmkdir $INSTALL_DIR
945 885
946 886 TARFILE=$INSTALL_DIR/Install.${KARCH}.tar
947 887 INSTALL_FILES=$INSTALL_DIR/$KARCH
948 888
949 889 #
950 890 # Extract the target machine and target directory from a target of the
951 891 # form [user@]machine:/dir .
952 892 #
953 893
954 894 if [ "$IMODE" != "n" ]; then
955 895 eval `echo $TARGET | nawk -F':' '{
956 896 if (NF != 2 || !length($1) || !length($2))
957 897 print "usage \"Invalid target\""
958 898 m = $1; d = $2
959 899 if ($1 ~ /@/) {
960 900 k = split($1, f, "@");
961 901 if (k != 2 || !length(f[1]) || !length (f[2]))
962 902 print "usage \"Invalid target\""
963 903 u = f[1]; m = f[2]
964 904 }
965 905 print "TARGET_USER=" u ";"
966 906 print "TARGET_MACHINE=" m ";"
967 907 print "TARGET_DIR=" d ";"
968 908 }'`
969 909 if [ -z "$TARGET_USER" ]; then
970 910 TARGET_USER=$LOGNAME
971 911 fi
972 912 fi
973 913
974 914 #
975 915 # Allow the use of library source or target for the install
976 916 #
977 917
978 918 if [ -n "$LIBSRC" ]; then
979 919 LIBSRC="`basename $LIBSRC .tar`.tar"
980 920 TARFILE=$INSTALL_LIB/$LIBSRC
981 921 test -s $TARFILE || fail "Can't find tarfile $TARFILE"
982 922 verbose "Installing from library tarfile $TARFILE"
983 923 STATE=3
984 924 elif [ "$LIBCREATE" = "yes" ]; then
985 925 tstmkdir $INSTALL_LIB
986 926 TARFILE="$INSTALL_LIB/${ENV_NAME}.${KARCH}.tar"
987 927 fi
988 928
989 929 #
990 930 # The next few lines allow recovery and activation with -R,
991 931 # and library installs with -l.
992 932 #
993 933
994 934 [[ $STATE -eq 1 ]] && copy_kmdb
995 935 [[ $STATE -eq 2 ]] && make_tarfile
996 936 [[ $STATE -eq 3 ]] && remote_install
997 937 [[ $STATE -eq 4 ]] && okexit
998 938
999 939 save_state
1000 940
1001 941 cd $DOT
1002 942 DOTDOT=`cd ..; pwd`
1003 943
1004 944 #
1005 945 # Try to be smart: if DOTDOT ends in uts, then infer UTS and KARCH from DOT
1006 946 # Otherwise, if SRC is set, infer UTS = $SRC/uts.
1007 947 #
1008 948
1009 949 if [ "`basename $DOTDOT`" = "uts" ]; then
1010 950 UTS=$DOTDOT
1011 951 KARCH=`basename $DOT`
1012 952 if [ ! -n "$SRC" ]; then
1013 953 SRC=`dirname $DOTDOT`
1014 954 verbose "Setting SRC to $SRC"
1015 955 fi
1016 956 export SRC
1017 957 fi
1018 958
1019 959 if [ -z "$UTS" -a -n "$SRC" ]; then
1020 960 UTS="${SRC}/uts"
1021 961 test -n "$KARCH" || fail "no karch specified (e.g. -k sun4u)"
1022 962 fi
1023 963
1024 964 if [ "$LIBCREATE" = "yes" ]; then
1025 965 TARFILE=$INSTALL_LIB/${ENV_NAME}.${KARCH}.tar
1026 966 else
1027 967 TARFILE=$INSTALL_DIR/Install.${KARCH}.tar
1028 968 fi
1029 969 INSTALL_FILES=$INSTALL_DIR/$KARCH
1030 970 save_state
1031 971
1032 972 cd $DOT
1033 973 test -z "$UTS" && fail 'Cannot find kernel sources -- $SRC not set'
1034 974 test -d "$UTS" || fail "${UTS}: no such directory"
1035 975
1036 976 #
1037 977 # Convert UTS into an absolute path.
1038 978 #
1039 979
1040 980 cd $UTS
1041 981 UTS=`pwd`
1042 982
1043 983 test "`basename $UTS`" = "uts" || \
1044 984 verbose "Warning: source path $UTS doesn't end in 'uts'"
1045 985
1046 986 remove_dir $INSTALL_DIR/$KARCH
1047 987 rm -f $TARFILE
1048 988
1049 989 copy_kernel # sets STATE=1 if successful
1050 990 copy_kmdb # sets STATE=2 if successful
1051 991 make_tarfile # sets STATE=3 if successful
1052 992 remote_install # sets STATE=4 if successful
1053 993
1054 994 okexit
↓ open down ↓ |
306 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX