2010-04-05 22:25:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-01-25 08:03:51 +00:00
|
|
|
export CLEANIMG=$1
|
|
|
|
export NAME=$2
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2013-02-16 15:00:50 +00:00
|
|
|
. ./builder_setup
|
|
|
|
|
2011-09-25 20:41:27 +00:00
|
|
|
set -e
|
|
|
|
|
2010-04-05 22:25:37 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "usage $0 <clean_image_file> <template_name>"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ x$CLEANIMG = x ]; then
|
|
|
|
echo "Image file not specified!"
|
2010-06-18 23:43:52 +00:00
|
|
|
exit 1
|
2010-04-05 22:25:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ x$NAME = x ]; then
|
|
|
|
echo "Name not given!"
|
2010-06-18 23:43:52 +00:00
|
|
|
exit 1
|
2010-04-05 22:25:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
ID=$(id -ur)
|
|
|
|
|
|
|
|
if [ $ID != 0 ] ; then
|
2013-02-16 14:27:44 +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
|
2013-02-16 14:27:44 +00:00
|
|
|
export YUM_OPTS="$YUM_OPTS -q"
|
2012-11-18 03:01:49 +00:00
|
|
|
fi
|
|
|
|
|
2012-11-17 11:55:05 +00:00
|
|
|
function cleanup() {
|
2013-12-08 19:33:28 +00:00
|
|
|
if grep -q " $PWD/mnt/proc " /proc/mounts; then
|
|
|
|
umount mnt/proc
|
|
|
|
fi
|
2013-02-16 14:27:44 +00:00
|
|
|
if grep -q " $PWD/mnt " /proc/mounts; then
|
2013-12-08 19:33:28 +00:00
|
|
|
umount mnt
|
2013-02-16 14:27:44 +00:00
|
|
|
fi
|
2012-11-17 11:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup ERR
|
2010-04-05 22:25:37 +00:00
|
|
|
|
2013-01-25 08:03:51 +00:00
|
|
|
export IMG=qubeized_images/$NAME-root.img
|
2010-04-05 22:25:37 +00:00
|
|
|
echo "--> Copying $CLEANIMG to $IMG..."
|
|
|
|
cp $CLEANIMG $IMG || exit 1
|
|
|
|
|
|
|
|
echo "--> Mouting $IMG"
|
|
|
|
|
|
|
|
mkdir -p mnt
|
2011-03-19 02:30:23 +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-05-13 02:30:01 +00:00
|
|
|
$SCRIPTSDIR/04_install_qubes.sh || exit 1
|
2010-04-05 22:25:37 +00:00
|
|
|
|
|
|
|
echo "--> Copying the Apps Menu shortcuts..."
|
2013-01-25 08:03:51 +00:00
|
|
|
export APPSORIG=qubeized_images/$NAME-apps.orig
|
|
|
|
export APPSTEMPL=qubeized_images/$NAME-apps.templates
|
2010-04-05 22:25:37 +00:00
|
|
|
mkdir -p $APPSORIG
|
|
|
|
cp -r $(pwd)/mnt/usr/share/applications/* $APPSORIG
|
|
|
|
|
2012-06-22 19:12:57 +00:00
|
|
|
echo "--> Creating the Apps Menu templates..."
|
2010-06-18 23:43:52 +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
|
|
|
|
if [ -d "appmenus_$DIST" ]; then
|
2013-02-16 14:27:44 +00:00
|
|
|
ln -s "appmenus_$DIST" appmenus
|
2012-06-22 19:12:57 +00:00
|
|
|
else
|
2013-02-16 14:27:44 +00:00
|
|
|
ln -s "appmenus_generic" appmenus
|
2012-06-22 19:12:57 +00:00
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
2012-11-20 18:52:21 +00:00
|
|
|
if ! [ -r mnt/etc/sysconfig/i18n ]; then
|
2013-02-16 14:27:44 +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
|
|
|
|
|
2010-04-05 22:25:37 +00:00
|
|
|
echo "--> Unmounting $IMG"
|
2013-01-25 08:03:51 +00:00
|
|
|
umount mnt
|
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)..."
|
|
|
|
./cleanup_image $IMG
|