#!/bin/sh
# /usr/lib/emacsen-common/packages/remove/foo
set -e

ELPA_DIR=#ELPAPACKAGE#-#ELPAVERSION#

FLAVOR=$1
elc_dir=/usr/share/${FLAVOR}/site-lisp/elpa/${ELPA_DIR}

FLAVOR=$1
case $FLAVOR in
    emacs)
        exit 0
        ;;
    emacs23)
        echo remove/${ELPA_DIR}: Skipping obsolete emacs ${FLAVOUR}
        exit 0
        ;;
    xemacs*)
           echo remove/${ELPA_DIR}: Skipping unsupported emacs ${FLAVOUR}
        ;;
    *)
        echo remove/${ELPA_DIR}: Handling removal of emacsen flavor ${FLAVOR}
esac

echo dh-elpa: purging flavor specific files for ${FLAVOR}
rm -f ${elc_dir}/*.elc
find ${elc_dir} -type l -delete
rm -f ${elc_dir}/Install.log*
if test -e "${elc_dir}"
then
  rmdir --ignore-fail-on-non-empty "${elc_dir}"
fi

exit 0;
