Skip to content

Commit 8365d56

Browse files
committed
fix(portable): Correct arch runtime packaging and brew install layout
Download the Node runtime for the requested target architecture instead of\ncopying the host runtime so x64 packaging and universal lipo assembly\nwork reliably from arm64 builders.\n\nInstall portable archive contents at formula prefix to preserve wrapper\nresource-root path resolution during Homebrew installs.\n\nCo-Authored-By: Claude <noreply@anthropic.com>
1 parent 058b6f8 commit 8365d56

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

scripts/create-homebrew-formula.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ class Xcodebuildmcp < Formula
6767
end
6868
6969
def install
70-
libexec.install Dir["*"]
71-
bin.install_symlink libexec/"bin/xcodebuildmcp"
72-
bin.install_symlink libexec/"bin/xcodebuildmcp-doctor"
70+
prefix.install Dir["*"]
7371
end
7472
7573
test do
@@ -85,4 +83,3 @@ if [[ -n "$OUT_PATH" ]]; then
8583
else
8684
printf "%s\n" "$FORMULA_CONTENT"
8785
fi
88-

scripts/package-macos-portable.sh

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,45 @@ verify_axe_assets() {
115115
fi
116116
}
117117

118+
install_node_runtime_for_arch() {
119+
local target_arch="$1"
120+
local output_path="$2"
121+
local node_version="${NODE_RUNTIME_VERSION:-$(node -p "process.versions.node")}"
122+
local node_arch=""
123+
124+
case "$target_arch" in
125+
arm64)
126+
node_arch="arm64"
127+
;;
128+
x64)
129+
node_arch="x64"
130+
;;
131+
*)
132+
echo "Unsupported target arch for Node runtime: $target_arch"
133+
exit 1
134+
;;
135+
esac
136+
137+
local archive_name="node-v${node_version}-darwin-${node_arch}.tar.gz"
138+
local download_url="https://nodejs.org/dist/v${node_version}/${archive_name}"
139+
local temp_dir
140+
temp_dir="$(mktemp -d)"
141+
142+
curl -fLsS "$download_url" -o "$temp_dir/$archive_name"
143+
tar -xzf "$temp_dir/$archive_name" -C "$temp_dir"
144+
145+
local extracted_node="$temp_dir/node-v${node_version}-darwin-${node_arch}/bin/node"
146+
if [[ ! -x "$extracted_node" ]]; then
147+
echo "Failed to locate extracted Node runtime at $extracted_node"
148+
rm -r "$temp_dir"
149+
exit 1
150+
fi
151+
152+
cp "$extracted_node" "$output_path"
153+
chmod +x "$output_path"
154+
rm -r "$temp_dir"
155+
}
156+
118157
write_wrapper_scripts() {
119158
local root="$1"
120159
local bin_dir="$root/bin"
@@ -223,8 +262,7 @@ if [[ -d "$PORTABLE_ROOT" ]]; then
223262
fi
224263
mkdir -p "$PORTABLE_ROOT/bin" "$PORTABLE_ROOT/libexec"
225264

226-
cp "$(command -v node)" "$PORTABLE_ROOT/libexec/node-runtime"
227-
chmod +x "$PORTABLE_ROOT/libexec/node-runtime"
265+
install_node_runtime_for_arch "$ARCH" "$PORTABLE_ROOT/libexec/node-runtime"
228266

229267
cp -R "$PROJECT_ROOT/build" "$PORTABLE_ROOT/libexec/"
230268
cp -R "$PROJECT_ROOT/manifests" "$PORTABLE_ROOT/libexec/"

0 commit comments

Comments
 (0)