#!/bin/sh -e

# Source the debconf library only because it ensures our config script is
# run.
. /usr/share/debconf/confmodule

db_get debconf/preconfig
if [ "$RET" = "true" ]; then
	if [ ! -e /etc/apt/apt.conf ]; then
		mkdir -p /etc/apt/ 2>/dev/null || true
		touch /etc/apt/apt.conf
	fi
	if ! grep -q "dpkg-preconfigure --apt" /etc/apt/apt.conf; then
		echo '// Pre-configure all packages before they are installed.' >> /etc/apt/apt.conf
		echo "// (Automatically added by debconf.)" >> /etc/apt/apt.conf
		echo 'DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};' >> /etc/apt/apt.conf
	fi
fi

# Make sure the directory has safe permissions.
chmod 700 /var/lib/debconf

# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
	if [ -d /usr/doc -a ! -e /usr/doc/debconf-tiny -a -d /usr/share/doc/debconf-tiny ]; then
		ln -sf ../share/doc/debconf-tiny /usr/doc/debconf-tiny
	fi
fi
# End automatically added section

