# Clean up stuff we don't need in the chroot

case "$MODE" in
    after-install)
        echo "Cleaning up chroot $ROOT"
        ### Clean up stuff that is actually harmful in the chroot
        # 64bit db4 locks makes it impossible for 32bit rpm to operate within the chroot
        rm -rf $ROOT/var/lib/rpm/__db*
        # Import RPM GPG Key
        setarch $ARCH $CHROOTEXEC $ROOT rpm --import /etc/pki/rpm-gpg/* > /dev/null 2>&1 ||:
        # Remove db4 locks again because we don't need them in the image
        rm -rf $ROOT/var/lib/rpm/__db*
        # Cleanup possible yum.conf mixup
        if [ -f $ROOT/etc/yum.conf.rpmnew ]; then
            mv -f $ROOT/etc/yum.conf.rpmnew $ROOT/etc/yum.conf
            rm -f $ROOT/etc/yum/yum.conf
        fi
        ;;
esac
