Print this page
2675 EOF itutools
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/boot/scripts/root_archive.ksh
+++ new/usr/src/cmd/boot/scripts/root_archive.ksh
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.
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
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 2010 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 +# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
26 27
27 28 # utility to pack and unpack a boot/root archive
28 29 # both ufs and hsfs (iso9660) format archives are unpacked
29 30 # only ufs archives are generated
30 31 #
31 32 # usage: pack <archive> <root>
32 33 # unpack <archive> <root>
33 -# packmedia <solaris_image> <root>
34 -# unpackmedia <solaris_image> <root>
35 34 #
36 35 # Where <root> is the directory to unpack to and will be cleaned out
37 36 # if it exists.
38 37 #
39 -# In the case of (un)packmedia, the image is packed or unpacked to/from
40 -# Solaris media and all the things that don't go into the ramdisk image
41 -# are (un)cpio'd as well
42 -#
43 38
44 39 usage()
45 40 {
46 41 printf "usage: root_archive pack <archive> <root>\n"
47 42 printf " root_archive unpack <archive> <root>\n"
48 - printf " root_archive packmedia <solaris_image> <root>\n"
49 - printf " root_archive unpackmedia <solaris_image> <root>\n"
50 43 exit 1
51 44 }
52 45
53 46 cleanup()
54 47 {
55 48 if [ -d $MNT ] ; then
56 49 umount $MNT 2> /dev/null
57 50 rmdir $MNT
58 51 fi
59 52
60 53 lofiadm -d "$TMR" 2>/dev/null
61 54 if [ "$REALTHING" != true ] ; then
62 55 rm -f "$TMR"
63 56 fi
64 57 rm -f "$TMR.gz"
65 58 rm -f /tmp/flist$$
66 59 }
67 60
68 -preload_Gnome()
69 -{
70 - MEDIA="$1"
71 - MINIROOT="$2"
72 -
73 -
74 - (
75 - # Prepopulate the gconf database. This needs to be done and
76 - # done first for several reasons. 1) Archiving out the gnome
77 - # libraries and binaries causes the gconftool-2 to not run
78 - # appropriately at boot time. 2) The binaries and libraries
79 - # needed to run this are big and thus we want to archive
80 - # them separately. 3) Having schemas prepopluated in the
81 - # miniroot means faster boot times.
82 - #
83 -
84 - cd "$MINIROOT"
85 - HOME="./tmp/root"
86 - export HOME
87 - umask 0022
88 - mumble=.tmp_proto/root/etc/gconf/gconf.xml.defaults
89 - GCONF_CONFIG_SOURCE="xml:merged:$MINIROOT/$mumble"
90 - export GCONF_CONFIG_SOURCE
91 - SCHEMADIR="$MINIROOT/.tmp_proto/root/etc/gconf/schemas"
92 - export SCHEMADIR
93 - /usr/bin/gconftool-2 --makefile-install-rule \
94 - $SCHEMADIR/*.schemas >/dev/null 2>&1
95 - echo '
96 - xml:readwrite:/tmp/root/.gconf
97 - xml:readonly:/etc/gconf/gconf.xml.defaults
98 - ' > /"$MINIROOT"/.tmp_proto/root/etc/gconf/2/path
99 - )
100 -}
101 -
102 -archive_Gnome()
103 -{
104 - MEDIA="$1"
105 - MINIROOT="$2"
106 -
107 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
108 - RELEASE=`basename "$RELEASE"`
109 - CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
110 -
111 - # Create the gnome archive
112 - #
113 - (
114 - # usr/share gnome stuff
115 - cd "$MINIROOT"
116 - find usr/share/GConf usr/share/application-registry \
117 - usr/share/autostart usr/share/dtds \
118 - usr/share/emacs usr/share/gnome usr/share/gnome-2.0 \
119 - usr/share/gnome-background-properties \
120 - usr/share/gtk-engines usr/share/gui-install \
121 - usr/share/icon-naming-utils usr/share/control-center \
122 - usr/share/icons usr/share/locale usr/share/metacity \
123 - usr/share/mime usr/share/mime-info usr/share/pixmaps \
124 - usr/share/scrollkeeper usr/share/sgml usr/share/themes \
125 - usr/share/xml \
126 - -print > /tmp/gnome_share.$$ 2>/dev/null
127 -
128 - if [ ! -f /tmp/gnome_share.$$ ] ; then
129 - echo "/tmp/gnome_share.$$ file list not found."
130 - return
131 - fi
132 -
133 - # usr/lib gnome stuff
134 -
135 - find usr/lib/libgnome*\.so\.* \
136 - usr/lib/libgst*\.so\.* usr/lib/libgconf*\.so\.* \
137 - usr/lib/libgdk*\.so\.* usr/lib/libgtk*\.so\.* \
138 - usr/lib/libglade*\.so\.* usr/lib/libmetacity*\.so\.* \
139 - usr/lib/libfontconfig*\.so\.* usr/lib/libgmodule*\.so\.* \
140 - usr/lib/libgobject*\.so\.* usr/lib/libgthread*\.so\.* \
141 - usr/lib/libpopt*\.so\.* usr/lib/libstartup*\.so\.* \
142 - usr/lib/libexif*\.so\.* usr/lib/libtiff*\.so\.* \
143 - usr/lib/libstartup*\.so\.* \
144 - usr/lib/libexif*\.so\.* usr/lib/libORBit*\.so\.* \
145 - usr/lib/libmlib*\.so\.* usr/lib/libxsl*\.so\.* \
146 - usr/lib/libpango*\.so\.* usr/lib/libpng*\.so\.* \
147 - usr/lib/liboil*\.so\.* usr/lib/libbonobo*\.so\.* \
148 - usr/lib/libart*\.so\.* usr/lib/libcairo*\.so\.* \
149 - usr/lib/libjpeg*\.so\.* \
150 - usr/lib/libpolkit*\.so\.* \
151 - -print | egrep -v '\.so\.[0]$' > \
152 - /tmp/gnome_lib.$$ 2>/dev/null
153 -
154 - find usr/lib/nautilus usr/lib/pango usr/lib/iconv \
155 - usr/lib/metacity-dialog usr/lib/window-manager-settings \
156 - usr/lib/bonobo-2.0 usr/lib/bononbo usr/lib/gtk-2.0 \
157 - usr/lib/GConf usr/lib/bonobo-activation-server \
158 - usr/lib/python2.4 usr/lib/gstreamer-0.10 \
159 - usr/lib/gconf-sanity-check-2 usr/lib/gconfd \
160 - usr/lib/gnome-vfs-2.0 usr/lib/dbus-daemon \
161 - usr/lib/gnome-vfs-daemon usr/lib/gnome-settings-daemon \
162 - usr/lib/gnome_segv2 usr/lib/orbit-2.0 \
163 - usr/lib/libmlib \
164 - print > /tmp/gnome_libdir.$$ 2>/dev/null
165 -
166 - if [ ! -f /tmp/gnome_lib.$$ -a ! -f gnome_libdir.$$ ] ; then
167 - echo "/tmp/gnome_lib.$$ file list not found."
168 - return
169 - fi
170 -
171 - # /usr/sfw gnome stuff
172 - find usr/sfw/bin usr/sfw/include usr/sfw/share usr/sfw/src \
173 - -print > /tmp/gnome_sfw.$$ 2>/dev/null
174 -
175 - if [ ! -f /tmp/gnome_sfw.$$ ] ; then
176 - echo "/tmp/gnome_sfw.$$ file list not found."
177 - return
178 - fi
179 -
180 - # gnome app binaries usr/bin
181 - find usr/bin/gnome* usr/bin/gui-install usr/bin/bonobo* \
182 - usr/bin/gtk-* usr/bin/fax* usr/bin/gdk* usr/bin/gif2tiff \
183 - usr/bin/install-lan \
184 - usr/bin/metacity* usr/bin/gst-* usr/bin/gconftool-2 \
185 - usr/bin/pango* usr/bin/desktop* usr/bin/djpeg \
186 - usr/bin/notify-send usr/bin/oil-bugreport \
187 - usr/bin/bmp2tiff usr/bin/thembus-theme-applier \
188 - usr/bin/thumbnail usr/lib/update-* \
189 - usr/bin/ras2tiff usr/bin/raw2tiff usr/bin/rdjpgcom \
190 - usr/bin/thumbnail usr/bin/dbus* \
191 - usr/bin/tiff* usr/bin/rgb2ycbcr \
192 - usr/bin/fc-cache usr/bin/fc-list \
193 - -print > /tmp/gnome_bin.$$ 2>/dev/null
194 -
195 - if [ ! -f /tmp/gnome_bin.$$ ] ; then
196 - echo "/tmp/gnome_bin.$$ file list not found."
197 - return
198 - fi
199 -
200 - # Cat all the files together and create the gnome archive
201 - #
202 -
203 - cat /tmp/gnome_libdir.$$ /tmp/gnome_lib.$$ \
204 - /tmp/gnome_share.$$ /tmp/gnome_sfw.$$ /tmp/gnome_bin.$$ \
205 - > /tmp/gnome.$$
206 -
207 - if [ ! -f /tmp/gnome.$$ ] ; then
208 - echo "/tmp/gnome.$$ file not found."
209 - return
210 - fi
211 - # Save off this file in the miniroot for use later
212 - # when unpacking. Clean up old cruft if there.
213 - #
214 -
215 - if [ -f .tmp_proto/gnome_saved ]; then
216 - rm -f .tmp_proto/gnome_saved
217 - fi
218 -
219 - cp /tmp/gnome.$$ .tmp_proto/gnome_saved
220 -
221 - # Create gnome archive
222 - #
223 -
224 - cpio -ocmPuB < /tmp/gnome.$$ 2>/dev/null | bzip2 > \
225 - "$CPIO_DIR/gnome.cpio.bz2"
226 -
227 - # Remove files from miniroot that are in archive.
228 - # Create symlinks for files in archive
229 -
230 - rm -rf `cat /tmp/gnome_share.$$`
231 -
232 - for i in `cat /tmp/gnome_share.$$`
233 - do
234 - ln -s /tmp/root/$i $i 2>/dev/null
235 - done
236 -
237 - rm -rf `cat /tmp/gnome_lib.$$`
238 - for i in `cat /tmp/gnome_lib.$$`
239 - do
240 - ln -s /tmp/root/$i $i 2>/dev/null
241 - done
242 -
243 - rm -rf `cat /tmp/gnome_libdir.$$`
244 - for i in `cat /tmp/gnome_libdir.$$`
245 - do
246 - ln -s /tmp/root/$i $i 2>/dev/null
247 - done
248 -
249 - rm -rf `cat /tmp/gnome_sfw.$$`
250 - for i in `cat /tmp/gnome_sfw.$$`
251 - do
252 - ln -s /tmp/root/$i $i 2>/dev/null
253 - done
254 -
255 - rm -rf `cat /tmp/gnome_bin.$$`
256 - for i in `cat /tmp/gnome_bin.$$`
257 - do
258 - ln -s /tmp/root/$i $i 2>/dev/null
259 - done
260 - rm -f /tmp/gnome_share.$$
261 - rm -f /tmp/gnome_lib.$$
262 - rm -f /tmp/gnome_libdir.$$
263 - rm -f /tmp/gnome_bin.$$
264 - )
265 -}
266 -
267 -archive_JavaGUI()
268 -{
269 - MEDIA="$1"
270 - MINIROOT="$2"
271 -
272 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
273 - RELEASE=`basename "$RELEASE"`
274 -
275 - CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
276 -
277 - # Archive the java wizard components that are only used in the
278 - # non developer express path.
279 - #
280 - (
281 - # path is usr/lib/install/data
282 - cd "$MINIROOT"
283 - find usr/lib/install/data/wizards \
284 - -print > /tmp/java_ui.$$ 2>/dev/null
285 -
286 - if [ ! -f /tmp/java_ui.$$ ] ; then
287 - echo "/tmp/java_ui.$$ file list not found."
288 - return
289 - fi
290 -
291 - cpio -ocmPuB < /tmp/java_ui.$$ 2>/dev/null | bzip2 > \
292 - "$CPIO_DIR/javaui.cpio.bz2"
293 -
294 - rm -rf `cat /tmp/java_ui.$$`
295 - ln -s /tmp/root/usr/lib/install/data/wizards \
296 - usr/lib/install/data/wizards 2>/dev/null
297 -
298 - rm -f /tmp/java_ui.$$
299 -
300 - )
301 -}
302 -
303 -archive_Misc()
304 -{
305 - MEDIA="$1"
306 - MINIROOT="$2"
307 -
308 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
309 - RELEASE=`basename "$RELEASE"`
310 -
311 - CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
312 -
313 - # Archive misc stuff that is needed by non devex installer
314 - #
315 - (
316 - # usr/lib stuff
317 - cd "$MINIROOT"
318 - find usr/lib/lp -print > /tmp/lp.$$ 2>/dev/null
319 - if [ ! -f /tmp/lp.$$ ] ; then
320 - echo "/tmp/lp.$$ file list not found."
321 - return
322 - fi
323 -
324 - cpio -ocmPuB < /tmp/lp.$$ 2>/dev/null | bzip2 > \
325 - "$CPIO_DIR/lpmisc.cpio.bz2"
326 -
327 - rm -rf `cat /tmp/lp.$$`
328 - ln -s /tmp/root/usr/lib/lp usr/lib/lp 2>/dev/null
329 -
330 - rm -f /tmp/lp.$$
331 - )
332 -
333 -}
334 -
335 -archive_Perl()
336 -{
337 - MEDIA="$1"
338 - MINIROOT="$2"
339 -
340 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
341 - RELEASE=`basename "$RELEASE"`
342 -
343 - CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
344 -
345 - # Archive perl, it is only needed by gnome gui.
346 - #
347 - (
348 - # in usr
349 - cd "$MINIROOT"
350 - find usr/perl5 -print > /tmp/perl.$$ 2>/dev/null
351 -
352 - if [ ! -f /tmp/perl.$$ ] ; then
353 - echo "/tmp/perl.$$ file list not found."
354 - return
355 - fi
356 - cpio -ocmPuB < /tmp/perl.$$ 2>/dev/null | bzip2 > \
357 - "$CPIO_DIR/perl.cpio.bz2"
358 -
359 - rm -rf `cat /tmp/perl.$$` 2>/dev/null
360 - ln -s /tmp/root/usr/perl5 usr/perl5 2>/dev/null
361 -
362 - rm -f /tmp/perl.$$
363 - )
364 -}
365 -archive_X()
366 -{
367 - MEDIA="$1"
368 - MINIROOT="$2"
369 -
370 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
371 - RELEASE=`basename "$RELEASE"`
372 -
373 - CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
374 -
375 - # create the graphics and non-graphics X archive
376 - #
377 - (
378 - cd "$MINIROOT"
379 - find usr/openwin usr/dt usr/X11 -print 2> /dev/null |\
380 - cpio -ocmPuB 2> /dev/null | bzip2 > "$CPIO_DIR/X.cpio.bz2"
381 -
382 - find usr/openwin/bin/mkfontdir \
383 - usr/openwin/lib/installalias \
384 - usr/openwin/server/lib/libfont.so.1 \
385 - usr/openwin/server/lib/libtypesclr.so.0 \
386 - -print | cpio -ocmPuB 2> /dev/null | bzip2 > \
387 - "$CPIO_DIR/X_small.cpio.bz2"
388 -
389 - rm -rf usr/dt usr/openwin usr/X11
390 - ln -s /tmp/root/usr/dt usr/dt
391 - ln -s /tmp/root/usr/openwin usr/openwin
392 - ln -s /tmp/root/usr/X11 usr/X11
393 - )
394 -}
395 -
396 -archive_lu()
397 -{
398 - MEDIA="$1"
399 - MINIROOT="$2"
400 -
401 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
402 - RELEASE=`basename "$RELEASE"`
403 -
404 - CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
405 -
406 - (
407 - cd "$MINIROOT"
408 - find usr/lib/install usr/snadm usr/sbin usr/lib/locale \
409 - boot/grub boot/solaris/bootenv.rc \
410 - tmp/root/boot/grub tmp/root/boot/solaris/bootenv.rc \
411 - 2> /dev/null | cpio -ocmPuB 2> /dev/null | bzip2 \
412 - > "$CPIO_DIR"/lu.cpio.bz2
413 - ls platform > "$CPIO_DIR/lu.platforms"
414 - )
415 -}
416 -
417 -cleanout_pkgdata()
418 -{
419 - rm -Rf tmp/root/var/sadm/install tmp/root/var/sadm/pkg
420 -}
421 -
422 -packmedia()
423 -{
424 - MEDIA="$1"
425 - MINIROOT="$2"
426 -
427 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
428 - RELEASE=`basename "$RELEASE"`
429 - ARCHIVES="X X_small perl lpmisc javaui gnome"
430 -
431 - mkdir -p "$MEDIA/$RELEASE/Tools/Boot"
432 -
433 - if [ -d "$MINIROOT/platform/i86pc" ] ; then
434 - mkdir -p "$MEDIA/boot/amd64"
435 - mkdir -p "$MEDIA/boot/platform/i86pc/kernel"
436 - mkdir -p "$MEDIA/boot/platform/i86pc/kernel/amd64"
437 - mkdir -p "$MEDIA/boot/platform/i86xpv/kernel"
438 - mkdir -p "$MEDIA/boot/platform/i86xpv/kernel/amd64"
439 - cp "$MINIROOT/platform/i86pc/multiboot" "$MEDIA/boot"
440 - cp "$MINIROOT/platform/i86pc/kernel/unix" \
441 - "$MEDIA/boot/platform/i86pc/kernel/unix"
442 - cp "$MINIROOT/platform/i86pc/kernel/amd64/unix" \
443 - "$MEDIA/boot/platform/i86pc/kernel/amd64/unix"
444 - cp "$MINIROOT/platform/i86xpv/kernel/unix" \
445 - "$MEDIA/boot/platform/i86xpv/kernel/unix"
446 - cp "$MINIROOT/platform/i86xpv/kernel/amd64/unix" \
447 - "$MEDIA/boot/platform/i86xpv/kernel/amd64/unix"
448 - (
449 - cd "$MEDIA/$RELEASE/Tools/Boot"
450 - ln -sf ../../../boot/x86.miniroot
451 - ln -sf ../../../boot/multiboot
452 - ln -sf ../../../boot/platform/i86pc/kernel/unix
453 - ln -sf ../../../boot/platform/i86pc/kernel/amd64/unix
454 - ln -sf ../../../boot/platform/i86xpv/kernel/unix
455 - ln -sf ../../../boot/platform/i86xpv/kernel/amd64/unix
456 - ln -sf ../../../boot/grub/pxegrub
457 - )
458 - fi
459 -
460 - if [ -d "$MINIROOT/platform/sun4u" ] ; then
461 - mkdir -p "$MEDIA/boot"
462 - dd if="$MINIROOT/platform/sun4u/lib/fs/hsfs/bootblk" \
463 - of="$MEDIA/boot/hsfs.bootblock" \
464 - bs=1b oseek=1 count=15 conv=sync 2> /dev/null
465 - fi
466 -
467 - for arch in sun4u sun4v ; do
468 - if [ -d "$MINIROOT/platform/$arch" ] ; then
469 - archdir="$MEDIA/$RELEASE/Tools/Boot/platform/$arch"
470 - mkdir -p $archdir
471 - ln -sf ../../../../../boot/sparc.miniroot \
472 - "$archdir/boot_archive"
473 - cp "$MINIROOT/usr/platform/$arch/lib/fs/nfs/inetboot" \
474 - "$archdir"
475 - cp "$MINIROOT/platform/$arch/wanboot" \
476 - "$archdir"
477 - mkdir -p "$MEDIA/platform/$arch"
478 - ln -sf ../../boot/sparc.miniroot \
479 - "$MEDIA/platform/$arch/boot_archive"
480 - ln -sf ../../$RELEASE/Tools/Boot/platform/$arch/wanboot \
481 - "$MEDIA/platform/$arch/wanboot"
482 - fi
483 - done
484 -
485 - # archive package databases to conserve memory
486 - #
487 - (
488 - cd "$MINIROOT"
489 - find tmp/root/var/sadm/install tmp/root/var/sadm/pkg -print | \
490 - cpio -ocmPuB 2> /dev/null | bzip2 > \
491 - "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2"
492 -
493 - cleanout_pkgdata
494 - )
495 -
496 - archive_lu "$MEDIA" "$MINIROOT"
497 -
498 - archive_X "$MEDIA" "$MINIROOT"
499 -
500 - # Take out the gnome and java parts of the installer from
501 - # the miniroot. These are not required to boot the system
502 - # and start the installers.
503 -
504 - if [ -d "$MINIROOT/platform/i86pc" ] ; then
505 - preload_Gnome "$MEDIA" "$MINIROOT"
506 - archive_Gnome "$MEDIA" "$MINIROOT"
507 - archive_JavaGUI "$MEDIA" "$MINIROOT"
508 - archive_Misc "$MEDIA" "$MINIROOT"
509 - archive_Perl "$MEDIA" "$MINIROOT"
510 - pack "$MEDIA/boot/amd64/x86.miniroot"
511 -
512 - # Now that the 64-bit archives & miniroot have been created,
513 - # restore the files from archives and save the 64-bit
514 - # archives. Strip the 64-bit objects and create the
515 - # 32-bit archives and miniroot
516 -
517 - unpackmedia "$MEDIA" "$MINIROOT"
518 - cleanout_pkgdata
519 - mkdir -p "$MEDIA/$RELEASE/Tools/Boot/amd64"
520 - for i in $ARCHIVES; do
521 - mv "$MEDIA/$RELEASE/Tools/Boot/${i}.cpio.bz2" \
522 - "$MEDIA/$RELEASE/Tools/Boot/amd64"
523 - done
524 - if [ -z "$STRIP_AMD64" ]; then
525 - strip_amd64
526 - fi
527 -
528 - archive_X "$MEDIA" "$MINIROOT"
529 - archive_Gnome "$MEDIA" "$MINIROOT"
530 - archive_JavaGUI "$MEDIA" "$MINIROOT"
531 - archive_Perl "$MEDIA" "$MINIROOT"
532 - archive_Misc "$MEDIA" "$MINIROOT"
533 - fi
534 -
535 - # copy the install menu to menu.lst so we have a menu
536 - # on the install media
537 - #
538 - if [ -f "$MINIROOT/boot/grub/install_menu" ] ; then
539 - cp $MINIROOT/boot/grub/install_menu \
540 - $MEDIA/boot/grub/menu.lst
541 - fi
542 -
543 - #
544 - # jumpstart utilities in usr/sbin/install.d
545 - #
546 - if [ -d "$MINIROOT/usr/sbin/install.d" ] ; then
547 - (
548 - cd ${MINIROOT}
549 - find usr/sbin/install.d/chkprobe \
550 - -print | cpio -ocmPuB 2> /dev/null | bzip2 > \
551 - ${MEDIA}/${RELEASE}/Tools/Boot/usr_sbin_install_d.cpio.bz2
552 - )
553 - fi
554 -}
555 -
556 -unarchive_X()
557 -{
558 - MEDIA="$1"
559 - UNPACKED_ROOT="$2"
560 -
561 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
562 - RELEASE=`basename "$RELEASE"`
563 -
564 - CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
565 -
566 - # unpack X
567 - #
568 - (
569 - cd "$UNPACKED_ROOT"
570 - rm -rf usr/dt usr/openwin usr/X11
571 - bzcat "$CPIO_DIR/X.cpio.bz2" | cpio -icdmu 2> /dev/null
572 - )
573 -}
574 -
575 -unpackmedia()
576 -{
577 - MEDIA="$1"
578 - UNPACKED_ROOT="$2"
579 -
580 - RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
581 - RELEASE=`basename "$RELEASE"`
582 -
583 - unarchive_X "$MEDIA" "$UNPACKED_ROOT"
584 -
585 - # unpack package databases
586 - #
587 - (
588 - cd "$UNPACKED_ROOT"
589 - bzcat "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2" |
590 - cpio -icdmu 2> /dev/null
591 -
592 - if [ -d "$MINIROOT/platform/i86pc" ] ; then
593 -
594 - # unpack gnome, perl, java and misc
595 - # Remove symlinks left from unpacking x86.miniroot
596 - # so that unpacking subsequent archives will populate
597 - # appropriately.
598 - #
599 - rm -rf usr/perl5
600 - rm -rf usr/lib/install/data/wizards
601 - rm -rf usr/lib/lp
602 -
603 - # Gnome list saved off from packmedia
604 - for i in `cat .tmp_proto/gnome_saved`
605 - do
606 - rm -rf $i
607 - done
608 -
609 - bzcat "$MEDIA/$RELEASE/Tools/Boot/gnome.cpio.bz2" |
610 - cpio -icdmu 2>/dev/null
611 - bzcat "$MEDIA/$RELEASE/Tools/Boot/javaui.cpio.bz2" |
612 - cpio -icdmu 2>/dev/null
613 - bzcat "$MEDIA/$RELEASE/Tools/Boot/lpmisc.cpio.bz2" |
614 - cpio -icdmu 2>/dev/null
615 - bzcat "$MEDIA/$RELEASE/Tools/Boot/perl.cpio.bz2" |
616 - cpio -icdmu 2>/dev/null
617 - fi
618 - )
619 -}
620 -
621 61 do_unpack()
622 62 {
623 63 (
624 64 cd $MNT
625 65 find . -print | cpio -pdum "$UNPACKED_ROOT" 2> /dev/null
626 66 )
627 67 # increase the chances the unmount will succeed
628 68 umount -f $MNT
629 69 }
630 70
631 71 unpack()
632 72 {
633 73 MR=$1
634 74 if [ ! -f "$MR" ] ; then
635 75 printf "$MR: not found\n"
636 76 usage
637 77 fi
638 78
639 79 if [ `uname -i` = i86pc ] ; then
640 80 gzcat "$MR" > $TMR
641 81 else
642 82 REALTHING=true ; export REALTHING
643 83 TMR="$MR"
644 84 fi
645 85
646 86 LOFIDEV=`/usr/sbin/lofiadm -a $TMR`
647 87 if [ $? != 0 ] ; then
648 88 echo lofi plumb failed
649 89 exit 2
650 90 fi
651 91
652 92 mkdir -p $MNT
653 93
654 94 FSTYP=`fstyp $LOFIDEV`
655 95
656 96 if [ "$FSTYP" = ufs ] ; then
657 97 /usr/sbin/mount -o ro,nologging $LOFIDEV $MNT
658 98 do_unpack
659 99 elif [ "$FSTYP" = hsfs ] ; then
660 100 /usr/sbin/mount -F hsfs -o ro $LOFIDEV $MNT
661 101 do_unpack
662 102 else
663 103 printf "invalid root archive\n"
664 104 fi
665 105
666 106
667 107 rmdir $MNT
668 108 lofiadm -d $TMR ; LOFIDEV=
669 109 if [ "$REALTHING" != true ] ; then
670 110 rm $TMR
671 111 fi
672 112 }
673 113
674 114 compress()
675 115 {
676 116 SRC=$1
677 117 DST=$2
678 118
679 119 (
680 120 cd $SRC
681 121 filelist=`find .`
682 122
683 123 for file in $filelist ; do
684 124
685 125 file=`echo $file | sed s#^./##`
686 126
687 127 # copy all files over to preserve hard links
688 128 #
689 129 echo $file | cpio -pdum $DST 2> /dev/null
690 130
691 131 if [ -f $file ] && [ -s $file ] && [ ! -h $file ] ; then
692 132 fiocompress -mc $file $DST/$file &
693 133 fi
694 134
695 135 done
696 136
697 137 wait `pgrep fiocompress`
698 138
699 139 # now re-copy a couple of uncompressed files
700 140
701 141 if [ -d "$SRC/platform/i86pc" ] ; then
702 142 find `cat boot/solaris/filelist.ramdisk` -type file \
703 143 -print 2> /dev/null > /tmp/flist$$
704 144 find usr/kernel -type file -print 2> /dev/null \
705 145 >> /tmp/flist$$
706 146 # some of the files are replaced with links into
707 147 # tmp/root on the miniroot, so find the backing files
708 148 # from there as well and add them to the list ti
709 149 # be copied uncompressed
710 150 (
711 151 cd $SRC/tmp/root
712 152 find `cat ../../boot/solaris/filelist.ramdisk` \
713 153 -type file -print 2> /dev/null | \
714 154 sed 's#^#tmp/root/#' >> /tmp/flist$$
715 155 )
716 156 flist=`cat /tmp/flist$$`
717 157 (
718 158 cd $DST
719 159 rm -f $flist
720 160 )
721 161 for file in $flist ; do
722 162 echo $file | cpio -pdum $DST 2> /dev/null
723 163 done
724 164 else
725 165 find kernel platform -name unix | \
726 166 cpio -pdum $DST 2> /dev/null
727 167 find kernel platform -name genunix | cpio -pdum $DST \
728 168 2> /dev/null
729 169 find kernel platform -name platmod | cpio -pdum $DST \
730 170 2> /dev/null
731 171 find `find kernel platform -name cpu` | \
732 172 cpio -pdum $DST 2> /dev/null
733 173 find `find kernel platform -name kmdb\*` | \
734 174 cpio -pdum $DST 2> /dev/null
735 175 find kernel/misc/sparcv9/ctf kernel/fs/sparcv9/dcfs \
736 176 etc/system etc/name_to_major etc/path_to_inst \
737 177 etc/name_to_sysnum etc/driver_aliases \
738 178 etc/driver_classes etc/minor_perm | \
739 179 cpio -pdum $DST 2> /dev/null
740 180 fi
741 181 )
742 182 }
743 183
744 184 root_is_ramdisk()
745 185 {
746 186 grep -v "set root_is_ramdisk=" "$UNPACKED_ROOT"/etc/system | \
747 187 grep -v "set ramdisk_size=" > /tmp/system.$$
748 188 cat /tmp/system.$$ > "$UNPACKED_ROOT"/etc/system
749 189 rm /tmp/system.$$
750 190
751 191 echo set root_is_ramdisk=1 >> "$UNPACKED_ROOT"/etc/system
752 192 echo set ramdisk_size=$1 >> "$UNPACKED_ROOT"/etc/system
753 193 }
754 194
755 195 pack()
756 196 {
757 197 MR="$1"
758 198 [ -d "$UNPACKED_ROOT" ] || usage
759 199
760 200 # always compress if fiocompress exists
761 201 #
762 202 if [ -x /usr/sbin/fiocompress ] ; then
763 203 COMPRESS=true
764 204 fi
765 205
766 206 # Estimate image size and add %10 overhead for ufs stuff.
767 207 # Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem,
768 208 # e.g. zfs, in which the disk usage is less than the sum of the file
769 209 # sizes. The nawk code
770 210 #
771 211 # {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
772 212 #
773 213 # below rounds up the size of a file/directory, in bytes, to the
774 214 # next multiple of 1024. This mimics the behavior of ufs especially
775 215 # with directories. This results in a total size that's slightly
776 216 # bigger than if du was called on a ufs directory.
777 217 #
778 218 # if the operation in turn is compressing the files the amount
779 219 # of typical shrinkage is used to come up with a useful archive
780 220 # size
781 221 size=$(find "$UNPACKED_ROOT" -ls | nawk '
782 222 {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
783 223 END {print int(t * 1.10 / 1024)}')
784 224 if [ "$COMPRESS" = true ] ; then
785 225 size=`echo $size | nawk '{s = $1} END {print int(s * 0.6)}'`
786 226 fi
787 227
788 228 /usr/sbin/mkfile ${size}k "$TMR"
789 229
790 230 LOFIDEV=`/usr/sbin/lofiadm -a "$TMR"`
791 231 if [ $? != 0 ] ; then
792 232 echo lofi plumb failed
793 233 exit 2
794 234 fi
795 235
796 236 RLOFIDEV=`echo $LOFIDEV | sed s/lofi/rlofi/`
797 237 newfs $RLOFIDEV < /dev/null 2> /dev/null
798 238 mkdir -p $MNT
799 239 mount -o nologging $LOFIDEV $MNT
800 240 rmdir $MNT/lost+found
801 241
802 242 if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
803 243 root_is_ramdisk $size
804 244 fi
805 245
806 246 (
807 247 cd "$UNPACKED_ROOT"
808 248 if [ "$COMPRESS" = true ] ; then
809 249 compress . $MNT
810 250 else
811 251 find . -print | cpio -pdum $MNT 2> /dev/null
812 252 fi
813 253 )
814 254 lockfs -f $MNT
815 255 umount $MNT
816 256 rmdir $MNT
817 257
818 258 if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
819 259 "$UNPACKED_ROOT/usr/sbin/installboot" \
820 260 "$UNPACKED_ROOT/platform/sun4u/lib/fs/ufs/bootblk" \
821 261 $RLOFIDEV
822 262 fi
823 263
824 264 lofiadm -d $LOFIDEV
825 265 LOFIDEV=
826 266
827 267 rm -f "$TMR.gz"
828 268
829 269 if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
830 270 mv "$TMR" "$MR"
831 271 else
832 272 gzip -f "$TMR"
833 273 mv "$TMR.gz" "$MR"
834 274 fi
835 275
836 276 chmod a+r "$MR"
837 277 }
838 278
839 279 strip_amd64()
840 280 {
841 281 find "$UNPACKED_ROOT" -name amd64 -type directory | xargs rm -rf
842 282 }
843 283
844 284 # main
845 285 #
846 286
847 287 EXTRA_SPACE=0
848 288 STRIP_AMD64=
849 289 COMPRESS=
850 290
851 291 PATH=/usr/sbin:/usr/bin:/opt/sfw/bin ; export PATH
852 292
853 293 while getopts s:6c opt ; do
854 294 case $opt in
855 295 s) EXTRA_SPACE="$OPTARG"
856 296 ;;
857 297 6) STRIP_AMD64=false
858 298 ;;
859 299 c) COMPRESS=true
860 300 ;;
861 301 *) usage
862 302 ;;
863 303 esac
864 304 done
865 305 shift `expr $OPTIND - 1`
866 306
867 307 [ $# == 3 ] || usage
868 308
869 309 UNPACKED_ROOT="$3"
870 310 BASE="`pwd`"
871 311 MNT=/tmp/mnt$$
872 312 TMR=/tmp/mr$$
873 313 LOFIDEV=
874 314 MR="$2"
875 315
↓ open down ↓ |
245 lines elided |
↑ open up ↑ |
876 316 # sanity check
877 317 [ "$UNPACKED_ROOT" != "/" ] || usage
878 318
879 319 if [ "`dirname $MR`" = . ] ; then
880 320 MR="$BASE/$MR"
881 321 fi
882 322 if [ "`dirname $UNPACKED_ROOT`" = . ] ; then
883 323 UNPACKED_ROOT="$BASE/$UNPACKED_ROOT"
884 324 fi
885 325
886 -
887 -MEDIA="$MR"
888 -
889 326 trap cleanup EXIT
890 327
891 328 # always unpack into a fresh root
892 329 case $1 in
893 - unpack|unpackmedia)
330 + unpack)
894 331 rm -rf "$UNPACKED_ROOT"
895 332 mkdir -p "$UNPACKED_ROOT"
896 333 ;;
897 334 esac
898 335 [ -d "$UNPACKED_ROOT" ] || usage
899 336
900 337 case $1 in
901 - packmedia)
902 - packmedia "$MEDIA" "$UNPACKED_ROOT"
903 - if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
904 - pack "$MEDIA/boot/sparc.miniroot"
905 - else
906 - pack "$MEDIA/boot/x86.miniroot"
907 - fi
908 -
909 - ;;
910 - unpackmedia)
911 - if [ -f "$MEDIA/boot/sparc.miniroot" ] ; then
912 - unpack "$MEDIA/boot/sparc.miniroot"
913 - else
914 - unpack "$MEDIA/boot/x86.miniroot"
915 - unpack "$MEDIA/boot/amd64/x86.miniroot"
916 - fi
917 - unpackmedia "$MEDIA" "$UNPACKED_ROOT"
918 - ;;
919 338 pack) pack "$MR"
920 339 ;;
921 340 unpack) unpack "$MR"
922 341 ;;
923 342 *) usage
924 343 ;;
925 344 esac
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX