xiaoxiang781216 commented on a change in pull request #1382: URL: https://github.com/apache/incubator-nuttx/pull/1382#discussion_r454506981
########## File path: tools/checkrelease.sh ########## @@ -19,114 +19,221 @@ # ############################################################################# -set -e - +VERBOSE=0 +RETURN_CODE=0 BASE_URL="https://dist.apache.org/repos/dist/dev/incubator/nuttx" -TEMPDIR="dist.apache.org" +DIST_DIR="dist.apache.org" +TMP="/tmp" +TEMPDIR="$TMP/nuttx-checkrelease" ORIGINAL_DIR="$(pwd)" -trap "{ cd $ORIGINAL_DIR; rm -rf $TEMPDIR; }" EXIT +trap "{ rm -rf $TEMPDIR; }" EXIT + +function validate_url() { + if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fi +} function download_release() { - wget -r -np -R "index.html*" -P . --cut-dirs 7 "$URL" - cd "$TEMPDIR" + rm -rf "$TEMPDIR" + if [[ -n "$URL" ]]; then + mkdir "$TEMPDIR" + if [[ $(validate_url "$URL") ]]; then + echo "Downloading release files from $URL" + wget --quiet -r --no-parent -P "$TEMPDIR" --cut-dirs 100 "$URL" + cd "$TEMPDIR" + mv $DIST_DIR/apache-nuttx-* . + else + echo "The URL given doesn't return HTTP 200 OK return code— exiting. ($URL)" + exit 1 + fi + else + if [[ -n "$DIRECTORY" ]]; then + cp -r "$DIRECTORY" "$TEMPDIR" + cd "$TEMPDIR" + else + echo "One of --dir or --url is required!" + exit 1 + fi + fi } function check_sha512() { - # check release sha512 RELEASE_FILE=$1 echo "Checking $RELEASE_FILE sha512..." - sha512sum -c "$RELEASE_FILE.sha512" + output="$(sha512sum -c $RELEASE_FILE.sha512 2>&1)" + return_value=$? + if [ $return_value -eq 0 ]; then + echo " OK: $RELEASE_FILE sha512 hash matches." + else + RETURN_CODE=1 + echo " - $RELEASE_FILE sha512 hash does not match:" + echo "$output" + fi + echo } function check_gpg() { - # check nuttx sha512 and gpg RELEASE_FILE=$1 echo "Checking $RELEASE_FILE GPG signature:" - gpg --verify "$RELEASE_FILE.asc" "$RELEASE_FILE" + gpg --verify $RELEASE_FILE.asc $RELEASE_FILE + return_value=$? + if [ $return_value -eq 0 ]; then + echo " OK: $RELEASE_FILE gpg signature matches." + else + RETURN_CODE=1 + echo " - Error checking $RELEASE_FILE gpg signature:" + echo "$output" + echo Review comment: I hit the similar issue only when the temp directory isn't empty and wget rename the new download to *.1. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org