#!/bin/sh -e

# Unfortunately, we can't use in-target here as this doesn't allow to set the
# debconf frontend to noninteractive.

. /lib/chroot-setup.sh

if ! chroot_setup; then
	logger -t live-installer -- "Unexpected error; command not executed: '$@'"
	exit 1
fi

DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND

# Reconfigure popularity-contest to regenerate host ID
if [ -e /target/etc/popularity-contest.conf ]; then
	rm -f /target/etc/popularity-contest.conf
	log-output -t live-installer chroot /target \
	dpkg-reconfigure --no-reload popularity-contest
fi

chroot_cleanup
