fix(installer): resolve local macOS patcher after cwd changes

This commit is contained in:
Haitao Pan 2026-06-27 09:02:08 +08:00
parent 5093e21e35
commit 2d3289fbc5
2 changed files with 18 additions and 5 deletions

View File

@ -1085,9 +1085,8 @@ patch_playbooks_for_macos() {
info "Fetching and running macOS playbook patches..." info "Fetching and running macOS playbook patches..."
local patch_script="/tmp/patch-macos-playbooks.py" local patch_script="/tmp/patch-macos-playbooks.py"
local raw_url="https://raw.githubusercontent.com/ai-workspace-lab/xworkspace-console/main/scripts/patch-macos-playbooks.py" local raw_url="https://raw.githubusercontent.com/ai-workspace-lab/xworkspace-console/main/scripts/patch-macos-playbooks.py"
local bootstrap_script_dir local_patch_script local local_patch_script
bootstrap_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-}")" 2>/dev/null && pwd || true)" local_patch_script="${XWORKSPACE_CONSOLE_DIR}/scripts/patch-macos-playbooks.py"
local_patch_script="${bootstrap_script_dir}/patch-macos-playbooks.py"
if [ -f "$local_patch_script" ]; then if [ -f "$local_patch_script" ]; then
cp "$local_patch_script" "$patch_script" cp "$local_patch_script" "$patch_script"

View File

@ -251,8 +251,22 @@ test_macos_plugin_patch_uses_stable_directory() {
} }
test_local_bootstrap_prefers_local_macos_patcher() { test_local_bootstrap_prefers_local_macos_patcher() {
grep -Fq 'if [ -f "$local_patch_script" ]' "$BOOTSTRAP" || local checkout workdir
fail "local bootstrap does not prefer its checked-in macOS patcher" checkout="$(mktemp -d)"
workdir="$(mktemp -d)"
mkdir -p "$checkout/scripts"
printf 'local-patcher-marker\n' > "$checkout/scripts/patch-macos-playbooks.py"
(
XWORKSPACE_CONSOLE_DIR="$checkout"
cd "$workdir"
# shellcheck disable=SC2329
python3() {
grep -q '^local-patcher-marker$' "$1" ||
fail "patch function did not execute the checked-in patcher"
}
patch_playbooks_for_macos
)
rm -rf "$checkout" "$workdir"
grep -Fq '"${raw_url}?rev=$(date +%s)"' "$BOOTSTRAP" || grep -Fq '"${raw_url}?rev=$(date +%s)"' "$BOOTSTRAP" ||
fail "remote macOS patcher download is not cache-busted" fail "remote macOS patcher download is not cache-busted"
} }