#!/bin/sh -e

# print a list of PostgreSQL versions that are supported for the platform this
# script runs on.
#
# (C) 2005 Martin Pitt <mpitt@debian.org>

DEFAULT="8.1\n8.2"

lsb_ubuntu() {
    case "$1" in
        5.10)
            /bin/echo -e "7.4\n8.0\n8.1"
            ;;
        6.06 | 6.06LTS | 6.10)
            /bin/echo -e "$DEFAULT"
            ;;
        7.04)
            /bin/echo -e "8.2"
            ;;
        *)
            echo "supported_versions: WARNING: Unknown Ubuntu release: $1" >&2
            /bin/echo -e "$DEFAULT"
            ;;
    esac
} 

lsb_debian() {
    case "$1" in
        testing/unstable | testing | unstable | 3.1 | 4.0)
            /bin/echo -e "7.4\n8.1\n8.2"
            ;;
        *)
            echo "supported_versions: WARNING: Unknown Debian release: $1" >&2
            /bin/echo -e "$DEFAULT"
            ;;
    esac
} 

# If we have lsb_release, use it
if type lsb_release >/dev/null 2>/dev/null; then
    DISTRO="`lsb_release -is`"
    RELEASE="`lsb_release -rs`"
    
    # Ubuntu?
    case "$DISTRO" in
        Ubuntu)
            lsb_ubuntu "$RELEASE"
            ;;

        Debian)
            lsb_debian "$RELEASE"
            ;;

        *)
            echo "supported_versions: WARNING! Unknown distribution: $DISTRO" >&2
            echo "Please submit this as a bug report to your distribution." >&2
            /bin/echo -e "8.1\n8.2"
            ;;
    esac
else
    # Debian?
    if [ -e /etc/debian_version ]; then
        echo -e "7.4\n8.1\n8.2";
    else
        exit 1
    fi
fi

exit 0
