12851Sjongkis#!/bin/ksh -p 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 61777Ssetje# Common Development and Distribution License (the "License"). 71777Ssetje# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 220Sstevel@tonic-gate 233446Smrj# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate# Use is subject to license terms. 250Sstevel@tonic-gate# 261777Ssetje# ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate# utility to pack and unpack a boot/root archive 290Sstevel@tonic-gate# both ufs and hsfs (iso9660) format archives are unpacked 300Sstevel@tonic-gate# only ufs archives are generated 310Sstevel@tonic-gate# 320Sstevel@tonic-gate# usage: pack <archive> <root> 330Sstevel@tonic-gate# unpack <archive> <root> 340Sstevel@tonic-gate# packmedia <solaris_image> <root> 350Sstevel@tonic-gate# unpackmedia <solaris_image> <root> 360Sstevel@tonic-gate# 370Sstevel@tonic-gate# Where <root> is the directory to unpack to and will be cleaned out 380Sstevel@tonic-gate# if it exists. 390Sstevel@tonic-gate# 400Sstevel@tonic-gate# In the case of (un)packmedia, the image is packed or unpacked to/from 410Sstevel@tonic-gate# Solaris media and all the things that don't go into the ramdisk image 420Sstevel@tonic-gate# are (un)cpio'd as well 430Sstevel@tonic-gate# 441777Ssetje# This utility is also used to pack parts (in essence the window system, 451777Ssetje# usr/dt and usr/openwin) of the non ramdisk SPARC 461777Ssetje# miniroot. (un)packmedia will recognize that they are being run a SPARC 471777Ssetje# miniroot and do the appropriate work. 481777Ssetje# 490Sstevel@tonic-gate 500Sstevel@tonic-gateusage() 510Sstevel@tonic-gate{ 520Sstevel@tonic-gate printf "usage: root_archive pack <archive> <root>\n" 530Sstevel@tonic-gate printf " root_archive unpack <archive> <root>\n" 540Sstevel@tonic-gate printf " root_archive packmedia <solaris_image> <root>\n" 550Sstevel@tonic-gate printf " root_archive unpackmedia <solaris_image> <root>\n" 560Sstevel@tonic-gate} 570Sstevel@tonic-gate 582334Ssetjecleanup() 592334Ssetje{ 602334Ssetje if [ -d $MNT ] ; then 612334Ssetje umount $MNT 2> /dev/null 622334Ssetje rmdir $MNT 632334Ssetje fi 642334Ssetje 652851Sjongkis lofiadm -d "$TMR" 2>/dev/null 662851Sjongkis rm -f "$TMR" "$TMR.gz" 672334Ssetje} 682334Ssetje 694889Ssjelinekarchive_Gnome() 704889Ssjelinek{ 714889Ssjelinek MEDIA="$1" 724889Ssjelinek MINIROOT="$2" 734889Ssjelinek 744889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 754889Ssjelinek RELEASE=`basename "$RELEASE"` 764889Ssjelinek 774889Ssjelinek if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 784889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/miniroot_extra" 794889Ssjelinek mkdir -p "$CPIO_DIR" 804889Ssjelinek else 814889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 824889Ssjelinek fi 834889Ssjelinek 844889Ssjelinek 854889Ssjelinek # Create the gnome archive 864889Ssjelinek # 874889Ssjelinek ( 884889Ssjelinek # Prepopulate the gconf database. This needs to be done and 894889Ssjelinek # done first for several reasons. 1) Archiving out the gnome 904889Ssjelinek # libraries and binaries causes the gconftool-2 to not run 914889Ssjelinek # appropriately at boot time. 2) The binaries and libraries 924889Ssjelinek # needed to run this are big and thus we want to archive 934889Ssjelinek # them separately. 3) Having schemas prepopluated in the 944889Ssjelinek # miniroot means faster boot times. 954889Ssjelinek # 964889Ssjelinek 974889Ssjelinek cd "$MINIROOT" 984889Ssjelinek HOME="./tmp/root" 994889Ssjelinek export HOME 1004889Ssjelinek umask 0022 1014889Ssjelinek GCONF_CONFIG_SOURCE="xml:merged:"$MINIROOT"/.tmp_proto/root/etc/gconf/gconf.xml.defaults" 1024889Ssjelinek export GCONF_CONFIG_SOURCE 1034889Ssjelinek SCHEMADIR="$MINIROOT/.tmp_proto/root/etc/gconf/schemas" 1044889Ssjelinek export SCHEMADIR 1054889Ssjelinek /usr/bin/gconftool-2 --makefile-install-rule $SCHEMADIR/*.schemas >/dev/null 2>&1 1064889Ssjelinek # usr/share gnome stuff 1074889Ssjelinek cd "$MINIROOT" 1084889Ssjelinek find usr/share/GConf usr/share/application-registry \ 1094889Ssjelinek usr/share/autostart usr/share/dbus-1 usr/share/dtds \ 1104889Ssjelinek usr/share/emacs usr/share/gnome usr/share/gnome-2.0 \ 1114889Ssjelinek usr/share/gnome-background-properties \ 1124889Ssjelinek usr/share/gtk-engines usr/share/gui-install \ 1134889Ssjelinek usr/share/icon-naming-utils usr/share/control-center \ 1144889Ssjelinek usr/share/icons usr/share/locale usr/share/metacity \ 1154889Ssjelinek usr/share/mime usr/share/mime-info usr/share/pixmaps \ 1164889Ssjelinek usr/share/scrollkeeper usr/share/sgml usr/share/themes \ 1174889Ssjelinek usr/share/xml \ 1184889Ssjelinek -print > /tmp/gnome_share.$$ 2>/dev/null 1194889Ssjelinek 1204889Ssjelinek if [ ! -f /tmp/gnome_share.$$ ] ; then 1214889Ssjelinek echo "/tmp/gnome_share.$$ file list not found." 1224889Ssjelinek return 1234889Ssjelinek fi 1244889Ssjelinek 1254889Ssjelinek # usr/lib gnome stuff 1264889Ssjelinek 1274889Ssjelinek find usr/lib/libgnome*\.so\.* \ 1284889Ssjelinek usr/lib/libgst*\.so\.* usr/lib/libgconf*\.so\.* \ 1294889Ssjelinek usr/lib/libgdk*\.so\.* usr/lib/libgtk*\.so\.* \ 1304889Ssjelinek usr/lib/libglade*\.so\.* usr/lib/libmetacity*\.so\.* \ 1314889Ssjelinek usr/lib/libfontconfig*\.so\.* usr/lib/libgmodule*\.so\.* \ 1324889Ssjelinek usr/lib/libgobject*\.so\.* usr/lib/libgthread*\.so\.* \ 1334889Ssjelinek usr/lib/libpopt*\.so\.* usr/lib/libstartup*\.so\.* \ 1344889Ssjelinek usr/lib/libexif*\.so\.* usr/lib/libtiff*\.so\.* \ 1354889Ssjelinek usr/lib/libdbus*\.so\.* usr/lib/libstartup*\.so\.* \ 1364889Ssjelinek usr/lib/libexif*\.so\.* usr/lib/libORBit*\.so\.* \ 1374889Ssjelinek usr/lib/libmlib*\.so\.* usr/lib/libxsl*\.so\.* \ 1384889Ssjelinek usr/lib/libpango*\.so\.* usr/lib/libpng*\.so\.* \ 1394889Ssjelinek usr/lib/liboil*\.so\.* usr/lib/libbonobo*\.so\.* \ 1404889Ssjelinek usr/lib/libart*\.so\.* usr/lib/libcairo*\.so\.* \ 1414889Ssjelinek usr/lib/libjpeg*\.so\.* \ 1424889Ssjelinek usr/lib/libpolkit*\.so\.* \ 1434889Ssjelinek -print | egrep -v '\.so\.[0]$' > \ 1444889Ssjelinek /tmp/gnome_lib.$$ 2>/dev/null 1454889Ssjelinek 1464889Ssjelinek find usr/lib/nautilus usr/lib/pango usr/lib/iconv \ 1474889Ssjelinek usr/lib/metacity-dialog usr/lib/window-manager-settings \ 1484889Ssjelinek usr/lib/bonobo-2.0 usr/lib/bononbo usr/lib/gtk-2.0 \ 1494889Ssjelinek usr/lib/GConf usr/lib/bonobo-activation-server \ 1504889Ssjelinek usr/lib/python2.4 usr/lib/gstreamer-0.10 \ 1514889Ssjelinek usr/lib/gconf-sanity-check-2 usr/lib/gconfd \ 1524889Ssjelinek usr/lib/gnome-vfs-2.0 usr/lib/dbus-daemon \ 1534889Ssjelinek usr/lib/gnome-vfs-daemon usr/lib/gnome-settings-daemon \ 1544889Ssjelinek usr/lib/gnome_segv2 usr/lib/orbit-2.0 \ 1554889Ssjelinek usr/lib/libmlib \ 1564889Ssjelinek print > /tmp/gnome_libdir.$$ 2>/dev/null 1574889Ssjelinek 1584889Ssjelinek if [ ! -f /tmp/gnome_lib.$$ -a ! -f gnome_libdir.$$ ] ; then 1594889Ssjelinek echo "/tmp/gnome_lib.$$ file list not found." 1604889Ssjelinek return 1614889Ssjelinek fi 1624889Ssjelinek 1634889Ssjelinek # /usr/sfw gnome stuff 1644889Ssjelinek find usr/sfw/bin usr/sfw/include usr/sfw/share usr/sfw/src \ 1654889Ssjelinek -print > /tmp/gnome_sfw.$$ 2>/dev/null 1664889Ssjelinek 1674889Ssjelinek if [ ! -f /tmp/gnome_sfw.$$ ] ; then 1684889Ssjelinek echo "/tmp/gnome_sfw.$$ file list not found." 1694889Ssjelinek return 1704889Ssjelinek fi 1714889Ssjelinek 1724889Ssjelinek # gnome app binaries usr/bin 1734889Ssjelinek find usr/bin/gnome* usr/bin/gui-install usr/bin/bonobo* \ 1744889Ssjelinek usr/bin/gtk-* usr/bin/fax* usr/bin/gdk* usr/bin/gif2tiff \ 1754889Ssjelinek usr/bin/install-lan \ 1764889Ssjelinek usr/bin/metacity* usr/bin/gst-* usr/bin/gconftool-2 \ 1774889Ssjelinek usr/bin/pango* usr/bin/desktop* usr/bin/djpeg \ 1784889Ssjelinek usr/bin/notify-send usr/bin/oil-bugreport \ 1794889Ssjelinek usr/bin/bmp2tiff usr/bin/thembus-theme-applier \ 1804889Ssjelinek usr/bin/thumbnail usr/lib/update-* \ 1814889Ssjelinek usr/bin/ras2tiff usr/bin/raw2tiff usr/bin/rdjpgcom \ 1824889Ssjelinek usr/bin/thumbnail usr/bin/dbus* \ 1834889Ssjelinek usr/bin/tiff* usr/bin/rgb2ycbcr \ 1844889Ssjelinek usr/bin/fc-cache usr/bin/fc-list \ 1854889Ssjelinek -print > /tmp/gnome_bin.$$ 2>/dev/null 1864889Ssjelinek 1874889Ssjelinek if [ ! -f /tmp/gnome_bin.$$ ] ; then 1884889Ssjelinek echo "/tmp/gnome_bin.$$ file list not found." 1894889Ssjelinek return 1904889Ssjelinek fi 1914889Ssjelinek 1924889Ssjelinek # Cat all the files together and create the gnome archive 1934889Ssjelinek # 1944889Ssjelinek 1954889Ssjelinek cat /tmp/gnome_libdir.$$ /tmp/gnome_lib.$$ \ 1964889Ssjelinek /tmp/gnome_share.$$ /tmp/gnome_sfw.$$ /tmp/gnome_bin.$$ \ 1974889Ssjelinek > /tmp/gnome.$$ 1984889Ssjelinek 1994889Ssjelinek if [ ! -f /tmp/gnome.$$ ] ; then 2004889Ssjelinek echo "/tmp/gnome.$$ file not found." 2014889Ssjelinek return 2024889Ssjelinek fi 2034889Ssjelinek # Save off this file in the miniroot for use later 2044889Ssjelinek # when unpacking. Clean up old cruft if there. 2054889Ssjelinek # 2064889Ssjelinek 2074889Ssjelinek if [ -f .tmp_proto/gnome_saved ]; then 2084889Ssjelinek rm -f .tmp_proto/gnome_saved 2094889Ssjelinek fi 2104889Ssjelinek 2114889Ssjelinek cp /tmp/gnome.$$ .tmp_proto/gnome_saved 2124889Ssjelinek 2134889Ssjelinek # Create gnome archive 2144889Ssjelinek # 2154889Ssjelinek 2164889Ssjelinek cpio -ocmPuB < /tmp/gnome.$$ 2>/dev/null | bzip2 > \ 2174889Ssjelinek "$CPIO_DIR/gnome.cpio.bz2" 2184889Ssjelinek 2194889Ssjelinek # Remove files from miniroot that are in archive. 2204889Ssjelinek # Create symlinks for files in archive 2214889Ssjelinek 2224889Ssjelinek rm -rf `cat /tmp/gnome_share.$$` 2234889Ssjelinek 2244889Ssjelinek for i in `cat /tmp/gnome_share.$$` 2254889Ssjelinek do 2264889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2274889Ssjelinek done 2284889Ssjelinek 2294889Ssjelinek rm -rf `cat /tmp/gnome_lib.$$` 2304889Ssjelinek for i in `cat /tmp/gnome_lib.$$` 2314889Ssjelinek do 2324889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2334889Ssjelinek done 2344889Ssjelinek 2354889Ssjelinek rm -rf `cat /tmp/gnome_libdir.$$` 2364889Ssjelinek for i in `cat /tmp/gnome_libdir.$$` 2374889Ssjelinek do 2384889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2394889Ssjelinek done 2404889Ssjelinek 2414889Ssjelinek rm -rf `cat /tmp/gnome_sfw.$$` 2424889Ssjelinek for i in `cat /tmp/gnome_sfw.$$` 2434889Ssjelinek do 2444889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2454889Ssjelinek done 2464889Ssjelinek 2474889Ssjelinek rm -rf `cat /tmp/gnome_bin.$$` 2484889Ssjelinek for i in `cat /tmp/gnome_bin.$$` 2494889Ssjelinek do 2504889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2514889Ssjelinek done 2524889Ssjelinek rm -f /tmp/gnome_share.$$ 2534889Ssjelinek rm -f /tmp/gnome_lib.$$ 2544889Ssjelinek rm -f /tmp/gnome_libdir.$$ 2554889Ssjelinek rm -f /tmp/gnome_bin.$$ 2564889Ssjelinek ) 2574889Ssjelinek} 2584889Ssjelinek 2594889Ssjelinekarchive_JavaGUI() 2604889Ssjelinek{ 2614889Ssjelinek MEDIA="$1" 2624889Ssjelinek MINIROOT="$2" 2634889Ssjelinek 2644889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 2654889Ssjelinek RELEASE=`basename "$RELEASE"` 2664889Ssjelinek 2674889Ssjelinek if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 2684889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/miniroot_extra" 2694889Ssjelinek mkdir -p "$CPIO_DIR" 2704889Ssjelinek else 2714889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 2724889Ssjelinek fi 2734889Ssjelinek 2744889Ssjelinek # Archive the java wizard components that are only used in the 2754889Ssjelinek # non developer express path. 2764889Ssjelinek # 2774889Ssjelinek ( 2784889Ssjelinek # path is usr/lib/install/data 2794889Ssjelinek cd "$MINIROOT" 2804889Ssjelinek find usr/lib/install/data/wizards \ 2814889Ssjelinek -print > /tmp/java_ui.$$ 2>/dev/null 2824889Ssjelinek 2834889Ssjelinek if [ ! -f /tmp/java_ui.$$ ] ; then 2844889Ssjelinek echo "/tmp/java_ui.$$ file list not found." 2854889Ssjelinek return 2864889Ssjelinek fi 2874889Ssjelinek 2884889Ssjelinek cpio -ocmPuB < /tmp/java_ui.$$ 2>/dev/null | bzip2 > \ 2894889Ssjelinek "$CPIO_DIR/javaui.cpio.bz2" 2904889Ssjelinek 2914889Ssjelinek rm -rf `cat /tmp/java_ui.$$` 2924889Ssjelinek ln -s /tmp/root/usr/lib/install/data/wizards usr/lib/install/data/wizards 2>/dev/null 2934889Ssjelinek 2944889Ssjelinek rm -f /tmp/java_ui.$$ 2954889Ssjelinek 2964889Ssjelinek ) 2974889Ssjelinek} 2984889Ssjelinek 2994889Ssjelinekarchive_Misc() 3004889Ssjelinek{ 3014889Ssjelinek MEDIA="$1" 3024889Ssjelinek MINIROOT="$2" 3034889Ssjelinek 3044889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 3054889Ssjelinek RELEASE=`basename "$RELEASE"` 3064889Ssjelinek 3074889Ssjelinek if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 3084889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/miniroot_extra" 3094889Ssjelinek mkdir -p "$CPIO_DIR" 3104889Ssjelinek else 3114889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 3124889Ssjelinek fi 3134889Ssjelinek 3144889Ssjelinek # Archive misc stuff that is needed by non devex installer 3154889Ssjelinek # 3164889Ssjelinek ( 3174889Ssjelinek # usr/lib stuff 3184889Ssjelinek cd "$MINIROOT" 3194889Ssjelinek find usr/lib/lp -print > /tmp/lp.$$ 2>/dev/null 3204889Ssjelinek if [ ! -f /tmp/lp.$$ ] ; then 3214889Ssjelinek echo "/tmp/lp.$$ file list not found." 3224889Ssjelinek return 3234889Ssjelinek fi 3244889Ssjelinek 3254889Ssjelinek cpio -ocmPuB < /tmp/lp.$$ 2>/dev/null | bzip2 > \ 3264889Ssjelinek "$CPIO_DIR/lpmisc.cpio.bz2" 3274889Ssjelinek 3284889Ssjelinek rm -rf `cat /tmp/lp.$$` 3294889Ssjelinek ln -s /tmp/root/usr/lib/lp usr/lib/lp 2>/dev/null 3304889Ssjelinek 3314889Ssjelinek rm -f /tmp/lp.$$ 3324889Ssjelinek ) 3334889Ssjelinek 3344889Ssjelinek} 3354889Ssjelinek 3364889Ssjelinekarchive_Perl() 3374889Ssjelinek{ 3384889Ssjelinek MEDIA="$1" 3394889Ssjelinek MINIROOT="$2" 3404889Ssjelinek 3414889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 3424889Ssjelinek RELEASE=`basename "$RELEASE"` 3434889Ssjelinek 3444889Ssjelinek if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 3454889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/miniroot_extra" 3464889Ssjelinek mkdir -p "$CPIO_DIR" 3474889Ssjelinek else 3484889Ssjelinek CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 3494889Ssjelinek fi 3504889Ssjelinek 3514889Ssjelinek # Archive perl, it is only needed by gnome gui. 3524889Ssjelinek # 3534889Ssjelinek ( 3544889Ssjelinek # in usr 3554889Ssjelinek cd "$MINIROOT" 3564889Ssjelinek find usr/perl5 -print > /tmp/perl.$$ 2>/dev/null 3574889Ssjelinek 3584889Ssjelinek if [ ! -f /tmp/perl.$$ ] ; then 3594889Ssjelinek echo "/tmp/perl.$$ file list not found." 3604889Ssjelinek return 3614889Ssjelinek fi 3624889Ssjelinek cpio -ocmPuB < /tmp/perl.$$ 2>/dev/null | bzip2 > \ 3634889Ssjelinek "$CPIO_DIR/perl.cpio.bz2" 3644889Ssjelinek 3654889Ssjelinek rm -rf `cat /tmp/perl.$$` 2>/dev/null 3664889Ssjelinek ln -s /tmp/root/perl5 usr/perl5 2>/dev/null 3674889Ssjelinek 3684889Ssjelinek rm -f /tmp/perl.$$ 3694889Ssjelinek ) 3704889Ssjelinek} 3711777Ssetjearchive_X() 3720Sstevel@tonic-gate{ 3731777Ssetje MEDIA="$1" 3741777Ssetje MINIROOT="$2" 3750Sstevel@tonic-gate 3761777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 3771777Ssetje RELEASE=`basename "$RELEASE"` 3780Sstevel@tonic-gate 3791777Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 3801777Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/miniroot_extra" 3811777Ssetje mkdir -p "$CPIO_DIR" 3821777Ssetje else 3831777Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 3841777Ssetje fi 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate # create the graphics and non-graphics X archive 3870Sstevel@tonic-gate # 3882851Sjongkis ( 3894889Ssjelinek cd "$MINIROOT" 3904889Ssjelinek find usr/openwin usr/dt usr/X11 -print 2> /dev/null |\ 3912851Sjongkis cpio -ocmPuB 2> /dev/null | bzip2 > "$CPIO_DIR/X.cpio.bz2" 3920Sstevel@tonic-gate 3934889Ssjelinek find usr/openwin/bin/mkfontdir \ 3944889Ssjelinek usr/openwin/lib/installalias \ 3954889Ssjelinek usr/openwin/server/lib/libfont.so.1 \ 3964889Ssjelinek usr/openwin/server/lib/libtypesclr.so.0 \ 3972851Sjongkis -print | cpio -ocmPuB 2> /dev/null | bzip2 > \ 3982851Sjongkis "$CPIO_DIR/X_small.cpio.bz2" 3990Sstevel@tonic-gate 4004889Ssjelinek rm -rf usr/dt usr/openwin usr/X11 4014889Ssjelinek ln -s /tmp/root/usr/dt usr/dt 4024889Ssjelinek ln -s /tmp/root/usr/openwin usr/openwin 4034889Ssjelinek ln -s /tmp/root/usr/X11 usr/X11 4042851Sjongkis ) 4051777Ssetje} 4061777Ssetje 4071777Ssetjepackmedia() 4081777Ssetje{ 4091777Ssetje MEDIA="$1" 4101777Ssetje MINIROOT="$2" 4111777Ssetje 4121777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 4131777Ssetje RELEASE=`basename "$RELEASE"` 4141777Ssetje 4151777Ssetje mkdir -p "$MEDIA/$RELEASE/Tools/Boot" 416*5084Sjohnlev mkdir -p "$MEDIA/boot/amd64" 4173446Smrj mkdir -p "$MEDIA/boot/platform/i86pc/kernel" 418*5084Sjohnlev mkdir -p "$MEDIA/boot/platform/i86pc/kernel/amd64" 419*5084Sjohnlev mkdir -p "$MEDIA/boot/platform/i86xpv/kernel" 420*5084Sjohnlev mkdir -p "$MEDIA/boot/platform/i86xpv/kernel/amd64" 4211777Ssetje 4221777Ssetje # archive package databases to conserve memory 4231777Ssetje # 4242851Sjongkis ( 4252851Sjongkis cd "$MINIROOT" 4262851Sjongkis find tmp/root/var/sadm/install tmp/root/var/sadm/pkg -print | \ 4272851Sjongkis cpio -ocmPuB 2> /dev/null | bzip2 > \ 4282851Sjongkis "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2" 4292851Sjongkis ) 4301777Ssetje 4311777Ssetje rm -rf "$MINIROOT/tmp/root/var/sadm/install" 4321777Ssetje rm -rf "$MINIROOT/tmp/root/var/sadm/pkg" 4331777Ssetje 4342595Ssetje archive_X "$MEDIA" "$MINIROOT" 4352595Ssetje 4364889Ssjelinek # Take out the gnome and java parts of the installer from 4374889Ssjelinek # the miniroot. These are not required to boot the system 4384889Ssjelinek # and start the installers. 4394889Ssjelinek 4404889Ssjelinek archive_Gnome "$MEDIA" "$MINIROOT" 4414889Ssjelinek archive_JavaGUI "$MEDIA" "$MINIROOT" 4424889Ssjelinek archive_Perl "$MEDIA" "$MINIROOT" 4434889Ssjelinek archive_Misc "$MEDIA" "$MINIROOT" 4444889Ssjelinek 4451777Ssetje cp "$MINIROOT/platform/i86pc/multiboot" "$MEDIA/boot" 4463446Smrj cp "$MINIROOT/platform/i86pc/kernel/unix" \ 4473446Smrj "$MEDIA/boot/platform/i86pc/kernel/unix" 448*5084Sjohnlev cp "$MINIROOT/platform/i86pc/kernel/amd64/unix" \ 449*5084Sjohnlev "$MEDIA/boot/platform/i86pc/kernel/amd64/unix" 450*5084Sjohnlev cp "$MINIROOT/platform/i86xpv/kernel/unix" \ 451*5084Sjohnlev "$MEDIA/boot/platform/i86xpv/kernel/unix" 452*5084Sjohnlev cp "$MINIROOT/platform/i86xpv/kernel/amd64/unix" \ 453*5084Sjohnlev "$MEDIA/boot/platform/i86xpv/kernel/amd64/unix" 4540Sstevel@tonic-gate 4551821Ssetje # copy the install menu to menu.lst so we have a menu 4561821Ssetje # on the install media 4571821Ssetje # 4581821Ssetje if [ -f "${MINIROOT}/boot/grub/install_menu" ] ; then 4591821Ssetje cp ${MINIROOT}/boot/grub/install_menu \ 4601821Ssetje ${MEDIA}/boot/grub/menu.lst 4611821Ssetje fi 4621821Ssetje 4632851Sjongkis ( 4642851Sjongkis cd "$MEDIA/$RELEASE/Tools/Boot" 4652851Sjongkis ln -sf ../../../boot/x86.miniroot 466*5084Sjohnlev ln -sf ../../../boot/platform/i86pc/kernel/unix 467*5084Sjohnlev ln -sf ../../../boot/platform/i86pc/kernel/amd64/unix 468*5084Sjohnlev ln -sf ../../../boot/platform/i86xpv/kernel/unix 469*5084Sjohnlev ln -sf ../../../boot/platform/i86xpv/kernel/amd64/unix 4702851Sjongkis ln -sf ../../../boot/multiboot 4712851Sjongkis ln -sf ../../../boot/grub/pxegrub 4722851Sjongkis ) 4731777Ssetje} 4740Sstevel@tonic-gate 4751777Ssetjeunarchive_X() 4761777Ssetje{ 4771777Ssetje MEDIA="$1" 4781777Ssetje UNPACKED_ROOT="$2" 4791777Ssetje 4801777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 4811777Ssetje RELEASE=`basename "$RELEASE"` 4821777Ssetje 4831777Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 4841777Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/miniroot_extra" 4851777Ssetje else 4861777Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 4870Sstevel@tonic-gate fi 4881777Ssetje 4891777Ssetje # unpack X 4901777Ssetje # 4912851Sjongkis ( 4924889Ssjelinek cd "$UNPACKED_ROOT" 4934889Ssjelinek rm -rf usr/dt usr/openwin usr/X11 4942851Sjongkis bzcat "$CPIO_DIR/X.cpio.bz2" | cpio -icdmu 2> /dev/null 4952851Sjongkis ) 4960Sstevel@tonic-gate} 4970Sstevel@tonic-gate 4980Sstevel@tonic-gateunpackmedia() 4991777Ssetje{ 5001777Ssetje MEDIA="$1" 5011777Ssetje UNPACKED_ROOT="$2" 5020Sstevel@tonic-gate 5031777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 5041777Ssetje RELEASE=`basename "$RELEASE"` 5051777Ssetje 5061777Ssetje unarchive_X "$MEDIA" "$UNPACKED_ROOT" 5070Sstevel@tonic-gate 5080Sstevel@tonic-gate # unpack package databases 5090Sstevel@tonic-gate # 5102851Sjongkis ( 5112851Sjongkis cd "$UNPACKED_ROOT" 5122851Sjongkis bzcat "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2" | 5132851Sjongkis cpio -icdmu 2> /dev/null 5144889Ssjelinek 5154889Ssjelinek # unpack gnome, perl, java and misc 5164889Ssjelinek # Remove symlinks left from unpacking x86.miniroot so that 5174889Ssjelinek # unpacking subsequent archives will populate appropriately. 5184889Ssjelinek # 5194889Ssjelinek rm -rf usr/perl5 5204889Ssjelinek rm -rf usr/lib/install/data/wizards 5214889Ssjelinek rm -rf usr/lib/lp 5224889Ssjelinek 5234889Ssjelinek # Gnome list saved off from packmedia 5244889Ssjelinek for i in `cat .tmp_proto/gnome_saved` 5254889Ssjelinek do 5264889Ssjelinek rm -rf $i 5274889Ssjelinek done 5284889Ssjelinek 5294889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/gnome.cpio.bz2" | 5304889Ssjelinek cpio -icdmu 2>/dev/null 5314889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/javaui.cpio.bz2" | 5324889Ssjelinek cpio -icdmu 2>/dev/null 5334889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/lpmisc.cpio.bz2" | 5344889Ssjelinek cpio -icdmu 2>/dev/null 5354889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/perl.cpio.bz2" | 5364889Ssjelinek cpio -icdmu 2>/dev/null 5372851Sjongkis ) 5380Sstevel@tonic-gate} 5390Sstevel@tonic-gate 5400Sstevel@tonic-gatedo_unpack() 5410Sstevel@tonic-gate{ 5421777Ssetje rm -rf "$UNPACKED_ROOT" 5431777Ssetje mkdir -p "$UNPACKED_ROOT" 5442851Sjongkis ( 5452851Sjongkis cd $MNT 5462851Sjongkis find . -print | cpio -pdum "$UNPACKED_ROOT" 2> /dev/null 5472851Sjongkis ) 5480Sstevel@tonic-gate umount $MNT 5490Sstevel@tonic-gate} 5500Sstevel@tonic-gate 5510Sstevel@tonic-gateunpack() 5520Sstevel@tonic-gate{ 5530Sstevel@tonic-gate 5541777Ssetje if [ ! -f "$MR" ] ; then 5550Sstevel@tonic-gate usage 5560Sstevel@tonic-gate exit 1 5570Sstevel@tonic-gate fi 5580Sstevel@tonic-gate 5591777Ssetje gzcat "$MR" > $TMR 5600Sstevel@tonic-gate 5612334Ssetje LOFIDEV=`/usr/sbin/lofiadm -a $TMR` 5620Sstevel@tonic-gate if [ $? != 0 ] ; then 5630Sstevel@tonic-gate echo lofi plumb failed 5640Sstevel@tonic-gate exit 2 5650Sstevel@tonic-gate fi 5660Sstevel@tonic-gate 5671777Ssetje mkdir -p $MNT 5680Sstevel@tonic-gate 5692334Ssetje FSTYP=`fstyp $LOFIDEV` 5700Sstevel@tonic-gate 5711777Ssetje if [ "$FSTYP" = ufs ] ; then 5722334Ssetje /usr/sbin/mount -o ro,nologging $LOFIDEV $MNT 5730Sstevel@tonic-gate do_unpack 5741777Ssetje elif [ "$FSTYP" = hsfs ] ; then 5752334Ssetje /usr/sbin/mount -F hsfs -o ro $LOFIDEV $MNT 5760Sstevel@tonic-gate do_unpack 5770Sstevel@tonic-gate else 5780Sstevel@tonic-gate printf "invalid root archive\n" 5790Sstevel@tonic-gate fi 5800Sstevel@tonic-gate 5810Sstevel@tonic-gate rmdir $MNT 5822851Sjongkis lofiadm -d $TMR ; LOFIDEV= 5830Sstevel@tonic-gate rm $TMR 5840Sstevel@tonic-gate} 5850Sstevel@tonic-gate 5860Sstevel@tonic-gatepack() 5870Sstevel@tonic-gate{ 5881777Ssetje if [ ! -d "$UNPACKED_ROOT" -o -z "$MR" ] ; then 5890Sstevel@tonic-gate usage 5900Sstevel@tonic-gate exit 1 5910Sstevel@tonic-gate fi 5920Sstevel@tonic-gate 5932511Sjongkis # Estimate image size and add %10 overhead for ufs stuff. 5942511Sjongkis # Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem, 5952511Sjongkis # e.g. zfs, in which the disk usage is less than the sum of the file 5962511Sjongkis # sizes. The nawk code 5972511Sjongkis # 5982511Sjongkis # {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} 5992511Sjongkis # 6002511Sjongkis # below rounds up the size of a file/directory, in bytes, to the 6012511Sjongkis # next multiple of 1024. This mimics the behavior of ufs especially 6022511Sjongkis # with directories. This results in a total size that's slightly 6032511Sjongkis # bigger than if du was called on a ufs directory. 6042511Sjongkis size=$(find "$UNPACKED_ROOT" -ls | nawk ' 6052511Sjongkis {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} 6062511Sjongkis END {print int(t * 1.10 / 1024)}') 6070Sstevel@tonic-gate 6082334Ssetje /usr/sbin/mkfile ${size}k "$TMR" 6092334Ssetje 6102334Ssetje LOFIDEV=`/usr/sbin/lofiadm -a "$TMR"` 6110Sstevel@tonic-gate if [ $? != 0 ] ; then 6120Sstevel@tonic-gate echo lofi plumb failed 6130Sstevel@tonic-gate exit 2 6140Sstevel@tonic-gate fi 6150Sstevel@tonic-gate 6162334Ssetje RLOFIDEV=`echo $LOFIDEV | sed s/lofi/rlofi/` 6172334Ssetje newfs $RLOFIDEV < /dev/null 2> /dev/null 6181777Ssetje mkdir -p $MNT 6192334Ssetje mount -o nologging $LOFIDEV $MNT 6201777Ssetje rmdir $MNT/lost+found 6212851Sjongkis ( 6222851Sjongkis cd "$UNPACKED_ROOT" 6232851Sjongkis find . -print | cpio -pdum $MNT 2> /dev/null 6242851Sjongkis ) 6250Sstevel@tonic-gate lockfs -f $MNT 6260Sstevel@tonic-gate umount $MNT 6270Sstevel@tonic-gate rmdir $MNT 6282334Ssetje lofiadm -d $LOFIDEV 6292851Sjongkis LOFIDEV= 6300Sstevel@tonic-gate 6312334Ssetje rm -f "$TMR.gz" 6322334Ssetje gzip -f "$TMR" 6332334Ssetje mv "$TMR.gz" "$MR" 6341777Ssetje chmod a+r "$MR" 6350Sstevel@tonic-gate} 6360Sstevel@tonic-gate 6370Sstevel@tonic-gate# main 6380Sstevel@tonic-gate# 6390Sstevel@tonic-gate 6402334SsetjeEXTRA_SPACE=0 6412851SjongkisSTRIP_AMD64= 6422334Ssetje 6432334Ssetjewhile getopts s:6 opt ; do 6442334Ssetje case $opt in 6452334Ssetje s) EXTRA_SPACE="$OPTARG" 6462334Ssetje ;; 6472334Ssetje 6) STRIP_AMD64=false 6482334Ssetje ;; 6492334Ssetje *) usage 6502334Ssetje exit 1 6512334Ssetje ;; 6522334Ssetje esac 6532334Ssetjedone 6542334Ssetjeshift `expr $OPTIND - 1` 6552334Ssetje 6560Sstevel@tonic-gateif [ $# != 3 ] ; then 6570Sstevel@tonic-gate usage 6580Sstevel@tonic-gate exit 1 6590Sstevel@tonic-gatefi 6600Sstevel@tonic-gate 6611777SsetjeUNPACKED_ROOT="$3" 6621777SsetjeBASE="`pwd`" 6630Sstevel@tonic-gateMNT=/tmp/mnt$$ 6642334SsetjeTMR=/tmp/mr$$ 6652334SsetjeLOFIDEV= 6661777SsetjeMR="$2" 6670Sstevel@tonic-gate 6680Sstevel@tonic-gateif [ "`dirname $MR`" = . ] ; then 6691777Ssetje MR="$BASE/$MR" 6700Sstevel@tonic-gatefi 6710Sstevel@tonic-gateif [ "`dirname $UNPACKED_ROOT`" = . ] ; then 6721777Ssetje UNPACKED_ROOT="$BASE/$UNPACKED_ROOT" 6730Sstevel@tonic-gatefi 6740Sstevel@tonic-gate 6752334Ssetjetrap cleanup EXIT 6762334Ssetje 6770Sstevel@tonic-gatecase $1 in 6780Sstevel@tonic-gate packmedia) 6791777Ssetje MEDIA="$MR" 680*5084Sjohnlev MR="$MEDIA/boot/x86.miniroot" 6811777Ssetje 6821777Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 6831777Ssetje archive_X "$MEDIA" "$UNPACKED_ROOT" 6841777Ssetje else 6851777Ssetje packmedia "$MEDIA" "$UNPACKED_ROOT" 686*5084Sjohnlev 687*5084Sjohnlev # create the 64-bit miniroot 688*5084Sjohnlev # if the -6 option was passed, don't strip 689*5084Sjohnlev # the 64-bit modules from the 32-bit miniroot 690*5084Sjohnlev MR="$MEDIA/boot/amd64/x86.miniroot" 6911777Ssetje pack 692*5084Sjohnlev 693*5084Sjohnlev if [ "$STRIP_AMD64" = false ] ; then 694*5084Sjohnlev ln $MR $MEDIA/boot/x86.miniroot 695*5084Sjohnlev else 696*5084Sjohnlev # create the 32-bit miniroot 697*5084Sjohnlev MR="$MEDIA/boot/x86.miniroot" 698*5084Sjohnlev find "$UNPACKED_ROOT" -name amd64 \ 699*5084Sjohnlev -type directory | xargs rm -rf 700*5084Sjohnlev pack 701*5084Sjohnlev fi 7021777Ssetje fi ;; 7030Sstevel@tonic-gate unpackmedia) 7041777Ssetje MEDIA="$MR" 7051777Ssetje MR="$MR/boot/x86.miniroot" 7061777Ssetje 7071777Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 7081777Ssetje unarchive_X "$MEDIA" "$UNPACKED_ROOT" 7091777Ssetje else 7101777Ssetje unpack 7111777Ssetje unpackmedia "$MEDIA" "$UNPACKED_ROOT" 7121777Ssetje fi ;; 7130Sstevel@tonic-gate pack) pack ;; 7140Sstevel@tonic-gate unpack) unpack ;; 7150Sstevel@tonic-gate *) usage ;; 7160Sstevel@tonic-gateesac 717