root_archive.ksh revision e482cb0a07ec2a52aa89607892b8e7571b2bff92
#
# 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 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
# 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
#
# This utility is also used to pack parts (in essence the window system,
# miniroot. (un)packmedia will recognize that they are being run a SPARC
# miniroot and do the appropriate work.
#
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
}
{
MEDIA="$1"
MINIROOT="$2"
else
fi
# create the graphics and non-graphics X archive
#
(
cd "$MINIROOT/usr"
)
}
{
MEDIA="$1"
MINIROOT="$2"
# archive package databases to conserve memory
#
(
cd "$MINIROOT"
)
# clear out 64 bit support to conserve memory
#
fi
# copy the install menu to menu.lst so we have a menu
# on the install media
#
cp ${MINIROOT}/boot/grub/install_menu \
fi
(
ln -sf ../../../boot/x86.miniroot
)
}
{
MEDIA="$1"
UNPACKED_ROOT="$2"
else
fi
# unpack X
#
(
cd "$UNPACKED_ROOT/usr"
)
}
{
MEDIA="$1"
UNPACKED_ROOT="$2"
# unpack package databases
#
(
cd "$UNPACKED_ROOT"
)
}
{
rm -rf "$UNPACKED_ROOT"
mkdir -p "$UNPACKED_ROOT"
(
cd $MNT
)
}
unpack()
{
exit 1
fi
if [ $? != 0 ] ; then
exit 2
fi
else
printf "invalid root archive\n"
fi
}
pack()
{
exit 1
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.
{t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
END {print int(t * 1.10 / 1024)}')
if [ $? != 0 ] ; then
exit 2
fi
(
cd "$UNPACKED_ROOT"
)
}
# main
#
while getopts s:6 opt ; do
s) EXTRA_SPACE="$OPTARG"
;;
6) STRIP_AMD64=false
;;
*) usage
exit 1
;;
esac
done
if [ $# != 3 ] ; then
exit 1
fi
UNPACKED_ROOT="$3"
MR="$2"
fi
fi
case $1 in
if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
else
fi ;;
if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
else
fi ;;
*) usage ;;
esac