diff options
author | Dubiousjim <dubiousjim@gmail.com> | 2013-07-05 00:21:19 -0400 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2013-07-09 06:59:30 +0000 |
commit | ef9fb52908d3f423e6e537b84f62cb76c7868782 (patch) | |
tree | ae6e61c807f98893d84f189468444d5aa04ba3c7 /abuild-sign.in | |
parent | 7b2030a06ad926035fabbad64aac4ddeab0bb602 (diff) | |
download | abuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.tar.gz abuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.tar.bz2 abuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.tar.xz abuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.zip |
various: use long options, rework usages
Diffstat (limited to 'abuild-sign.in')
-rw-r--r-- | abuild-sign.in | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/abuild-sign.in b/abuild-sign.in index 3260e53..b5250af 100644 --- a/abuild-sign.in +++ b/abuild-sign.in @@ -40,26 +40,43 @@ do_sign() { } usage() { - echo "abuild-sign $abuild_ver" - echo "usage: abuild-sign [-hq] [-k PRIVKEY] [-p PUBKEY] INDEXFILE..." - echo "options:" - echo " -h Show this help" - echo " -k The private key to use for signing" - echo " -p The name of public key. apk add will look for /etc/apk/keys/PUBKEY" - exit 1 + cat >&2 <<__EOF__ +$prog $abuild_ver - sign indexes +Usage: $prog [-k PRIVKEY] [-p PUBKEY] INDEXFILE... +Options: + -k, --private KEY The private key to use for signing + -p, --public KEY The name of public key. apk add will look for /etc/apk/keys/KEY + -q, --quiet + -h, --help Show this help + +__EOF__ } privkey="$PACKAGER_PRIVKEY" +pubkey= +quiet= -while getopts "hk:p:q" opt; do - case $opt in - h) usage;; - k) privkey=$OPTARG;; - p) pubkey=$OPTARG;; - q) quiet=yes;; +args=`getopt -o k:p:qh --long private:,public:,quiet,help -n "$prog" -- "$@"` +if [ $? -ne 0 ]; then + usage + exit 2 +fi +eval set -- "$args" +while true; do + case $1 in + -k|--private) privkey=$2; shift;; + -p|--public) pubkey=$2; shift;; + -q|--quiet) quiet=1;; # suppresses msg + -h|--help) usage; exit;; + --) shift; break;; + *) exit 1;; # getopt error esac + shift done -shift $(( $OPTIND - 1)) +if [ $# -eq 0 ]; then + usage + exit 2 +fi if [ -z "$privkey" ]; then echo "No private key found. Use 'abuild-keygen' to generate the keys" |