#! /bin/sh
 
packageinfo='./packageinfo.sh'
case "$#" in
 2)
    case "$1" in
     -p|--packageinfo)
	packageinfo="$2"
    esac
    ;;
 0)
    ;;
 *) echo "Usage: $0 [-p packageinfo.sh]"
    exit 1
    ;;
esac

# This script must be executed from the TLD of the source tree...
. "$packageinfo"

NAME="$version"
case $point in
 [1-9]*)
    NAME="${NAME}p${point}"
    ;;
 NEW) ;;
 '') ;;
 *) echo "Unexpected value for 'point' <$point>!"
    exit 1
    ;;
esac

case $special in
 '') ;;
 *) NAME="${NAME}-${special}" ;;
esac

case "$prerelease::$repotype" in
 ''::*)
    ;;
 beta::stable)
    NAME="${NAME}-beta${betapoint}"
    ;;
 rc::dev|RC::dev)
    NAME="${NAME}-RC"
    ;;
 rc::stable|RC::stable)
    NAME="${NAME}-RC${rcpoint}"
    ;;
 *) echo "Unexpected value for 'prerelease::repotype' <$prerelease::$repotype>!"
    exit 1
    ;;
esac

echo "$NAME"
