Files
arcrun-collector/cmd/arcrun-tray/build-mac.sh
T
Leo 8dd15fbe43 t150: 小幫手自我更新(背景備妥+重啟完成)+版本一致性
leo 07-29 三句話定調:
「小白不會動不動就刪除再裝新的」
「如果它都掛着,那準備好就告訴他重啓更新」
「**我要他下載多幾次他就放棄了,所以抓到一個客戶後不能讓他有機會離開**」

① 版本一致性(leo:「我的和下載下來的會是同一個嗎?」)
   真因:build-mac.sh L22/build-windows.sh L46 **只有 tray 注入版本,collector 沒有**
   ⇒ 托盤顯示 tray 的版本,實際幹活的 collector 無版本可查、可能不同版。
   修:collector 加 version/buildTime 變數與 --version 旗標;兩個 build 腳本都改為
   兩支注入同一個 LDFLAGS_VER(各 2 處)。
   驗:collector --version → v0.15.0 (build 20260729-2238);tray 內含同一組值。

② 自我更新(leo 選 1+3:完全自動,但要有提醒與手動檢查)
   - 背景每日檢查 manifest 的 daemon 版本(單一 CDN 靜態檔,非 GitHub API,不違反不輪詢紅線)
   - 有新版**默默下載並驗 sha256**,備妥後選單變「🟢 新版已就緒 — 點此重新啟動完成更新」
   - daemon 常駐不重啟 ⇒ 不偷換正在跑的自己;使用者按一下才 ditto 覆蓋並重啟
   - 另有「檢查更新…」讓人隨時手動按(不必等每日排程)
   - 驗章不符或解壓失敗=保留舊版不動(壞掉的 .app 比舊版更糟)
   ⇒ **封測者完全不必再下載任何東西**

驗:go build/go vet 過;三個版本比較測試通過(dev 不提示/同版不提示/新版要提示);
未剝離符號版確認 5 個更新函式在 build 範圍內
(註:打包版被 -s -w 剝符號,用 grep/strings 驗會誤判為「功能沒進去」)。
2026-07-29 22:40:58 +08:00

53 lines
3.1 KiB
Bash
Executable File
Raw 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.
#!/usr/bin/env bash
# build-mac.sh — 打包 Arcrun RAG 托盤 appdaemon-beta t7/t8,真機執行)。
#
# leo 07-24 裁決:**選單列托盤 icon 是唯一指示器,不佔 Dock**——
# fyne 預設 bundle 會出現 Dock icon,打包後把 LSUIElement=true 寫進 Info.plist 即隱。
#
# 用法(真機、需 Xcode CLT):
# cd collector/cmd/arcrun-tray && bash build-mac.sh
# 產物:Arcrun RAG.app(含同綑 arcrun-collector)。簽章/公證另行(見 README)。
set -euo pipefail
cd "$(dirname "$0")"
# 版本編號(leo 2026-07-27:「daemon 要加上版本編號」)——沒版本號就只能靠 shasum 對帳,
# 使用者回報問題時我們也不知道他跑的是哪一版(見 t63「修好的東西傳不到用戶」)。
# 用法:VERSION=v0.9.0 bash build-mac.sh(未給則用 git 描述,再不行才 dev)
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
BUILD_TIME="$(date '+%Y%m%d-%H%M')"
LDFLAGS_VER="-X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}"
echo "🏷 版本:${VERSION}build ${BUILD_TIME}"
echo "① 編 collector(同綑執行檔)"
# t150leo 07-29「我的和下載下來的會是同一個嗎」):collector **也要**注入版本,
# 否則托盤顯示的是 tray 的版本、實際幹活的 collector 無版本可查(兩支獨立編譯)。
( cd ../.. && go build -ldflags "-s -w ${LDFLAGS_VER}" -o "cmd/arcrun-tray/arcrun-collector" . )
echo "② fyne package"
go run fyne.io/fyne/v2/cmd/fyne@latest package -os darwin -icon icon.png -name "Arcrun RAG" -appID dev.arcrun.rag.tray
# ②b 用 -s -w 重編托盤覆蓋回 bundle2026-07-27t72/t63)。
# 為什麼:`fyne package` 內部自己 go build,吃不到 -ldflags,產出含符號表與 DWARF 的胖執行檔。
# 實測(本機):托盤 28.6MB → 21.3MB**整包 zip 21.1MB → 14.65MB**
# **掉進 jsDelivr 單檔 20MB 上限內**(此前 Mac 版超標,jsDelivr 直接回
# "File size exceeded the configured limit of 20 MB.",只能走 rawWindows 版 13MB 無此問題)。
# ⇒ 這一步讓 Mac 版也能走 CDN,且**免除拆檔工程**。功能指紋與簽章實測皆不受影響。
echo "②b strip 重編托盤(-s -w;為了掉進 jsDelivr 20MB 線內)+注入版本號"
go build -ldflags "-s -w ${LDFLAGS_VER}" -o "Arcrun RAG.app/Contents/MacOS/arcrun-tray" .
APP="Arcrun RAG.app"
PLIST="$APP/Contents/Info.plist"
echo "③ LSUIElement=true(托盤唯一指示器,隱 Dock icon——leo 07-24 裁決)"
/usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" "$PLIST" 2>/dev/null \
|| /usr/libexec/PlistBuddy -c "Set :LSUIElement true" "$PLIST"
echo "④ 同綑 collector 進 app bundle(托盤 collectorBinPath 找同層)"
cp arcrun-collector "$APP/Contents/MacOS/arcrun-collector"
echo "⑤ ad-hoc 重簽(Apple Silicon:改過 plist/塞過檔必重簽,否則 launchd 拒開 error 162——07-24 真機實撞)"
codesign --force --deep -s - "$APP"
echo "✅ 完成:$APP"
echo "驗法:open '$APP' → 選單列出現 icon、Dock **不出現** icon → 選單列出資料夾清單"