Skip to content

Commit

Permalink
Update prior installer versions def. branch
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Evich <cevich@redhat.com>
  • Loading branch information
cevich committed May 14, 2021
1 parent c3ae42a commit d07b34a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bin/install_automation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions common/test/testbin-install_automation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down

0 comments on commit d07b34a

Please sign in to comment.