#!/bin/bash # 打包 MomentryCore.dmg set -e SRC="/Users/accusys/momentry_core" BUILD="$SRC/installer/build" APP="$BUILD/MomentryCore" echo ">>> 清理舊 build..." rm -rf "$BUILD" mkdir -p "$APP"/{bin,config,tools,logs} echo ">>> 複製 binaries..." cp "$SRC/target/release/momentry" "$APP/bin/" 2>/dev/null || echo " [!] momentry 不存在,執行: cargo build --release" cp "$SRC/target/release/pipeline_worker" "$APP/bin/" 2>/dev/null || echo " [!] pipeline_worker 不存在" chmod +x "$APP/bin/"* 2>/dev/null || true echo ">>> 複製 config..." cp "$SRC/installer/config/"* "$APP/config/" cp "$SRC/config/pipeline_flows.json" "$APP/config/" 2>/dev/null || true cp "$SRC/config/processor_tools_v3.json" "$APP/config/" 2>/dev/null || true cp "$SRC/config/admin_config.json" "$APP/config/" 2>/dev/null || true echo ">>> 複製 tools (排除 .build, __pycache__)..." rsync -av --exclude='.build' --exclude='__pycache__' --exclude='*.pyc' \ "$SRC/tools/" "$APP/tools/" 2>/dev/null || \ cp -rf "$SRC/tools/"* "$APP/tools/" 2>/dev/null || true echo ">>> 複製 install.sh..." cp "$SRC/installer/install.sh" "$APP/" cp "$SRC/installer/uninstall.sh" "$APP/" chmod +x "$APP/install.sh" "$APP/uninstall.sh" echo ">>> 建立 README..." cat > "$APP/README.txt" << 'README' Momentry Core 安裝說明 1. 確認依賴已安裝: brew install postgresql redis mongodb-mongosh qdrant ffmpeg python@3.11 2. 啟動外部服務: brew services start postgresql brew services start redis brew services start mongodb-community brew services start qdrant 3. 執行安裝腳本: ./install.sh 4. 驗證: curl http://localhost:3002/api/v1/health README echo ">>> 建立 .dmg..." DMG="$BUILD/MomentryCore.dmg" hdiutil create -volname "MomentryCore" \ -srcfolder "$APP" \ -ov -format UDZO "$DMG" echo "" echo "================================================" echo " DMG 建立完成!" echo " 位置: $DMG" echo " 大小: $(du -h "$DMG" | cut -f1)" echo "================================================"