From f1b7ade1fa378b1e9218e8d62119b54b75239825 Mon Sep 17 00:00:00 2001 From: morfize <233522679+morfize@users.noreply.github.com> Date: Wed, 15 Apr 2026 04:45:50 +0900 Subject: [PATCH] Fix install.sh sourced-invocation and stale template alias Two install failures observed on fresh macOS + zsh setups: - Sourcing from zsh (. ./scripts/install.sh) silently misplaced the installer venv one directory above the repo root, because zsh leaves BASH_SOURCE unset and SCRIPT_DIR collapsed to cwd. Now refuse sourced or non-bash invocation with a clear error, using return when sourced and exit otherwise. - The shared opengauss template alias at morph.new has been observed to return 404, breaking --experimental-run-locally runs that fell through to the remote fetch. Prefer the checked-in .github/morph/opengauss-template.yaml when present, so local installs are self-contained and no longer depend on the remote alias. Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/install.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 3da71c9..8c915b1 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,10 +1,26 @@ #!/usr/bin/env bash set -euo pipefail +# Refuse sourced or non-bash invocation: zsh leaves BASH_SOURCE unset, misplacing the venv. +if [[ -z "${BASH_VERSION:-}" ]]; then + printf 'error: scripts/install.sh must be executed with bash, not sourced. Run: ./scripts/install.sh\n' >&2 + return 1 2>/dev/null || exit 1 +fi +if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then + printf 'error: scripts/install.sh must be executed, not sourced. Run: ./scripts/install.sh\n' >&2 + return 1 2>/dev/null || exit 1 +fi + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" RUNNER_VENV="$REPO_ROOT/.opengauss-installer-venv" -DEFAULT_INSTALL_TARGET="opengauss" +# Prefer the checked-in template: the shared `opengauss` alias at morph.new has been observed to 404. +LOCAL_TEMPLATE_YAML="$REPO_ROOT/.github/morph/opengauss-template.yaml" +if [ -f "$LOCAL_TEMPLATE_YAML" ]; then + DEFAULT_INSTALL_TARGET="$LOCAL_TEMPLATE_YAML" +else + DEFAULT_INSTALL_TARGET="opengauss" +fi INSTALL_TARGET="${OPEN_GAUSS_INSTALL_TARGET:-${OPEN_GAUSS_TEMPLATE_TARGET:-$DEFAULT_INSTALL_TARGET}}" DEFAULT_SESSION_NAME="gauss" SESSION_NAME="${OPEN_GAUSS_SESSION_NAME:-$DEFAULT_SESSION_NAME}"