From d07b34acc80d31b4aad52c6414baf15bb7062937 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Fri, 14 May 2021 11:15:59 -0400 Subject: [PATCH] Update prior installer versions def. branch Signed-off-by: Chris Evich --- bin/install_automation.sh | 17 +++++++++++++++++ common/test/testbin-install_automation.sh | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/bin/install_automation.sh b/bin/install_automation.sh index bf81630..917209c 100755 --- a/bin/install_automation.sh +++ b/bin/install_automation.sh @@ -44,6 +44,22 @@ msg() { echo -e "${1:-No Message given}" > /dev/stderr; } dbg() { if ((DEBUG)); then msg "\n# $1"; fi } +# On 5/14/2021 the default branch was renamed to 'main'. +# Since prior versions of the installer reference the old +# default branch, the version-specific installer could fail. +# Work around this with some inline editing of the downloaded +# script, before re-exec()ing it. +fix_branch_ref() { + local filepath="$1" + if [[ ! -w "$filepath" ]]; then + msg "Error updating default branch name in installer script at '$filepath'" + exit 19 + fi + sed -i -r -e \ + 's/^(AUTOMATION_REPO_BRANCH.+)master/\1main/' \ + "$filepath" +} + # System-wide access to special environment, not used during installer testing. install_environment() { msg "##### Installing automation environment file." @@ -170,6 +186,7 @@ exec_installer() { # Full path is required so script can find and install itself DOWNLOADED_INSTALLER="$INSTALLATION_SOURCE/bin/$SCRIPT_FILENAME" if [[ -x "$DOWNLOADED_INSTALLER" ]]; then + fix_branch_ref "$DOWNLOADED_INSTALLER" msg "Executing installer version '$version_arg'\n" dbg "Using \$INSTALL_PREFIX '$INSTALL_PREFIX'; installer '$DOWNLOADED_INSTALLER'" # Execution likely trouble-free, cancel removal on exit diff --git a/common/test/testbin-install_automation.sh b/common/test/testbin-install_automation.sh index 19f8e0c..6e85b8d 100755 --- a/common/test/testbin-install_automation.sh +++ b/common/test/testbin-install_automation.sh @@ -27,6 +27,16 @@ test_cmd \ 128 "fatal.+v99.99.99.*not found" \ $INSTALLER_FILEPATH 99.99.99 +test_cmd \ + "The installer successfully installs the oldest tag" \ + 0 "installer version 'v1.0.0'.+exec.+AUTOMATION_REPO_BRANCH=main.+Installation complete" \ + $INSTALLER_FILEPATH 1.0.0 + +test_cmd \ + "The oldest installed installer's default branch was modified" \ + 0 "" \ + grep -Eqm1 '^AUTOMATION_REPO_BRANCH=.+main' "$INSTALL_PREFIX/automation/bin/$SUBJ_FILENAME" + test_cmd \ "The installer detects incompatible future installer source version by an internal mechanism" \ 10 "Error.+incompatible.+99.99.99" \