fix(installer): use checked-in macOS patcher locally

This commit is contained in:
Haitao Pan 2026-06-27 08:58:37 +08:00
parent 50c2d85a14
commit 5093e21e35
2 changed files with 18 additions and 4 deletions

View File

@ -1085,11 +1085,16 @@ patch_playbooks_for_macos() {
info "Fetching and running macOS playbook patches..."
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"
if command -v curl >/dev/null 2>&1; then
curl -sfL -o "$patch_script" "$raw_url"
local bootstrap_script_dir local_patch_script
bootstrap_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-}")" 2>/dev/null && pwd || true)"
local_patch_script="${bootstrap_script_dir}/patch-macos-playbooks.py"
if [ -f "$local_patch_script" ]; then
cp "$local_patch_script" "$patch_script"
elif command -v curl >/dev/null 2>&1; then
curl -sfL -o "$patch_script" "${raw_url}?rev=$(date +%s)"
else
wget -qO "$patch_script" "$raw_url"
wget -qO "$patch_script" "${raw_url}?rev=$(date +%s)"
fi
if [ -f "$patch_script" ]; then

View File

@ -250,6 +250,13 @@ test_macos_plugin_patch_uses_stable_directory() {
fi
}
test_local_bootstrap_prefers_local_macos_patcher() {
grep -Fq 'if [ -f "$local_patch_script" ]' "$BOOTSTRAP" ||
fail "local bootstrap does not prefer its checked-in macOS patcher"
grep -Fq '"${raw_url}?rev=$(date +%s)"' "$BOOTSTRAP" ||
fail "remote macOS patcher download is not cache-busted"
}
test_root_does_not_require_sudo
printf 'ok - root execution does not require sudo\n'
test_non_root_uses_sudo
@ -283,3 +290,5 @@ test_provider_api_keys_use_secret_logging
printf 'ok - provider API keys use masked secret logging\n'
test_macos_plugin_patch_uses_stable_directory
printf 'ok - macOS plugin patch uses stable extension storage\n'
test_local_bootstrap_prefers_local_macos_patcher
printf 'ok - local bootstrap prefers the checked-in macOS patcher\n'