Commit b53d4ad7 authored by Natanael Copa's avatar Natanael Copa

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.
parent c28aa713
...@@ -46,7 +46,9 @@ usage() { ...@@ -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: ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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
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