This is an automated email from the ASF dual-hosted git repository.

jfeinauer pushed a commit to branch tooling-for-release
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit df1007694aaee324bd48be046f5090e51173717e
Author: Julian Feinauer <[email protected]>
AuthorDate: Fri Jul 26 15:52:28 2019 +0200

    Added Tooling for release checking
---
 tools/check_sigs.sh              |  67 +++++++++++++
 tools/clean-site.sh              |  35 +++++++
 tools/common.sh                  | 202 +++++++++++++++++++++++++++++++++++++++
 tools/download_staged_release.sh | 141 +++++++++++++++++++++++++++
 4 files changed, 445 insertions(+)

diff --git a/tools/check_sigs.sh b/tools/check_sigs.sh
new file mode 100755
index 0000000..3cd874c
--- /dev/null
+++ b/tools/check_sigs.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+
+set -e
+
+# Checks the signatures of all bundles in the build/release-edgent directory
+# Or checks the bundles in the specified directory
+
+. `dirname $0`/common.sh
+
+setUsage "`basename $0` [bundle-directory]"
+handleHelp "$@"
+
+if [ $# -ge 1 ]
+then
+    BUNDLE_DIR=$1; shift
+fi
+
+noExtraArgs "$@"
+
+[ -d ${BUNDLE_DIR} ] || die "Bundle directory \"${BUNDLE_DIR}\" does not exist"
+
+function checkFile() {
+    FILE="$1"
+    echo
+    echo "Checking $FILE..."
+
+    HASH=`shasum -a 512 "${FILE}" | awk '{print$1}'`
+    CHECK=`cat "${FILE}.sha512"`
+
+    if [ "$HASH" != "$CHECK" ]
+    then
+        echo "${FILE} SHA incorrect"
+        exit 1;
+    else
+       echo "${FILE} SHA OK";
+    fi
+
+    gpg --verify "${FILE}.asc"
+
+}
+
+for bundle in ${BUNDLE_DIR}/*.zip
+do
+    checkFile ${bundle}
+done
+
+echo
+echo "SUCCESS: all checksum and signature files OK"
diff --git a/tools/clean-site.sh b/tools/clean-site.sh
new file mode 100644
index 0000000..a8c9333
--- /dev/null
+++ b/tools/clean-site.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+
+# Remove all the css and js directories except the ones in the root of the 
site.
+find target/staging -type d | grep 'target\/staging\/.*\/css$' | xargs rm -r
+find target/staging -type d | grep 'target\/staging\/.*\/js$' | xargs rm -r
+
+# Delete some individual images.
+find target/staging -type f | grep 'target\/staging\/.*/images/close\.png$' | 
xargs rm
+find target/staging -type f | grep 'target\/staging\/.*/images/close\.gif$' | 
xargs rm
+find target/staging -type f | grep 'target\/staging\/.*/images/loading\.png$' 
| xargs rm
+find target/staging -type f | grep 'target\/staging\/.*/images/loading\.gif$' 
| xargs rm
+find target/staging -type f | grep 'target\/staging\/.*/images/next\.png$' | 
xargs rm
+find target/staging -type f | grep 'target\/staging\/.*/images/prev\.png$' | 
xargs rm
+
+# Delete any now empty directories.
+find target/staging -type d -empty | xargs rm -r
\ No newline at end of file
diff --git a/tools/common.sh b/tools/common.sh
new file mode 100755
index 0000000..e90d712
--- /dev/null
+++ b/tools/common.sh
@@ -0,0 +1,202 @@
+#!/bin/sh
+
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+
+BUILDTOOLS_DIR=`dirname $0`
+
+IOTDB_ROOT_DIR=.
+# BUNDLE_DIR is results of maven release:perform's creation of release 
candidate
+BUNDLE_DIR=${IOTDB_ROOT_DIR}/target/checkout/target
+
+IOTDB_ASF_GIT_URL=https://git-wip-us.apache.org/repos/asf/incubator-iotdb.git
+IOTDB_ASF_DIST_URL=https://www.apache.org/dist/iotdb
+IOTDB_ASF_DIST_DYN_URL=https://www.apache.org/dyn/closer.cgi/iotdb
+IOTDB_ASF_SVN_RELEASE_URL=https://dist.apache.org/repos/dist/release/iotdb
+IOTDB_ASF_SVN_RC_URL=https://dist.apache.org/repos/dist/dev/iotdb
+
+USAGE=
+
+RELEASE_PROP_FILE=${IOTDB_ROOT_DIR}/iotdb.release.properties
+
+function die() {  # [$* msgs]
+  [ $# -gt 0 ] && echo "Error: $*"
+  exit 1
+}
+
+function setUsage() {  # $1: usage string
+  USAGE=$1
+}
+
+function usage() {  #  [$*: msgs]
+  [ $# -gt 0 ] && echo "Error: $*"
+  echo "Usage: ${USAGE}"
+  exit 1
+}
+
+function handleHelp() { # usage: handleHelp "$@"
+  if [ "$1" == "-?" -o "$1" == "--help" ]; then
+    usage
+  fi
+}
+
+function requireArg() {  # usage: requireArgs "$@"
+  if [ $# -lt 1 ] || [[ $1 =~ ^- ]]; then
+    usage "missing argument"
+  fi
+}
+
+function noExtraArgs() { # usage: noExtraArgs "$@"
+  [ $# = 0 ] || usage "extra arguments"
+}
+
+function getAbsPath() { # $1: rel-or-abs-path 
+    echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
+}
+
+function confirm () {  # [$1: question]
+  while true; do
+    # call with a prompt string or use a default                               
                                                                                
                                    
+    /bin/echo -n "${1:-Are you sure?}"
+    read -r -p " [y/n] " response
+    case $response in
+      [yY]) return `true` ;;
+      [nN]) return `false` ;;
+      *) echo "illegal response '$response'" ;;
+    esac
+  done
+}
+
+function dieSuperceeded { # no args
+  die "This tool is superceeded with the new maven build tooling.  See 
src/site/asciidoc/releasing.adoc."
+}
+
+function checkIOTDBSourceRootGitDie { # no args; dies if !ok
+  [ -d "${IOTDB_ROOT_DIR}/.git" ] || die "Not an IOTDB source root git 
directory \"${IOTDB_ROOT_DIR}\""
+}
+
+function checkUsingMgmtCloneWarn() { # no args; warns if iotdb root isn't a 
mgmt clone
+  CLONE_DIR=`cd ${IOTDB_ROOT_DIR}; pwd`
+  CLONE_DIRNAME=`basename $CLONE_DIR`
+  if [ ! `echo $CLONE_DIRNAME | grep -o -E '^mgmt-iotdb'` ]; then
+    echo "Warning: the IOTDB root dir \"${IOTDB_ROOT_DIR}\" is not a release 
mgmt clone!"
+    return 1
+  else
+    return 0
+  fi 
+}
+
+function checkBundleDir() { # no args  returns true/false (0/1)
+  if [ -d ${BUNDLE_DIR} ]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+function checkVerNum() {  #  $1: X.Y.Z  returns true/false (0/1)
+  if [ `echo $1 | grep -o -E '^\d+\.\d+\.\d+$'` ]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+function checkVerNumDie() { #  $1: X.Y.Z  dies if not ok
+  checkVerNum $1 || die "Not a X.Y.Z version number \"$1\""
+}
+
+function checkRcNum() {  # $1: rc-num   returns true/false (0/1)
+  if [ `echo $1 | grep -o -E '^\d+$'` ] && [ $1 != 0 ]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+function checkRcNumDie() {  # $1: rc-num dies if not ok
+  checkRcNum $1 || die "Not a release candidate number \"$1\""
+}
+
+function createReleaseProperties { # X.Y.Z
+  VER="$1"
+  checkVerNumDie ${VER}
+  echo "releaseNum=${VER}" > ${RELEASE_PROP_FILE}
+}
+
+function getReleaseProperty {  # <property-name>
+  PN=$1
+  PNVAL=`grep ${PN} ${RELEASE_PROP_FILE}`
+  VAL=`echo ${PNVAL} | sed -e "s/^${PN}=//"`
+  echo ${VAL}
+}
+
+function getIOTDBVer() {  # [$1 == "bundle"]
+  MSG="getIOTDBVer(): unknown mode \"$1\""
+  VER=""
+  if [ "$1" == "" ]; then
+    VER=`getReleaseProperty releaseNum`
+    MSG="Unable to identify the release version id from ${RELEASE_PROP_FILE}"
+  elif [ $1 == "gradle" ]; then
+    die "'getIOTDBVer() gradle' is no longer supported"
+    # Get the X.Y.Z version from gradle build info
+    PROPS=${IOTDB_ROOT_DIR}/gradle.properties
+    VER=`grep build_version ${PROPS} | grep -o -E '\d+\.\d+\.\d+'`
+    MSG="Unable to identify the version id from ${PROPS}"
+  elif [ $1 == "bundle" ]; then
+    # Get the X.Y.Z version from a build generated bundle's name
+    BUNDLE=`echo ${BUNDLE_DIR}/apache-iotdb-*-source-release.tar.gz`
+    VER=`echo ${BUNDLE} | grep -o -E '\d+\.\d+\.\d+'`
+    MSG="Unable to identify the version id from bundle ${BUNDLE}"
+  fi
+  [ "${VER}" ] || die "${MSG}"
+  echo $VER
+}
+
+function getMajMinVerNum() {  #  $1: X.Y.Z  returns X.Y
+  VER=$1; shift
+  checkVerNumDie ${VER}
+  MAJ_MIN_VER=`echo ${VER} | sed -e 's/\.[0-9][0-9]*$//'`
+  echo ${MAJ_MIN_VER}
+}
+
+function getReleaseBranch() { # $1: X.Y.Z version
+  MAJ_MIN_NUM=`getMajMinVerNum $1`
+  echo "release/${MAJ_MIN_NUM}"
+}
+
+function getReleaseTag() {  # $1: X.Y.Z  [$2: rc-num]
+  VER=$1; shift
+  checkVerNumDie ${VER}
+  RC_SFX=""
+  if [ $# -gt 0 ] && [ "$1" != "" ]; then
+    RC_SFX="-RC$1"
+  fi
+  echo "${VER}${RC_SFX}"
+}
+
+function getReleaseTagComment() {  # $1: X.Y.Z  [$2: rc-num]
+  VER=$1; shift
+  checkVerNumDie ${VER}
+  RC_SFX=""
+  if [ $# -gt 0 ] && [ "$1" != "" ]; then
+    RC_SFX=" RC$1"
+  fi
+  echo "Apache IOTDB ${VER}${RC_SFX}"
+}
diff --git a/tools/download_staged_release.sh b/tools/download_staged_release.sh
new file mode 100755
index 0000000..5da8108
--- /dev/null
+++ b/tools/download_staged_release.sh
@@ -0,0 +1,141 @@
+#!/bin/sh
+
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+
+set -e
+
+# NOTICE This is mostly copied from the PLC4X Project and was adopted to 
+# the IoTDB Project
+
+# Download the collection of files associated with an Apache IoTDB
+# Release or Release Candidate from the Apache Distribution area:
+# https://dist.apache.org/repos/dist/release/iotdb
+# or https://dist.apache.org/repos/dist/dev/iotdb
+# respectively.
+#
+# Prompts before taking actions unless "--nquery"
+# Prompts to perform signature validation (using buildTools/check_sigs.sh)
+# unless --nvalidate or --validate is specified.
+
+
+. `dirname $0`/common.sh
+
+
+
+setUsage "`basename $0` [--nquery] [--validate|--nvalidate] <version> 
[<rc-num>]"
+handleHelp "$@"
+
+BUILDTOOLS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+NQUERY=
+if [ "$1" == "--nquery" ]; then
+  NQUERY="--nquery"; shift
+fi
+
+VALIDATE=-1  # query
+if [ "$1" == "--validate" ]; then
+  VALIDATE=1; shift
+elif [ "$1" == "--nvalidate" ]; then
+  VALIDATE=0; shift
+fi
+
+requireArg "$@"
+VER=$1; shift
+checkVerNum $VER || usage "Not a X.Y.Z version number \"$VER\""
+
+RC_NUM=
+if [ $# -gt 0 ]; then
+  RC_NUM=$1; shift
+  checkRcNum ${RC_NUM} || usage "Not a release candidate number \"${RC_NUM}\""
+fi
+
+noExtraArgs "$@"
+
+# Release or Release Candidate mode
+IS_RC=
+if [ ${RC_NUM} ]; then
+  IS_RC=1
+fi
+
+BASE_URL=${IOTDB_ASF_SVN_RELEASE_URL}
+if [ ${IS_RC} ]; then
+  BASE_URL=${IOTDB_ASF_SVN_RC_URL}
+fi
+
+RC_SFX=
+if [ ${IS_RC} ]; then
+    RC_SFX=rc${RC_NUM}
+fi
+
+DST_BASE_DIR=downloaded-iotdb-${VER}${RC_SFX}
+[ -d ${DST_BASE_DIR} ] && die "${DST_BASE_DIR} already exists"
+
+[ ${NQUERY} ] || confirm "Proceed to download to ${DST_BASE_DIR} from 
${BASE_URL}?" || exit
+
+echo Downloading to ${DST_BASE_DIR} ...
+
+function mywget() {
+  # OSX lacks wget by default
+  (set -x; curl -f -O $1)
+}
+
+function getSignedBundle() {
+  mywget ${1}
+  mywget ${1}.asc
+  mywget ${1}.sha512
+}
+
+mkdir -p ${DST_BASE_DIR}
+cd ${DST_BASE_DIR}
+ABS_BASE_DIR=`pwd`
+URL=${BASE_URL}
+mywget ${URL}/KEYS
+
+DST_VER_DIR=${VER}
+URL=${BASE_URL}/${VER}
+if [ ${IS_RC} ]; then
+  DST_VER_DIR=${DST_VER_DIR}/${RC_SFX}
+  URL=${URL}/${RC_SFX}
+fi
+
+mkdir -p ${DST_VER_DIR}
+cd ${DST_VER_DIR}
+mywget ${URL}/README.md
+mywget ${URL}/RELEASE_NOTES.md
+getSignedBundle ${URL}/apache-iotdb-${VER}-incubating-source-release.zip
+getSignedBundle ${URL}/apache-iotdb-${VER}-incubating-bin.zip
+
+echo
+echo Done Downloading to ${DST_BASE_DIR}
+
+[ ${VALIDATE} == 0 ] && exit
+[ ${VALIDATE} == 1 ] || [ ${NQUERY} ] || confirm "Do you want to check the 
bundle signatures and compare source bundles?" || exit
+
+cd ${ABS_BASE_DIR}
+
+echo
+echo "If the following bundle gpg signature checks fail, you may need to"
+echo "import the project's list of signing keys to your keyring"
+echo "    $ gpg ${DST_BASE_DIR}/KEYS            # show the included keys"
+echo "    $ gpg --import ${DST_BASE_DIR}/KEYS"
+
+echo
+echo "Verifying the source bundle signatures..."
+(set -x; $BUILDTOOLS_DIR/check_sigs.sh ${DST_VER_DIR})

Reply via email to