Print this page
4108 remove ON_CRYPTO_BINS from tools
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
↓ open down ↓ |
328 lines elided |
↑ open up ↑ |
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 -# Unpack the crypto tarball into the given tree, then massage the
340 -# tree so that the binaries are all in objNN or debugNN directories.
341 -#
342 -function unpack_crypto {
343 - typeset tarfile=$1
344 - typeset ctop=$2
345 - [ -d "$ctop" ] || fail "Can't create tree for crypto modules."
346 -
347 - [ "$VERBOSE" = "V" ] && echo "unpacking crypto tarball into $ctop..."
348 - bzcat "$tarfile" | (cd "$ctop"; tar xf -)
349 -
350 - typeset root="$ctop/proto/root_$MACH"
351 - [ $OBJD = obj ] && root="$ctop/proto/root_$MACH-nd"
352 - [ -d "$root" ] || fail "Can't unpack crypto tarball."
353 -
354 - (cd "$root"; for d in platform kernel usr/kernel; do
355 - [ ! -d $d ] && continue
356 - find $d -type f -print
357 - done) | while read file; do
358 - typeset dir=$(dirname "$file")
359 - typeset base=$(basename "$file")
360 - typeset type=$(basename "$dir")
361 - if [ "$type" = amd64 ]; then
362 - newdir="$dir/${OBJD}64"
363 - elif [ "$type" = sparcv9 ]; then
364 - newdir="$dir/${OBJD}64"
365 - else
366 - newdir="$dir/${OBJD}32"
367 - fi
368 - mkdir -p "$root/$newdir"
369 - [ "$VERBOSE" = "V" ] && echo "mv $file $newdir"
370 - mv "$root/$file" "$root/$newdir"
371 - done
372 -}
373 -
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 339 # Copy a module, or create a link, as needed.
413 340 #
414 341
415 342 function copymod {
416 343 case $1 in
417 344 MOD)
418 345 targdir=$INSTALL_FILES/$4
419 346 tstmkdir $targdir
420 347 target=$targdir/$3
421 348 verbose "$INSTALL_CP $2/${OBJD}$5/$3 $target"
422 349 $INSTALL_CP $2/${OBJD}$5/$3 $target || \
423 350 fail "can't create $target"
424 351 ;;
425 352 SYMLINK)
426 353 targdir=$INSTALL_FILES/$4
427 354 tstmkdir $targdir
428 355 target=$targdir/$5
429 356 rm -f $target
430 357 verbose "ln -s $3 $target"
431 358 ln -s $3 $target || fail "can't create $target"
432 359 ;;
433 360 LINK)
434 361 targdir=$INSTALL_FILES/$5
435 362 tstmkdir $targdir
436 363 target=$targdir/$6
437 364 rm -f $target
438 365 verbose "ln $INSTALL_FILES/$3/$4 $target"
439 366 ln $INSTALL_FILES/$3/$4 $target || fail "can't create $target"
440 367 ;;
441 368 CONF)
442 369 target=$INSTALL_FILES/$3
443 370 tstmkdir `dirname $target`
444 371 conffile=`basename $3`
445 372 verbose "$INSTALL_CP $4/$conffile $target"
446 373 $INSTALL_CP $4/$conffile $target
447 374 ;;
448 375 *)
449 376 fail "unrecognized modlist entry: $*"
450 377 ;;
451 378 esac
452 379 }
453 380
454 381 # Sanity-check the given module list.
455 382 function check_modlist {
456 383 nawk '
457 384 BEGIN {
458 385 nfields["MOD"] = 6
459 386 nfields["CONF"] = 6
460 387 nfields["LINK"] = 7
461 388 nfields["SYMLINK"] = 7
462 389 }
463 390 {
464 391 # This also catches unknown tags.
465 392 if (nfields[$1] != NF) {
466 393 print "error: invalid modlist record:"
467 394 print $0
468 395 print "expected", nfields[$1], "fields, found", NF
469 396 status=1
470 397 }
471 398 }
472 399 END {
473 400 exit status
474 401 }
475 402 ' $1 || fail "Errors in kernel module list"
476 403 }
477 404
478 405 #
479 406 # Copy kernel modules to $INSTALL_DIR
480 407 #
481 408
482 409 function copy_kernel {
483 410
484 411 case $KARCH in
485 412 sun4*) ISA=sparc; MACH=sparc ;;
486 413 i86*) ISA=intel; MACH=i386 ;;
487 414 *) fail "${KARCH}: invalid kernel architecture";;
488 415 esac
489 416 export MACH
490 417
491 418 if [ "$GLOM" = "no" ]; then
492 419 verbose "Source = $UTS, ISA = $ISA, kernel = $KARCH"
493 420 else
494 421 verbose "Source = $UTS, ISA = $ISA, kernel = $KARCH, impl = $IMPL"
495 422 fi
496 423
497 424 test -d $KARCH || fail "${KARCH}: invalid kernel architecture"
498 425 test -d $ISA || fail "${ISA}: invalid instruction set architecture"
499 426
500 427 tstmkdir $INSTALL_FILES
501 428 rm -rf $modstatedir
502 429 tstmkdir $modstatedir
503 430 export MODSTATE=$modstatedir/state
504 431
505 432 #
506 433 # Figure out which "make" to use. dmake is faster than serial
507 434 # make, but dmake 7.3 has a bug that causes it to lose log
508 435 # output, which means the modlist might be incomplete.
509 436 #
510 437 make=dmake
511 438 dmvers=`$make -version`
512 439 if [ $? -ne 0 ]; then
513 440 make=/usr/ccs/bin/make
514 441 elif [[ $dmvers = *Distributed?Make?7.3* ]]; then
515 442 unset make
516 443 searchpath="/ws/onnv-tools/SUNWspro/SOS10/bin
517 444 /opt/SUNWspro/SOS10/bin
518 445 /opt/SUNWspro/bin"
519 446 for dmpath in $searchpath; do
520 447 verbose "Trying $dmpath/dmake"
521 448 if [ -x $dmpath/dmake ]; then
522 449 dmvers=`$dmpath/dmake -version`
523 450 if [[ $dmvers != *Distributed?Make?7.3* ]]; then
524 451 make="$dmpath/dmake"
525 452 break;
526 453 fi
527 454 fi
528 455 done
529 456 if [ -z $make ]; then
530 457 make=/usr/ccs/bin/make
531 458 echo "Warning: dmake 7.3 doesn't work with Install;" \
532 459 "using $make"
533 460 fi
534 461 fi
↓ open down ↓ |
113 lines elided |
↑ open up ↑ |
535 462
536 463 #
537 464 # Get a list of all modules, configuration files, and links
538 465 # that we might want to install.
539 466 #
540 467 verbose "Building module list..."
541 468 (cd $KARCH; MAKEFLAGS=e $make -K $MODSTATE modlist.karch) | \
542 469 egrep "^MOD|^CONF|^LINK|^SYMLINK" > $modlist
543 470 [ "$VERBOSE" = "V" ] && cat $modlist
544 471 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 472 if [ "$GLOM" = "yes" ]; then
564 473 fixglom $modlist $GLOMNAME
565 474 filtimpl $modlist $IMPL
566 475 fi
567 476 if [[ -n "$files" && "$files" != All ]]; then
568 477 filtmod $modlist "$files"
569 478 fi
570 479
571 480 #
572 481 # Copy modules and create links. For architectures with both
573 482 # 32- and 64-bit modules, we'll likely have duplicate
574 483 # configuration files, so do those after filtering out the
575 484 # duplicates.
576 485 #
577 486 verbose "Copying files to ${INSTALL_FILES}..."
578 487
579 488 #
580 489 # The IFS is reset to the newline character so we can buffer the
581 490 # output of grep without piping it directly to copymod, otherwise
582 491 # if fail() is called, then it will deadlock in fail()'s wait call
583 492 #
584 493 OIFS="$IFS"
585 494 IFS="
586 495 "
587 496 set -- `grep -v "^CONF" $modlist`;
588 497 IFS="$OIFS"
589 498 for onemod in "$@"; do
590 499 copymod $onemod
591 500 done
592 501
593 502 OIFS="$IFS"
594 503 IFS="
595 504 "
596 505 set -- `grep "^CONF" $modlist | sort | uniq`;
597 506 IFS="$OIFS"
598 507 for onemod in "$@"; do
599 508 copymod $onemod
600 509 done
601 510
602 511 #
603 512 # Add the glommed kernel name to the root archive
604 513 #
605 514 if [[ $GLOM == "yes" ]];
606 515 then
607 516 filelist="$INSTALL_FILES/etc/boot/solaris/filelist.ramdisk"
608 517 mkdir -p `dirname $filelist`
609 518 echo "platform/$KARCH/$GLOMNAME" >$filelist
610 519 fi
611 520
612 521 STATE=1 # all kernel modules copied correctly
613 522 save_state
614 523 }
615 524
616 525 function kmdb_copy {
617 526 typeset src="$1"
618 527 typeset destdir="$2"
619 528
620 529 if [[ ! -d $dest ]] ; then
621 530 [[ "$VERBOSE" != "q" ]] && echo "mkdir -p $destdir"
622 531
623 532 mkdir -p $destdir || fail "failed to create $destdir"
624 533 fi
625 534
626 535 [[ "$VERBOSE" != "q" ]] && echo "cp $src $destdir"
627 536
628 537 cp $src $destdir || fail "failed to copy $src to $destdir"
629 538 }
630 539
631 540 function kmdb_copy_machkmods {
632 541 typeset modbase="$1"
633 542 typeset destdir="$2"
634 543 typeset dir=
635 544 typeset kmod=
636 545
637 546 [[ ! -d $modbase ]] && return
638 547
639 548 for dir in $(find $modbase -name kmod) ; do
640 549 set -- $(echo $dir |tr '/' ' ')
641 550
642 551 [[ $# -lt 2 ]] && fail "invalid mach kmod dir $dir"
643 552
644 553 shift $(($# - 2))
645 554 kmod=$1
646 555
647 556 [[ ! -f $dir/$kmod ]] && continue
648 557
649 558 kmdb_copy $dir/$kmod $destdir
650 559 done
651 560 }
652 561
653 562 function kmdb_copy_karchkmods {
654 563 typeset modbase="$1"
655 564 typeset destdir="$2"
656 565 typeset bitdir="$3"
657 566 typeset dir=
658 567 typeset kmod=
659 568 typeset karch=
660 569
661 570 [[ ! -d $modbase ]] && return
662 571
663 572 for dir in $(find $modbase -name kmod) ; do
664 573 set -- $(echo $dir | tr '/' ' ')
665 574
666 575 [[ $# -lt 3 ]] && fail "invalid karch kmod dir $dir"
667 576
668 577 shift $(($# - 3))
669 578 kmod=$1
670 579 bdir=$2
671 580
672 581 [[ $bdir != $bitdir ]] && continue
673 582 [[ ! -f $dir/$1 ]] && continue
674 583
675 584 kmdb_copy $dir/$kmod $destdir
676 585 done
677 586 }
678 587
679 588 function kmdb_copy_kmdbmod {
680 589 typeset kmdbpath="$1"
681 590 typeset destdir="$2"
682 591
683 592 [[ ! -f $kmdbpath ]] && return 1
684 593
685 594 kmdb_copy $kmdbpath $destdir
686 595
687 596 return 0
688 597 }
689 598
690 599 function copy_kmdb {
691 600 typeset kmdbtgtdir=$INSTALL_FILES/platform/$KARCH/$GLOMNAME/misc
692 601 typeset bitdirs=
693 602 typeset isadir=
694 603 typeset b64srcdir=
695 604 typeset b64tgtdir=
696 605 typeset b32srcdir=
697 606 typeset b32tgtdir=
698 607 typeset machdir=
699 608 typeset platdir=
700 609
701 610 if [[ $KMDB = "no" || ! -d $SRC/cmd/mdb ]] ; then
702 611 # The kmdb copy was suppressed or the workspace doesn't contain
703 612 # the mdb subtree. Either way, there's nothing to do.
704 613 STATE=2
705 614 save_state
706 615 return
707 616 fi
708 617
709 618 if [[ $(mach) = "i386" ]] ; then
710 619 isadir="intel"
711 620 b64srcdir="amd64"
712 621 b64tgtdir="amd64"
713 622 b32srcdir="ia32"
714 623 b32tgtdir="."
715 624 else
716 625 isadir="sparc"
717 626 b64srcdir="v9"
718 627 b64tgtdir="sparcv9"
719 628 b32srcdir="v7"
720 629 b32tgtdir="."
721 630 fi
722 631
723 632 typeset foundkmdb=no
724 633 typeset kmdbpath=
725 634 typeset destdir=
726 635
↓ open down ↓ |
154 lines elided |
↑ open up ↑ |
727 636 platdir=$INSTALL_FILES/platform/$KARCH/$GLOMNAME
728 637 if [[ $GLOM = "yes" ]] ; then
729 638 machdir=$platdir
730 639 else
731 640 machdir=$INSTALL_FILES/kernel
732 641 fi
733 642
734 643 srctrees=$SRC
735 644 if [[ -d $SRC/../closed && "$CLOSED_IS_PRESENT" != no ]]; then
736 645 srctrees="$srctrees $SRC/../closed"
737 - else
738 - if [ -z "$ON_CRYPTO_BINS" ]; then
739 - echo "Warning: ON_CRYPTO_BINS not set; pre-signed" \
740 - "crypto not provided."
741 - fi
742 646 fi
743 647 if [[ $WANT64 = "yes" ]] ; then
744 648 # kmdbmod for sparc and x86 are built and installed
745 649 # in different places
746 650 if [[ $(mach) = "i386" ]] ; then
747 651 kmdbpath=$SRC/cmd/mdb/$isadir/$b64srcdir/kmdb/kmdbmod
748 652 destdir=$machdir/misc/$b64tgtdir
749 653 else
750 654 kmdbpath=$SRC/cmd/mdb/$KARCH/$b64srcdir/kmdb/kmdbmod
751 655 destdir=$platdir/misc/$b64tgtdir
752 656 fi
753 657
754 658 if kmdb_copy_kmdbmod $kmdbpath $destdir ; then
755 659 foundkmdb="yes"
756 660
757 661 for tree in $srctrees; do
758 662 kmdb_copy_machkmods \
759 663 $tree/cmd/mdb/$isadir/$b64srcdir \
760 664 $machdir/kmdb/$b64tgtdir
761 665 kmdb_copy_karchkmods $tree/cmd/mdb/$KARCH \
762 666 $platdir/kmdb/$b64tgtdir $b64srcdir
763 667 done
764 668 fi
765 669 fi
766 670
767 671 if [[ $WANT32 = "yes" ]] ; then
768 672 kmdbpath=$SRC/cmd/mdb/$isadir/$b32srcdir/kmdb/kmdbmod
769 673 destdir=$machdir/misc/$b32tgtdir
770 674
771 675 if kmdb_copy_kmdbmod $kmdbpath $destdir ; then
772 676 foundkmdb="yes"
773 677
774 678 for tree in $srctrees; do
775 679 kmdb_copy_machkmods \
776 680 $tree/cmd/mdb/$isadir/$b32srcdir \
777 681 $machdir/kmdb/$b32tgtdir
778 682 kmdb_copy_karchkmods $tree/cmd/mdb/$KARCH \
779 683 $platdir/kmdb/$b32tgtdir $b32srcdir
780 684 done
781 685 fi
782 686 fi
783 687
784 688 # A kmdb-less workspace isn't fatal, but it is potentially problematic,
785 689 # as the changes made to uts may have altered something upon which kmdb
786 690 # depends. We will therefore remind the user that they haven't built it
787 691 # yet.
788 692 if [[ $foundkmdb != "yes" ]] ; then
789 693 echo "WARNING: kmdb isn't built, and won't be included"
790 694 fi
791 695
792 696 STATE=2
793 697 save_state
794 698 return
795 699 }
796 700
797 701 #
798 702 # Make tarfile
799 703 #
800 704
801 705 function make_tarfile {
802 706 echo "Creating tarfile $TARFILE"
803 707 test -d $INSTALL_FILES || fail "Can't find $INSTALL_FILES"
804 708 cd $INSTALL_FILES
805 709 rm -f $TARFILE files
806 710
807 711 # We don't want to change the permissions or ownership of pre-existing
808 712 # directories on the target machine, so we're going to take care to
809 713 # avoid including directories in the tarfile. On extraction, tar won't
810 714 # modify pre-existing directories, and will create non-existent ones as
811 715 # the user doing the extraction.
812 716 find . ! -type d -print |fgrep -vx './files' >files
813 717 tar cf $TARFILE -I files || fail "Couldn't create tarfile $TARFILE"
814 718 STATE=3
815 719 }
816 720
817 721 #
818 722 # Routines to copy files to the target machine
819 723 #
820 724
821 725 function remote_fail {
822 726 fail "" "$1" "" \
823 727 "Make sure that $TARGET_MACHINE is up." \
824 728 "Check .rhosts in the home directory of user $TARGET_USER on $TARGET_MACHINE." \
825 729 "Check /etc/hosts.equiv, /etc/passwd, and /etc/shadow." \
826 730 "Change permissions on $TARGET_MACHINE as necessary." \
827 731 "Then, use \"$INSTALL -R\" to resume the install." ""
828 732 }
829 733
830 734 function remote_install {
831 735 if [ "$IMODE" = "n" ]; then
832 736 STATE=4
833 737 return 0
834 738 fi
835 739 test -s $TARFILE || fail "$TARFILE missing or empty"
836 740 verbose "Installing system on $TARGET"
837 741 test -d $INSTALL_DIR || fail "Can't find $INSTALL_DIR"
838 742 cd $INSTALL_DIR
839 743 rm -f errors fatal nonfatal
840 744 if [ "$IMODE" = "T" ]; then
841 745 EMESG="Can't rcp to $TARGET"
842 746 touch errors
843 747 sh -e${SHV}c "$INSTALL_RCP $TARFILE $TARGET/Install.tar"
844 748 else
845 749 EMESG="Can't rsh to $TARGET_MACHINE"
846 750 rsh -l $TARGET_USER $TARGET_MACHINE \
847 751 "(cd $TARGET_DIR; /usr/bin/tar x${V}f -)" \
848 752 <$TARFILE 2>errors
849 753 fi
850 754 test $? -ne 0 && remote_fail "$EMESG"
851 755 cd $INSTALL_DIR
852 756 egrep "set time|warning|blocksize" errors >nonfatal
853 757 egrep -v "set time|warning|blocksize" errors >fatal
854 758 if [ -s fatal ]; then
855 759 echo "Fatal errors from rsh:"
856 760 cat fatal
857 761 remote_fail "Can't install on $TARGET_MACHINE"
858 762 fi
859 763 if [ -s nonfatal -a "$VERBOSE" != "q" ]; then
860 764 echo "Non-fatal errors from rsh:"
861 765 cat nonfatal
862 766 fi
863 767 rm -f fatal nonfatal errors
864 768 test "$IMODE" = "T" && echo "Files can be extracted on \
↓ open down ↓ |
113 lines elided |
↑ open up ↑ |
865 769 $TARGET_MACHINE using 'tar xvf $TARGET_DIR/Install.tar'"
866 770 STATE=4
867 771 }
868 772
869 773 function okexit {
870 774 cd /tmp
871 775 test "$CLEANUP" = c && remove_dir $INSTALL_DIR
872 776 save_state
873 777 rm -rf $modstatedir
874 778 rm -f $modlist
875 - [ -n "$cryptotree" ] && rm -rf "$cryptotree"
876 779 verbose "Install complete"
877 780 exit 0
878 781 }
879 782
880 783 #
881 784 # Process options
882 785 #
883 786
884 787 RCOPTS=""
885 788 LIBCREATE="no"
886 789 LIBSRC=""
887 790 ENV_PATH=$CODEMGR_WS
888 791 OBJD="debug"
889 792 KMDB="yes"
890 793
891 794 test -s $INSTALL_RC && RCOPTS=`cat $INSTALL_RC`
892 795 set $INSTALL $DEFAULT_OPTIONS $RCOPTS $*
893 796 shift
894 797
895 798 while getopts acd:D:G:hi:k:Kl:Lmno:pPqRs:t:T:uvVw:xX36 opt
896 799 do
897 800 case $opt in
898 801 w) ENV_PATH="$OPTARG"; SRC="$ENV_PATH/usr/src";;
899 802 s) UTS="$OPTARG";;
900 803 k) KARCH="$OPTARG";;
901 804 t|T) TARGET="$OPTARG"; IMODE=$opt; CLEANUP="c";;
902 805 n) TARGET=""; IMODE="n"; CLEANUP="p";;
903 806 u) files="unix genunix";;
904 807 m) files="Modules";;
905 808 a) files="All";;
906 809 v|V|q) VERBOSE=$opt;;
907 810 c|p) CLEANUP=$opt;;
908 811 L) LIBCREATE="yes"; CLEANUP="c";;
909 812 l) LIBSRC="$OPTARG";;
910 813 D) INSTALL_LIB="$OPTARG";;
911 814 d) INSTALL_DIR="$OPTARG/$TRAILER";;
912 815 G) GLOM=yes; GLOMNAME="$OPTARG";;
913 816 P|X|x) echo "-$opt is obsolete; ignored";;
914 817 h) usage "${INSTALL}: installs unix and modules";;
915 818 R) x=$OPTIND; restore_state; OPTIND=$x;;
916 819 i) IMPL="$OPTARG";;
917 820 o) OBJD="$OPTARG";;
918 821 K) KMDB="no";;
919 822 3) WANT64="no";;
920 823 6) WANT32="no";;
921 824 \?) usage "Illegal option";;
922 825 esac
923 826 done
924 827 shift `expr $OPTIND - 1`
925 828
926 829 ENV_NAME=`basename $ENV_PATH`
927 830
928 831 #
929 832 # The rest of the command line is a list of individual files to copy.
930 833 # If non-null, this list overrides the -uma options.
931 834 #
932 835
933 836 if [[ $# -gt 0 ]] ; then
934 837 files="$*"
935 838 KMDB="no"
936 839 fi
937 840
938 841 case "$VERBOSE" in
939 842 v) V="v"; SHV="x";;
940 843 V) V="v"; SHV="x"; set -x;;
941 844 q) V=""; SHV="";;
942 845 esac
943 846
944 847 #
945 848 # Create temp directory for Install's files
946 849 #
947 850
948 851 tstmkdir $INSTALL_DIR
949 852
950 853 TARFILE=$INSTALL_DIR/Install.${KARCH}.tar
951 854 INSTALL_FILES=$INSTALL_DIR/$KARCH
952 855
953 856 #
954 857 # Extract the target machine and target directory from a target of the
955 858 # form [user@]machine:/dir .
956 859 #
957 860
958 861 if [ "$IMODE" != "n" ]; then
959 862 eval `echo $TARGET | nawk -F':' '{
960 863 if (NF != 2 || !length($1) || !length($2))
961 864 print "usage \"Invalid target\""
962 865 m = $1; d = $2
963 866 if ($1 ~ /@/) {
964 867 k = split($1, f, "@");
965 868 if (k != 2 || !length(f[1]) || !length (f[2]))
966 869 print "usage \"Invalid target\""
967 870 u = f[1]; m = f[2]
968 871 }
969 872 print "TARGET_USER=" u ";"
970 873 print "TARGET_MACHINE=" m ";"
971 874 print "TARGET_DIR=" d ";"
972 875 }'`
973 876 if [ -z "$TARGET_USER" ]; then
974 877 TARGET_USER=$LOGNAME
975 878 fi
976 879 fi
977 880
978 881 #
979 882 # Allow the use of library source or target for the install
980 883 #
981 884
982 885 if [ -n "$LIBSRC" ]; then
983 886 LIBSRC="`basename $LIBSRC .tar`.tar"
984 887 TARFILE=$INSTALL_LIB/$LIBSRC
985 888 test -s $TARFILE || fail "Can't find tarfile $TARFILE"
986 889 verbose "Installing from library tarfile $TARFILE"
987 890 STATE=3
988 891 elif [ "$LIBCREATE" = "yes" ]; then
989 892 tstmkdir $INSTALL_LIB
990 893 TARFILE="$INSTALL_LIB/${ENV_NAME}.${KARCH}.tar"
991 894 fi
992 895
993 896 #
994 897 # The next few lines allow recovery and activation with -R,
995 898 # and library installs with -l.
996 899 #
997 900
998 901 [[ $STATE -eq 1 ]] && copy_kmdb
999 902 [[ $STATE -eq 2 ]] && make_tarfile
1000 903 [[ $STATE -eq 3 ]] && remote_install
1001 904 [[ $STATE -eq 4 ]] && okexit
1002 905
1003 906 save_state
1004 907
1005 908 cd $DOT
1006 909 DOTDOT=`cd ..; pwd`
1007 910
1008 911 #
1009 912 # Try to be smart: if DOTDOT ends in uts, then infer UTS and KARCH from DOT
1010 913 # Otherwise, if SRC is set, infer UTS = $SRC/uts.
1011 914 #
1012 915
1013 916 if [ "`basename $DOTDOT`" = "uts" ]; then
1014 917 UTS=$DOTDOT
1015 918 KARCH=`basename $DOT`
1016 919 if [ ! -n "$SRC" ]; then
1017 920 SRC=`dirname $DOTDOT`
1018 921 verbose "Setting SRC to $SRC"
1019 922 fi
1020 923 export SRC
1021 924 fi
1022 925
1023 926 if [ -z "$UTS" -a -n "$SRC" ]; then
1024 927 UTS="${SRC}/uts"
1025 928 test -n "$KARCH" || fail "no karch specified (e.g. -k sun4u)"
1026 929 fi
1027 930
1028 931 if [ "$LIBCREATE" = "yes" ]; then
1029 932 TARFILE=$INSTALL_LIB/${ENV_NAME}.${KARCH}.tar
1030 933 else
1031 934 TARFILE=$INSTALL_DIR/Install.${KARCH}.tar
1032 935 fi
1033 936 INSTALL_FILES=$INSTALL_DIR/$KARCH
1034 937 save_state
1035 938
1036 939 cd $DOT
1037 940 test -z "$UTS" && fail 'Cannot find kernel sources -- $SRC not set'
1038 941 test -d "$UTS" || fail "${UTS}: no such directory"
1039 942
1040 943 #
1041 944 # Convert UTS into an absolute path.
1042 945 #
1043 946
1044 947 cd $UTS
1045 948 UTS=`pwd`
1046 949
1047 950 test "`basename $UTS`" = "uts" || \
1048 951 verbose "Warning: source path $UTS doesn't end in 'uts'"
1049 952
1050 953 remove_dir $INSTALL_DIR/$KARCH
1051 954 rm -f $TARFILE
1052 955
1053 956 copy_kernel # sets STATE=1 if successful
1054 957 copy_kmdb # sets STATE=2 if successful
1055 958 make_tarfile # sets STATE=3 if successful
1056 959 remote_install # sets STATE=4 if successful
1057 960
1058 961 okexit
↓ open down ↓ |
173 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX