#! /bin/sh

set -e

if [ "$1" = "remove" ]; then
    pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W lib@PVER@-minimal \
	| grep -v '^.n' | wc -l)
    if [ "$pc" -le 1 ]; then
	find /usr/lib/@PVER@ -name '*.py[co]' -print0 | xargs -r0 rm -f
    fi
fi

if [ "$1" = "purge" ]; then
    pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W lib@PVER@-minimal \
	| grep -v '^.n' | wc -l)
    if [ "$pc" -le 1 ]; then
	rm -f /etc/@PVER@/site.py /etc/@PVER@/sitecustomize.py
	if [ -d /etc/@PVER@ ]; then
	   rmdir --ignore-fail-on-non-empty /etc/@PVER@ 2>/dev/null
	fi
    fi
fi

#DEBHELPER#

exit 0
