#!/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.3"

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

lsb_debian() {
    case "$1" in
        # Sarge (backports) and Etch
        3.1 | 4.0*)
            /bin/echo -e "7.4\n8.1\n8.2\n8.3"
            ;;
        # Lenny and unstable
        testing/unstable | testing | unstable)
            /bin/echo -e "8.3"
            ;;
        *)
            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 "$DEFAULT"
            ;;
    esac
else
    # Debian?
    if [ -e /etc/debian_version ]; then
        /bin/echo -e "8.3";
    else
        echo "supported_versions: WARNING: Unknown distribution" >&2
        /bin/echo -e "$DEFAULT"
    fi
fi

exit 0
