#! /bin/sh -e

PACKAGE=@PVER@-minimal
DIRLIST=@SCRIPTDIR@

case "$1" in
    configure)
        for i in $DIRLIST; do
	    if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
		echo "Compiling python modules in $i ..."
	    fi
            /usr/bin/@PVER@ @SCRIPTDIR@/compileall.py -q $i
	    if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
		echo "Compiling optimized python modules in $i ..."
	    fi
            /usr/bin/@PVER@ -O @SCRIPTDIR@/compileall.py -q $i
        done

        # Create empty directories in /usr/local
        if [ ! -e /usr/local/lib/@PVER@ ]; then
            mkdir -p /usr/local/lib/@PVER@ 2> /dev/null || true
            chmod 2775 /usr/local/lib/@PVER@ 2> /dev/null || true
            chown root:staff /usr/local/lib/@PVER@ 2> /dev/null || true
        fi
        if [ ! -e /usr/local/lib/@PVER@/site-packages ]; then
            mkdir -p /usr/local/lib/@PVER@/site-packages 2> /dev/null || true
            chmod 2775 /usr/local/lib/@PVER@/site-packages 2> /dev/null || true
            chown root:staff /usr/local/lib/@PVER@/site-packages 2> /dev/null || true
        fi
    ;;
esac

#DEBHELPER#

exit 0
