#!/bin/sh -e

DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND

if ! test -x $TARGET/usr/bin/debconf-set-selections; then
    echo "debconf is too old for us to seed the database; not running base-config"
    exit 0
fi

# set root password - We can't do this through base-config because the
# passwd .config script clears the database before asking for the
# password

if [ -n "$root_password" ]; then
    chroot $TARGET chpasswd <<"EOF"
root:$root_password
EOF
fi

# apt-setup insists on invoking clear(1)
TERM=vt100
export TERM
# let apt-setup believe we're editing sources.list by hand; we already set it up
EDITOR=touch
export EDITOR

chroot $TARGET debconf-set-selections <<"EOF"
passwd passwd/make-user boolean false
base-config apt-setup/uri_type text edit sources list by hand
base-config base-config/pkgsel select nothing - you may manually run apt-get or any of the above later
EOF

chroot $TARGET base-config
