case "$MODE" in
    commandline)
        add_option "stage-uri" "`eval_gettext "Stage 3 URI"`" "advanced" "true"
        ;;
    configure)
        if [ -n "$option_stage_uri_value" ] || [ -n "$STAGE_URI" ]; then
            STAGE_URI="${option_stage_uri_value:-$STAGE_URI}"
            PROTOCOL=$(echo ${STAGE_URI} | sed -e 's|://.\+$||')
        fi

        # only download if stage not local
        if [[ "$PROTOCOL" != "file" ]]; then
            DISTFILES_BASE="http://distfiles.gentoo.org/releases/${MAIN_ARCH}/autobuilds"

            # getting the correct stagefile from gentoo and grepping out hardened
            LATEST_STAGE=$( /usr/bin/wget -qO- ${DISTFILES_BASE}/latest-stage3-${ARCH}.txt | grep "${ARCH}-[0-9]\{8\}" )
            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
