qubes-linux-template-builder/fedorize_image
Marek Marczykowski bf43862f3b fedorize-image: clean yum cache before install
This is mostly required for template-builder-repo, in which packages can be
rebuild without version change (so rpm hash will be different). In case of image update (instead of fresh install) cache can contain outdated information.

This is especially needed before qubeize_image, which install packages from
this repo, but one package in fedorize_image (qubes-vm-kernel-placeholder) is
installed at this stage. In any case fedorize_images is always called just
before qubeize_image, so one yum clean is enough.
2012-11-17 12:56:19 +01:00

62 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
IMG=$1
PKGLISTFILE=$2
RETCODE=0
: ${DIST=fc14}
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*..."
mount -o loop $IMG mnt || exit 1
INSTALLDIR=`pwd`/mnt/
else
echo "-> Preparing instalation of $DIST template..."
rm -f keys base_rpms
ln -sf keys_$DIST keys
ln -sf base_rpms_$DIST base_rpms
echo "-> Initializing empty image..."
truncate -s 10G $IMG || exit 1
echo "-> Creating filesystem..."
mkfs.ext4 -q -F $IMG || exit 1
mkdir -p mnt
mount -o loop $IMG mnt || exit 1
INSTALLDIR=`pwd`/mnt/
echo "-> Initializing RPM database..."
rpm --initdb --root=$INSTALLDIR
rpm --import --root=$INSTALLDIR keys/*
echo "-> Installing core RPM packages..."
rpm -i --root=$INSTALLDIR base_rpms/*.rpm || exit 1
cp clean_images/network $INSTALLDIR/etc/sysconfig
cp clean_images/resolv.conf $INSTALLDIR/etc
cp -a /dev/null /dev/zero /dev/random /dev/urandom $INSTALLDIR/dev/
fi
mount -t proc proc mnt/proc
PKGGROUPS=$(cat $PKGLISTFILE)
export YUM0=$PWD/yum_repo_qubes
echo "-> Installing package groups..."
yum clean all -c $PWD/yum.conf $YUM_OPTS -y --installroot=$PWD/mnt
yum install -c $PWD/yum.conf $YUM_OPTS -y --installroot=$INSTALLDIR $PKGGROUPS || RETCODE=1
yum update -c $PWD/yum.conf $YUM_OPTS -y --installroot=$INSTALLDIR || RETCODE=1
umount mnt/proc mnt
exit $RETCODE