abuild-sign: add -e/--installed option

This is supposed to be used in abuild only to make it possible to exit
with error early, before package is built, in case the signing key is
missing.
This commit is contained in:
Natanael Copa 2013-10-25 07:57:35 +00:00
parent c28aa71335
commit b53d4ad7de
1 changed files with 9 additions and 4 deletions

View File

@ -46,7 +46,9 @@ usage() {
cat >&2 <<__EOF__
$program $program_version - sign indexes
Usage: $program [-k PRIVKEY] [-p PUBKEY] INDEXFILE...
$program -e
Options:
-e, --installed Check only of there exist a private key for signing
-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
@ -56,11 +58,12 @@ Options:
__EOF__
}
check_installed=false
privkey="$PACKAGER_PRIVKEY"
pubkey=
quiet=
args=`getopt -o k:p:qh --long private:,public:,quiet,help -n "$program" -- "$@"`
args=`getopt -o ek:p:qh --long installed,private:,public:,quiet,help -n "$program" -- "$@"`
if [ $? -ne 0 ]; then
usage
exit 2
@ -68,6 +71,7 @@ fi
eval set -- "$args"
while true; do
case $1 in
-e|--installed) check_installed=true;;
-k|--private) privkey=$2; shift;;
-p|--public) pubkey=$2; shift;;
-q|--quiet) quiet=1;; # suppresses msg
@ -77,7 +81,7 @@ while true; do
esac
shift
done
if [ $# -eq 0 ]; then
if [ $# -eq 0 ] && ! $check_installed; then
usage
exit 2
fi
@ -99,5 +103,6 @@ if [ -z "$pubkey" ]; then
pubkey=${PACKAGER_PUBKEY:-"${privkey}.pub"}
fi
do_sign "$@"
exit 0
if ! $check_installed; then
do_sign "$@"
fi