2010-06-18 23:41:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
IMG=$1
|
|
|
|
PKGLISTFILE=$2
|
|
|
|
|
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..."
|
|
|
|
mkfs.ext4 -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-24 09:58:14 +00:00
|
|
|
rpm -i --root=$INSTALLDIR base_rpms/*.rpm
|
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
|
|
|
|
|
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)
|
|
|
|
echo "-> Installing package groups..."
|
2010-10-01 13:39:00 +00:00
|
|
|
yum install -y --installroot=$INSTALLDIR $PKGGROUPS
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2011-09-24 10:02:02 +00:00
|
|
|
umount mnt/proc mnt
|