Repository: drill
Updated Branches:
  refs/heads/master dd4f03be9 -> 050ff9679


DRILL-4050: Add zip archives to the list of artifacts in verify_release.sh

This enhanced version of the script allows integrated download and verification 
of a Drill release. It can be used to verify both the main release artifacts 
and maven repository artifacts.

For example, to verify the 1.6 rc0 release artifacts, I ran

./verify_release.sh 
https://repository.apache.org/content/repositories/orgapachedrill-1030/ 
/tmp/drill-1.6/maven/
./verify_release.sh http://home.apache.org/~parthc/drill/releases/1.6.0/rc0/ 
/tmp/drill-1.6/main/

If I had pre-downloaded the files in the respective folders, I'd run

./verify_release.sh /tmp/drill-1.6/maven/
./verify_release.sh /tmp/drill-1.6/main/

Finally, run with `-nv` option to reduce the verbosity of the output.

Closes #249.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/050ff967
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/050ff967
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/050ff967

Branch: refs/heads/master
Commit: 050ff9679d99b5cdacc86f5501802c3d2a6dd3e3
Parents: dd4f03b
Author: Aditya Kishore <a...@apache.org>
Authored: Mon Mar 14 15:15:38 2016 -0700
Committer: Aditya Kishore <a...@apache.org>
Committed: Mon Mar 14 15:15:38 2016 -0700

----------------------------------------------------------------------
 tools/verify_release.sh | 176 ++++++++++++++++++++++++++++++-------------
 1 file changed, 125 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/050ff967/tools/verify_release.sh
----------------------------------------------------------------------
diff --git a/tools/verify_release.sh b/tools/verify_release.sh
index eb50a31..90b991d 100755
--- a/tools/verify_release.sh
+++ b/tools/verify_release.sh
@@ -23,10 +23,15 @@
 
 DRILL_CHECKUM_ALOGRITHMS="sha1 md5"
 DRILL_SIGNATURE_EXTENSION=asc
-DRILL_ARTIFACT_EXTENSION=tar.gz
-DRILL_ARTIFACTS=*.${DRILL_ARTIFACT_EXTENSION}
+DRILL_DOWNLOAD_EXTENSIONS="tar.gz,zip,xml,asc,jar,md5,pom,sha1"
+DRILL_ARTIFACTS="*.tar.gz *.zip *.pom *.jar"
 DRILL_ARTIFACT_DIR=.
 
+TERSE=false
+CMD_REDIRECT="/dev/stdout"
+DOWNLOAD_URL=
+ARTIFACT_COUNT=0
+
 ERROR='\e[0;31m'
 SUCCESS='\e[0;32m'
 DEBUG='\e[1;30m'
@@ -36,68 +41,137 @@ RESET='\e[0m'
 #
 # Helper methods
 #
