#!/bin/sh
# postinst script for bergman
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package

export BMROOT=/usr/share/common-lisp/source/bergman

case "$1" in
    configure)
	mkdir -p $BMROOT/bin/clisp/unix
	mkdir -p $BMROOT/lap/clisp/unix
	mkdir -p $BMROOT/logs
	mkdir -p /usr/libexec/bergman
	cd $BMROOT/scripts/clisp/unix
	./mkbergman /usr/bin
	mv $BMROOT/bin/clisp/unix/bergman.exe /usr/libexec/bergman/bergman.exe
	mv -v $BMROOT/bin/clisp/unix/bergman /usr/bin
	sed -i "s|$BMROOT/bin/clisp/unix|/usr/libexec/bergman|" /usr/bin/bergman
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
