2010-06-18 23:41:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
IMG=$1
|
|
|
|
PKGLISTFILE=$2
|
|
|
|
|
2011-09-25 20:41:27 +00:00
|
|
|
RETCODE=0
|
|
|
|
|
2011-09-24 09:58:14 +00:00
|
|
|
: ${DIST=fc14}
|
|
|
|
|
2010-06-18 23:41:29 +00:00
|
|
|
if ! [ $# -eq 2 ]; then
|
|
|
|
echo "usage $0 <img_file_name> <package_list>"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -f $IMG ]; then
|
|
|
|
echo "-> Image file already exists, assuming *update*..."
|
2011-03-19 02:30:23 +00:00
|
|
|
mount -o loop $IMG mnt || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
INSTALLDIR=`pwd`/mnt/
|
|
|
|
else
|
|
|
|
|
2011-09-24 09:58:14 +00:00
|
|
|
echo "-> Preparing instalation of $DIST template..."
|
|
|
|
rm -f keys base_rpms
|
|
|
|
ln -sf keys_$DIST keys
|
|
|
|
ln -sf base_rpms_$DIST base_rpms
|
|
|
|
|
2011-03-19 02:30:23 +00:00
|
|
|
echo "-> Initializing empty image..."
|
|
|
|
truncate -s 10G $IMG || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2011-03-19 02:30:23 +00:00
|
|
|
echo "-> Creating filesystem..."
|
2012-11-14 15:50:28 +00:00
|
|
|
mkfs.ext4 -q -F $IMG || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
|
|
|
|
mkdir -p mnt
|
2011-03-19 02:30:23 +00:00
|
|
|
mount -o loop $IMG mnt || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
|
|
|
|
INSTALLDIR=`pwd`/mnt/
|
|
|
|
|
|
|
|
echo "-> Initializing RPM database..."
|
|
|
|
rpm --initdb --root=$INSTALLDIR
|
|
|
|
rpm --import --root=$INSTALLDIR keys/*
|
|
|
|
|
|
|
|
echo "-> Installing core RPM packages..."
|
2011-09-25 20:41:27 +00:00
|
|
|
rpm -i --root=$INSTALLDIR base_rpms/*.rpm || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2010-06-20 20:16:30 +00:00
|
|
|
cp clean_images/network $INSTALLDIR/etc/sysconfig
|
|
|
|
cp clean_images/resolv.conf $INSTALLDIR/etc
|
2012-10-19 01:44:11 +00:00
|
|
|
cp -a /dev/null /dev/zero /dev/random /dev/urandom $INSTALLDIR/dev/
|
2010-06-20 20:16:30 +00:00
|
|
|
|
2010-06-18 23:41:29 +00:00
|
|
|
fi
|
|
|
|
|
2011-09-24 10:02:02 +00:00
|
|
|
mount -t proc proc mnt/proc
|
2010-06-18 23:41:29 +00:00
|
|
|
PKGGROUPS=$(cat $PKGLISTFILE)
|
2012-11-14 15:12:18 +00:00
|
|
|
export YUM0=$PWD/yum_repo_qubes
|
2010-06-18 23:41:29 +00:00
|
|
|
echo "-> Installing package groups..."
|
2012-11-17 11:16:54 +00:00
|
|
|
yum clean all -c $PWD/yum.conf $YUM_OPTS -y --installroot=$PWD/mnt
|
2011-11-09 14:00:14 +00:00
|
|
|
yum install -c $PWD/yum.conf $YUM_OPTS -y --installroot=$INSTALLDIR $PKGGROUPS || RETCODE=1
|
2012-07-20 14:00:56 +00:00
|
|
|
yum update -c $PWD/yum.conf $YUM_OPTS -y --installroot=$INSTALLDIR || RETCODE=1
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2011-09-24 10:02:02 +00:00
|
|
|
umount mnt/proc mnt
|
2011-09-25 20:41:27 +00:00
|
|
|
|
|
|
|
exit $RETCODE
|