#! /bin/sh
set -e

. /usr/share/debconf/confmodule

db_get languagechooser/language-name
db_subst ubiquity/summary LANGUAGE "$RET"
if db_get console-setup/variant && [ "$RET" ]; then
	db_subst ubiquity/summary KEYMAP "$RET"
else
	db_get console-setup/layout
	db_subst ubiquity/summary KEYMAP "$RET"
fi
db_get passwd/user-fullname
db_subst ubiquity/summary FULLNAME "$RET"
db_get passwd/username
db_subst ubiquity/summary USERNAME "$RET"
db_get time/zone # actually continent/city (usually)
db_subst ubiquity/summary LOCATION "$RET"

# We need to run this to get hold of the partitioning summary. Our component
# takes care of ensuring that changes are not actually committed.
if [ "$PARTMAN_UPDATE_BEFORE_COMMIT" ]; then
	partman-commit || true
fi

db_capb escape
db_get ubiquity/partman-made-changes
if [ "$RET" = true ]; then
	db_metaget partman/confirm Extended_description
else
	db_metaget partman/confirm_nochanges Extended_description
fi
db_subst ubiquity/summary PARTMAN_CHANGES \
	"$(printf %s "$RET" | debconf-escape -e)"
db_capb

if [ -x /usr/share/grub-installer/grub-installer ]; then
	db_metaget ubiquity/summary/grub Description
	db_subst ubiquity/summary EXTRAS "$RET"
else
	db_subst ubiquity/summary EXTRAS ''
fi

db_input high ubiquity/summary || true
db_go

exit 0
