From 17bd5f3d1a8ac448ba552893d33cba0e13f98a4a Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sat, 18 Jul 2020 15:55:38 +0800 Subject: [PATCH] tools/checkrelease.sh: auto import KEYS from the release server Signed-off-by: Xiang Xiao --- tools/checkrelease.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/checkrelease.sh b/tools/checkrelease.sh index 99e328119f..fe3f720e57 100755 --- a/tools/checkrelease.sh +++ b/tools/checkrelease.sh @@ -23,6 +23,7 @@ RETURN_CODE=0 BASE_URL="https://dist.apache.org/repos/dist/dev/incubator/nuttx" TEMPDIR="/tmp/nuttx-checkrelease" +KEY="$BASE_URL/KEYS" function validate_url() { if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fi @@ -46,6 +47,17 @@ function download_release() { fi } +function import_key() { + if [[ $(validate_url "$KEY") ]]; then + export GNUPGHOME="$TEMPDIR/.gnupg" + wget -q -O- "$KEY" | gpg --import + echo " OK: $KEY is imported." + else + echo " - Error importing $KEY." + exit 1 + fi +} + function check_sha512() { RELEASE_FILE=$1 echo "Checking $RELEASE_FILE sha512..." @@ -150,7 +162,7 @@ function usage() { echo "Examples:" echo echo " $0 --release 9.1.0-RC1" - echo " $0 --url https://dist.apache.org/repos/dist/dev/incubator/nuttx/9.1.0-RC1/" + echo " $0 --url https://dist.apache.org/repos/dist/dev/incubator/nuttx/9.1.0-RC1" echo " $0 --dir ./some-dir-that-has-nuttx-and-apps" echo } @@ -164,6 +176,7 @@ do -U|--url) shift URL="$1/" + KEY="$1/../KEYS" ;; -R|--release) shift @@ -196,6 +209,7 @@ if [[ (-z "$URL") && (-z "$DIRECTORY") ]]; then fi download_release +import_key check_nuttx check_nuttx_apps check_sim_nsh_build