fix: 兼容 macOS localized 应用安装路径

macOS 安装器可能将应用放入 Ydisks Xianyu Helper.localized 目录,安装脚本改为自动发现普通路径和 localized 路径,避免 postinstall 找不到模板文件。
This commit is contained in:
Christ committed 2026-08-11 23:27:33 +08:00
1 parent 13b57891fb
commit 9cb50a229c
2 files changed
+29 -9

No files matched your search

+15 -1
View File
@@ -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"
+14 -8
View File
@@ -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