#!/bin/sh
#
# Report if anything went wrong during installation, and ask the user
# to report the errors.  This must be done after 85debian-edu to make
# sure noninteractive installation is turned off, and before
# 90final-messages to leave the user with the "successful
# installation" greeting after this message.

set -e

pkglibdir=/usr/lib/debian-edu-install

. $pkglibdir/debian-edu-common

init_debconf

#set -x

# Ask the installer to report bugs if something went wrong.
if test -f $debian_edu_error_flag_file ; then
    print "info: Something failed during installation."

    db_title "Debian-Edu installation failed"

    # Quick fix to make sure all error entries at least are displayed.
    # The correct fix is to find out how to replace a debconf variable
    # with multiline content.
    errorlist=`cat $debian_edu_error_flag_file | tr "\n" "," | sed 's/,$//'`

    # This do not work on multiline substitution content
    db_subst debian-edu-install/report-bug errorlist "$errorlist"

    db_input critical debian-edu-install/report-bug || [ $? -eq 30 ]
    db_go
    rm -f $debian_edu_error_flag_file
else
    print "info: Successful installation."
fi
print "info: debian-edu-install done."

exit 0
