X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id 0885EDC7576 for ; Fri, 5 Jul 2013 04:21:49 +0000 (UTC) Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 1DDFC20767 for ; Fri, 5 Jul 2013 00:21:46 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 05 Jul 2013 00:21:46 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :in-reply-to:references; s=smtpout; bh=wZc46X4wfB6bbXNtMhXnNd2sM X4=; b=GGJ2LRwN4xWYwhyTm6VyTOtjEkZoHW9XybTgJuA+W7+nV3jDpeoHyWDon get7CV58BrCGE/U1iK3xme57y/574UCOBZ27ugnILUE9yXMt1eNEUJQ8EWK0mCBN MlevlVD6c+E4v6VIH1ks42Tw30ZdxDDn2Et3Y14KkPXC3wb1K0= X-Sasl-enc: nhKxw4EVFCXDKMRY2trphjsFpIm5A12qSQnKhDDXa0lz 1372998105 Received: from localhost (unknown [69.86.161.244]) by mail.messagingengine.com (Postfix) with ESMTPA id C9FDA680204 for ; Fri, 5 Jul 2013 00:21:45 -0400 (EDT) From: Dubiousjim To: alpine-devel@lists.alpinelinux.org Subject: [alpine-devel] [PATCH 10/31] various: use long options, rework usages Date: Fri, 5 Jul 2013 00:21:19 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: --- abuild-keygen.in | 54 +++++++++++++++++++++++++++++++------------------ abuild-sign.in | 45 ++++++++++++++++++++++++++++------------- abump.in | 53 ++++++++++++++++++++++++++++++++---------------- apkgrel.in | 61 ++++++++++++++++++++++++++++++++------------------------ checkapk.in | 12 +++++++++++ newapkbuild.in | 35 ++++++++++++++++---------------- 6 files changed, 167 insertions(+), 93 deletions(-) diff --git a/abuild-keygen.in b/abuild-keygen.in index 9b748d3..34af0ee 100644 --- a/abuild-keygen.in +++ b/abuild-keygen.in @@ -90,30 +90,46 @@ do_keygen() { msg "" } -# print usage and exit usage() { - echo "abuild-keygen $abuild_ver" - echo "usage: abuild-keygen [-ih]" - echo "options:" - echo " -a Set PACKAGER_PRIVKEY= in $abuild_userconf" - echo " -i Install public key into /etc/apk/keys using sudo" - echo " -h Show this help" - echo " -n Non-interactive. Use defaults" - echo " -q Quiet mode" - echo "" - exit 1 + cat >&2 <<__EOF__ +$prog $abuild_ver - generate signing keys +Usage: $prog [-a|--append] [-i|--install] [-n] +Options: + -a, --append Set PACKAGER_PRIVKEY= in $abuild_userconf + -i, --install Install public key into /etc/apk/keys using sudo + -n Non-interactive. Use defaults + -q, --quiet + -h, --help Show this help + +__EOF__ } +append_config= +install_pubkey= +non_interactive= +quiet= -while getopts "ahinq" opt; do - case $opt in - a) append_config=yes;; - h) usage;; - i) install_pubkey=yes;; - n) non_interactive=yes;; - q) quiet=-quiet;; +args=`getopt -o ainqh --long append,install,quiet,help -n "$prog" -- "$@"` +if [ $? -ne 0 ]; then + usage + exit 2 +fi +eval set -- "$args" +while true; do + case $1 in + -a|--append) append_config=1;; + -i|--install) install_pubkey=1;; + -n) non_interactive=yes;; + -q|--quiet) quiet=1;; # suppresses msg + -h|--help) usage; exit;; + --) shift; break;; + *) exit 1;; # getopt error esac + shift done -shift $(( $OPTIND - 1)) +if [ $# -ne 0 ]; then + usage + exit 2 +fi do_keygen 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" diff --git a/abump.in b/abump.in index 32ff4af..3b501e3 100755 --- a/abump.in +++ b/abump.in @@ -56,29 +56,48 @@ fixes #${fixes#\#} } usage() { - echo "$prog - utility to bump pkgver in APKBUILDs" - echo "usage: $prog [-hR] [-s CVE-1,CVE-2,...] [-f ISSUE]" - echo "" - echo " -h show this help" - echo " -R run abuild with -R for recursive building" - echo " -k keep existing packages" - echo " -s security update" - echo " -f fixes ISSUE" - exit 0 + cat >&2 <<__EOF__ +$prog $abuild_ver - bump pkgver in APKBUILDs +Usage: $prog [-s CVE-1,CVE-2,...] [-f ISSUE] [-R|--recursive] [-k|--keep] PKGNAME-1.2.3 ... +Options: + -s, --security CVE1,CVE-2,... Security update + -f, --fixes ISSUE Fixes ISSUE + -R, --recursive Run abuild with -R for recursive building + -k, --keep Run abuild with -k to keep existing packages + -q, --quiet + -h, --help Show this help + +__EOF__ } keep= recursive="-r" -while getopts "f:hkRs:" opt; do - case $opt in - f) fixes="${OPTARG}";; - h) usage;; - k) keep="-k";; - R) recursive="-R";; - s) cvelist="$OPTARG";; +cvelist= +fixes= + +args=`getopt -o s:Rkqh --long security:,recursive,keep,quiet,help -n "$prog" -- "$@"` +if [ $? -ne 0 ]; then + usage + exit 2 +fi +eval set -- "$args" +while true; do + case $1 in + -s|--security) cvelist="$2"; shift;; + -f|--fixes) fixes="$2"; shift;; + -R|--recursive) recursive="-R";; + -k|--keep) keep="-k";; + -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 abuild_opts="$recursive $keep" diff --git a/apkgrel.in b/apkgrel.in index 46e189f..57b3b93 100644 --- a/apkgrel.in +++ b/apkgrel.in @@ -55,42 +55,51 @@ do_nothing() { return 0 } -do_usage() { - cat <<__EOF__ -Usage: $prog -a|-h|-s NUM|-t|-z [-f] FILE... -Commands: - -a Add 1 to current pkgrel - -g Only do the change on files that have clean git status - -h Show this help - -s Set pkgrel to NUM - -t Only verify that files are in proper format - -z Set pkgrel to 0 - +usage() { + cat >&2 <<__EOF__ +$prog $abuild_ver - display or bump pkgrel in APKBUILDs +Usage: $prog [-z|--zero] [-a|--add] [-g|--clean-git] [-s|--set NUM] [-t|--test] [-f|--force] DIR or APKBUILD... Options: - -f Force, even if given files are not in proper format + -z, --zero Set pkgrel to 0 + -a, --add Add 1 to current pkgrel + -g, --clean-git Only operate on APKBUILDs with clean git status + -s, --set NUM Set pkgrel to NUM + -t, --test Only verify that files have a valid pkgrel + -f, --force Operate on files without a valid pkgrel + -h, --help Show this help __EOF__ } cmd=do_show force= -while getopts "afghs:tz" opt; do - case $opt in - a) cmd=do_add;; - g) only_clean_git=1;; - f) force=1;; - h) cmd=do_usage;; - s) setto=$OPTARG; cmd=do_set;; - t) cmd=do_nothing;; - z) setto=0; cmd=do_set;; +setto= +only_clean_git= + +args=`getopt -o zags:tfqh --long zero,add,clean-git,set:,test,force,quiet,help -n "$prog" -- "$@"` +if [ $? -ne 0 ]; then + usage + exit 2 +fi +eval set -- "$args" +while true; do + case $1 in + -z|--zero) setto=0; cmd=do_set;; + -a|--add) cmd=do_add;; + -g|--clean-git) only_clean_git=1;; + -s|--set) setto=$2; shift; cmd=do_set;; + -t|--test) cmd=do_nothing;; + -f|--force) force=1;; + -q|--quiet) quiet=1;; # noop + -h|--help) usage; exit;; + --) shift; break;; + *) exit 1;; # getopt error esac + shift done - -shift $(( $OPTIND - 1)) - if [ $# -eq 0 ]; then - do_usage - exit 1 + usage + exit 2 fi do_verify "$@" || exit 1 diff --git a/checkapk.in b/checkapk.in index e95249e..2953b8b 100644 --- a/checkapk.in +++ b/checkapk.in @@ -16,8 +16,20 @@ fi . "$datadir/functions.sh" +usage() { + cat >&2 <<__EOF__ +$prog $abuild_ver - find ABI breakages in package upgrades +Usage: $prog +Run in the directory of a built package. +__EOF__ +} + +if [ $# -gt 0 ]; then + usage + exit 2 +fi if ! [ -f "$abuild_conf" ] && ! [ -f "$abuild_userconf" ]; then die "no abuild.conf found" diff --git a/newapkbuild.in b/newapkbuild.in index 0f95f19..1b65815 100755 --- a/newapkbuild.in +++ b/newapkbuild.in @@ -253,22 +253,23 @@ __EOF__ } usage() { - echo "$prog $abuild_ver" - echo "usage: $prog [-cfh] [-d DESC] [-l LICENSE] [-n NAME] [-u URL] PKGNAME[-PKGVER]|SRCURL" - echo "Options:" - echo " -a Create autotools (use ./configure ...)" - echo " -c Copy a sample init.d, conf.d, and install script to new directory" - echo " -d Set package description (pkgdesc) to DESC" - echo " -f Force even if directory already exist" - echo " -h Show this help" - echo " -l Set package license to LICENSE" - echo " -n Set package name to NAME" - echo " -p Create perl package (Assume Makefile.PL is there)" - echo " -y Create python package (Assume setup.py is there)" - echo " -u Set package URL" - echo " -s Use sourceforge source URL" - echo "" - exit 0 + cat >&2 <<__EOF__ +$prog $abuild_ver - generate a new APKBUILD +Usage: $prog [-cfh] [-d DESC] [-l LICENSE] [-n NAME] [-u URL] PKGNAME[-PKGVER]|SRCURL +Options: + -n Set package name to NAME + -d Set package description (pkgdesc) to DESC + -l Set package license to LICENSE + -u Set package URL + -a Create autotools (use ./configure ...) + -p Create perl package (Assume Makefile.PL is there) + -y Create python package (Assume setup.py is there) + -s Use sourceforge source URL + -c Copy a sample init.d, conf.d, and install script to new directory + -f Force even if directory already exist + -h Show this help + +__EOF__ } while getopts "acd:fhl:n:pyu:s" opt; do @@ -277,7 +278,7 @@ while getopts "acd:fhl:n:pyu:s" opt; do 'c') cpinitd=1;; 'd') pkgdesc="$OPTARG";; 'f') force=1;; - 'h') usage;; + 'h') usage; exit;; 'l') license="$OPTARG";; 'n') pkgname="$OPTARG";; 'p') buildtype="perl";; -- 1.8.3.1 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---