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 235648Ssetje# 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# 445648Ssetje# This utility is also used to pack parts (in essence the window system, 455648Ssetje# usr/dt and usr/openwin) of the non ramdisk SPARC 465648Ssetje# miniroot. (un)packmedia will recognize that they are being run a SPARC 475648Ssetje# 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 665648Ssetje if [ "$REALTHING" != true ] ; then 675648Ssetje rm -f "$TMR" 685648Ssetje fi 695648Ssetje rm -f "$TMR.gz" 702334Ssetje} 712334Ssetje 724889Ssjelinekarchive_Gnome() 734889Ssjelinek{ 744889Ssjelinek MEDIA="$1" 754889Ssjelinek MINIROOT="$2" 764889Ssjelinek 774889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 784889Ssjelinek RELEASE=`basename "$RELEASE"` 794889Ssjelinek 805648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 814889Ssjelinek 824889Ssjelinek 834889Ssjelinek # Create the gnome archive 844889Ssjelinek # 854889Ssjelinek ( 864889Ssjelinek # Prepopulate the gconf database. This needs to be done and 874889Ssjelinek # done first for several reasons. 1) Archiving out the gnome 884889Ssjelinek # libraries and binaries causes the gconftool-2 to not run 894889Ssjelinek # appropriately at boot time. 2) The binaries and libraries 904889Ssjelinek # needed to run this are big and thus we want to archive 914889Ssjelinek # them separately. 3) Having schemas prepopluated in the 924889Ssjelinek # miniroot means faster boot times. 934889Ssjelinek # 944889Ssjelinek 954889Ssjelinek cd "$MINIROOT" 964889Ssjelinek HOME="./tmp/root" 974889Ssjelinek export HOME 984889Ssjelinek umask 0022 995648Ssetje mumble=.tmp_proto/root/etc/gconf/gconf.xml.defaults 1005648Ssetje GCONF_CONFIG_SOURCE="xml:merged:$MINIROOT/$mumble" 1014889Ssjelinek export GCONF_CONFIG_SOURCE 1024889Ssjelinek SCHEMADIR="$MINIROOT/.tmp_proto/root/etc/gconf/schemas" 1034889Ssjelinek export SCHEMADIR 1045648Ssetje /usr/bin/gconftool-2 --makefile-install-rule \ 1055648Ssetje $SCHEMADIR/*.schemas >/dev/null 2>&1 1065571Ssjelinek echo ' 1075571Ssjelinek xml:readwrite:/tmp/root/.gconf 1085571Ssjelinek xml:readonly:/etc/gconf/gconf.xml.defaults 1095571Ssjelinek ' > /"$MINIROOT"/.tmp_proto/root/etc/gconf/2/path 1105571Ssjelinek 1114889Ssjelinek # usr/share gnome stuff 1124889Ssjelinek cd "$MINIROOT" 1134889Ssjelinek find usr/share/GConf usr/share/application-registry \ 1144889Ssjelinek usr/share/autostart usr/share/dbus-1 usr/share/dtds \ 1154889Ssjelinek usr/share/emacs usr/share/gnome usr/share/gnome-2.0 \ 1164889Ssjelinek usr/share/gnome-background-properties \ 1174889Ssjelinek usr/share/gtk-engines usr/share/gui-install \ 1184889Ssjelinek usr/share/icon-naming-utils usr/share/control-center \ 1194889Ssjelinek usr/share/icons usr/share/locale usr/share/metacity \ 1204889Ssjelinek usr/share/mime usr/share/mime-info usr/share/pixmaps \ 1214889Ssjelinek usr/share/scrollkeeper usr/share/sgml usr/share/themes \ 1224889Ssjelinek usr/share/xml \ 1234889Ssjelinek -print > /tmp/gnome_share.$$ 2>/dev/null 1244889Ssjelinek 1254889Ssjelinek if [ ! -f /tmp/gnome_share.$$ ] ; then 1264889Ssjelinek echo "/tmp/gnome_share.$$ file list not found." 1275648Ssetje return 1284889Ssjelinek fi 1294889Ssjelinek 1304889Ssjelinek # usr/lib gnome stuff 1314889Ssjelinek 1324889Ssjelinek find usr/lib/libgnome*\.so\.* \ 1334889Ssjelinek usr/lib/libgst*\.so\.* usr/lib/libgconf*\.so\.* \ 1344889Ssjelinek usr/lib/libgdk*\.so\.* usr/lib/libgtk*\.so\.* \ 1354889Ssjelinek usr/lib/libglade*\.so\.* usr/lib/libmetacity*\.so\.* \ 1364889Ssjelinek usr/lib/libfontconfig*\.so\.* usr/lib/libgmodule*\.so\.* \ 1374889Ssjelinek usr/lib/libgobject*\.so\.* usr/lib/libgthread*\.so\.* \ 1384889Ssjelinek usr/lib/libpopt*\.so\.* usr/lib/libstartup*\.so\.* \ 1394889Ssjelinek usr/lib/libexif*\.so\.* usr/lib/libtiff*\.so\.* \ 1404889Ssjelinek usr/lib/libdbus*\.so\.* usr/lib/libstartup*\.so\.* \ 1414889Ssjelinek usr/lib/libexif*\.so\.* usr/lib/libORBit*\.so\.* \ 1424889Ssjelinek usr/lib/libmlib*\.so\.* usr/lib/libxsl*\.so\.* \ 1434889Ssjelinek usr/lib/libpango*\.so\.* usr/lib/libpng*\.so\.* \ 1444889Ssjelinek usr/lib/liboil*\.so\.* usr/lib/libbonobo*\.so\.* \ 1454889Ssjelinek usr/lib/libart*\.so\.* usr/lib/libcairo*\.so\.* \ 1464889Ssjelinek usr/lib/libjpeg*\.so\.* \ 1474889Ssjelinek usr/lib/libpolkit*\.so\.* \ 1484889Ssjelinek -print | egrep -v '\.so\.[0]$' > \ 1494889Ssjelinek /tmp/gnome_lib.$$ 2>/dev/null 1504889Ssjelinek 1514889Ssjelinek find usr/lib/nautilus usr/lib/pango usr/lib/iconv \ 1524889Ssjelinek usr/lib/metacity-dialog usr/lib/window-manager-settings \ 1534889Ssjelinek usr/lib/bonobo-2.0 usr/lib/bononbo usr/lib/gtk-2.0 \ 1544889Ssjelinek usr/lib/GConf usr/lib/bonobo-activation-server \ 1554889Ssjelinek usr/lib/python2.4 usr/lib/gstreamer-0.10 \ 1564889Ssjelinek usr/lib/gconf-sanity-check-2 usr/lib/gconfd \ 1574889Ssjelinek usr/lib/gnome-vfs-2.0 usr/lib/dbus-daemon \ 1584889Ssjelinek usr/lib/gnome-vfs-daemon usr/lib/gnome-settings-daemon \ 1594889Ssjelinek usr/lib/gnome_segv2 usr/lib/orbit-2.0 \ 1604889Ssjelinek usr/lib/libmlib \ 1614889Ssjelinek print > /tmp/gnome_libdir.$$ 2>/dev/null 1624889Ssjelinek 1634889Ssjelinek if [ ! -f /tmp/gnome_lib.$$ -a ! -f gnome_libdir.$$ ] ; then 1644889Ssjelinek echo "/tmp/gnome_lib.$$ file list not found." 1654889Ssjelinek return 1664889Ssjelinek fi 1674889Ssjelinek 1684889Ssjelinek # /usr/sfw gnome stuff 1694889Ssjelinek find usr/sfw/bin usr/sfw/include usr/sfw/share usr/sfw/src \ 1704889Ssjelinek -print > /tmp/gnome_sfw.$$ 2>/dev/null 1714889Ssjelinek 1724889Ssjelinek if [ ! -f /tmp/gnome_sfw.$$ ] ; then 1734889Ssjelinek echo "/tmp/gnome_sfw.$$ file list not found." 1744889Ssjelinek return 1754889Ssjelinek fi 1764889Ssjelinek 1774889Ssjelinek # gnome app binaries usr/bin 1784889Ssjelinek find usr/bin/gnome* usr/bin/gui-install usr/bin/bonobo* \ 1794889Ssjelinek usr/bin/gtk-* usr/bin/fax* usr/bin/gdk* usr/bin/gif2tiff \ 1804889Ssjelinek usr/bin/install-lan \ 1814889Ssjelinek usr/bin/metacity* usr/bin/gst-* usr/bin/gconftool-2 \ 1824889Ssjelinek usr/bin/pango* usr/bin/desktop* usr/bin/djpeg \ 1834889Ssjelinek usr/bin/notify-send usr/bin/oil-bugreport \ 1844889Ssjelinek usr/bin/bmp2tiff usr/bin/thembus-theme-applier \ 1854889Ssjelinek usr/bin/thumbnail usr/lib/update-* \ 1864889Ssjelinek usr/bin/ras2tiff usr/bin/raw2tiff usr/bin/rdjpgcom \ 1874889Ssjelinek usr/bin/thumbnail usr/bin/dbus* \ 1884889Ssjelinek usr/bin/tiff* usr/bin/rgb2ycbcr \ 1894889Ssjelinek usr/bin/fc-cache usr/bin/fc-list \ 1904889Ssjelinek -print > /tmp/gnome_bin.$$ 2>/dev/null 1914889Ssjelinek 1924889Ssjelinek if [ ! -f /tmp/gnome_bin.$$ ] ; then 1934889Ssjelinek echo "/tmp/gnome_bin.$$ file list not found." 1945648Ssetje return 1954889Ssjelinek fi 1964889Ssjelinek 1974889Ssjelinek # Cat all the files together and create the gnome archive 1984889Ssjelinek # 1994889Ssjelinek 2004889Ssjelinek cat /tmp/gnome_libdir.$$ /tmp/gnome_lib.$$ \ 2014889Ssjelinek /tmp/gnome_share.$$ /tmp/gnome_sfw.$$ /tmp/gnome_bin.$$ \ 2024889Ssjelinek > /tmp/gnome.$$ 2034889Ssjelinek 2044889Ssjelinek if [ ! -f /tmp/gnome.$$ ] ; then 2054889Ssjelinek echo "/tmp/gnome.$$ file not found." 2064889Ssjelinek return 2074889Ssjelinek fi 2084889Ssjelinek # Save off this file in the miniroot for use later 2094889Ssjelinek # when unpacking. Clean up old cruft if there. 2104889Ssjelinek # 2114889Ssjelinek 2124889Ssjelinek if [ -f .tmp_proto/gnome_saved ]; then 2134889Ssjelinek rm -f .tmp_proto/gnome_saved 2144889Ssjelinek fi 2154889Ssjelinek 2164889Ssjelinek cp /tmp/gnome.$$ .tmp_proto/gnome_saved 2174889Ssjelinek 2184889Ssjelinek # Create gnome archive 2194889Ssjelinek # 2204889Ssjelinek 2214889Ssjelinek cpio -ocmPuB < /tmp/gnome.$$ 2>/dev/null | bzip2 > \ 2224889Ssjelinek "$CPIO_DIR/gnome.cpio.bz2" 2234889Ssjelinek 2245648Ssetje # Remove files from miniroot that are in archive. 2254889Ssjelinek # Create symlinks for files in archive 2264889Ssjelinek 2274889Ssjelinek rm -rf `cat /tmp/gnome_share.$$` 2284889Ssjelinek 2294889Ssjelinek for i in `cat /tmp/gnome_share.$$` 2305648Ssetje do 2314889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2324889Ssjelinek done 2334889Ssjelinek 2344889Ssjelinek rm -rf `cat /tmp/gnome_lib.$$` 2354889Ssjelinek for i in `cat /tmp/gnome_lib.$$` 2364889Ssjelinek do 2374889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2384889Ssjelinek done 2394889Ssjelinek 2404889Ssjelinek rm -rf `cat /tmp/gnome_libdir.$$` 2414889Ssjelinek for i in `cat /tmp/gnome_libdir.$$` 2425648Ssetje do 2434889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2444889Ssjelinek done 2454889Ssjelinek 2464889Ssjelinek rm -rf `cat /tmp/gnome_sfw.$$` 2474889Ssjelinek for i in `cat /tmp/gnome_sfw.$$` 2485648Ssetje do 2494889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2504889Ssjelinek done 2514889Ssjelinek 2524889Ssjelinek rm -rf `cat /tmp/gnome_bin.$$` 2534889Ssjelinek for i in `cat /tmp/gnome_bin.$$` 2545648Ssetje do 2554889Ssjelinek ln -s /tmp/root/$i $i 2>/dev/null 2564889Ssjelinek done 2574889Ssjelinek rm -f /tmp/gnome_share.$$ 2584889Ssjelinek rm -f /tmp/gnome_lib.$$ 2594889Ssjelinek rm -f /tmp/gnome_libdir.$$ 2604889Ssjelinek rm -f /tmp/gnome_bin.$$ 2614889Ssjelinek ) 2624889Ssjelinek} 2634889Ssjelinek 2644889Ssjelinekarchive_JavaGUI() 2654889Ssjelinek{ 2664889Ssjelinek MEDIA="$1" 2674889Ssjelinek MINIROOT="$2" 2684889Ssjelinek 2694889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 2704889Ssjelinek RELEASE=`basename "$RELEASE"` 2714889Ssjelinek 2725648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 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." 2855648Ssetje 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.$$` 2925648Ssetje ln -s /tmp/root/usr/lib/install/data/wizards \ 2935648Ssetje usr/lib/install/data/wizards 2>/dev/null 2944889Ssjelinek 2954889Ssjelinek rm -f /tmp/java_ui.$$ 2964889Ssjelinek 2974889Ssjelinek ) 2984889Ssjelinek} 2994889Ssjelinek 3004889Ssjelinekarchive_Misc() 3014889Ssjelinek{ 3024889Ssjelinek MEDIA="$1" 3034889Ssjelinek MINIROOT="$2" 3044889Ssjelinek 3054889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 3064889Ssjelinek RELEASE=`basename "$RELEASE"` 3074889Ssjelinek 3085648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 3094889Ssjelinek 3104889Ssjelinek # Archive misc stuff that is needed by non devex installer 3114889Ssjelinek # 3124889Ssjelinek ( 3134889Ssjelinek # usr/lib stuff 3144889Ssjelinek cd "$MINIROOT" 3154889Ssjelinek find usr/lib/lp -print > /tmp/lp.$$ 2>/dev/null 3164889Ssjelinek if [ ! -f /tmp/lp.$$ ] ; then 3174889Ssjelinek echo "/tmp/lp.$$ file list not found." 3185648Ssetje return 3194889Ssjelinek fi 3204889Ssjelinek 3214889Ssjelinek cpio -ocmPuB < /tmp/lp.$$ 2>/dev/null | bzip2 > \ 3224889Ssjelinek "$CPIO_DIR/lpmisc.cpio.bz2" 3234889Ssjelinek 3244889Ssjelinek rm -rf `cat /tmp/lp.$$` 3254889Ssjelinek ln -s /tmp/root/usr/lib/lp usr/lib/lp 2>/dev/null 3264889Ssjelinek 3274889Ssjelinek rm -f /tmp/lp.$$ 3284889Ssjelinek ) 3294889Ssjelinek 3304889Ssjelinek} 3314889Ssjelinek 3324889Ssjelinekarchive_Perl() 3334889Ssjelinek{ 3344889Ssjelinek MEDIA="$1" 3354889Ssjelinek MINIROOT="$2" 3364889Ssjelinek 3374889Ssjelinek RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 3384889Ssjelinek RELEASE=`basename "$RELEASE"` 3394889Ssjelinek 3405648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 3414889Ssjelinek 3424889Ssjelinek # Archive perl, it is only needed by gnome gui. 3434889Ssjelinek # 3444889Ssjelinek ( 3454889Ssjelinek # in usr 3464889Ssjelinek cd "$MINIROOT" 3474889Ssjelinek find usr/perl5 -print > /tmp/perl.$$ 2>/dev/null 3484889Ssjelinek 3494889Ssjelinek if [ ! -f /tmp/perl.$$ ] ; then 3504889Ssjelinek echo "/tmp/perl.$$ file list not found." 3515648Ssetje return 3524889Ssjelinek fi 3534889Ssjelinek cpio -ocmPuB < /tmp/perl.$$ 2>/dev/null | bzip2 > \ 3544889Ssjelinek "$CPIO_DIR/perl.cpio.bz2" 3554889Ssjelinek 3564889Ssjelinek rm -rf `cat /tmp/perl.$$` 2>/dev/null 3575571Ssjelinek ln -s /tmp/root/usr/perl5 usr/perl5 2>/dev/null 3584889Ssjelinek 3594889Ssjelinek rm -f /tmp/perl.$$ 3604889Ssjelinek ) 3614889Ssjelinek} 3621777Ssetjearchive_X() 3630Sstevel@tonic-gate{ 3641777Ssetje MEDIA="$1" 3651777Ssetje MINIROOT="$2" 3660Sstevel@tonic-gate 3671777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 3681777Ssetje RELEASE=`basename "$RELEASE"` 3690Sstevel@tonic-gate 3705648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate # create the graphics and non-graphics X archive 3730Sstevel@tonic-gate # 3742851Sjongkis ( 3754889Ssjelinek cd "$MINIROOT" 3764889Ssjelinek find usr/openwin usr/dt usr/X11 -print 2> /dev/null |\ 3772851Sjongkis cpio -ocmPuB 2> /dev/null | bzip2 > "$CPIO_DIR/X.cpio.bz2" 3780Sstevel@tonic-gate 3794889Ssjelinek find usr/openwin/bin/mkfontdir \ 3804889Ssjelinek usr/openwin/lib/installalias \ 3814889Ssjelinek usr/openwin/server/lib/libfont.so.1 \ 3824889Ssjelinek usr/openwin/server/lib/libtypesclr.so.0 \ 3832851Sjongkis -print | cpio -ocmPuB 2> /dev/null | bzip2 > \ 3842851Sjongkis "$CPIO_DIR/X_small.cpio.bz2" 3850Sstevel@tonic-gate 3864889Ssjelinek rm -rf usr/dt usr/openwin usr/X11 3874889Ssjelinek ln -s /tmp/root/usr/dt usr/dt 3884889Ssjelinek ln -s /tmp/root/usr/openwin usr/openwin 3894889Ssjelinek ln -s /tmp/root/usr/X11 usr/X11 3902851Sjongkis ) 3911777Ssetje} 3921777Ssetje 3935648Ssetjearchive_lu() 3945648Ssetje{ 3955648Ssetje MEDIA="$1" 3965648Ssetje MINIROOT="$2" 3975648Ssetje 3985648Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 3995648Ssetje RELEASE=`basename "$RELEASE"` 4005648Ssetje 4015648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 4025648Ssetje 4035648Ssetje ( 4045648Ssetje cd "$MINIROOT" 4055648Ssetje find usr/lib/install usr/snadm usr/sbin | \ 4065648Ssetje cpio -ocmPuB 2> /dev/null | bzip2 > "$CPIO_DIR"/lu.cpio.bz2 4075648Ssetje ls platform > "$CPIO_DIR/lu.platforms" 4085648Ssetje ) 4095648Ssetje} 4105648Ssetje 4111777Ssetjepackmedia() 4121777Ssetje{ 4131777Ssetje MEDIA="$1" 4141777Ssetje MINIROOT="$2" 4151777Ssetje 4161777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 4171777Ssetje RELEASE=`basename "$RELEASE"` 4181777Ssetje 4191777Ssetje mkdir -p "$MEDIA/$RELEASE/Tools/Boot" 4205648Ssetje 4215648Ssetje if [ -d "$MINIROOT/platform/i86pc" ] ; then 4225648Ssetje mkdir -p "$MEDIA/boot/amd64" 4235648Ssetje mkdir -p "$MEDIA/boot/platform/i86pc/kernel" 4245648Ssetje mkdir -p "$MEDIA/boot/platform/i86pc/kernel/amd64" 4255648Ssetje mkdir -p "$MEDIA/boot/platform/i86xpv/kernel" 4265648Ssetje mkdir -p "$MEDIA/boot/platform/i86xpv/kernel/amd64" 4275648Ssetje cp "$MINIROOT/platform/i86pc/multiboot" "$MEDIA/boot" 4285648Ssetje cp "$MINIROOT/platform/i86pc/kernel/unix" \ 4295648Ssetje "$MEDIA/boot/platform/i86pc/kernel/unix" 4305648Ssetje cp "$MINIROOT/platform/i86pc/kernel/amd64/unix" \ 4315648Ssetje "$MEDIA/boot/platform/i86pc/kernel/amd64/unix" 4325648Ssetje cp "$MINIROOT/platform/i86xpv/kernel/unix" \ 4335648Ssetje "$MEDIA/boot/platform/i86xpv/kernel/unix" 4345648Ssetje cp "$MINIROOT/platform/i86xpv/kernel/amd64/unix" \ 4355648Ssetje "$MEDIA/boot/platform/i86xpv/kernel/amd64/unix" 4365648Ssetje ( 4375648Ssetje cd "$MEDIA/$RELEASE/Tools/Boot" 4385648Ssetje ln -sf ../../../boot/x86.miniroot 4395648Ssetje ln -sf ../../../boot/multiboot 4405648Ssetje ln -sf ../../../boot/platform/i86pc/kernel/unix 4415648Ssetje ln -sf ../../../boot/platform/i86pc/kernel/amd64/unix 4425648Ssetje ln -sf ../../../boot/platform/i86xpv/kernel/unix 4435648Ssetje ln -sf ../../../boot/platform/i86xpv/kernel/amd64/unix 4445648Ssetje ln -sf ../../../boot/grub/pxegrub 4455648Ssetje ) 4465648Ssetje fi 4475648Ssetje 4485648Ssetje if [ -d "$MINIROOT/platform/sun4u" ] ; then 4495648Ssetje mkdir -p "$MEDIA/boot" 4505648Ssetje dd if="$MINIROOT/usr/platform/sun4u/lib/fs/hsfs/bootblk" \ 4515648Ssetje of="$MEDIA/boot/hsfs.bootblock" \ 4525648Ssetje bs=1b oseek=1 count=15 conv=sync 2> /dev/null 4535648Ssetje fi 4545648Ssetje 4555648Ssetje for arch in sun4u sun4v ; do 4565648Ssetje if [ -d "$MINIROOT/platform/$arch" ] ; then 4575648Ssetje archdir="$MEDIA/$RELEASE/Tools/Boot/platform/$arch" 4585648Ssetje mkdir -p $archdir 4595648Ssetje ln -sf ../../../../../boot/sparc.miniroot \ 4605648Ssetje "$archdir/boot_archive" 4615648Ssetje cp "$MINIROOT/usr/platform/$arch/lib/fs/nfs/inetboot" \ 4625648Ssetje "$archdir" 4635648Ssetje cp "$MINIROOT/platform/$arch/wanboot" \ 4645648Ssetje "$archdir" 4655648Ssetje mkdir -p "$MEDIA/platform/$arch" 4665648Ssetje ln -sf ../../boot/sparc.miniroot \ 4675648Ssetje "$MEDIA/platform/$arch/boot_archive" 4685648Ssetje fi 4695648Ssetje done 4701777Ssetje 4711777Ssetje # archive package databases to conserve memory 4721777Ssetje # 4732851Sjongkis ( 4742851Sjongkis cd "$MINIROOT" 4752851Sjongkis find tmp/root/var/sadm/install tmp/root/var/sadm/pkg -print | \ 4762851Sjongkis cpio -ocmPuB 2> /dev/null | bzip2 > \ 4772851Sjongkis "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2" 4782851Sjongkis ) 4791777Ssetje rm -rf "$MINIROOT/tmp/root/var/sadm/install" 4801777Ssetje rm -rf "$MINIROOT/tmp/root/var/sadm/pkg" 4811777Ssetje 4825648Ssetje if [ -d "$MINIROOT/kernel/drv/sparcv9" ] ; then 4835648Ssetje archive_lu "$MEDIA" "$MINIROOT" 4845648Ssetje fi 4855648Ssetje 4862595Ssetje archive_X "$MEDIA" "$MINIROOT" 4872595Ssetje 4884889Ssjelinek # Take out the gnome and java parts of the installer from 4894889Ssjelinek # the miniroot. These are not required to boot the system 4904889Ssjelinek # and start the installers. 4914889Ssjelinek 4925648Ssetje if [ -d "$MINIROOT/platform/i86pc" ] ; then 4935648Ssetje archive_Gnome "$MEDIA" "$MINIROOT" 4945648Ssetje archive_JavaGUI "$MEDIA" "$MINIROOT" 4955648Ssetje archive_Misc "$MEDIA" "$MINIROOT" 4965648Ssetje archive_Perl "$MEDIA" "$MINIROOT" 4975648Ssetje fi 4980Sstevel@tonic-gate 4991821Ssetje # copy the install menu to menu.lst so we have a menu 5001821Ssetje # on the install media 5011821Ssetje # 5025648Ssetje if [ -f "$MINIROOT/boot/grub/install_menu" ] ; then 5035648Ssetje cp $MINIROOT/boot/grub/install_menu \ 5045648Ssetje $MEDIA/boot/grub/menu.lst 5051821Ssetje fi 5061777Ssetje} 5070Sstevel@tonic-gate 5081777Ssetjeunarchive_X() 5091777Ssetje{ 5101777Ssetje MEDIA="$1" 5111777Ssetje UNPACKED_ROOT="$2" 5121777Ssetje 5131777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 5141777Ssetje RELEASE=`basename "$RELEASE"` 5151777Ssetje 5165648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 5171777Ssetje 5181777Ssetje # unpack X 5191777Ssetje # 5202851Sjongkis ( 5214889Ssjelinek cd "$UNPACKED_ROOT" 5224889Ssjelinek rm -rf usr/dt usr/openwin usr/X11 5232851Sjongkis bzcat "$CPIO_DIR/X.cpio.bz2" | cpio -icdmu 2> /dev/null 5242851Sjongkis ) 5250Sstevel@tonic-gate} 5260Sstevel@tonic-gate 5270Sstevel@tonic-gateunpackmedia() 5281777Ssetje{ 5291777Ssetje MEDIA="$1" 5301777Ssetje UNPACKED_ROOT="$2" 5310Sstevel@tonic-gate 5321777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 5331777Ssetje RELEASE=`basename "$RELEASE"` 5341777Ssetje 5351777Ssetje unarchive_X "$MEDIA" "$UNPACKED_ROOT" 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate # unpack package databases 5380Sstevel@tonic-gate # 5392851Sjongkis ( 5402851Sjongkis cd "$UNPACKED_ROOT" 5412851Sjongkis bzcat "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2" | 5422851Sjongkis cpio -icdmu 2> /dev/null 5434889Ssjelinek 5444889Ssjelinek # unpack gnome, perl, java and misc 5454889Ssjelinek # Remove symlinks left from unpacking x86.miniroot so that 5464889Ssjelinek # unpacking subsequent archives will populate appropriately. 5474889Ssjelinek # 5484889Ssjelinek rm -rf usr/perl5 5494889Ssjelinek rm -rf usr/lib/install/data/wizards 5504889Ssjelinek rm -rf usr/lib/lp 5514889Ssjelinek 5524889Ssjelinek # Gnome list saved off from packmedia 5534889Ssjelinek for i in `cat .tmp_proto/gnome_saved` 5545648Ssetje do 5554889Ssjelinek rm -rf $i 5564889Ssjelinek done 5574889Ssjelinek 5584889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/gnome.cpio.bz2" | 5594889Ssjelinek cpio -icdmu 2>/dev/null 5604889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/javaui.cpio.bz2" | 5614889Ssjelinek cpio -icdmu 2>/dev/null 5624889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/lpmisc.cpio.bz2" | 5634889Ssjelinek cpio -icdmu 2>/dev/null 5644889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/perl.cpio.bz2" | 5654889Ssjelinek cpio -icdmu 2>/dev/null 5662851Sjongkis ) 5670Sstevel@tonic-gate} 5680Sstevel@tonic-gate 5690Sstevel@tonic-gatedo_unpack() 5700Sstevel@tonic-gate{ 5711777Ssetje rm -rf "$UNPACKED_ROOT" 5721777Ssetje mkdir -p "$UNPACKED_ROOT" 5732851Sjongkis ( 5742851Sjongkis cd $MNT 5752851Sjongkis find . -print | cpio -pdum "$UNPACKED_ROOT" 2> /dev/null 5762851Sjongkis ) 5770Sstevel@tonic-gate umount $MNT 5780Sstevel@tonic-gate} 5790Sstevel@tonic-gate 5800Sstevel@tonic-gateunpack() 5810Sstevel@tonic-gate{ 5820Sstevel@tonic-gate 5831777Ssetje if [ ! -f "$MR" ] ; then 5840Sstevel@tonic-gate usage 5850Sstevel@tonic-gate exit 1 5860Sstevel@tonic-gate fi 5870Sstevel@tonic-gate 5885648Ssetje if [ `basename $MR` = x86.miniroot ] ; then 5895648Ssetje gzcat "$MR" > $TMR 5905648Ssetje else 5915648Ssetje REALTHING=true ; export REALTHING 5925648Ssetje TMR="$MR" 5935648Ssetje fi 5940Sstevel@tonic-gate 5952334Ssetje LOFIDEV=`/usr/sbin/lofiadm -a $TMR` 5960Sstevel@tonic-gate if [ $? != 0 ] ; then 5970Sstevel@tonic-gate echo lofi plumb failed 5980Sstevel@tonic-gate exit 2 5990Sstevel@tonic-gate fi 6000Sstevel@tonic-gate 6011777Ssetje mkdir -p $MNT 6020Sstevel@tonic-gate 6032334Ssetje FSTYP=`fstyp $LOFIDEV` 6040Sstevel@tonic-gate 6051777Ssetje if [ "$FSTYP" = ufs ] ; then 6062334Ssetje /usr/sbin/mount -o ro,nologging $LOFIDEV $MNT 6070Sstevel@tonic-gate do_unpack 6081777Ssetje elif [ "$FSTYP" = hsfs ] ; then 6092334Ssetje /usr/sbin/mount -F hsfs -o ro $LOFIDEV $MNT 6100Sstevel@tonic-gate do_unpack 6110Sstevel@tonic-gate else 6120Sstevel@tonic-gate printf "invalid root archive\n" 6130Sstevel@tonic-gate fi 6140Sstevel@tonic-gate 6155648Ssetje 6160Sstevel@tonic-gate rmdir $MNT 6172851Sjongkis lofiadm -d $TMR ; LOFIDEV= 6185648Ssetje if [ "$REALTHING" != true ] ; then 6195648Ssetje rm $TMR 6205648Ssetje fi 6215648Ssetje} 6225648Ssetje 6235648Ssetjecompress() 6245648Ssetje{ 6255648Ssetje SRC=$1 6265648Ssetje DST=$2 6275648Ssetje 6285648Ssetje ( 6295648Ssetje cd $SRC 6305648Ssetje filelist=`find .` 6315648Ssetje 6325648Ssetje for file in $filelist ; do 6335648Ssetje 6345648Ssetje file=`echo $file | sed s#^./##` 6355648Ssetje 6365648Ssetje # copy all files over to preserve hard links 6375648Ssetje # 6385648Ssetje echo $file | cpio -pdum $DST 2> /dev/null 6395648Ssetje 6405648Ssetje if [ -f $file ] && [ -s $file ] && [ ! -h $file ] ; then 6415648Ssetje fiocompress -mc $file $DST/$file & 6425648Ssetje fi 6435648Ssetje 6445648Ssetje done 6455648Ssetje 6465648Ssetje # now re-copy a couple of uncompressed files 6475648Ssetje # 6485648Ssetje 6495648Ssetje find kernel platform -name unix | cpio -pdum $DST 2> /dev/null 6505648Ssetje find kernel platform -name genunix | cpio -pdum $DST \ 6515648Ssetje 2> /dev/null 6525648Ssetje find kernel platform -name platmod | cpio -pdum $DST \ 6535648Ssetje 2> /dev/null 6545648Ssetje find `find kernel platform -name cpu` | cpio -pdum $DST \ 6555648Ssetje 2> /dev/null 6565648Ssetje find `find kernel platform -name kmdb\*` | cpio -pdum $DST \ 6575648Ssetje 2> /dev/null 6585648Ssetje find kernel/misc/sparcv9/ctf kernel/fs/sparcv9/dcfs \ 6595648Ssetje etc/system etc/name_to_major etc/path_to_inst \ 6605648Ssetje etc/name_to_sysnum | cpio -pdum $DST 2> /dev/null 6615648Ssetje ) 6625648Ssetje} 6635648Ssetje 6645648Ssetjeroot_is_ramdisk() 6655648Ssetje{ 6665648Ssetje grep -v "set root_is_ramdisk=" "$UNPACKED_ROOT"/etc/system | \ 6675648Ssetje grep -v "set ramdisk_size=" > /tmp/system.$$ 6685648Ssetje cat /tmp/system.$$ > "$UNPACKED_ROOT"/etc/system 6695648Ssetje rm /tmp/system.$$ 6705648Ssetje 6715648Ssetje echo set root_is_ramdisk=1 >> "$UNPACKED_ROOT"/etc/system 6725648Ssetje echo set ramdisk_size=$1 >> "$UNPACKED_ROOT"/etc/system 6730Sstevel@tonic-gate} 6740Sstevel@tonic-gate 6750Sstevel@tonic-gatepack() 6760Sstevel@tonic-gate{ 6771777Ssetje if [ ! -d "$UNPACKED_ROOT" -o -z "$MR" ] ; then 6780Sstevel@tonic-gate usage 6790Sstevel@tonic-gate exit 1 6800Sstevel@tonic-gate fi 6810Sstevel@tonic-gate 6825648Ssetje # always compress on sparc if fiocompress exists 6835648Ssetje # 6845648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] && \ 6855648Ssetje [ -x /usr/sbin/fiocompress ] ; then 6865648Ssetje COMPRESS=true 6875648Ssetje fi 6885648Ssetje 6892511Sjongkis # Estimate image size and add %10 overhead for ufs stuff. 6902511Sjongkis # Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem, 6912511Sjongkis # e.g. zfs, in which the disk usage is less than the sum of the file 6925648Ssetje # sizes. The nawk code 6932511Sjongkis # 6942511Sjongkis # {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} 6952511Sjongkis # 6962511Sjongkis # below rounds up the size of a file/directory, in bytes, to the 6972511Sjongkis # next multiple of 1024. This mimics the behavior of ufs especially 6982511Sjongkis # with directories. This results in a total size that's slightly 6992511Sjongkis # bigger than if du was called on a ufs directory. 7005648Ssetje # 7015648Ssetje # if the operation in turn is compressing the files the amount 7025648Ssetje # of typical shrinkage is used to come up with a useful archive 7035648Ssetje # size 7042511Sjongkis size=$(find "$UNPACKED_ROOT" -ls | nawk ' 7052511Sjongkis {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} 7062511Sjongkis END {print int(t * 1.10 / 1024)}') 7075648Ssetje if [ "$COMPRESS" = true ] ; then 7085648Ssetje size=`echo $size | nawk '{s = $1} END {print int(s * .53)}'` 7095648Ssetje fi 7100Sstevel@tonic-gate 7112334Ssetje /usr/sbin/mkfile ${size}k "$TMR" 7122334Ssetje 7132334Ssetje LOFIDEV=`/usr/sbin/lofiadm -a "$TMR"` 7140Sstevel@tonic-gate if [ $? != 0 ] ; then 7150Sstevel@tonic-gate echo lofi plumb failed 7160Sstevel@tonic-gate exit 2 7170Sstevel@tonic-gate fi 7180Sstevel@tonic-gate 7192334Ssetje RLOFIDEV=`echo $LOFIDEV | sed s/lofi/rlofi/` 7205648Ssetje newfs $RLOFIDEV < /dev/null 2> /dev/null 7211777Ssetje mkdir -p $MNT 7225648Ssetje mount -o nologging $LOFIDEV $MNT 7231777Ssetje rmdir $MNT/lost+found 7245648Ssetje 7255648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 7265648Ssetje root_is_ramdisk $size 7275648Ssetje fi 7285648Ssetje 7292851Sjongkis ( 7302851Sjongkis cd "$UNPACKED_ROOT" 7315648Ssetje if [ "$COMPRESS" = true ] ; then 7325648Ssetje compress . $MNT 7335648Ssetje else 7345648Ssetje find . -print | cpio -pdum $MNT 2> /dev/null 7355648Ssetje fi 7362851Sjongkis ) 7370Sstevel@tonic-gate lockfs -f $MNT 7380Sstevel@tonic-gate umount $MNT 7390Sstevel@tonic-gate rmdir $MNT 7405648Ssetje 7415648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 7425648Ssetje "$UNPACKED_ROOT/usr/sbin/installboot" \ 7435648Ssetje "$UNPACKED_ROOT/usr/platform/sun4u/lib/fs/ufs/bootblk" \ 7445648Ssetje $RLOFIDEV 7455648Ssetje fi 7465648Ssetje 7472334Ssetje lofiadm -d $LOFIDEV 7482851Sjongkis LOFIDEV= 7490Sstevel@tonic-gate 7502334Ssetje rm -f "$TMR.gz" 7515648Ssetje 7525648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 7535648Ssetje mv "$TMR" "$MR" 7545648Ssetje else 7555648Ssetje gzip -f "$TMR" 7565648Ssetje mv "$TMR.gz" "$MR" 7575648Ssetje fi 7585648Ssetje 7591777Ssetje chmod a+r "$MR" 7600Sstevel@tonic-gate} 7610Sstevel@tonic-gate 762*5716Ssetjestrip_amd64() 763*5716Ssetje{ 764*5716Ssetje find "$UNPACKED_ROOT" -name amd64 -type directory | xargs rm -rf 765*5716Ssetje} 766*5716Ssetje 7670Sstevel@tonic-gate# main 7680Sstevel@tonic-gate# 7690Sstevel@tonic-gate 7702334SsetjeEXTRA_SPACE=0 7712851SjongkisSTRIP_AMD64= 7725648SsetjeCOMPRESS= 7732334Ssetje 7745648SsetjePATH=/usr/sbin:/usr/bin:/opt/sfw/bin ; export PATH 7755648Ssetje 7765648Ssetjewhile getopts s:6c opt ; do 7772334Ssetje case $opt in 7782334Ssetje s) EXTRA_SPACE="$OPTARG" 7792334Ssetje ;; 7802334Ssetje 6) STRIP_AMD64=false 7812334Ssetje ;; 7825648Ssetje c) COMPRESS=true 7835648Ssetje ;; 7842334Ssetje *) usage 7852334Ssetje exit 1 7862334Ssetje ;; 7872334Ssetje esac 7882334Ssetjedone 7892334Ssetjeshift `expr $OPTIND - 1` 7902334Ssetje 7910Sstevel@tonic-gateif [ $# != 3 ] ; then 7920Sstevel@tonic-gate usage 7930Sstevel@tonic-gate exit 1 7940Sstevel@tonic-gatefi 7950Sstevel@tonic-gate 7961777SsetjeUNPACKED_ROOT="$3" 7971777SsetjeBASE="`pwd`" 7980Sstevel@tonic-gateMNT=/tmp/mnt$$ 7992334SsetjeTMR=/tmp/mr$$ 8002334SsetjeLOFIDEV= 8011777SsetjeMR="$2" 8020Sstevel@tonic-gate 8030Sstevel@tonic-gateif [ "`dirname $MR`" = . ] ; then 8041777Ssetje MR="$BASE/$MR" 8050Sstevel@tonic-gatefi 8060Sstevel@tonic-gateif [ "`dirname $UNPACKED_ROOT`" = . ] ; then 8071777Ssetje UNPACKED_ROOT="$BASE/$UNPACKED_ROOT" 8080Sstevel@tonic-gatefi 8090Sstevel@tonic-gate 8105648Ssetje 8115648SsetjeMEDIA="$MR" 8125648Ssetje 8132334Ssetjetrap cleanup EXIT 8142334Ssetje 8150Sstevel@tonic-gatecase $1 in 8160Sstevel@tonic-gate packmedia) 8171777Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 8185648Ssetje ARCHIVE=sparc.miniroot 8195648Ssetje else 820*5716Ssetje ARCHIVE=amd64/x86.miniroot 8215648Ssetje fi 822*5716Ssetje MR="$MEDIA/boot/$ARCHIVE" 823*5716Ssetje 8245648Ssetje packmedia "$MEDIA" "$UNPACKED_ROOT" 8255648Ssetje pack 826*5716Ssetje 827*5716Ssetje if [ -d "$MINIROOT/platform/i86pc" ] ; then 828*5716Ssetje if [ "$STRIP_AMD64" = false ] ; then 829*5716Ssetje ln $MR $MEDIA/boot/x86.miniroot 830*5716Ssetje else 831*5716Ssetje MR="$MEDIA/boot/x86.miniroot" 832*5716Ssetje strip_amd64 833*5716Ssetje pack 834*5716Ssetje fi 835*5716Ssetje fi 836*5716Ssetje 8375648Ssetje ;; 8385648Ssetje unpackmedia) 8395648Ssetje if [ -f "$MEDIA/boot/sparc.miniroot" ] ; then 8405648Ssetje ARCHIVE=sparc.miniroot 8411777Ssetje else 8425648Ssetje ARCHIVE=x86.miniroot 8435648Ssetje fi 844*5716Ssetje MR="$MEDIA/boot/$ARCHIVE" 8455648Ssetje unpack 8465648Ssetje unpackmedia "$MEDIA" "$UNPACKED_ROOT" 8475648Ssetje ;; 8485648Ssetje pack) pack 8495648Ssetje ;; 8505648Ssetje unpack) unpack 8515648Ssetje ;; 8525648Ssetje *) usage 8535648Ssetje ;; 8540Sstevel@tonic-gateesac 855