From: Emil Velikov <[email protected]> To allow users with multiple keys to select the appropriate one.
Signed-off-by: Emil Velikov <[email protected]> --- All the "if x$GPGKEY = x" checking looks iffy so any suggestions how to minimise/remove it are greatly appreciated. --- release.sh | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 74a94d4..71ac830 100755 --- a/release.sh +++ b/release.sh @@ -68,6 +68,29 @@ check_option_args() { } #------------------------------------------------------------------------------ +# Function: check_gpgkey +#------------------------------------------------------------------------------ +# +# check if the gpg key provided is known/available +# arguments: +# $1 - the gpg key +# returns: +# if it returns, everything is good +# otherwise it exit's +check_gpgkey() { + arg=$1 + + $GPG --list-keys "$arg" &>/dev/null + if [ $? -ne 0 ]; then + echo "" + echo "Error: the argument '$arg' is not a known gpg key." + echo "" + usage + exit 1 + fi +} + +#------------------------------------------------------------------------------ # Function: check_modules_specification #------------------------------------------------------------------------------ # @@ -272,7 +295,11 @@ sign_or_fail() { if [ -n "$1" ]; then sig=$1.sig rm -f $sig - $GPG -b $1 1>&2 + if [ x"$GPGKEY" = x ]; then + $GPG -b $1 1>&2 + else + $GPG -b -u $GPGKEY $1 1>&2 + fi if [ $? -ne 0 ]; then echo "Error: failed to sign $1." >&2 return 1 @@ -469,7 +496,11 @@ process_module() { else # Tag the top commit with the tar name if [ x"$DRY_RUN" = x ]; then - git tag -s -m $tag_name $tag_name + if [ x"$GPGKEY" = x ]; then + git tag -s -m $tag_name $tag_name + else + git tag -u $GPGKEY -s -m $tag_name $tag_name + fi if [ $? -ne 0 ]; then echo "Error: unable to tag module with \"$tag_name\"." cd $top_src @@ -713,6 +744,7 @@ Options: --dist make 'dist' instead of 'distcheck'; use with caution --distcheck Default, ignored for compatibility --dry-run Does everything except tagging and uploading tarballs + --gpgkey <key> Specify the key used to sign the git tag/release tarballs --force Force overwriting an existing release --help Display this help and exit successfully --modfile <file> Release the git modules specified in <file> @@ -779,6 +811,13 @@ do --force) FORCE=yes ;; + # Allow user specified GPG key + --gpgkey) + check_option_args $1 $2 + shift + check_gpgkey $1 + GPGKEY=$1 + ;; # Display this help and exit successfully --help) usage -- 2.8.2 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
