Update promoteToReleases.sh script

Change-Id: Id500efd8acb23fd9b89c8f0cbc7782cbf8e61333
Signed-off-by: Frederic Gurr <frederic.gurr@eclipse-foundation.org>
diff --git a/promoteUtils/promoteToReleases.sh b/promoteUtils/promoteToReleases.sh
index 2a43e95..b1c610e 100755
--- a/promoteUtils/promoteToReleases.sh
+++ b/promoteUtils/promoteToReleases.sh
@@ -1,204 +1,56 @@
 #!/usr/bin/env bash
 #*******************************************************************************
-# Copyright (c) 2016 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-#     IBM Corporation - initial API and implementation
+# Copyright (c) 2020 Eclipse Foundation and others.
+# This program and the accompanying materials are made available
+# under the terms of the Eclipse Public License 2.0
+# which is available at http://www.eclipse.org/legal/epl-v20.html
+# SPDX-License-Identifier: EPL-2.0
 #*******************************************************************************
 
-# script to copy update jars from their staging area to the releases area
+# Script to copy SimRel build artifacts from the staging area to the releases area
 
-function usage
-{
-  printf "\n\tScript to promote aggregation to staging area" >&2
-  printf "\n\tUsage: %s [-n] -s <stream> -d <dirdate>" "$(basename $0)" >&2
-  printf "\n\t\t%s" "where <stream> is train name, such as 'neon' or 'oxygen'" >&2
-  printf "\n\t\t%s" "and where <dirdate> is the date and time for the directory name of the composite child repository, such as '201208240900'" >&2
-  printf "\n\t\t%s" "and the optional \"-n\" means \"no copying\" or 'dry-run'" >&2
-  printf "\n" >&2
-}
+# Bash strict-mode
+set -o errexit
+set -o nounset
+set -o pipefail
 
-dirdate=
-stream=
-DRYRUN=""
-# the initial ':' keeps getopts in quiet mode ... meaning it doesn't print "illegal argument" type messages.
-# to get it in completely silent mode, assign $OPTERR=0
-# the other ':' is the ususal "OPTARG"
-while getopts ':hns:d:' OPTION
-do
-  options_found=1
-  case $OPTION in
-    h)
-      usage
-      exit 1
-      ;;
-    n)
-      DRYRUN="--dry-run"
-      ;;
-    s)
-      stream=$OPTARG
-      ;;
-    d)
-      dirdate=$OPTARG
-      ;;
-    \?)
-      # I've seen examples where just ?, or [?] is used, which means "match any one character",
-      # whereas literal '?' is returned if getops finds unrecognized argument.
-      # I've not seen documented, but if no arguments supplied, seems getopts returns
-      # '?' and sets $OPTARG to '-'.
-      # so ... decided to handle "no arguments" case before calling getopts.
-      printf "\n\tUnknown option: -%s\n" $OPTARG
-      usage
-      exit 1
-      ;;
-    *)
-      # This fall-through not really needed in this case, esp. with '?' clause.
-      # Usually need one or the other.
-      # getopts appears to return '?' if no options or an unrecognized option.
-      # Decide to use it for program check, in case allowable options are added,
-      # but no matching case statemetns.
-      printf "\n\t%s" "ERROR: unhandled option found: $OPTION. Check script case statements. " >&2
-      printf "\n" >&2
-      usage
-      exit 1
-      ;;
-  esac
-done
+IFS=$'\n\t'
 
-# while we currently don't use/expect additional arguments, it's best to
-# shift away arguments handled by above getopts, so other code (in future) could
-# handle additional trailing arguments not intended for getopts.
-shift $(($OPTIND - 1))
+SCRIPT_FOLDER="$(dirname "$(readlink -f "${0}")")"
 
-case "$stream" in
-  2019-03)
-    export release=2019-03
-    ;;
-  2019-06)
-    export release=2019-06
-    ;;
-  2019-09)
-    export release=2019-09
-    ;;
-  2019-12)
-    export release=2019-12
-    ;;
-  2020-03)
-    export release=2020-03
-    ;;
-  2020-06)
-    export release=2020-06
-    ;;
-  2020-09)
-    export release=2020-09
-    ;;
-  2020-12)
-    export release=2020-12
-    ;;
+SSH_REMOTE="genie.simrel@projects-storage.eclipse.org"
 
