origin="Greenstone"
label="greenstone"
codename="greenstone"
uri_root='greenstone.org/repo'
arch="i386 amd64 source"
description="Repository for Greenstone packages"
base=$(dirname $0)
repos=$base/repos
setup_cmd_instruction="To use this repository, run the following commands in a terminal as root:"
install_cmd_instruction="You should now be able to install greenstone packages with:"

y() {
    echo "$@? [y|n]..." >&2
    echo -n "> " >&2
    read cho
    test "$cho" = "y" -o "$cho" = "Y"
    return $?
}

get() {
    echo "$1? [$2]..." >&2
    echo -n "> " >&2
    read cho
    test -z $cho && {
        cho=$2
        echo "Set to default '$cho'" >&2
    }
    echo $cho
}

write() {
    file=$1
    if touch $file 2>/dev/null; then
        cat - > $file
    else
        cat - | sudo tee $file
    fi
}

get_gpg() {
    if test -f $base/gpg.key.id; then
        keyid=$(cat $base/gpg.key.id)
    else
        gpg --list-keys >&2
        echo "Enter the keyid of the GPG key to use:" >&2
        while test -z $keyid; do
            echo -n "> " >&2
            read keyid
        done
        echo $keyid > $base/gpg.key.id
        echo >&2
    fi
    echo $keyid
}
