case $MODE in
  configure)
    ARCH=${ARCH:-"$(dpkg --print-architecture)"}
    # force building an i386 environment on amd64 servers
    if [ "$ARCH" = "amd64" ]; then
	ARCH=i386

	if [ -z "$option_dist_value" ] ; then
	    option_dist_value=$(lsb_release -sc)
	    echo "info: Missing LTSP dist value, setting to $option_dist_value"
	fi

	# Make sure to inherit proxy setting from host, inspired by
	# ltsp-build-client/Debian/010-http-proxy in the ltsp-server
	# package.  See also bug #766460.
	if [ -z "$http_proxy" ]; then
	    eval $(apt-config shell http_proxy acquire::http::proxy)
	    [ "$http_proxy" = "false" ] && http_proxy=""
	    export http_proxy
	fi

	# Force network APT source for the netinst CD, as the i386
	# binaries are missing on the CD.
	if [ file:///media/cdrom = "$option_mirror_value" ] ; then
	    if grep -qi "^deb cdrom:.*i386" /etc/apt/sources.list; then
		echo "info: Found i386 binaries on amd64 CD/DVD.  Keeping LTSP mirror as '$MIRROR'"
	    else
		NEWMIRROR=$(awk '/^deb (http|ftp):\/\/.* main/ { if (!first) { print $2; first=1 } }' < /etc/apt/sources.list)
		echo "info: Changing LTSP mirror from '$option_mirror_value' to '$NEWMIRROR'"
		option_mirror_value=$NEWMIRROR
		if [ high = "$http_proxy" ]; then
		    unset http_proxy
		    echo "info: http_proxy was set to high, this seems to be a debconf bug, remove it"
		fi
	    fi
	fi
    fi
  ;;
esac