-  *)
-    usage
-    exit 1
-    ;;
-esac
+REPO_ROOT=${REPO_ROOT:-/home/data/httpd/download.eclipse.org}
 
-export BUILD_HOME=${BUILD_HOME:-${WORKSPACE}}
+BUILD_HOME=${BUILD_HOME:-${WORKSPACE}}
+BUILD_TOOLS_DIR=${BUILD_HOME}/org.eclipse.simrel.tools
 
-# finds source file on users path, before current directory
-# hence, non-production users can set their own values for test machines
-# must be called (included) after the above variables set, since
-# above variables are used to compute some other values.
+release="${1:-}"
+dirdate="${2:-}"
 
-source promote.shsource 2>/dev/null
-source ${BUILD_HOME}/org.eclipse.simrel.tools/promoteUtils/promote.shsource
-
-export fromDirectory=${stagingDirectory}
-export toDirectory=${releaseDirectory}
-
-
-# make sure 'toDirectory' has been defined and is not zero length
-if [ -z "${toDirectory}" ]; then
-  printf "\n\t[ERROR] the variable toDirectory must be defined to run this script\n"
+if [ -z "${release}" ]; then
+  printf "\n\t[ERROR] the variable release must be defined to run this script\n"
   exit 1
 fi
 
-# make sure 'dirdate' has been defined and is no zero length
 if [ -z "${dirdate}" ]; then
-  printf "\n\t[ERROR] the variable dirdate must be defined to run this script.\n"
+  printf "\n\t[ERROR] the variable dirdate must be defined to run this script\n"
   exit 1
 fi
 
-# sanity check existence
-if [[ ! -e "${toDirectory}" ]]; then
-  printf "\n\t[ERROR] the 'toDirectory' does not exist\n\t\t${toDirectory}\n"
-  exit 1
-fi
+stagingDirectory="${REPO_ROOT}/staging/${release}"
+releaseDirectory="${REPO_ROOT}/releases/${release}"
+releaseSubDir="${releaseDirectory}/${dirdate}"
 
-# sanity check that we have write access to "toDirectory"
-if [[ ! -w "${toDirectory}" ]]; then
-  printf "\n\t[ERROR] No write access to ${toDirectory}\n"
-  exit 1
-fi
+printf "\nCopying new plugins and features "
+printf "\n\tfrom  %s" "${stagingDirectory}"
+printf "\n\tto  %s\n" "${releaseSubDir}"
 
-toSubDir=${toDirectory}/${dirdate}
+# Create ../releases/<release>/<dirdate> dir if it does not exist yet
+ssh "${SSH_REMOTE}" mkdir -p "${releaseSubDir}"
+# use -w and --no-compress, since it's a local copy on the same drive
+ssh "${SSH_REMOTE}" rsync -ahW --no-compress "${stagingDirectory}/*" "${releaseSubDir}/"
 
-if [[ -z "${DRYRUN}" ]]; then
-  printf "\n\tCopying new plugins and features "
-  printf "\n\t\tfrom  ${fromDirectory}"
-  printf "\n\t\tto  ${toSubDir}\n"
+scp "${BUILD_TOOLS_DIR}/promoteUtils/addRepoProperties-release_bash.sh" "${SSH_REMOTE}:~/"
+ssh "${SSH_REMOTE}" "~/addRepoProperties-release_bash.sh" "${release}" "${dirdate}"
 
