1#!/bin/sh
2set -e
3
4if [ -r debian/control ]; then
5    control=debian/control
6    changelog=debian/changelog
7
8elif [ -r ../debian/control ]; then
9    control=../debian/control
10    changelog=../debian/changelog
11
12elif [ -r control ]; then
13    control=control
14    changelog=changelog
15
16else
17    echo "can't find the Debian control file." >&2
18    exit 1
19fi
20
21case "$1" in
22    "-d")
23        grep '^Description:' $control | sed -e 's/.*: //'
24        ;;
25
26    "-dl")
27        sed -e '1,/^Description:/ d' $control
28        ;;
29
30    *)
31        version=$(grep '^amavis-stats \(.*\)' $changelog | head -1 | \
32        sed -e 's/.*(\(.*\)).*/\1/')
33        echo $version
34        ;;
35esac
36
37