diff options
| author | Igor Soarez <igor@soarez.org> | 2026-10-05 12:02:45 +0300 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-05 12:02:45 +0300 |
| commit | 10fb1ab5ac9091e59957e97c3e75ea6bc288b8c5 (patch) | |
| tree | 7adca7723f6f5e6d76540df9e9d0a1af3674803e /tmuxrdr/scripts/build | |
| parent | 2312d3978b7d123968e834c0e0080ad2ff5559df (diff) | |
tmuxrdr: build and run as its own binary beside stock herdr
scripts/build builds the checkout with the pinned toolchains -- Homebrew's
keg-only rustup, Zig 0.16.0 from ~/.local/opt, crates through sfw, Zig's
hash-pinned packages prefetched by Zig since sfw's proxy breaks them -- and
installs it as ~/.local/bin/tmuxrdr. install now sets up tmuxrdr only, in
~/.config/tmuxrdr, and refuses a binary that reads its config elsewhere.
test-e2e tests tmuxrdr and starts with a config check. The config turns off
herdr's update check, whose update would install stock herdr over the fork.
Diffstat (limited to 'tmuxrdr/scripts/build')
| -rwxr-xr-x | tmuxrdr/scripts/build | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tmuxrdr/scripts/build b/tmuxrdr/scripts/build new file mode 100755 index 00000000..2305ef73 --- /dev/null +++ b/tmuxrdr/scripts/build @@ -0,0 +1,52 @@ +#!/bin/bash + +# Build tmuxrdr from this checkout and install it as ~/.local/bin/tmuxrdr +# (or $TMUXRDR_BIN). cargo's output is herdr's binary, target/release/herdr; +# the name it is installed under is all the renaming there is -- it starts its +# server from its own path, and src/config/io.rs gives it its own directories. +# +# Toolchains, found without PATH or shell-profile changes: +# Rust the version rust-toolchain.toml pins, through rustup; Homebrew's +# keg-only rustup (/opt/homebrew/opt/rustup/bin) is used when no +# cargo is on PATH +# Zig exactly 0.16.0, which herdr's vendored libghostty-vt requires: +# $ZIG, else ~/.local/opt/zig-0.16.0/zig +# sfw Socket Firewall, which every crate fetch goes through (Zig's +# packages are fetched first, by Zig, hash-checked) +# +# The binary is replaced by a rename, so a running tmuxrdr server keeps the +# old one until it is restarted. + +set -euo pipefail + +repo="$(cd "$(dirname "$0")/../.." && pwd -P)" +dest="${TMUXRDR_BIN:-$HOME/.local/bin/tmuxrdr}" + +die() { >&2 echo "ERROR: $*"; exit 1; } + +if ! command -v cargo >/dev/null && [[ -x /opt/homebrew/opt/rustup/bin/cargo ]]; then + PATH="/opt/homebrew/opt/rustup/bin:$PATH" +fi +command -v cargo >/dev/null || die "no cargo: brew install rustup" +command -v sfw >/dev/null || die "no sfw: crates are fetched through Socket Firewall" + +export ZIG="${ZIG:-$HOME/.local/opt/zig-0.16.0/zig}" +[[ -x "$ZIG" ]] || die "no Zig at $ZIG (needs exactly 0.16.0: ziglang.org/download, signature-checked)" +[[ "$("$ZIG" version)" == "0.16.0" ]] || die "$ZIG is Zig $("$ZIG" version), not 0.16.0" + +cd "$repo" +# Zig's packages are fetched by Zig itself, each checked against the hash +# build.zig.zon pins -- not through sfw, whose proxy breaks Zig's downloads +# (400 Bad Request). With them cached, the build itself needs only crates. +(cd vendor/libghostty-vt && "$ZIG" build --fetch=all) +sfw cargo build --release --locked + +mkdir -p "$(dirname "$dest")" +cp target/release/herdr "$dest.new" +mv -f "$dest.new" "$dest" +echo "installed: $dest ($("$dest" --version))" + +if "$dest" status server 2>/dev/null | grep -q 'status: running'; then + echo "A tmuxrdr server is running the previous build; it switches on its next" + echo "start (tmuxrdr server stop ends it, and its panes)." +fi |
