#!/bin/sh
# This is part of the lw-installer program: 
#    http://b9.com/lw-installer.html
#
# Copyright (c) 2002 Kevin M. Rosenberg <kmr@debian.org>
#
# lw-installer is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License (version 2) as
# published by the Free Software Foundation.
#
# lw-installer 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 a copy of the GNU General Public License on your
# Debian system in the file /usr/share/common-licenses/GPL-2

set -e

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/



pkg=lw-pro-installer
lw_dir=/usr/lib/lispworks
lw_version=4300
readme_file=readme-${lw_version}.txt
online_dirname=online

pkg_name=lispworks
lw_usrbin=/usr/bin/${pkg_name}
doc_dir=/usr/share/doc/${pkg}
lw_console=lw-console
lw_gui=lw-gui
lw_console_usrbin=/usr/bin/${lw_console}
lw_gui_usrbin=/usr/bin/${lw_gui}
clc_bin_dir=/usr/lib/common-lisp/bin
lw_clc=${clc_bin_dir}/${pkg_name}.sh


rm_lispworks()
{
    rm -f ${doc_dir}/${readme_file}.gz
    rm -f ${doc_dir}/$online_dirnamed}
    rm -fr $lw_dir
    rm -f $lw_usrbin $lw_console_usrbin $lw_gui_usrbin 
    rm -f $lw_clc
    rm -f /usr/bin/lwlicense
    rm -fr $doc_dir 
}


case "$1" in
    remove|failed-upgrade)
	if [ -x ${lw_clc} ]; then
	    /usr/sbin/unregister-common-lisp-implementation ${pkg_name} || true
	fi
	rm_lispworks
	;;            
    upgrade)
	if [ -x ${lw_clc} ]; then
	    /usr/sbin/unregister-common-lisp-implementation ${pkg_name} || true
	fi
	new_version=$2
        if [ `echo $new_version | cut -c 1-3` != '4.3' ]; then
	    rm_lispworks
	fi
	;;
    deconfigure)
	if [ -x $lw_clc ]; then
	    /usr/sbin/unregister-common-lisp-implementation $pkg_name || true
	fi
	rm_lispworks
	;;
    *)
	echo "prerm called with unknown argument \`$1'" >&2
	exit 0
	;;
esac

#DEBHELPER#



