2014-10-14 16:02:12 +00:00
|
|
|
#!/bin/bash
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Configurations
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
export IMG="$1"
|
2014-07-28 16:53:49 +00:00
|
|
|
export LC_ALL=POSIX
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2011-09-25 20:41:27 +00:00
|
|
|
RETCODE=0
|
|
|
|
|
2011-09-24 09:58:14 +00:00
|
|
|
: ${DIST=fc14}
|
|
|
|
|
2014-07-26 02:30:31 +00:00
|
|
|
. ./builder_setup >/dev/null
|
2014-10-14 21:04:42 +00:00
|
|
|
. ./umount_kill.sh >/dev/null
|
2013-02-16 15:00:50 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
if [ "$VERBOSE" -ge 2 -o "$DEBUG" == "1" ]; then
|
|
|
|
set -x
|
|
|
|
else
|
|
|
|
set -e
|
|
|
|
fi
|
2013-02-16 20:06:11 +00:00
|
|
|
|
2013-01-25 08:03:51 +00:00
|
|
|
if ! [ $# -eq 1 ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "usage $0 <img_file_name>"
|
|
|
|
exit
|
2010-06-18 23:41:29 +00:00
|
|
|
fi
|
|
|
|
|
2012-11-18 03:01:49 +00:00
|
|
|
if [ "$VERBOSE" == "1" ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
export YUM_OPTS="$YUM_OPTS -q"
|
2012-11-18 03:01:49 +00:00
|
|
|
fi
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Prepare for mount
|
|
|
|
# ------------------------------------------------------------------------------
|
2013-02-16 15:00:50 +00:00
|
|
|
echo "-> Preparing instalation of $DIST template..."
|
2014-11-06 01:11:07 +00:00
|
|
|
export INSTALLDIR="$(readlink -m mnt)"
|
|
|
|
mkdir -p "$INSTALLDIR"
|
2014-10-14 16:02:12 +00:00
|
|
|
"$SCRIPTSDIR/00_prepare.sh"
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Mount image and install core OS
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-14 20:30:12 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
if [ -f "$IMG" ]; then
|
|
|
|
echo "-> Image file already exists, assuming *update*..."
|
2010-06-18 23:41:29 +00:00
|
|
|
else
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "-> Initializing empty image..."
|
|
|
|
truncate -s 10G "$IMG" || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "-> Creating filesystem..."
|
|
|
|
mkfs.ext4 -q -F "$IMG" || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-14 20:30:12 +00:00
|
|
|
mount -o loop "$IMG" "$INSTALLDIR" || exit 1
|
2014-10-14 21:04:42 +00:00
|
|
|
trap "umount_kill $(readlink -m $INSTALLDIR)" EXIT
|
2014-10-14 20:30:12 +00:00
|
|
|
"$SCRIPTSDIR/01_install_core.sh"
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Install package groups
|
|
|
|
# ------------------------------------------------------------------------------
|
2010-06-18 23:41:29 +00:00
|
|
|
echo "-> Installing package groups..."
|
2014-10-14 16:02:12 +00:00
|
|
|
"$SCRIPTSDIR/02_install_groups.sh"
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Cleanup
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-05-13 02:30:01 +00:00
|
|
|
trap - EXIT
|
2014-10-14 16:02:12 +00:00
|
|
|
|
2013-02-16 20:18:20 +00:00
|
|
|
echo "-> Unmounting prepared_image..."
|
2014-10-14 21:04:42 +00:00
|
|
|
umount_kill "$(readlink -m $INSTALLDIR)" || :
|
2011-09-25 20:41:27 +00:00
|
|
|
|
|
|
|
exit $RETCODE
|