From 9cb50a229cd4ddc6bad6f70df065e18288d6e11c Mon Sep 17 00:00:00 2001 From: Christ Date: Tue, 11 Aug 2026 23:27:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=20macOS=20localized?= =?UTF-8?q?=20=E5=BA=94=E7=94=A8=E5=AE=89=E8=A3=85=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS 安装器可能将应用放入 Ydisks Xianyu Helper.localized 目录,安装脚本改为自动发现普通路径和 localized 路径,避免 postinstall 找不到模板文件。 --- packaging/macos/scripts/postinstall | 16 +++++++++++++++- packaging/macos/scripts/preinstall | 22 ++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/packaging/macos/scripts/postinstall b/packaging/macos/scripts/postinstall index 770718c..50125df 100755 --- a/packaging/macos/scripts/postinstall +++ b/packaging/macos/scripts/postinstall @@ -9,8 +9,22 @@ printf '\n[%s] postinstall start; uid=%s; user=%s; args=%s\n' \ "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$(id -u)" "$(id -un)" "$*" set -x -APP="/Applications/Ydisks Xianyu Helper.app" SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" +APP="" +for app_path in \ + "/Applications/Ydisks Xianyu Helper.app" \ + "/Applications/Ydisks Xianyu Helper.localized/Ydisks Xianyu Helper.app" +do + if [ -f "$app_path/Contents/Info.plist" ]; then + APP="$app_path" + break + fi +done +if [ -z "$APP" ]; then + echo "找不到已安装的 Ydisks Xianyu Helper.app,无法继续注册服务。" + exit 1 +fi + SERVER="$APP/Contents/Helpers/xianyu-server" TRAY="$APP/Contents/MacOS/xianyu-tray" BROWSER_INSTALL="$APP/Contents/Helpers/browser-install" diff --git a/packaging/macos/scripts/preinstall b/packaging/macos/scripts/preinstall index ee8df32..2357b43 100755 --- a/packaging/macos/scripts/preinstall +++ b/packaging/macos/scripts/preinstall @@ -9,7 +9,6 @@ printf '\n[%s] preinstall start; uid=%s; user=%s; args=%s\n' \ "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$(id -u)" "$(id -un)" "$*" set -x -APP="/Applications/Ydisks Xianyu Helper.app" EXPECTED_BUNDLE_ID="com.ydisks.xianyu-helper" CONSOLE_USER="$(stat -f '%Su' /dev/console)" @@ -25,11 +24,18 @@ if [ "$CONSOLE_USER" != "root" ] && [ -n "$CONSOLE_USER" ]; then done fi -if [ -d "$APP" ]; then - existing_bundle_id="$(/usr/bin/plutil -extract CFBundleIdentifier raw -o - \ - "$APP/Contents/Info.plist" 2>/dev/null || true)" - if [ "$existing_bundle_id" != "$EXPECTED_BUNDLE_ID" ]; then - echo "清理旧 Bundle ID 的应用:${existing_bundle_id:-未知}" - rm -rf "$APP" +for app_path in \ + "/Applications/Ydisks Xianyu Helper.app" \ + "/Applications/Ydisks Xianyu Helper.localized/Ydisks Xianyu Helper.app" +do + if [ ! -d "$app_path" ]; then + continue fi -fi + + existing_bundle_id="$(/usr/bin/plutil -extract CFBundleIdentifier raw -o - \ + "$app_path/Contents/Info.plist" 2>/dev/null || true)" + if [ "$existing_bundle_id" != "$EXPECTED_BUNDLE_ID" ]; then + echo "清理旧 Bundle ID 的应用:${existing_bundle_id:-未知}($app_path)" + rm -rf "$app_path" + fi +done