#!/bin/sh

# Emacs remove: /usr/lib/emacsen-common/packages/remove/miscbits-el

# Copyright 2005, 2007, 2008, 2009, 2012 Kevin Ryde
# Copyright 1998, 2009 Robert Browning
#
# This file is part of miscbits-el.  It was derived from the example code
# in /usr/share/doc/emacsen-common/debian-emacs-policy.gz of emacsen-common
# version 1.4.16.  That code is by Rob Browning and covered by the GPL, as
# described in /usr/share/doc/emacsen-common/copyright.
#
#
# miscbits-el 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 3, or (at your option) any later
# version.
#
# miscbits-el 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, see <http://www.gnu.org/licenses/>.

set -e

FLAVOR=$1
elc_dir=/usr/share/${FLAVOR}/site-lisp/miscbits-el

echo remove/miscbits-el: Handling removal of emacsen flavor ${FLAVOR}

if [ ${FLAVOR} != emacs ]
then
  echo miscbits-el: purging byte-compiled files for ${FLAVOR}

  # -f to ignore if the directory is somehow already gone.
  #
  # *.el~ to remove miscbits-el-loaddefs.el~ which may have been created by
  # the loaddefs generation in past miscbits-el package versions.
  #
  rm -f $elc_dir/*.el $elc_dir/*.el~ $elc_dir/*.elc

  # || true to quietly ignore if the directory is somehow not empty
  #
  rmdir $elc_dir || true
fi
exit 0
