2010-04-05 22:25:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Configurations and Conditionals
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
export CLEANIMG="$1"
|
|
|
|
export NAME="$2"
|
2014-07-28 16:53:49 +00:00
|
|
|
export LC_ALL=POSIX
|
2010-04-05 22:25:37 +00:00
|
|
|
|
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 20:30:12 +00:00
|
|
|
if [ "$VERBOSE" -ge 2 -o "$DEBUG" == "1" ]; then
|
|
|
|
set -x
|
|
|
|
else
|
|
|
|
set -e
|
|
|
|
fi
|
2011-09-25 20:41:27 +00:00
|
|
|
|
2010-04-05 22:25:37 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "usage $0 <clean_image_file> <template_name>"
|
|
|
|
exit
|
2010-04-05 22:25:37 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
if [ "x$CLEANIMG" = x ]; then
|
|
|
|
echo "Image file not specified!"
|
|
|
|
exit 1
|
2010-04-05 22:25:37 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
if [ "x$NAME" = x ]; then
|
|
|
|
echo "Name not given!"
|
|
|
|
exit 1
|
2010-04-05 22:25:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
ID=$(id -ur)
|
|
|
|
|
|
|
|
if [ $ID != 0 ] ; then
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "This script should be run as root user."
|
|
|
|
exit 1
|
2010-04-05 22:25:37 +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
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Cleanup function
|
|
|
|
# ------------------------------------------------------------------------------
|
2012-11-17 11:55:05 +00:00
|
|
|
function cleanup() {
|
2014-10-14 21:04:42 +00:00
|
|
|
umount_kill "$PWD/mnt" || :
|
2012-11-17 11:55:05 +00:00
|
|
|
}
|
|
|
|
trap cleanup ERR
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Mount qubeized_image
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
export IMG="qubeized_images/$NAME-root.img"
|
|
|
|
|
2014-10-19 05:18:58 +00:00
|
|
|
echo "--> Copying $CLEANIMG to $IMG..."
|
|
|
|
cp "$CLEANIMG" "$IMG" || exit 1
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "--> Mounting $IMG"
|
2010-04-05 22:25:37 +00:00
|
|
|
mkdir -p mnt
|
2014-10-14 16:02:12 +00:00
|
|
|
mount -o loop "$IMG" mnt || exit 1
|
2013-01-25 08:03:51 +00:00
|
|
|
export INSTALLDIR=mnt
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Run qubeize script
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
"$SCRIPTSDIR/04_install_qubes.sh" || { umount "$INSTALLDIR"; exit 1; }
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Create App Menus
|
|
|
|
# ------------------------------------------------------------------------------
|
2010-04-05 22:25:37 +00:00
|
|
|
echo "--> Copying the Apps Menu shortcuts..."
|
2014-10-14 16:02:12 +00:00
|
|
|
export APPSORIG="qubeized_images/$NAME-apps.orig"
|
|
|
|
export APPSTEMPL="qubeized_images/$NAME-apps.templates"
|
|
|
|
mkdir -p "$APPSORIG"
|
|
|
|
cp -r "$(pwd)"/mnt/usr/share/applications/* "$APPSORIG"
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2012-06-22 19:12:57 +00:00
|
|
|
echo "--> Creating the Apps Menu templates..."
|
2014-10-14 16:02:12 +00:00
|
|
|
"./create_apps_templates.sh" "$APPSORIG" "$APPSTEMPL"
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2012-06-22 19:12:57 +00:00
|
|
|
echo "--> Choosing appmenus whitelists..."
|
|
|
|
rm -f appmenus
|
2014-05-13 02:40:09 +00:00
|
|
|
if [ -d "appmenus_${DIST}_${TEMPLATE_FLAVOR}" ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
ln -s "appmenus_${DIST}_${TEMPLATE_FLAVOR}" appmenus
|
2014-05-13 02:40:09 +00:00
|
|
|
elif [ -d "appmenus_$DIST" ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
ln -s "appmenus_$DIST" appmenus
|
2012-06-22 19:12:57 +00:00
|
|
|
else
|
2014-10-14 16:02:12 +00:00
|
|
|
ln -s "appmenus_generic" appmenus
|
2012-06-22 19:12:57 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Link directories so they can be mounted
|
|
|
|
# ------------------------------------------------------------------------------
|
2010-10-04 17:59:11 +00:00
|
|
|
echo "--> Linking /home to /rw/home..."
|
|
|
|
mv mnt/home mnt/home.orig
|
|
|
|
ln -sf /rw/home mnt/home
|
|
|
|
|
|
|
|
echo "--> Linking /usr/local to /rw/usrlocal..."
|
|
|
|
mv mnt/usr/local mnt/usr/local.orig
|
|
|
|
ln -sf /rw/usrlocal mnt/usr/local
|
|
|
|
|
2014-04-24 13:42:18 +00:00
|
|
|
if [ -e mnt/etc/sysconfig/i18n ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "--> Setting up default locale..."
|
|
|
|
echo LC_CTYPE=en_US.UTF-8 > mnt/etc/sysconfig/i18n
|
2012-11-20 18:52:21 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Finsh - unmount image
|
|
|
|
# ------------------------------------------------------------------------------
|
2010-04-05 22:25:37 +00:00
|
|
|
echo "--> Unmounting $IMG"
|
2014-10-14 16:02:12 +00:00
|
|
|
cleanup
|
2010-04-05 22:25:37 +00:00
|
|
|
|
|
|
|
echo "Qubeized image stored at: $IMG"
|
|
|
|
|
2010-10-04 17:18:58 +00:00
|
|
|
echo "Reducing image size (calling cleanup_image)..."
|
2014-10-14 16:02:12 +00:00
|
|
|
./cleanup_image "$IMG"
|