#!/bin/bash -e
#
# elisp remove file for Debian mailcrypt package.
# $Id: remove.in,v 1.9 2002/09/01 15:08:41 salve Exp $
#
# Copyright (C) 1998, 99, 2000, 01, 02 by Davide Giovanni Maria Salvetti.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to: The Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# On Debian GNU/Linux System you can find a copy of the GNU General Public
# License in "/usr/share/common-licenses/GPL".

set -o posix; shopt -s nullglob

FLAVOR=$1

### Historic cleanup code
clean_old_cruft () {
    rm -f /usr/share/emacs/$1/site-lisp/mailcrypt/CompilationLog.gz
    test -d /usr/share/emacs/$1/site-lisp/mailcrypt/ \
	&& rmdir --ignore-fail-on-non-empty --parents \
	/usr/share/emacs/$1/site-lisp/mailcrypt/
}
for i in /usr/share/emacs/*/site-lisp/mailcrypt/; do
    i=${i#/usr/share/emacs/}
    i=${i%/site-lisp/mailcrypt/}
    test -e /usr/bin/emacs-$i || clean_old_cruft $i
done

case "$FLAVOR" in
    (emacs)
	:
    ;;
    (emacs20|emacs21|mule2)
	echo -n "remove/mailcrypt: Removing for $FLAVOR... "
	rm -f /usr/share/$FLAVOR/site-lisp/mailcrypt//{*.elc,CompilationLog.gz}
	test -d /usr/share/$FLAVOR/site-lisp/mailcrypt/ && \
	    rmdir --ignore-fail-on-non-empty \
	    /usr/share/$FLAVOR/site-lisp/mailcrypt/
	echo "done."
    ;;
    (*)
	echo "remove/mailcrypt: Ignoring emacsen flavor $FLAVOR."
    ;;
esac

exit 0
