#!/bin/sh -e

DEBREINSTALL="`tempfile`.$$"

if [ "$1" = purge -a -e /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
    db_purge
    rm -rf /var/cache/localepurge
    rm -f /etc/locale.nopurge

echo ""
echo "  To reinstall all the packages which localepurge has been taking care"
echo "  of before, you can use the following command:"
echo ""
echo "    apt-get --reinstall install \`dpkg -S LC_MESSAGES | cut -d: -f1 | tr ', ' '\n' | sort -u\`"
echo ""
# create a ready made shell script for further usage:
echo "apt-get -u --reinstall --fix-missing install \`dpkg -S LC_MESSAGES | cut -d: -f1 | tr ', ' '\n' | sort -u\`" > $DEBREINSTALL
mv $DEBREINSTALL /var/tmp/reinstall_debs.sh

echo "  For your further usage, the file \"/var/tmp/reinstall_debs.sh\""
echo "  contains an enhanced version the command line printed out above."
echo ""
fi
