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