From 93854e42df1ea3c26c817e7849ad458dffa521ed Mon Sep 17 00:00:00 2001 From: deepend Date: Thu, 19 Feb 2026 10:19:40 -0700 Subject: [PATCH] Updated macOS bundling to detect the host architecture and introduce TARGET_ARCHES (overrideable) so bundle validation can target one or multiple architectures explicitly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a post-bundle architecture check using lipo -archs against ZoiteChat-bin, and made bundling fail early with a clear error/hint when required architectures are missing (prevents shipping a bundle that will fail with “Bad CPU type”). Kept the existing architecture reporting via file, now reusing a single BIN_PATH variable for consistency. --- osx/makebundle.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/osx/makebundle.sh b/osx/makebundle.sh index 30be7eda..9f2cb967 100755 --- a/osx/makebundle.sh +++ b/osx/makebundle.sh @@ -8,6 +8,9 @@ cd "$SCRIPT_DIR" BUNDLE_DEF="zoitechat.bundle" APP_NAME="ZoiteChat.app" +HOST_ARCH="$(uname -m 2>/dev/null || echo unknown)" +TARGET_ARCHES="${TARGET_ARCHES:-$HOST_ARCH}" + # Expected prefixes for macOS GTK dependencies: # - Homebrew: /opt/homebrew (Apple Silicon) or /usr/local (Intel) # - MacPorts: /opt/local @@ -92,9 +95,31 @@ if [ ! -d "$APP_NAME" ]; then exit 1 fi +BIN_PATH="$APP_NAME/Contents/MacOS/ZoiteChat-bin" + +if command -v lipo >/dev/null 2>&1; then + BIN_ARCHS="$(lipo -archs "$BIN_PATH" 2>/dev/null || true)" + if [ -z "$BIN_ARCHS" ]; then + echo "error: unable to detect architectures for $BIN_PATH" >&2 + exit 1 + fi + + for required_arch in $TARGET_ARCHES; do + if ! echo " $BIN_ARCHS " | grep -q " $required_arch "; then + cat >&2 </dev/null 2>&1; then echo "Bundled binary architecture:" - file "$APP_NAME/Contents/MacOS/ZoiteChat-bin" || true + file "$BIN_PATH" || true fi echo "Compressing bundle"