fix: ship hermit-update (and hermit-service) as 1.0.1
ci / tcc-check (push) Failing after 42s
ci / linux (aarch64, 0) (push) Skipped
ci / linux (x86, 1) (push) Skipped
ci / linux (x86_64, 1) (push) Skipped
ci / windows (push) Skipped

Install hermit-update / hermit-service from make install and bootstrap;
keep cst-agent-* as compat symlinks.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WHC
2026-10-29 22:00:07 +08:00
co-authored by Cursor
parent 41f4cf85ee
commit f29c1000b6
6 changed files with 83 additions and 31 deletions
+38 -22
View File
@@ -1,17 +1,18 @@
#!/usr/bin/env bash
# Install or upgrade CST-Agent on Linux, WSL or macOS. Safe to rerun: an
# Install or upgrade Hermit on Linux, WSL or macOS. Safe to rerun: an
# existing checkout is fast-forwarded, rebuilt and reinstalled.
#
# bootstrap_linux.sh [DIR] [--no-pull] [--release] [--source]
# cst-agent-update (installed by this script; same as rerunning it)
# hermit-update (installed by this script; same as rerunning it)
# cst-agent-update (compat symlink → hermit-update)
#
# --release downloads the static musl tarball for this host (fast; no compile).
# --source (default) builds from the checkout. CST_INSTALL_MODE=release|source
# overrides the flag.
#
# Env: CST_AGENT_PREFIX (install prefix, default ~/.local), CST_AGENT_DIR
# (checkout, default: current checkout or ~/CST-agent), CST_AGENT_REPO,
# CST_AGENT_VERSION (pin a release; default: cst_version.h or latest tag).
# Env: HERMIT_PREFIX / CST_AGENT_PREFIX (install prefix, default ~/.local),
# HERMIT_DIR / CST_AGENT_DIR (checkout), HERMIT_REPO / CST_AGENT_REPO,
# HERMIT_VERSION / CST_AGENT_VERSION (pin a release; default: cst_version.h).
set -euo pipefail
ROOT_HINT="$(cd "$(dirname "$0")/.." 2>/dev/null && pwd || true)"
@@ -80,15 +81,24 @@ install_font() {
install_helpers() {
local prefix="$1" dir="$2"
local bash_bin
bash_bin="$(command -v bash)"
mkdir -p "$prefix/bin"
cat >"$prefix/bin/cst-agent-update" <<EOF
#!$(command -v bash)
export CST_AGENT_PREFIX="\${CST_AGENT_PREFIX:-$prefix}"
exec bash "$dir/scripts/bootstrap_linux.sh" "$dir" "\$@"
cat >"$prefix/bin/hermit-update" <<EOF
#!$bash_bin
# Upgrade Hermit (source build or --release tarball).
export HERMIT_PREFIX="\${HERMIT_PREFIX:-\${CST_AGENT_PREFIX:-$prefix}}"
export CST_AGENT_PREFIX="\$HERMIT_PREFIX"
export HERMIT_DIR="\${HERMIT_DIR:-\${CST_AGENT_DIR:-$dir}}"
export CST_AGENT_DIR="\$HERMIT_DIR"
exec bash "$dir/scripts/bootstrap_linux.sh" "\$HERMIT_DIR" "\$@"
EOF
chmod 0755 "$prefix/bin/cst-agent-update"
cat >"$prefix/bin/cst-agent-service" <<EOF
#!$(command -v bash)
chmod 0755 "$prefix/bin/hermit-update"
ln -sfr "$prefix/bin/hermit-update" "$prefix/bin/cst-agent-update" 2>/dev/null || \
ln -sf hermit-update "$prefix/bin/cst-agent-update"
cat >"$prefix/bin/hermit-service" <<EOF
#!$bash_bin
# Manage the parliament seat service (foreground under systemd, or --service).
set -euo pipefail
BIN="$prefix/bin/hermit"
@@ -110,12 +120,14 @@ start) systemctl --user start cst-agent-parliament.service ;;
stop) systemctl --user stop cst-agent-parliament.service; "\$BIN" --service-stop || true ;;
restart) systemctl --user restart cst-agent-parliament.service ;;
*)
echo "usage: cst-agent-service {status|install-unit|start|stop|restart}" >&2
echo "usage: hermit-service {status|install-unit|start|stop|restart}" >&2
exit 2
;;
esac
EOF
chmod 0755 "$prefix/bin/cst-agent-service"
chmod 0755 "$prefix/bin/hermit-service"
ln -sfr "$prefix/bin/hermit-service" "$prefix/bin/cst-agent-service" 2>/dev/null || \
ln -sf hermit-service "$prefix/bin/cst-agent-service"
}
# Fast path: fetch static release tarball for this machine.
@@ -129,7 +141,7 @@ install_from_release() {
echo "no prebuilt release for $(uname -m); use --source" >&2
return 1
}
local ver="${CST_AGENT_VERSION:-}"
local ver="${HERMIT_VERSION:-${CST_AGENT_VERSION:-}}"
if [[ -z "$ver" ]]; then
ver="$(cst_version)"
fi
@@ -161,8 +173,8 @@ install_from_release() {
}
main() {
local repo_url="${CST_AGENT_REPO:-${HERMIT_REPO:-https://git.whcself.xyz/WHC/Hermit.git}}"
local prefix="${CST_AGENT_PREFIX:-$HOME/.local}"
local repo_url="${HERMIT_REPO:-${CST_AGENT_REPO:-https://git.whcself.xyz/WHC/Hermit.git}}"
local prefix="${HERMIT_PREFIX:-${CST_AGENT_PREFIX:-$HOME/.local}}"
local dir="" pull=1 changed=0 mode="${CST_INSTALL_MODE:-source}" arg
for arg in "$@"; do
case "$arg" in
@@ -178,12 +190,16 @@ main() {
esac
done
if [[ -z "$dir" ]]; then
if [[ -n "${CST_AGENT_DIR:-}" ]]; then
if [[ -n "${HERMIT_DIR:-}" ]]; then
dir="$HERMIT_DIR"
elif [[ -n "${CST_AGENT_DIR:-}" ]]; then
dir="$CST_AGENT_DIR"
elif [[ -f Makefile && -f src/main.c && -d .git ]]; then
dir="$(pwd)"
elif [[ -n "$ROOT_HINT" && -f "$ROOT_HINT/Makefile" ]]; then
dir="$ROOT_HINT"
elif [[ -d "$HOME/Hermit/.git" ]]; then
dir="$HOME/Hermit"
else
dir="$HOME/CST-agent"
fi
@@ -222,7 +238,7 @@ main() {
*":$prefix/bin:"*) ;;
*) echo "Add to PATH: export PATH=\"$prefix/bin:\$PATH\"" ;;
esac
echo "Upgrade: cst-agent-update --release Rebuild from source: --source"
echo "Upgrade: hermit-update --release Rebuild from source: hermit-update --source"
return 0
fi
echo "==> continuing with source build"
@@ -257,9 +273,9 @@ main() {
*":$prefix/bin:"*) ;;
*) echo "Add to PATH: export PATH=\"$prefix/bin:\$PATH\"" ;;
esac
echo "Run 'hermit' (or 'cst-agent') in a project; upgrade with 'cst-agent-update'."
echo "Fast upgrade from Release: 'cst-agent-update --release'."
echo "Parliament helper: 'cst-agent-service status|install-unit'."
echo "Run 'hermit' in a project; upgrade with 'hermit-update' (compat: cst-agent-update)."
echo "Fast upgrade from Release: 'hermit-update --release'."
echo "Parliament helper: 'hermit-service status|install-unit'."
echo "The first start asks for the provider and its API key and saves them."
}
+6 -4
View File
@@ -75,15 +75,17 @@ main() {
echo "==> install to $PREFIX/bin"
make install
cat >"$PREFIX/bin/cst-agent-update" <<EOF
cat >"$PREFIX/bin/hermit-update" <<EOF
#!$PREFIX/bin/bash
exec bash "$dir/scripts/bootstrap_termux.sh" "$dir" "\$@"
EOF
chmod 0755 "$PREFIX/bin/cst-agent-update"
chmod 0755 "$PREFIX/bin/hermit-update"
ln -sfr "$PREFIX/bin/hermit-update" "$PREFIX/bin/cst-agent-update" 2>/dev/null || \
ln -sf hermit-update "$PREFIX/bin/cst-agent-update"
echo
echo "OK: $("$PREFIX/bin/cst-agent" --version)"
echo "Run 'cst-agent' inside a project directory; upgrade later with 'cst-agent-update'."
echo "OK: $("$PREFIX/bin/hermit" --version 2>/dev/null || "$PREFIX/bin/cst-agent" --version)"
echo "Run 'hermit' inside a project directory; upgrade later with 'hermit-update'."
echo "The first start asks for the provider and its API key and saves them."
}