#!/bin/sh

if [ -r debian/control ]; then
    control=debian/control
    changelog=debian/changelog

elif [ -r ../debian/control ]; then
    control=../debian/control
    changelog=../debian/changelog

elif [ -r control ]; then
    control=control
    changelog=changelog

else
    echo "can't find the Debian control file." >&2
    exit 1
fi

case "$1" in
    "-d")
        grep '^Description:' $control | sed -e 's/.*: //'
        ;;

    "-dl")
        sed -e '1,/^Description:/ d' $control
        ;;

    *)
        grep '^amavis-stats \(.*\)' $changelog | head -1 | \
        sed -e 's/.*(\(.*\)).*/\1/'
        
        ;;
esac