-  mkdir -p ${toSubDir}
-  RC=$?
-  if [[ $RC != 0 ]]; then
-    printf "\n\t[ERROR] Could not make the directory ${toSubDir}. RC: $RC\n"
-    exit $RC
-  fi
-else
-  printf "\n\tDoing DRYRUN. But if were not doing dry run, then would first make directory:"
-  printf "\n\t\t ${toSubDir}"
-  printf "\n\tAnd, if not dry run, would copy files there from:"
-  printf "\n\t\t ${fromDirectory}\n"
-fi
-
-# plugins and features
-rsync ${DRYRUN}  -rp ${fromDirectory}/* ${toSubDir}/
-RC=$?
-if [[ "$RC" != "0" ]]; then
-  printf "\n\t[ERROR] could not copy files as expected"
-  exit $RC
-fi
-
-"${BUILD_TOOLS_DIR}/promoteUtils/installEclipseAndTools.sh"
-RC=$?
-if [[ $RC != 0 ]]; then
-  printf "\n\t[ERROR] installEclipseAndTools.sh returned non zero return code: $RC\n"
-  exit $RC
-fi
-
-if [[ -z "${DRYRUN}" ]]; then
-  "${BUILD_TOOLS_DIR}/promoteUtils/addRepoProperties-release.sh" ${release} ${dirdate}
-  RC=$?
-  if [[ "$RC" != "0" ]]; then
-    printf "\n\t[ERROR] repo properties could not be updated as expected. RC: $RC"
-    exit $RC
-  fi
-  if [[ -e "${toSubDir}/p2.index" ]]; then
-    # remove p2.index, if exists, since convertxz will recreate, and
-    # convertxz (may) not recreate xz files, after modifications made in
-    # previous step, if p2.index already exists and appears correct.
-    rm "${toSubDir}/p2.index"
-  fi
-  "${BUILD_TOOLS_DIR}/convertxz.sh" "${toSubDir}"
-  RC=$?
-  if [[ "$RC" != "0" ]]; then
-    printf "\n\t[ERROR] convertxz.sh did not complete as expected. RC: $RC\n"
-  fi
-  exit $RC
-else
-  printf "\n\tDoing DRYRUN, otherwise addRepoProperties and createxz would be performed here at end.\n"
-  exit 0
-fi
diff --git a/promoteUtils/promoteToReleases2.sh b/promoteUtils/promoteToReleases2.sh
deleted file mode 100755
index 8146dd2..0000000
--- a/promoteUtils/promoteToReleases2.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env bash
-#*******************************************************************************
-# Copyright (c) 2020 Eclipse Foundation and others.
-# This program and the accompanying materials are made available
-# under the terms of the Eclipse Public License 2.0
-# which is available at http://www.eclipse.org/legal/epl-v20.html
-# SPDX-License-Identifier: EPL-2.0
-#*******************************************************************************
-
-# Bash strict-mode
-set -o errexit
-set -o nounset
-set -o pipefail
-
-IFS=$'\n\t'
-
-SCRIPT_FOLDER="$(dirname "$(readlink -f "${0}")")"
-
-SSH_REMOTE="genie.simrel@projects-storage.eclipse.org"
-
-REPO_ROOT=${REPO_ROOT:-/home/data/httpd/download.eclipse.org}
-
-BUILD_HOME=${BUILD_HOME:-${WORKSPACE}}
-BUILD_TOOLS_DIR=${BUILD_HOME}/org.eclipse.simrel.tools
-
-release="${1:-}"
-dirdate="${2:-}"
-
-if [ -z "${release}" ]; then
-  printf "\n\t[ERROR] the variable release must be defined to run this script\n"
-  exit 1
-fi
-
-if [ -z "${dirdate}" ]; then
-  printf "\n\t[ERROR] the variable dirdate must be defined to run this script\n"
-  exit 1
-fi
-
-stagingDirectory="${REPO_ROOT}/staging/${release}"
-releaseDirectory="${REPO_ROOT}/releases/${release}"
-releaseSubDir="${releaseDirectory}/${dirdate}"
-
-printf "\nCopying new plugins and features "
-printf "\n\tfrom  %s" "${stagingDirectory}"
-printf "\n\tto  %s\n" "${releaseSubDir}"
-
-# Create ../releases/<release>/<dirdate> dir if it does not exist yet
-ssh "${SSH_REMOTE}" mkdir -p "${releaseSubDir}"
-# use -w and --no-compress, since it's a local copy on the same drive
-ssh "${SSH_REMOTE}" rsync -ahW --no-compress "${stagingDirectory}/*" "${releaseSubDir}/"
-
-scp "${BUILD_TOOLS_DIR}/promoteUtils/addRepoProperties-release_bash.sh" "${SSH_REMOTE}:~/"
-ssh "${SSH_REMOTE}" "~/addRepoProperties-release_bash.sh" "${release}" "${dirdate}"
-