#!/bin/sh

set -e
if [ "${BASEDIR:=/}" = "/" ]; then
	BASEDIR=""
fi

# Package maintainers, DO NOT use this as an example for how to
# call update-menus in your postinst! This script does several things
# you shouldn't do, and doesn't do other things that you should
# do. See /usr/share/doc/menu/ for more info.

case "$1" in
triggered)
	# This is triggered by any installation of a menu file and by
	# any call to update-menus made in a package maintainer script.
	if [ -x ${BASEDIR}/usr/bin/update-menus ]; then
		if [ -z "${BASEDIR}" ]; then
			update-menus --trigger
		else
			chroot ${BASEDIR} update-menus --trigger
		fi
	fi
        exit 0
;;
*)
	chmod a+x ${BASEDIR}/usr/bin/update-menus
	if [ -z "${BASEDIR}" ]; then
		update-menus
	else
		chroot ${BASEDIR} update-menus
	fi
;;
esac

#DEBHELPER#