-error_exit() { echo -e $ERROR$@$RESET;  popd &> /dev/null; exit 1; }
-info_msg  () { echo -e $INFO$@$RESET; }
-debug_msg () { echo -e $DEBUG$@$RESET; }
+info_msg()   { echo -e $INFO$@$RESET; }
+debug_msg()  { if [ "$TERSE" == "false" ]; then echo -e $DEBUG$@$RESET; fi }
+error_msg()  { echo -e $ERROR$@$RESET; }
+error_exit() { echo -e $ERROR$@$RESET; popd &> /dev/null; exit 1; }
+
+header_msg() {
+  MSG=$@
+  info_msg ${MSG}
+  if [ "$TERSE" == "false" ]; then
+    info_msg $(eval printf "=%.0s" {1..${#MSG}});
+  fi
+}
+
+test_dir()   {
+  if [ ! -e $1 ]; then
+    mkdir -p $1
+  elif [ ! -d $1 ]; then
+    error_msg "The specified path '$1' is not a directory."
+    usage
+  fi
+}
+
+usage() {
+  echo -e "Usage:\n `basename $0` <path_of_drill_artifacts>\n `basename $0` 
<url_of_drill_artifacts> [path_of_download_directory]"
+  exit 1
+}
+
+download_files() {
+  if [[ $# == 2 ]]; then
+    test_dir $2
+    DRILL_ARTIFACT_DIR=$2
+  else
+    DRILL_ARTIFACT_DIR=`mktemp -d`
+  fi
+
+  info_msg "Downloading files from '$1' into '$DRILL_ARTIFACT_DIR'"
+  pushd ${DRILL_ARTIFACT_DIR} &> /dev/null
+  wget $1 -r -np -A ${DRILL_DOWNLOAD_EXTENSIONS} -l0 -e robots=off -nH -nv &> 
$CMD_REDIRECT
+  popd &> /dev/null
+}
+
+verify_directory() {
+  pushd $1 &> /dev/null
+
+  for ARTIFACT in ${DRILL_ARTIFACTS}; do
+    ARTIFACT_COUNT=$(($ARTIFACT_COUNT+1))
+    header_msg "Verifying artifact #$ARTIFACT_COUNT '$ARTIFACT' in $PWD"
+
+    debug_msg "Verifying signature..."
+    SIGNATURE_FILE=${ARTIFACT}.${DRILL_SIGNATURE_EXTENSION}
+    if ! [ -f ${SIGNATURE_FILE} ]; then error_exit "Signature file 
'${SIGNATURE_FILE}' was not found"; fi
+    if gpg --verify ${SIGNATURE_FILE} &> $CMD_REDIRECT; then
+      debug_msg "Signature verified (${SIGNATURE_FILE})."
+    else
+      error_exit "Signature verification failed for '${ARTIFACT}'!"
+    fi
+    debug_msg ""
+
+    debug_msg Verifying checksums...
+    for ALGO in $DRILL_CHECKUM_ALOGRITHMS; do
+      CHECKSUM_FILE=${ARTIFACT}.${ALGO}
+      if ! [ -f ${CHECKSUM_FILE} ]; then error_exit "Checksum file 
'${CHECKSUM_FILE}' was not found"; fi
+      COMPUTED_SUM=`${ALGO}sum ${ARTIFACT} | awk '{print $1}'`
+      FILE_SUM=`cat ${CHECKSUM_FILE}`
+      if [ "${FILE_SUM}" == "${COMPUTED_SUM}" ]; then
+        debug_msg "Verified ${ALGO} checksum (${CHECKSUM_FILE})."
+      else
+        error_exit "Computed ${ALGO} checksum did not match the one in 
'${CHECKSUM_FILE}'"
+      fi
+    done
+    debug_msg "Checksums verified.\n"
+  done
+  
+  # recurse through the sub-directories
+  for SUB_DIR in *; do
+    if [ -d ${SUB_DIR} ]; then
+      verify_directory ${SUB_DIR}
+    fi
+  done
+
+  popd &> /dev/null
+}
 
 #
-# Check the command line argument
+# Parse the command line arguments
 #
-case $# in
-  0) ;;
-  1)
-    if ! [ -d $1 ] ; then
-      pushd . &> /dev/null
-      error_exit "'$1' is not a directory."
-    fi
-    DRILL_ARTIFACT_DIR=$1
+if [ $# -eq 0 ]; then
+  usage
+fi
+while [ $# -gt 0 ]; do
+  case "$1" in
+  -nv)
+    TERSE=true
+    CMD_REDIRECT="/dev/null"
+  ;;
+  -*)
+    echo "Unknown option '$1'."
+    usage
   ;;
   *)
-    echo "Usage: $0 <path_to_drill_artifacts>"
-    exit 1
-esac
+    if [[ $1 == https://* ]] || [[ $1 == http://* ]] || [[ $1 == ftp://* ]]; 
then
+      DOWNLOAD_URL=$1
+    else
+      test_dir $1; DRILL_ARTIFACT_DIR=$1
+    fi
+  ;;
+  esac
+  shift
+done
+
+#
+# Download files if requested
+#
+if [ "$DOWNLOAD_URL" != "" ]; then
+  download_files ${DOWNLOAD_URL} ${DRILL_ARTIFACT_DIR}
+fi
 
 #
 # Begin validation
 #
-ARTIFACT_COUNT=0
-pushd $DRILL_ARTIFACT_DIR &> /dev/null
 shopt -s nullglob
-for ARTIFACT in ${DRILL_ARTIFACTS} ; do
-  MSG="Verifying artifact \"$ARTIFACT\"."
-  info_msg ${MSG}
-  info_msg $(eval printf "=%.0s" {1..${#MSG}})
-
-  debug_msg Verifying signature...
-  SIGNATURE_FILE=${ARTIFACT}.${DRILL_SIGNATURE_EXTENSION}
-  if  ! [ -f ${SIGNATURE_FILE} ] ; then error_exit "Signature file 
'${SIGNATURE_FILE}' was not found"; fi
-  if gpg --verify ${SIGNATURE_FILE} ; then
-    debug_msg "Signature verified (${SIGNATURE_FILE})."
-  else
-    error_exit "Signature verification failed for '${ARTIFACT}'!"
-  fi
-  echo
-
-  debug_msg Verifying checksums...
-  for ALGO in $DRILL_CHECKUM_ALOGRITHMS ; do
-    CHECKSUM_FILE=${ARTIFACT}.${ALGO}
-    if  ! [ -f ${CHECKSUM_FILE} ] ; then error_exit "Checksum file 
'${CHECKSUM_FILE}' was not found"; fi
-    COMPUTED_SUM=`${ALGO}sum ${ARTIFACT} | awk '{print $1}'`
-    FILE_SUM=`cat ${CHECKSUM_FILE}`
-    if [ "${FILE_SUM}" == "${COMPUTED_SUM}" ] ; then
-      debug_msg "Verified ${ALGO} checksum (${CHECKSUM_FILE})."
-    else
-      error_exit "Computed ${ALGO} checksum did not match the one in 
'${CHECKSUM_FILE}'"
-    fi
-  done
-  debug_msg "Checksums verified.\n"
-  ARTIFACT_COUNT=$(($ARTIFACT_COUNT+1))
-done
+verify_directory ${DRILL_ARTIFACT_DIR}
+info_msg ""
 
 # All GOOD
-if [ "$ARTIFACT_COUNT" == "0" ] ; then
+if [ "$DOWNLOAD_URL" != "" ]; then
+  info_msg "Files downloaded to '${DRILL_ARTIFACT_DIR}'"
+fi
+
+if [ "$ARTIFACT_COUNT" == "0" ]; then
   error_exit "No artifact found in '$DRILL_ARTIFACT_DIR'"
 else
   echo -e $SUCCESS"All verifications passed on ${ARTIFACT_COUNT} 
artifacts."$RESET
 fi
-popd &> /dev/null
\ No newline at end of file

Reply via email to