# Adapted from Fedora's `debconf' package.

abinfo "Building Debconf ..."
make

abinfo "Installing Debconf ..."
make install-utils install-i18n install-rest \
    prefix="$PKGDIR"

abinfo "Installing Python 3 helper ..."
install -Dvm644 "$SRCDIR"/debconf.py \
    "$PKGDIR"/usr/lib/python${ABPY3VER}/site-packages/debconf.py

abinfo "Generating empty status templates ..."
mkdir -pv "$PKGDIR"/var/cache/debconf
touch  \
    "$PKGDIR"/var/cache/debconf/config.dat \
    "$PKGDIR"/var/cache/debconf/passwords.dat \
    "$PKGDIR"/var/cache/debconf/templates.dat

abinfo "Installing extra directories ..."
mkdir -pv \
    "$PKGDIR"/usr/share/man/{,de,fr,ru,pt_BR}/man{1,3,5,7,8}

abinfo "Marking confmodules as executable ..."
chmod -v +x "$PKGDIR"/usr/share/debconf/confmodule*

abinfo "Installing man pages ..."
for man in \
    "debconf-apt-progress" \
    "debconf-communicate" \
    "debconf-copydb" \
    "debconf-escape" \
    "debconf-set-selections" \
    "debconf-show" \
    "debconf" \
    "dpkg-preconfigure" \
    "dpkg-reconfigure" \
    "Debconf::Client::ConfModule" \
    "confmodule" \
    "debconf.conf" \
    "debconf-devel" \
    "debconf" \
    get-selections \
    getlang \
    loadtemplate \
    mergetemplate; do
    for level in 1 3 5 7 8; do
        test -f "$SRCDIR"/doc/man/gen/$man.$level && \
            install -vm644 "$SRCDIR"/doc/man/gen/$man.$level \
                "$PKGDIR"/usr/share/man/man$level/$man.$level
    done
done

abinfo "Moving /usr/sbin => /usr/bin ..."
mv -v "$PKGDIR"/usr/sbin/* \
    "$PKGDIR"/usr/bin/
rm -rv "$PKGDIR"/usr/sbin
