Files
ModelRouter/packaging/verify-dist.sh
JianFeeeee ed05cccb72 feat(packaging): core distribution packages (deb + rpm + tar.gz) via nfpm
Previously only the Electron GUI had installers; server admins had to build the
core by hand (`make build` -> bare binary). This adds a first-class server
distribution:

- `make core-dist` -> packaging/core-dist.sh -> cmd/build/dist/
    llmsproxy_<ver>_amd64.deb        (systemd unit + adapters + example config)
    llmsproxy-<ver>.x86_64.rpm
    llmsproxy-<ver>-linux-amd64.tar.gz
- nfpm config (packaging/nfpm.yaml): binary to /usr/bin, systemd unit with the
  measured memory tuning (GOGC=50, MALLOC_ARENA_MAX=2) baked in, Lua adapters to
  /usr/share/llmsproxy/adapters, repo's config.yaml as the example.
- postinst seeds /etc/llmsproxy/config.yaml on first install and keeps existing
  runtime state across reinstalls; prerm stops the service on removal.

Gotchas handled: nfpm v2 here does not render `{{ .Env.VERSION }}`, so the script
stamps the version into a throwaway config copy; and under `set -o pipefail` the
idiom `strings | grep -q` is broken (grep -q closes the pipe and strings dies on
SIGPIPE -> spurious 141), so the symbol sanity-gate stages strings in a temp file.

README (zh/en) updated: memory figures replaced with production-measured
32-35 MB settled (was 37-42), and the packaging docs now describe core-dist and
the dockerized Windows build.
2026-08-30 10:49:25 +08:00

49 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Verify packaged GUI artifacts are healthy before a release is declared done.
#
# Background: on 2026-08-28 (1.3.0) the host wine broke (missing syswow64, so
# wine -- the NSIS self-extract step -- failed), and electron-builder silently
# wrote a 264 KB installer shell that did NOT embed the 86 MB payload. No gate
# caught it, so a broken Windows installer shipped. This script is that gate.
#
# It enforces a per-artifact minimum size, so a degenerate installer (or a
# build that only emitted a shell without its embedded payload) fails loudly.
# A size check is the right signal here: a healthy NSIS exe is ~86 MB and the
# broken 1.3.0 one was 264 KB (326x) — electron-builder compresses the embedded
# app.7z, so a plaintext-payload string probe would be unreliable.
set -uo pipefail
GUI_DIST="${1:-cmd/build/gui-dist}"
VERSION="${2:-}"
log() { printf '[verify-dist] %s\n' "$*"; }
fail() { printf '[verify-dist] FATAL: %s\n' "$*" >&2; exit 1; }
[ -d "$GUI_DIST" ] || fail "no dist dir: $GUI_DIST"
# (glob, min-bytes)
checks=(
"ModelRouter*.AppImage:10000000"
"modelrouter-*.deb:10000000"
"modelrouter-*.rpm:10000000"
"modelrouter-*.nsis.7z:10000000"
"ModelRouter Setup*.exe:5000000"
)
for entry in "${checks[@]}"; do
glob="${entry%%:*}"; min="${entry#*:}"
# gui-dist accumulates installers from previous versions; check the MOST
# RECENT artifact (last in sort) so a stale file never masks a broken build.
# `find -name` (not a bare glob) so the space in "ModelRouter Setup *.exe"
# is preserved as one file pattern.
match="$(find "$GUI_DIST" -maxdepth 1 -name "$glob" -type f | sort -V | tail -1)"
[ -z "$match" ] && fail "no artifact matching '$glob' in $GUI_DIST"
sz=$(stat -c%s "$match")
if [ "$sz" -lt "$min" ]; then
fail "$(basename "$match") is only $sz bytes (min $min) — likely a degenerate shell like the 1.3.0 264KB exe"
fi
log "$(basename "$match") ($((sz/1024)) KB)"
done
log "all artifacts healthy"