root_archive.ksh revision 342440ec94087b8c751c580ab9ed6c693d31d418
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# both ufs and hsfs (iso9660) format archives are unpacked
# only ufs archives are generated
#
# usage: pack <archive> <root>
# unpack <archive> <root>
# packmedia <solaris_image> <root>
# unpackmedia <solaris_image> <root>
#
# Where <root> is the directory to unpack to and will be cleaned out
# if it exists.
#
# Solaris media and all the things that don't go into the ramdisk image
# are (un)cpio'd as well
#
usage()
{
printf "usage: root_archive pack <archive> <root>\n"
printf " root_archive unpack <archive> <root>\n"
printf " root_archive packmedia <solaris_image> <root>\n"
printf " root_archive unpackmedia <solaris_image> <root>\n"
}
cleanup()
{
if [ -d $MNT ] ; then
fi
fi
}
{
MEDIA="$1"
MINIROOT="$2"
(
# Prepopulate the gconf database. This needs to be done and
# done first for several reasons. 1) Archiving out the gnome
# libraries and binaries causes the gconftool-2 to not run
# appropriately at boot time. 2) The binaries and libraries
# needed to run this are big and thus we want to archive
# them separately. 3) Having schemas prepopluated in the
# miniroot means faster boot times.
#
cd "$MINIROOT"
export HOME
umask 0022
GCONF_CONFIG_SOURCE="xml:merged:$MINIROOT/$mumble"
export GCONF_CONFIG_SOURCE
export SCHEMADIR
$SCHEMADIR/*.schemas >/dev/null 2>&1
echo '
xml:readonly:/etc/gconf/gconf.xml.defaults
)
}
{
MEDIA="$1"
MINIROOT="$2"
# Create the gnome archive
#
(
cd "$MINIROOT"
-print > /tmp/gnome_share.$$ 2>/dev/null
if [ ! -f /tmp/gnome_share.$$ ] ; then
echo "/tmp/gnome_share.$$ file list not found."
return
fi
usr/lib/libfontconfig*\.so\.* usr/lib/libgmodule*\.so\.* \
usr/lib/libgobject*\.so\.* usr/lib/libgthread*\.so\.* \
print > /tmp/gnome_libdir.$$ 2>/dev/null
if [ ! -f /tmp/gnome_lib.$$ -a ! -f gnome_libdir.$$ ] ; then
return
fi
return
fi
return
fi
# Cat all the files together and create the gnome archive
#
cat /tmp/gnome_libdir.$$ /tmp/gnome_lib.$$ \
return
fi
# Save off this file in the miniroot for use later
# when unpacking. Clean up old cruft if there.
#
if [ -f .tmp_proto/gnome_saved ]; then
rm -f .tmp_proto/gnome_saved
fi
cp /tmp/gnome.$$ .tmp_proto/gnome_saved
# Create gnome archive
#
# Remove files from miniroot that are in archive.
# Create symlinks for files in archive
rm -rf `cat /tmp/gnome_share.$$`
for i in `cat /tmp/gnome_share.$$`
do
done
do
done
rm -rf `cat /tmp/gnome_libdir.$$`
for i in `cat /tmp/gnome_libdir.$$`
do
done
do
done
do
done
rm -f /tmp/gnome_share.$$
rm -f /tmp/gnome_libdir.$$
)
}
{
MEDIA="$1"
MINIROOT="$2"
# Archive the java wizard components that are only used in the
# non developer express path.
#
(
cd "$MINIROOT"
return
fi
)
}
{
MEDIA="$1"
MINIROOT="$2"
# Archive misc stuff that is needed by non devex installer
#
(
cd "$MINIROOT"
return
fi
)
}
{
MEDIA="$1"
MINIROOT="$2"
# Archive perl, it is only needed by gnome gui.
#
(
# in usr
cd "$MINIROOT"
return
fi
)
}
{
MEDIA="$1"
MINIROOT="$2"
# create the graphics and non-graphics X archive
#
(
cd "$MINIROOT"
)
}
{
MEDIA="$1"
MINIROOT="$2"
(
cd "$MINIROOT"
)
}
{
}
{
MEDIA="$1"
MINIROOT="$2"
ARCHIVES="X X_small perl lpmisc javaui gnome"
(
ln -sf ../../../boot/x86.miniroot
)
fi
fi
ln -sf ../../../../../boot/sparc.miniroot \
"$archdir/boot_archive"
"$archdir"
"$archdir"
ln -sf ../../boot/sparc.miniroot \
fi
done
# archive package databases to conserve memory
#
(
cd "$MINIROOT"
)
# Take out the gnome and java parts of the installer from
# the miniroot. These are not required to boot the system
# and start the installers.
# Now that the 64-bit archives & miniroot have been created,
# restore the files from archives and save the 64-bit
# archives. Strip the 64-bit objects and create the
# 32-bit archives and miniroot
done
fi
fi
# copy the install menu to menu.lst so we have a menu
# on the install media
#
fi
#
#
(
cd ${MINIROOT}
)
fi
}
{
MEDIA="$1"
UNPACKED_ROOT="$2"
# unpack X
#
(
cd "$UNPACKED_ROOT"
)
}
{
MEDIA="$1"
UNPACKED_ROOT="$2"
# unpack package databases
#
(
cd "$UNPACKED_ROOT"
# unpack gnome, perl, java and misc
# Remove symlinks left from unpacking x86.miniroot so that
# unpacking subsequent archives will populate appropriately.
#
# Gnome list saved off from packmedia
for i in `cat .tmp_proto/gnome_saved`
do
done
)
}
{
rm -rf "$UNPACKED_ROOT"
mkdir -p "$UNPACKED_ROOT"
(
cd $MNT
)
}
unpack()
{
exit 1
fi
else
fi
if [ $? != 0 ] ; then
exit 2
fi
else
printf "invalid root archive\n"
fi
fi
}
compress()
{
SRC=$1
DST=$2
(
cd $SRC
# copy all files over to preserve hard links
#
fiocompress -mc $file $DST/$file &
fi
done
# now re-copy a couple of uncompressed files
# some of the files are replaced with links into
# from there as well and add them to the list ti
# be copied uncompressed
(
)
(
cd $DST
)
done
else
fi
)
}
{
}
pack()
{
exit 1
fi
# always compress if fiocompress exists
#
if [ -x /usr/sbin/fiocompress ] ; then
COMPRESS=true
fi
# Estimate image size and add %10 overhead for ufs stuff.
# Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem,
# e.g. zfs, in which the disk usage is less than the sum of the file
# sizes. The nawk code
#
# {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
#
# next multiple of 1024. This mimics the behavior of ufs especially
# with directories. This results in a total size that's slightly
# bigger than if du was called on a ufs directory.
#
# if the operation in turn is compressing the files the amount
# of typical shrinkage is used to come up with a useful archive
# size
{t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
END {print int(t * 1.10 / 1024)}')
fi
if [ $? != 0 ] ; then
exit 2
fi
fi
(
cd "$UNPACKED_ROOT"
else
fi
)
fi
else
fi
}
{
}
# main
#
while getopts s:6c opt ; do
s) EXTRA_SPACE="$OPTARG"
;;
6) STRIP_AMD64=false
;;
c) COMPRESS=true
;;
*) usage
exit 1
;;
esac
done
if [ $# != 3 ] ; then
exit 1
fi
UNPACKED_ROOT="$3"
MR="$2"
fi
fi
case $1 in
else
fi
;;
else
fi
;;
;;
;;
*) usage
;;
esac