adamfeuer commented on a change in pull request #1382:
URL: https://github.com/apache/incubator-nuttx/pull/1382#discussion_r454519482



##########
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:
       @xiaoxiang781216 Here's the output from `wget --version`:
   
   ```
   GNU Wget 1.19.4 built on linux-gnu.
   
   -cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls 
   +ntlm +opie +psl +ssl/openssl 
   
   Wgetrc: 
       /etc/wgetrc (system)
   Locale: 
       /usr/share/locale 
   Compile: 
       gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc" 
       -DLOCALEDIR="/usr/share/locale" -I. -I../../src -I../lib 
       -I../../lib -Wdate-time -D_FORTIFY_SOURCE=2 -DHAVE_LIBSSL -DNDEBUG 
       -g -O2 -fdebug-prefix-map=/build/wget-Xb5Z7Y/wget-1.19.4=. 
       -fstack-protector-strong -Wformat -Werror=format-security 
       -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall 
   Link: 
       gcc -DHAVE_LIBSSL -DNDEBUG -g -O2 
       -fdebug-prefix-map=/build/wget-Xb5Z7Y/wget-1.19.4=. 
       -fstack-protector-strong -Wformat -Werror=format-security 
       -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall -Wl,-Bsymbolic-functions 
       -Wl,-z,relro -Wl,-z,now -lpcre -luuid -lidn2 -lssl -lcrypto -lpsl 
       ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a 
   
   Copyright (C) 2015 Free Software Foundation, Inc.
   License GPLv3+: GNU GPL version 3 or later
   <http://www.gnu.org/licenses/gpl.html>.
   This is free software: you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.
   
   Originally written by Hrvoje Niksic <hnik...@xemacs.org>.
   Please send bug reports and questions to <bug-w...@gnu.org>.
   ```
   
   What's your wget version?




----------------------------------------------------------------
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


Reply via email to