#!/bin/sh -e
# Read the settings file wrote by the boot-floppies, and translaste some
# values therein into the debconf db.
. /usr/share/debconf/confmodule

if [ -e /root/dbootstrap_settings ]; then
	. /root/dbootstrap_settings || true

	# Take whatever verbosity level was used in boot floppies, and use
	# it, unless DEBIAN_PRIORITY is set (which overrides that..)
	if [ -z "$DEBIAN_PRIORITY" ]; then
		if [ "$VERBOSE" = yes ]; then
			db_set debconf/priority low
		elif [ "$VERBOSE" = quiet ]; then
			db_set debconf/priority critical
		fi
	fi

	# If there is a proxy setting, use that as the default for apt
	# setup.
	if [ "$HTTP_PROXY" ]; then
		db_set apt-setup/http_proxy "$HTTP_PROXY"
	fi

	# If there is a suite setting, use that as the default for apt
	# setup.
	if [ "$SUITE" ]; then
		# boot-floppies 3.0.22 get this wrong. Once 3.0.33 is out
		# this can be removed.
		if [ "$SUITE" = testing ]; then
			SUITE=woody
		fi
		db_set apt-setup/distribution "$SUITE"
	fi

	# TODO: move rest of settings over too. Ideally, all the dbootstrap
	# settings stuff should be in the debconf db and other scripts can
	# just use it from there. That will pave the way for d-i just
	# copying in a debconf db.
fi
