You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qubes-linux-template-builder/prepare_image

82 lines
2.2 KiB

#!/bin/bash
#XXX: use bash #!/bin/sh
# ------------------------------------------------------------------------------
# Configurations
# ------------------------------------------------------------------------------
export IMG="$1"
export LC_ALL=POSIX
RETCODE=0
: ${DIST=fc14}
. ./builder_setup >/dev/null
. ./umount.sh >/dev/null
if [ "$VERBOSE" -ge 2 -o "$DEBUG" == "1" ]; then
set -x
else
set -e
fi
if ! [ $# -eq 1 ]; then
echo "usage $0 <img_file_name>"
exit
fi
if [ "$VERBOSE" == "1" ]; then
export YUM_OPTS="$YUM_OPTS -q"
fi
# ------------------------------------------------------------------------------
# Prepare for mount
# ------------------------------------------------------------------------------
echo "-> Preparing instalation of $DIST template..."
"$SCRIPTSDIR/00_prepare.sh"
# ------------------------------------------------------------------------------
# Mount image and install core OS
# ------------------------------------------------------------------------------
if [ -f "$IMG" ]; then
echo "-> Image file already exists, assuming *update*..."
mount -o loop "$IMG" mnt || exit 1
export INSTALLDIR="`pwd`/mnt/"
trap "umount_image ${INSTALLDIR::-1}" EXIT
# XXX: Temp; just for debugging
if ! [ -f "$INSTALLDIR/tmp/.prepared_debootstrap" ]; then
"$SCRIPTSDIR/01_install_core.sh"
fi
else
echo "-> Initializing empty image..."
truncate -s 10G "$IMG" || exit 1
echo "-> Creating filesystem..."
mkfs.ext4 -q -F "$IMG" || exit 1
mkdir -p mnt
mount -o loop "$IMG" mnt || exit 1
export INSTALLDIR="`pwd`/mnt/"
trap "umount_image ${INSTALLDIR::-1}" EXIT
"$SCRIPTSDIR/01_install_core.sh"
fi
# ------------------------------------------------------------------------------
# Install package groups
# ------------------------------------------------------------------------------
echo "-> Installing package groups..."
"$SCRIPTSDIR/02_install_groups.sh"
# ------------------------------------------------------------------------------
# Cleanup
# ------------------------------------------------------------------------------
trap - EXIT
echo "-> Unmounting prepared_image..."
umount_image "$INSTALLDIR" || :
exit $RETCODE