Files
gentpan 40b7e41cbf 支持 Intel 芯片:分别打包 Apple 芯片版与 Intel 版,官网按芯片提供两个下载按钮
- Makefile 支持 ARCH=arm64 / x86_64,release.sh 两种芯片各自构建、签名、公证,生成 DMG 与升级包
- 版本清单顶层仍是 Apple 芯片版(兼容 0.3.0),intel 字段放 Intel 版;应用按芯片挑包,安装前核对架构
- Homebrew cask 按 arch 选择安装包
- 官网下载区改为 Apple 芯片 / Intel 两张卡片,README 安装段落与常见问题同步
2026-09-15 16:21:29 +05:00

51 lines
2.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 本机只保留一个 OpenStats:退出正在运行的旧版 → 删除 /Applications 里的旧版 → 把刚编译的新版移进去 → 启动。
# 用移动而不是复制,编译目录里不留第二份;其他位置被系统登记的同名应用会取消登记并提示。
#
# Scripts/install_local.sh build/DerivedData/Build/Products/Release/OpenStats.app
set -euo pipefail
cd "$(dirname "$0")/.."
SOURCE="${1:?用法:Scripts/install_local.sh <OpenStats.app>}"
TARGET="/Applications/OpenStats.app"
BUNDLE_ID="com.openstats.app"
LSREGISTER=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
[ -d "$SOURCE" ] || { echo "error: 找不到 $SOURCE" >&2; exit 1; }
codesign --verify --deep --strict "$SOURCE"
# 结束旧版。辅助工具在连接断开时会自动恢复风扇与睡眠设置,所以直接结束是安全的
# (不用 AppleScript 退出,免得弹出“自动化”权限请求)
if pgrep -x OpenStats >/dev/null; then
pkill -x OpenStats 2>/dev/null || true
for _ in $(seq 1 25); do pgrep -x OpenStats >/dev/null || break; sleep 0.2; done
fi
if [ -d "$TARGET" ]; then
"$LSREGISTER" -u "$TARGET" >/dev/null 2>&1 || true
rm -rf "$TARGET"
fi
mv "$SOURCE" "$TARGET"
"$LSREGISTER" -f "$TARGET"
# 编译目录里残留的旧产物(Debug / Release 另一种配置、发布时另一种芯片的版本)也清掉
for stale in build/DerivedData*/Build/Products/*/OpenStats.app; do
[ -d "$stale" ] || continue
"$LSREGISTER" -u "$stale" >/dev/null 2>&1 || true
rm -rf "$stale"
done
# 其他位置的同名应用只取消登记并提示,不擅自删除
others="$(mdfind "kMDItemCFBundleIdentifier == '$BUNDLE_ID'" 2>/dev/null | grep -vx "$TARGET" | grep -v '^/Volumes/' || true)"
if [ -n "$others" ]; then
echo "⚠️ 其他位置还有 OpenStats(已取消系统登记,如不需要请手动删除):"
while IFS= read -r path; do
"$LSREGISTER" -u "$path" >/dev/null 2>&1 || true
echo " $path"
done <<< "$others"
fi
open "$TARGET"
version="$(defaults read "$TARGET/Contents/Info" CFBundleShortVersionString) ($(defaults read "$TARGET/Contents/Info" CFBundleVersion))"
echo "✅ 已安装并启动 OpenStats $version:$TARGET"