case "$MODE" in
    configure)
	if [ -z "${STAGE_URI}" ]; then
	    DISTFILES_BASE="http://distfiles.gentoo.org/releases/${ARCH}/autobuilds"
	
	    # some architectures use other names in the stagefile
	    if [[ "${ARCH}" == "x86" ]]; then
		STAGE_ARCH="i686"
	    else
		STAGE_ARCH=${ARCH}
	    fi

	    # getting the correct stagefile from gentoo and grepping out hardened
	    LATEST_STAGE=$( /usr/bin/wget -qO- ${DISTFILES_BASE}/latest-stage3.txt | grep -E ".+${STAGE_ARCH}-[^hardened]" )
	    STAGE_URI="${DISTFILES_BASE}/${LATEST_STAGE}"

	    if [[ "${STAGE_URI}" != *.tar.bz2 ]]; then
		printf "`eval_gettext "Failed finding stage in: ${STAGE_URI}"`\n"
		STAGE_URI=""
	    fi
	fi
    ;;
esac
