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 23*5648Ssetje# 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# 44*5648Ssetje# This utility is also used to pack parts (in essence the window system, 45*5648Ssetje# usr/dt and usr/openwin) of the non ramdisk SPARC 46*5648Ssetje# miniroot. (un)packmedia will recognize that they are being run a SPARC 47*5648Ssetje# 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 66*5648Ssetje if [ "$REALTHING" != true ] ; then 67*5648Ssetje rm -f "$TMR" 68*5648Ssetje fi 69*5648Ssetje 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 80*5648Ssetje 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 99*5648Ssetje mumble=.tmp_proto/root/etc/gconf/gconf.xml.defaults 100*5648Ssetje GCONF_CONFIG_SOURCE="xml:merged:$MINIROOT/$mumble" 1014889Ssjelinek export GCONF_CONFIG_SOURCE 1024889Ssjelinek SCHEMADIR="$MINIROOT/.tmp_proto/root/etc/gconf/schemas" 1034889Ssjelinek export SCHEMADIR 104*5648Ssetje /usr/bin/gconftool-2 --makefile-install-rule \ 105*5648Ssetje $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." 127*5648Ssetje 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." 194*5648Ssetje 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 224*5648Ssetje # 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.$$` 230*5648Ssetje 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.$$` 242*5648Ssetje 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.$$` 248*5648Ssetje 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.$$` 254*5648Ssetje 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 272*5648Ssetje 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." 285*5648Ssetje 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.$$` 292*5648Ssetje ln -s /tmp/root/usr/lib/install/data/wizards \ 293*5648Ssetje 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 308*5648Ssetje 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." 318*5648Ssetje 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 340*5648Ssetje 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." 351*5648Ssetje 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 370*5648Ssetje 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 393*5648Ssetjearchive_lu() 394*5648Ssetje{ 395*5648Ssetje MEDIA="$1" 396*5648Ssetje MINIROOT="$2" 397*5648Ssetje 398*5648Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 399*5648Ssetje RELEASE=`basename "$RELEASE"` 400*5648Ssetje 401*5648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 402*5648Ssetje 403*5648Ssetje ( 404*5648Ssetje cd "$MINIROOT" 405*5648Ssetje find usr/lib/install usr/snadm usr/sbin | \ 406*5648Ssetje cpio -ocmPuB 2> /dev/null | bzip2 > "$CPIO_DIR"/lu.cpio.bz2 407*5648Ssetje ls platform > "$CPIO_DIR/lu.platforms" 408*5648Ssetje ) 409*5648Ssetje} 410*5648Ssetje 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" 420*5648Ssetje 421*5648Ssetje if [ -d "$MINIROOT/platform/i86pc" ] ; then 422*5648Ssetje mkdir -p "$MEDIA/boot/amd64" 423*5648Ssetje mkdir -p "$MEDIA/boot/platform/i86pc/kernel" 424*5648Ssetje mkdir -p "$MEDIA/boot/platform/i86pc/kernel/amd64" 425*5648Ssetje mkdir -p "$MEDIA/boot/platform/i86xpv/kernel" 426*5648Ssetje mkdir -p "$MEDIA/boot/platform/i86xpv/kernel/amd64" 427*5648Ssetje cp "$MINIROOT/platform/i86pc/multiboot" "$MEDIA/boot" 428*5648Ssetje cp "$MINIROOT/platform/i86pc/kernel/unix" \ 429*5648Ssetje "$MEDIA/boot/platform/i86pc/kernel/unix" 430*5648Ssetje cp "$MINIROOT/platform/i86pc/kernel/amd64/unix" \ 431*5648Ssetje "$MEDIA/boot/platform/i86pc/kernel/amd64/unix" 432*5648Ssetje cp "$MINIROOT/platform/i86xpv/kernel/unix" \ 433*5648Ssetje "$MEDIA/boot/platform/i86xpv/kernel/unix" 434*5648Ssetje cp "$MINIROOT/platform/i86xpv/kernel/amd64/unix" \ 435*5648Ssetje "$MEDIA/boot/platform/i86xpv/kernel/amd64/unix" 436*5648Ssetje ( 437*5648Ssetje cd "$MEDIA/$RELEASE/Tools/Boot" 438*5648Ssetje ln -sf ../../../boot/x86.miniroot 439*5648Ssetje ln -sf ../../../boot/multiboot 440*5648Ssetje ln -sf ../../../boot/platform/i86pc/kernel/unix 441*5648Ssetje ln -sf ../../../boot/platform/i86pc/kernel/amd64/unix 442*5648Ssetje ln -sf ../../../boot/platform/i86xpv/kernel/unix 443*5648Ssetje ln -sf ../../../boot/platform/i86xpv/kernel/amd64/unix 444*5648Ssetje ln -sf ../../../boot/grub/pxegrub 445*5648Ssetje ) 446*5648Ssetje fi 447*5648Ssetje 448*5648Ssetje if [ -d "$MINIROOT/platform/sun4u" ] ; then 449*5648Ssetje mkdir -p "$MEDIA/boot" 450*5648Ssetje dd if="$MINIROOT/usr/platform/sun4u/lib/fs/hsfs/bootblk" \ 451*5648Ssetje of="$MEDIA/boot/hsfs.bootblock" \ 452*5648Ssetje bs=1b oseek=1 count=15 conv=sync 2> /dev/null 453*5648Ssetje fi 454*5648Ssetje 455*5648Ssetje for arch in sun4u sun4v ; do 456*5648Ssetje if [ -d "$MINIROOT/platform/$arch" ] ; then 457*5648Ssetje archdir="$MEDIA/$RELEASE/Tools/Boot/platform/$arch" 458*5648Ssetje mkdir -p $archdir 459*5648Ssetje ln -sf ../../../../../boot/sparc.miniroot \ 460*5648Ssetje "$archdir/boot_archive" 461*5648Ssetje cp "$MINIROOT/usr/platform/$arch/lib/fs/nfs/inetboot" \ 462*5648Ssetje "$archdir" 463*5648Ssetje cp "$MINIROOT/platform/$arch/wanboot" \ 464*5648Ssetje "$archdir" 465*5648Ssetje mkdir -p "$MEDIA/platform/$arch" 466*5648Ssetje ln -sf ../../boot/sparc.miniroot \ 467*5648Ssetje "$MEDIA/platform/$arch/boot_archive" 468*5648Ssetje fi 469*5648Ssetje 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 482*5648Ssetje if [ -d "$MINIROOT/kernel/drv/sparcv9" ] ; then 483*5648Ssetje archive_lu "$MEDIA" "$MINIROOT" 484*5648Ssetje elif [ "$STRIP_AMD64" != false ] ; then 485*5648Ssetje # clear out 64 bit support to conserve memory 486*5648Ssetje # 487*5648Ssetje find "$MINIROOT" -name amd64 -type directory | xargs rm -rf 488*5648Ssetje fi 489*5648Ssetje 4902595Ssetje archive_X "$MEDIA" "$MINIROOT" 4912595Ssetje 4924889Ssjelinek # Take out the gnome and java parts of the installer from 4934889Ssjelinek # the miniroot. These are not required to boot the system 4944889Ssjelinek # and start the installers. 4954889Ssjelinek 496*5648Ssetje if [ -d "$MINIROOT/platform/i86pc" ] ; then 497*5648Ssetje archive_Gnome "$MEDIA" "$MINIROOT" 498*5648Ssetje archive_JavaGUI "$MEDIA" "$MINIROOT" 499*5648Ssetje archive_Misc "$MEDIA" "$MINIROOT" 500*5648Ssetje archive_Perl "$MEDIA" "$MINIROOT" 501*5648Ssetje fi 5020Sstevel@tonic-gate 5031821Ssetje # copy the install menu to menu.lst so we have a menu 5041821Ssetje # on the install media 5051821Ssetje # 506*5648Ssetje if [ -f "$MINIROOT/boot/grub/install_menu" ] ; then 507*5648Ssetje cp $MINIROOT/boot/grub/install_menu \ 508*5648Ssetje $MEDIA/boot/grub/menu.lst 5091821Ssetje fi 5101777Ssetje} 5110Sstevel@tonic-gate 5121777Ssetjeunarchive_X() 5131777Ssetje{ 5141777Ssetje MEDIA="$1" 5151777Ssetje UNPACKED_ROOT="$2" 5161777Ssetje 5171777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 5181777Ssetje RELEASE=`basename "$RELEASE"` 5191777Ssetje 520*5648Ssetje CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot" 5211777Ssetje 5221777Ssetje # unpack X 5231777Ssetje # 5242851Sjongkis ( 5254889Ssjelinek cd "$UNPACKED_ROOT" 5264889Ssjelinek rm -rf usr/dt usr/openwin usr/X11 5272851Sjongkis bzcat "$CPIO_DIR/X.cpio.bz2" | cpio -icdmu 2> /dev/null 5282851Sjongkis ) 5290Sstevel@tonic-gate} 5300Sstevel@tonic-gate 5310Sstevel@tonic-gateunpackmedia() 5321777Ssetje{ 5331777Ssetje MEDIA="$1" 5341777Ssetje UNPACKED_ROOT="$2" 5350Sstevel@tonic-gate 5361777Ssetje RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*` 5371777Ssetje RELEASE=`basename "$RELEASE"` 5381777Ssetje 5391777Ssetje unarchive_X "$MEDIA" "$UNPACKED_ROOT" 5400Sstevel@tonic-gate 5410Sstevel@tonic-gate # unpack package databases 5420Sstevel@tonic-gate # 5432851Sjongkis ( 5442851Sjongkis cd "$UNPACKED_ROOT" 5452851Sjongkis bzcat "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2" | 5462851Sjongkis cpio -icdmu 2> /dev/null 5474889Ssjelinek 5484889Ssjelinek # unpack gnome, perl, java and misc 5494889Ssjelinek # Remove symlinks left from unpacking x86.miniroot so that 5504889Ssjelinek # unpacking subsequent archives will populate appropriately. 5514889Ssjelinek # 5524889Ssjelinek rm -rf usr/perl5 5534889Ssjelinek rm -rf usr/lib/install/data/wizards 5544889Ssjelinek rm -rf usr/lib/lp 5554889Ssjelinek 5564889Ssjelinek # Gnome list saved off from packmedia 5574889Ssjelinek for i in `cat .tmp_proto/gnome_saved` 558*5648Ssetje do 5594889Ssjelinek rm -rf $i 5604889Ssjelinek done 5614889Ssjelinek 5624889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/gnome.cpio.bz2" | 5634889Ssjelinek cpio -icdmu 2>/dev/null 5644889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/javaui.cpio.bz2" | 5654889Ssjelinek cpio -icdmu 2>/dev/null 5664889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/lpmisc.cpio.bz2" | 5674889Ssjelinek cpio -icdmu 2>/dev/null 5684889Ssjelinek bzcat "$MEDIA/$RELEASE/Tools/Boot/perl.cpio.bz2" | 5694889Ssjelinek cpio -icdmu 2>/dev/null 5702851Sjongkis ) 5710Sstevel@tonic-gate} 5720Sstevel@tonic-gate 5730Sstevel@tonic-gatedo_unpack() 5740Sstevel@tonic-gate{ 5751777Ssetje rm -rf "$UNPACKED_ROOT" 5761777Ssetje mkdir -p "$UNPACKED_ROOT" 5772851Sjongkis ( 5782851Sjongkis cd $MNT 5792851Sjongkis find . -print | cpio -pdum "$UNPACKED_ROOT" 2> /dev/null 5802851Sjongkis ) 5810Sstevel@tonic-gate umount $MNT 5820Sstevel@tonic-gate} 5830Sstevel@tonic-gate 5840Sstevel@tonic-gateunpack() 5850Sstevel@tonic-gate{ 5860Sstevel@tonic-gate 5871777Ssetje if [ ! -f "$MR" ] ; then 5880Sstevel@tonic-gate usage 5890Sstevel@tonic-gate exit 1 5900Sstevel@tonic-gate fi 5910Sstevel@tonic-gate 592*5648Ssetje if [ `basename $MR` = x86.miniroot ] ; then 593*5648Ssetje gzcat "$MR" > $TMR 594*5648Ssetje else 595*5648Ssetje REALTHING=true ; export REALTHING 596*5648Ssetje TMR="$MR" 597*5648Ssetje fi 5980Sstevel@tonic-gate 5992334Ssetje LOFIDEV=`/usr/sbin/lofiadm -a $TMR` 6000Sstevel@tonic-gate if [ $? != 0 ] ; then 6010Sstevel@tonic-gate echo lofi plumb failed 6020Sstevel@tonic-gate exit 2 6030Sstevel@tonic-gate fi 6040Sstevel@tonic-gate 6051777Ssetje mkdir -p $MNT 6060Sstevel@tonic-gate 6072334Ssetje FSTYP=`fstyp $LOFIDEV` 6080Sstevel@tonic-gate 6091777Ssetje if [ "$FSTYP" = ufs ] ; then 6102334Ssetje /usr/sbin/mount -o ro,nologging $LOFIDEV $MNT 6110Sstevel@tonic-gate do_unpack 6121777Ssetje elif [ "$FSTYP" = hsfs ] ; then 6132334Ssetje /usr/sbin/mount -F hsfs -o ro $LOFIDEV $MNT 6140Sstevel@tonic-gate do_unpack 6150Sstevel@tonic-gate else 6160Sstevel@tonic-gate printf "invalid root archive\n" 6170Sstevel@tonic-gate fi 6180Sstevel@tonic-gate 619*5648Ssetje 6200Sstevel@tonic-gate rmdir $MNT 6212851Sjongkis lofiadm -d $TMR ; LOFIDEV= 622*5648Ssetje if [ "$REALTHING" != true ] ; then 623*5648Ssetje rm $TMR 624*5648Ssetje fi 625*5648Ssetje} 626*5648Ssetje 627*5648Ssetjecompress() 628*5648Ssetje{ 629*5648Ssetje SRC=$1 630*5648Ssetje DST=$2 631*5648Ssetje 632*5648Ssetje ( 633*5648Ssetje cd $SRC 634*5648Ssetje filelist=`find .` 635*5648Ssetje 636*5648Ssetje for file in $filelist ; do 637*5648Ssetje 638*5648Ssetje file=`echo $file | sed s#^./##` 639*5648Ssetje 640*5648Ssetje # copy all files over to preserve hard links 641*5648Ssetje # 642*5648Ssetje echo $file | cpio -pdum $DST 2> /dev/null 643*5648Ssetje 644*5648Ssetje if [ -f $file ] && [ -s $file ] && [ ! -h $file ] ; then 645*5648Ssetje fiocompress -mc $file $DST/$file & 646*5648Ssetje fi 647*5648Ssetje 648*5648Ssetje done 649*5648Ssetje 650*5648Ssetje # now re-copy a couple of uncompressed files 651*5648Ssetje # 652*5648Ssetje 653*5648Ssetje find kernel platform -name unix | cpio -pdum $DST 2> /dev/null 654*5648Ssetje find kernel platform -name genunix | cpio -pdum $DST \ 655*5648Ssetje 2> /dev/null 656*5648Ssetje find kernel platform -name platmod | cpio -pdum $DST \ 657*5648Ssetje 2> /dev/null 658*5648Ssetje find `find kernel platform -name cpu` | cpio -pdum $DST \ 659*5648Ssetje 2> /dev/null 660*5648Ssetje find `find kernel platform -name kmdb\*` | cpio -pdum $DST \ 661*5648Ssetje 2> /dev/null 662*5648Ssetje find kernel/misc/sparcv9/ctf kernel/fs/sparcv9/dcfs \ 663*5648Ssetje etc/system etc/name_to_major etc/path_to_inst \ 664*5648Ssetje etc/name_to_sysnum | cpio -pdum $DST 2> /dev/null 665*5648Ssetje ) 666*5648Ssetje} 667*5648Ssetje 668*5648Ssetjeroot_is_ramdisk() 669*5648Ssetje{ 670*5648Ssetje grep -v "set root_is_ramdisk=" "$UNPACKED_ROOT"/etc/system | \ 671*5648Ssetje grep -v "set ramdisk_size=" > /tmp/system.$$ 672*5648Ssetje cat /tmp/system.$$ > "$UNPACKED_ROOT"/etc/system 673*5648Ssetje rm /tmp/system.$$ 674*5648Ssetje 675*5648Ssetje echo set root_is_ramdisk=1 >> "$UNPACKED_ROOT"/etc/system 676*5648Ssetje echo set ramdisk_size=$1 >> "$UNPACKED_ROOT"/etc/system 6770Sstevel@tonic-gate} 6780Sstevel@tonic-gate 6790Sstevel@tonic-gatepack() 6800Sstevel@tonic-gate{ 6811777Ssetje if [ ! -d "$UNPACKED_ROOT" -o -z "$MR" ] ; then 6820Sstevel@tonic-gate usage 6830Sstevel@tonic-gate exit 1 6840Sstevel@tonic-gate fi 6850Sstevel@tonic-gate 686*5648Ssetje # always compress on sparc if fiocompress exists 687*5648Ssetje # 688*5648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] && \ 689*5648Ssetje [ -x /usr/sbin/fiocompress ] ; then 690*5648Ssetje COMPRESS=true 691*5648Ssetje fi 692*5648Ssetje 6932511Sjongkis # Estimate image size and add %10 overhead for ufs stuff. 6942511Sjongkis # Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem, 6952511Sjongkis # e.g. zfs, in which the disk usage is less than the sum of the file 696*5648Ssetje # sizes. The nawk code 6972511Sjongkis # 6982511Sjongkis # {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} 6992511Sjongkis # 7002511Sjongkis # below rounds up the size of a file/directory, in bytes, to the 7012511Sjongkis # next multiple of 1024. This mimics the behavior of ufs especially 7022511Sjongkis # with directories. This results in a total size that's slightly 7032511Sjongkis # bigger than if du was called on a ufs directory. 704*5648Ssetje # 705*5648Ssetje # if the operation in turn is compressing the files the amount 706*5648Ssetje # of typical shrinkage is used to come up with a useful archive 707*5648Ssetje # size 7082511Sjongkis size=$(find "$UNPACKED_ROOT" -ls | nawk ' 7092511Sjongkis {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} 7102511Sjongkis END {print int(t * 1.10 / 1024)}') 711*5648Ssetje if [ "$COMPRESS" = true ] ; then 712*5648Ssetje size=`echo $size | nawk '{s = $1} END {print int(s * .53)}'` 713*5648Ssetje fi 7140Sstevel@tonic-gate 7152334Ssetje /usr/sbin/mkfile ${size}k "$TMR" 7162334Ssetje 7172334Ssetje LOFIDEV=`/usr/sbin/lofiadm -a "$TMR"` 7180Sstevel@tonic-gate if [ $? != 0 ] ; then 7190Sstevel@tonic-gate echo lofi plumb failed 7200Sstevel@tonic-gate exit 2 7210Sstevel@tonic-gate fi 7220Sstevel@tonic-gate 7232334Ssetje RLOFIDEV=`echo $LOFIDEV | sed s/lofi/rlofi/` 724*5648Ssetje newfs $RLOFIDEV < /dev/null 2> /dev/null 7251777Ssetje mkdir -p $MNT 726*5648Ssetje mount -o nologging $LOFIDEV $MNT 7271777Ssetje rmdir $MNT/lost+found 728*5648Ssetje 729*5648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 730*5648Ssetje root_is_ramdisk $size 731*5648Ssetje fi 732*5648Ssetje 7332851Sjongkis ( 7342851Sjongkis cd "$UNPACKED_ROOT" 735*5648Ssetje if [ "$COMPRESS" = true ] ; then 736*5648Ssetje compress . $MNT 737*5648Ssetje else 738*5648Ssetje find . -print | cpio -pdum $MNT 2> /dev/null 739*5648Ssetje fi 7402851Sjongkis ) 7410Sstevel@tonic-gate lockfs -f $MNT 7420Sstevel@tonic-gate umount $MNT 7430Sstevel@tonic-gate rmdir $MNT 744*5648Ssetje 745*5648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 746*5648Ssetje "$UNPACKED_ROOT/usr/sbin/installboot" \ 747*5648Ssetje "$UNPACKED_ROOT/usr/platform/sun4u/lib/fs/ufs/bootblk" \ 748*5648Ssetje $RLOFIDEV 749*5648Ssetje fi 750*5648Ssetje 7512334Ssetje lofiadm -d $LOFIDEV 7522851Sjongkis LOFIDEV= 7530Sstevel@tonic-gate 7542334Ssetje rm -f "$TMR.gz" 755*5648Ssetje 756*5648Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 757*5648Ssetje mv "$TMR" "$MR" 758*5648Ssetje else 759*5648Ssetje gzip -f "$TMR" 760*5648Ssetje mv "$TMR.gz" "$MR" 761*5648Ssetje fi 762*5648Ssetje 7631777Ssetje chmod a+r "$MR" 7640Sstevel@tonic-gate} 7650Sstevel@tonic-gate 7660Sstevel@tonic-gate# main 7670Sstevel@tonic-gate# 7680Sstevel@tonic-gate 7692334SsetjeEXTRA_SPACE=0 7702851SjongkisSTRIP_AMD64= 771*5648SsetjeCOMPRESS= 7722334Ssetje 773*5648SsetjePATH=/usr/sbin:/usr/bin:/opt/sfw/bin ; export PATH 774*5648Ssetje 775*5648Ssetjewhile getopts s:6c opt ; do 7762334Ssetje case $opt in 7772334Ssetje s) EXTRA_SPACE="$OPTARG" 7782334Ssetje ;; 7792334Ssetje 6) STRIP_AMD64=false 7802334Ssetje ;; 781*5648Ssetje c) COMPRESS=true 782*5648Ssetje ;; 7832334Ssetje *) usage 7842334Ssetje exit 1 7852334Ssetje ;; 7862334Ssetje esac 7872334Ssetjedone 7882334Ssetjeshift `expr $OPTIND - 1` 7892334Ssetje 7900Sstevel@tonic-gateif [ $# != 3 ] ; then 7910Sstevel@tonic-gate usage 7920Sstevel@tonic-gate exit 1 7930Sstevel@tonic-gatefi 7940Sstevel@tonic-gate 7951777SsetjeUNPACKED_ROOT="$3" 7961777SsetjeBASE="`pwd`" 7970Sstevel@tonic-gateMNT=/tmp/mnt$$ 7982334SsetjeTMR=/tmp/mr$$ 7992334SsetjeLOFIDEV= 8001777SsetjeMR="$2" 8010Sstevel@tonic-gate 8020Sstevel@tonic-gateif [ "`dirname $MR`" = . ] ; then 8031777Ssetje MR="$BASE/$MR" 8040Sstevel@tonic-gatefi 8050Sstevel@tonic-gateif [ "`dirname $UNPACKED_ROOT`" = . ] ; then 8061777Ssetje UNPACKED_ROOT="$BASE/$UNPACKED_ROOT" 8070Sstevel@tonic-gatefi 8080Sstevel@tonic-gate 809*5648Ssetje 810*5648SsetjeMEDIA="$MR" 811*5648Ssetje 8122334Ssetjetrap cleanup EXIT 8132334Ssetje 8140Sstevel@tonic-gatecase $1 in 8150Sstevel@tonic-gate packmedia) 8161777Ssetje if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then 817*5648Ssetje ARCHIVE=sparc.miniroot 818*5648Ssetje else 819*5648Ssetje ARCHIVE=x86.miniroot 820*5648Ssetje fi 821*5648Ssetje MR="$MR/boot/$ARCHIVE" 822*5648Ssetje packmedia "$MEDIA" "$UNPACKED_ROOT" 823*5648Ssetje pack 824*5648Ssetje ;; 825*5648Ssetje unpackmedia) 826*5648Ssetje if [ -f "$MEDIA/boot/sparc.miniroot" ] ; then 827*5648Ssetje ARCHIVE=sparc.miniroot 8281777Ssetje else 829*5648Ssetje ARCHIVE=x86.miniroot 830*5648Ssetje fi 831*5648Ssetje MR="$MR/boot/$ARCHIVE" 832*5648Ssetje unpack 833*5648Ssetje unpackmedia "$MEDIA" "$UNPACKED_ROOT" 834*5648Ssetje ;; 835*5648Ssetje pack) pack 836*5648Ssetje ;; 837*5648Ssetje unpack) unpack 838*5648Ssetje ;; 839*5648Ssetje *) usage 840*5648Ssetje ;; 8410Sstevel@tonic-gateesac 842