qubes-linux-template-builder/qubeize_image
Olivier Medoc 7e17847377 template_builder: made make scripts OS independent.
An important note is that each OS script need to setup itself its own chroot environment (like creating /proc...).
2013-02-06 02:53:30 +01:00

92 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
export CLEANIMG=$1
export NAME=$2
set -e
if [ $# -eq 0 ]; then
echo "usage $0 <clean_image_file> <template_name>"
exit
fi
if [ x$CLEANIMG = x ]; then
echo "Image file not specified!"
exit 1
fi
if [ x$NAME = x ]; then
echo "Name not given!"
exit 1
fi
ID=$(id -ur)
if [ $ID != 0 ] ; then
echo "This script should be run as root user."
exit 1
fi
if [ "$VERBOSE" == "1" ]; then
export YUM_OPTS="$YUM_OPTS -q"
fi
function cleanup() {
if grep -q " $PWD/mnt " /proc/mounts; then
umount mnt/proc mnt
fi
}
trap cleanup ERR
export IMG=qubeized_images/$NAME-root.img
echo "--> Copying $CLEANIMG to $IMG..."
echo "--> cp could fail with a sparse file error"
cp $CLEANIMG $IMG || exit 1
echo "--> Mouting $IMG"
mkdir -p mnt
mount -o loop $IMG mnt || exit 1
export INSTALLDIR=mnt
scripts_"${DIST}"/04_install_qubes.sh
echo "--> Copying the Apps Menu shortcuts..."
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
echo "--> Creating the Apps Menu templates..."
./create_apps_templates.sh $APPSORIG $APPSTEMPL
echo "--> Choosing appmenus whitelists..."
rm -f appmenus
if [ -d "appmenus_$DIST" ]; then
ln -s "appmenus_$DIST" appmenus
else
ln -s "appmenus_generic" appmenus
fi
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
if ! [ -r mnt/etc/sysconfig/i18n ]; then
echo "--> Setting up default locale..."
echo LC_CTYPE=en_US.UTF-8 > mnt/etc/sysconfig/i18n
fi
echo "--> Unmounting $IMG"
umount mnt
echo "Qubeized image stored at: $IMG"
echo "Reducing image size (calling cleanup_image)..."
./cleanup_image $IMG