Files
VoiletMark/packaging/macos/bundle-libs.sh
T
liyepan 53a015a1ea
安装包 / Linux aarch64 (push) Canceled after 0s
安装包 / Linux x86_64 (push) Canceled after 0s
安装包 / Windows x86_64 (push) Canceled after 0s
安装包 / macOS arm64 (Apple Silicon) (push) Canceled after 0s
安装包 / macOS x86_64 (Intel) (push) Canceled after 0s
安装包 / 发布到 Release (push) Canceled after 0s
feat: v0.12.4 —— 安装包工作流扩到 Windows / macOS
- 工作流改名 .github/workflows/packages.yml,新增 Windows 和两个 macOS job
- Windows:windeployqt 收运行库,NSIS 按当前用户装到 LOCALAPPDATA(免管理员),
  关联 .md、「打开方式」注册、开始菜单/桌面快捷方式、卸载项,另出便携 zip;
  安装包未签名
- macOS arm64:Homebrew Qt 5(原生 arm64,不依赖 Rosetta),macdeployqt 后把
  Homebrew 的 libpng/freetype 等依赖收进 app,再 ad-hoc 签名、打 dmg
- macOS x86_64:Qt 5.15.2 官方二进制 + macos-15-intel runner,同样签名打 dmg
- Release 汇总所有平台产物并生成 SHA256SUMS;某个平台失败不影响其它平台
- README 写清三平台产物、未签名打开方式、.md 关联和发版方式
2026-10-23 14:41:25 +08:00

47 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# 把 .app 里引用到的 Homebrew 动态库收进 Contents/Frameworks,并把引用改成包内相对路径。
# Homebrew 的 Qt 会链到 /opt/homebrew 下的 libpng / freetype 等,macdeployqt 不会带它们。
# 用法: bundle-libs.sh <VoiletMark.app>
set -euo pipefail
app=$1
if [ ! -d "$app" ]; then
echo "找不到 $app" >&2
exit 1
fi
frameworks=$app/Contents/Frameworks
mkdir -p "$frameworks"
round=0
while [ "$round" -lt 12 ]; do
round=$((round + 1))
changed=0
while IFS= read -r file; do
[ -f "$file" ] || continue
while IFS= read -r dep; do
case "$dep" in
/opt/homebrew/*|/usr/local/*)
base=$(basename "$dep")
if [ ! -f "$frameworks/$base" ]; then
cp "$dep" "$frameworks/$base"
chmod 755 "$frameworks/$base"
install_name_tool -id "@executable_path/../Frameworks/$base" "$frameworks/$base" >/dev/null 2>&1 || true
changed=1
fi
install_name_tool -change "$dep" "@executable_path/../Frameworks/$base" "$file" >/dev/null 2>&1 || true
;;
esac
done < <(otool -L "$file" | tail -n +2 | awk '{print $1}')
done < <(find "$app" -type f \( -perm -111 -o -name '*.dylib' \) -print)
[ "$changed" -eq 1 ] || break
done
left=$(find "$app" -type f \( -perm -111 -o -name '*.dylib' \) -exec otool -L {} + 2>/dev/null | grep -E '^[[:space:]]*(/opt/homebrew|/usr/local)/' | wc -l | tr -d ' ')
if [ "$left" -ne 0 ]; then
echo "还有 $left 个 Homebrew 依赖没处理:" >&2
find "$app" -type f \( -perm -111 -o -name '*.dylib' \) -exec otool -L {} + 2>/dev/null | grep -E '^[[:space:]]*(/opt/homebrew|/usr/local)/' | head -20 >&2
exit 1
fi