#! /bin/sh

set -e

#DEBHELPER#

rebuild_cache()
{
    # remove all cache files, then rebuild for the installed python versions
    rm -f /usr/lib/python[23].?/*-packages/nevow/plugins/dropin.cache
    for p in $(pyversions -i); do
            $p -c 'from twisted.plugin import IPlugin, getPlugins; import nevow.plugins; list(getPlugins(IPlugin)); list(getPlugins(IPlugin, nevow.plugins))' >/dev/null 2>&1 || true
    done
}

case "$1" in
    triggered)
	if [ "$2" = "nevow-plugins-cache" ]; then
	    rebuild_cache
	fi
	;;
    configure)
	rebuild_cache
        ;;
esac

exit 0
