Print this page
2675 EOF itutools


   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #

  26 
  27 # utility to pack and unpack a boot/root archive
  28 # both ufs and hsfs (iso9660) format archives are unpacked
  29 # only ufs archives are generated
  30 #
  31 # usage: pack   <archive> <root>
  32 #        unpack <archive> <root>
  33 #        packmedia   <solaris_image> <root>
  34 #        unpackmedia <solaris_image> <root>
  35 #
  36 #   Where <root> is the directory to unpack to and will be cleaned out
  37 #   if it exists.
  38 #
  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 
  44 usage()
  45 {
  46         printf "usage: root_archive pack <archive> <root>\n"
  47         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         exit 1
  51 }
  52 
  53 cleanup()
  54 {
  55         if [ -d $MNT ] ; then
  56                 umount $MNT 2> /dev/null
  57                 rmdir $MNT
  58         fi
  59 
  60         lofiadm -d "$TMR" 2>/dev/null
  61         if [ "$REALTHING" != true ] ; then
  62                 rm -f "$TMR"
  63         fi
  64         rm -f "$TMR.gz"
  65         rm -f /tmp/flist$$
  66 }
  67 
  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 do_unpack()
 622 {
 623         (
 624                 cd $MNT
 625                 find . -print | cpio -pdum "$UNPACKED_ROOT" 2> /dev/null
 626         )
 627         # increase the chances the unmount will succeed
 628         umount -f $MNT
 629 }
 630 
 631 unpack()
 632 {
 633         MR=$1
 634         if [ ! -f "$MR" ] ; then
 635                 printf "$MR: not found\n"
 636                 usage
 637         fi
 638 
 639         if [ `uname -i` = i86pc ] ; then
 640                 gzcat "$MR" > $TMR


 866 
 867 [ $# == 3 ] || usage
 868 
 869 UNPACKED_ROOT="$3"
 870 BASE="`pwd`"
 871 MNT=/tmp/mnt$$
 872 TMR=/tmp/mr$$
 873 LOFIDEV=
 874 MR="$2"
 875 
 876 # sanity check
 877 [ "$UNPACKED_ROOT" != "/" ] || usage
 878 
 879 if [ "`dirname $MR`" = . ] ; then
 880         MR="$BASE/$MR"
 881 fi
 882 if [ "`dirname $UNPACKED_ROOT`" = . ] ; then
 883         UNPACKED_ROOT="$BASE/$UNPACKED_ROOT"
 884 fi
 885 
 886 
 887 MEDIA="$MR"
 888 
 889 trap cleanup EXIT
 890 
 891 # always unpack into a fresh root
 892 case $1 in
 893         unpack|unpackmedia)
 894                 rm -rf "$UNPACKED_ROOT"
 895                 mkdir -p "$UNPACKED_ROOT"
 896                 ;;
 897 esac
 898 [ -d "$UNPACKED_ROOT" ] || usage
 899 
 900 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         pack)   pack "$MR"
 920                 ;;
 921         unpack) unpack "$MR"
 922                 ;;
 923         *)      usage
 924                 ;;
 925 esac


   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  27 
  28 # utility to pack and unpack a boot/root archive
  29 # both ufs and hsfs (iso9660) format archives are unpacked
  30 # only ufs archives are generated
  31 #
  32 # usage: pack   <archive> <root>
  33 #        unpack <archive> <root>


  34 #
  35 #   Where <root> is the directory to unpack to and will be cleaned out
  36 #   if it exists.
  37 #




  38 
  39 usage()
  40 {
  41         printf "usage: root_archive pack <archive> <root>\n"
  42         printf "       root_archive unpack <archive> <root>\n"


  43         exit 1
  44 }
  45 
  46 cleanup()
  47 {
  48         if [ -d $MNT ] ; then
  49                 umount $MNT 2> /dev/null
  50                 rmdir $MNT
  51         fi
  52 
  53         lofiadm -d "$TMR" 2>/dev/null
  54         if [ "$REALTHING" != true ] ; then
  55                 rm -f "$TMR"
  56         fi
  57         rm -f "$TMR.gz"
  58         rm -f /tmp/flist$$
  59 }
  60 









































































































































































































































































































































































































































































































































































  61 do_unpack()
  62 {
  63         (
  64                 cd $MNT
  65                 find . -print | cpio -pdum "$UNPACKED_ROOT" 2> /dev/null
  66         )
  67         # increase the chances the unmount will succeed
  68         umount -f $MNT
  69 }
  70 
  71 unpack()
  72 {
  73         MR=$1
  74         if [ ! -f "$MR" ] ; then
  75                 printf "$MR: not found\n"
  76                 usage
  77         fi
  78 
  79         if [ `uname -i` = i86pc ] ; then
  80                 gzcat "$MR" > $TMR


 306 
 307 [ $# == 3 ] || usage
 308 
 309 UNPACKED_ROOT="$3"
 310 BASE="`pwd`"
 311 MNT=/tmp/mnt$$
 312 TMR=/tmp/mr$$
 313 LOFIDEV=
 314 MR="$2"
 315 
 316 # sanity check
 317 [ "$UNPACKED_ROOT" != "/" ] || usage
 318 
 319 if [ "`dirname $MR`" = . ] ; then
 320         MR="$BASE/$MR"
 321 fi
 322 if [ "`dirname $UNPACKED_ROOT`" = . ] ; then
 323         UNPACKED_ROOT="$BASE/$UNPACKED_ROOT"
 324 fi
 325 



 326 trap cleanup EXIT
 327 
 328 # always unpack into a fresh root
 329 case $1 in
 330         unpack)
 331                 rm -rf "$UNPACKED_ROOT"
 332                 mkdir -p "$UNPACKED_ROOT"
 333                 ;;
 334 esac
 335 [ -d "$UNPACKED_ROOT" ] || usage
 336 
 337 case $1 in


















 338         pack)   pack "$MR"
 339                 ;;
 340         unpack) unpack "$MR"
 341                 ;;
 342         *)      usage
 343                 ;;
 344 esac