Commit ef9fb529 authored by Dubiousjim's avatar Dubiousjim Committed by Natanael Copa

various: use long options, rework usages

parent 7b2030a0
......@@ -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=<generated key> 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=<generated key> 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
......@@ -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"
......
......@@ -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"
......
......@@ -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
......
......@@ -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"
......
......@@ -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";;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment