mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-07 09:47:23 +00:00
产品名早已是 ModelRouter,但仓库标识符仍沿用旧名。这次统一,读写两侧都做兼容, 已部署的机器不会因为顺序问题立刻失效。 - go module `llmsproxy` → `modelrouter`;全仓 import 与 `cmd/modelrouter` 同步。 - `Makefile BINARY=modelrouter`;发行包名、systemd unit、/usr/share 资源、 `/usr/local/bin` 目标全部改为 modelrouter。 - 默认配置目录 `/etc/llmsproxy` → `/etc/modelrouter`。**读取侧回退**:插件与 `storeDir` 仍会检查旧路径,所以"先换二进制、后改 unit"不会立即失效。 - 环境变量 `LLMSPROXY_*`(PLUGIN_DIR / XDISPLAY_BASE / ARCH / LIVE_ZEN / BUILD_DIR)改为 `MODELROUTER_*`;`LLMS_PROXY_MASTER_KEY` → `MODELROUTER_MASTER_KEY`。旧名在读取侧继续接受。 - 桌面端内嵌核心 `bin/llmsproxy` → `bin/modelrouter`,并保留旧文件名回退, 避免升级到一半的 profile 被判成"core binary missing"。 - 新增 `packaging/migrate-to-modelrouter.sh`:**默认 dry-run**,复制而非移动、 旧目录永不删除、支持 `--rollback`;随 release tar 分发并由 core-dist 校验。 - `deploy.sh` 增加改名保护:发现旧 `/etc/llmsproxy` 而新配置不存在时**中止**, 否则会部署出一个"能启动但没有 key、没有源"的空实例。 - 临时目录前缀 `/tmp/llmsproxy-*` → `/tmp/modelrouter-*`;清理逻辑同时回收两代。 兼容别名(`__llmsproxy_*` 全局、`llmsproxy` SDK 别名、旧路径/旧 env)刻意保留, 它们是升级路径而非遗留;docs/plugins.md 已标注为废弃。 本提交未包含:`adapters/opencodezen.lua`、`adapter_opencodezen_test.go`、 `adapter_opencodezen_live_test.go`(OpenCode UA/免费池的既有改动,另批提交)。
91 lines
3.4 KiB
Makefile
91 lines
3.4 KiB
Makefile
.PHONY: all build test gui gui-dev gui-dist gui-deb gui-win gui-win-docker help clean gui-test
|
|
|
|
# ModelRouter - single-binary gateway + optional Electron desktop GUI (embedded core)
|
|
export BINARY
|
|
BINARY=modelrouter
|
|
export BUILD_DIR
|
|
BUILD_DIR=build
|
|
export GUI_DIR
|
|
GUI_DIR=cmd/gui
|
|
VERSION ?= $(shell git describe --tags --dirty 2>/dev/null || echo "0.1.0")
|
|
|
|
# Clean env for GUI packaging: the host may have LD_LIBRARY_PATH polluted by
|
|
# third-party runtimes (e.g. /opt/cangjie) which electron-builder bakes into
|
|
# the produced binary's DT_RPATH/dep resolution -> the packaged app then
|
|
# SIGSEGVs inside ld.so on clean machines. Strip it for every pack step.
|
|
CLEAN_PACK_ENV = env -u LD_LIBRARY_PATH
|
|
|
|
all: build
|
|
|
|
# ---- core binary (server users / embedded core) ----
|
|
build:
|
|
@mkdir -p $(BUILD_DIR)
|
|
CGO_ENABLED=1 go build -tags luajit -trimpath -o $(BUILD_DIR)/$(BINARY) ./cmd/modelrouter
|
|
@echo "Built: $(BUILD_DIR)/$(BINARY) ($(VERSION))"
|
|
|
|
# ---- core distribution packages (deb + rpm + tar.gz) -----
|
|
# Server admins install these with dpkg/rpm; unlike the GUI they are the bare
|
|
# gateway binary + systemd unit (with memory tuning) + Lua adapters.
|
|
core-dist:
|
|
./packaging/core-dist.sh $(VERSION)
|
|
|
|
.PHONY: core-dist
|
|
|
|
# ---- GUI (Electron) ----
|
|
gui:
|
|
@cd $(GUI_DIR) && npm start
|
|
|
|
gui-dev:
|
|
@cd $(GUI_DIR) && npm run dev
|
|
|
|
# build the embedded core into the GUI, then run electron-builder
|
|
# targets: deb + rpm + AppImage (linux); rpm needs system rpmbuild
|
|
# NOTE: run in a clean env (no LD_LIBRARY_PATH pollution) so the packaged
|
|
# binary does not link against host-only libs and crash on user machines.
|
|
gui-dist:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:linux
|
|
./packaging/verify-dist.sh
|
|
|
|
# deb only (for local sharing), rpm needs rpmbuild
|
|
gui-deb:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:debian
|
|
|
|
# windows nsis installer: host-built core (needs apt install gcc-mingw-w64-x86-64 + wine)
|
|
gui-win:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:win
|
|
|
|
# windows nsis installer: full cross-build in docker (self-sufficient, no host mingw)
|
|
gui-win-docker:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) ./scripts/dist-win-docker.sh
|
|
./packaging/verify-dist.sh
|
|
|
|
gui-dist-dir:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:dir
|
|
|
|
test:
|
|
go test ./...
|
|
|
|
# Desktop shell unit tests (no Electron needed): plugin-tree seeding/migration.
|
|
# These guard the two things that silently break the desktop build:
|
|
# - plugin_dir missing from an embedded profile -> channels plugin invisible
|
|
# - bundled plugin files never refreshed -> old channels.lua survives upgrades
|
|
gui-test:
|
|
@cd $(GUI_DIR) && node --test plugin-sync.test.js
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR) cmd/build cmd/gui/dist cmd/gui/build/gui-dist cmd/gui/bin
|
|
|
|
help:
|
|
@echo "Targets:"
|
|
@echo " make build build core binary (luajit)"
|
|
@echo " make core-dist build core packages: deb + rpm + tar.gz (needs nfpm)"
|
|
@echo " make gui run desktop GUI (dev)"
|
|
@echo " make gui-dev run GUI with devtools"
|
|
@echo " make gui-dist build deb + rpm + AppImage (linux)"
|
|
@echo " make gui-test desktop shell unit tests (plugin tree seeding)"
|
|
@echo " make gui-deb build deb only"
|
|
@echo " make gui-win build Windows nsis (needs host mingw + wine)"
|
|
@echo " make gui-win-docker build Windows nsis all-in-docker (no host mingw needed)"
|
|
@echo " make test run go tests"
|
|
@echo " make clean remove build dirs and packaged installers (build/, cmd/build/, cmd/gui/dist/)"
|