Files
Hermit/scripts/package_linux.sh
T
WHCandCursor f30b4ede48
ci / tcc-check (push) Failing after 41s
ci / linux (aarch64, 0) (push) Skipped
ci / linux (x86, 1) (push) Skipped
ci / linux (x86_64, 1) (push) Skipped
ci / windows (push) Skipped
feat: rebrand as Hermit — TUI palette, dual glyphs, binary 0.10.0
Ship hermit binary (cst-agent symlink), ~/.config/hermit with legacy fallback,
Hermit color theme and mini crab frames, plus SVG→PUA font build pipeline.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-29 21:42:45 +08:00

68 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Static musl build of cst-agent for one architecture, packed as
# dist/cst-agent-VERSION-linux-ARCH.tar.gz (+ .sha256).
# scripts/package_linux.sh x86_64|x86|aarch64
# CST_LINUX_CHECK=1 also runs `make check` (only where the binaries can run).
# CST_FORCE_REBUILD=1 forces a clean tree; otherwise same compiler+version
# reuses object files (much faster CI/local repacks).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# shellcheck source=lib_release.sh
. "$ROOT/scripts/lib_release.sh"
ARCH="${1:?usage: $0 x86_64|x86|aarch64}"
PREFIX="$ROOT/third_party/prefix-linux-$ARCH"
cd "$ROOT"
read -r LINUX_HOST bindir < <(bash scripts/ci_linux_toolchain.sh "$ARCH")
export PATH="$bindir:$PATH" LINUX_HOST
T="$LINUX_HOST-"
if [[ ! -f "$PREFIX/lib/libcurl.a" || ! -f "$PREFIX/lib/libncursesw.a" ]]; then
bash scripts/build_third_party_linux.sh "$ARCH"
fi
# Only the static prefix: no host .pc file may leak into the link.
export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig"
unset PKG_CONFIG_PATH CC CFLAGS LDFLAGS
mk=(make CC="${T}gcc" AR="${T}ar" STATIC=1
CFLAGS="-std=c11 -Wall -Wextra -O2 -g -Werror")
stamp=".gen/release-linux-$ARCH.stamp"
want="$(cst_build_stamp "${T}gcc")"
if [[ "${CST_FORCE_REBUILD:-0}" == 1 || ! -f hermit || ! -f "$stamp" ||
"$(cat "$stamp" 2>/dev/null || true)" != "$want" ]]; then
echo "==> clean rebuild ($ARCH)"
make clean >/dev/null
make -C vendor/sashidown clean >/dev/null 2>&1 || true
else
echo "==> incremental rebuild ($ARCH, stamp match)"
fi
"${mk[@]}" -j"$(nproc)" hermit
mkdir -p .gen
printf '%s\n' "$want" >"$stamp"
if "${T}readelf" -l hermit | grep -q 'Requesting program interpreter'; then
echo "hermit is dynamically linked" >&2
exit 1
fi
if [[ "${CST_LINUX_CHECK:-0}" == 1 ]]; then
"${mk[@]}" check
fi
ver="$(cst_version)"
name="hermit-$ver-linux-$ARCH"
rel="dist/$name"
rm -rf "$rel"
mkdir -p "$rel"
cp -f hermit "$rel/hermit"
ln -sfr "$rel/hermit" "$rel/cst-agent" 2>/dev/null || ln -sf hermit "$rel/cst-agent"
"${T}strip" "$rel/hermit"
cp -f README.md "$rel/README.md"
echo "$ver" >"$rel/VERSION"
tgz="$(cst_pack_tgz dist "$name")"
# Compat alias package name for one release cycle
cp -f "$tgz" "dist/cst-agent-$ver-linux-$ARCH.tar.gz"
cst_sha256_write "dist/cst-agent-$ver-linux-$ARCH.tar.gz"
ls -la "$rel"
echo "$ROOT/$tgz"