c29f5819c5
/ crosscheck (push) Successful in 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
58 lines
2.7 KiB
Bash
Executable File
58 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build one svc-core binary natively on the development Orin, check it against the
|
|
# car's glibc, and install it on the car Orin as the yukart-<bin> service.
|
|
#
|
|
# usage: scripts/deploy-native.sh BIN [host] (host default: mikkeli-orin-nano)
|
|
# env: BUILD_HOST (default: mikkeli-orin-nano-2)
|
|
#
|
|
# Builds what is pushed, not the working tree: the build host pulls master of
|
|
# svc-core and contracts under ~/dev/yukart/. Signal names, units and layouts are
|
|
# compiled in from contracts' signals.json, so a registry change needs a redeploy.
|
|
# Native because std::process::Command cross-compiled against the workstation's
|
|
# newer glibc links GLIBC_2.39 symbols the car cannot load (check-glibc.sh gates it).
|
|
#
|
|
# A service that reads /etc/default/yukart-elm (the ELM327's address) gets the
|
|
# repo's copy installed when the host has none; an existing one is left alone.
|
|
set -euo pipefail
|
|
|
|
BIN="${1:?usage: scripts/deploy-native.sh BIN [host]}"
|
|
HOST="${2:-mikkeli-orin-nano}"
|
|
BUILD_HOST="${BUILD_HOST:-mikkeli-orin-nano-2}"
|
|
cd "$(dirname "$0")/.."
|
|
UNIT="deploy/yukart-$BIN.service"
|
|
[ -f "$UNIT" ] || { echo "no $UNIT" >&2; exit 2; }
|
|
OUT="$(mktemp -d)/$BIN"
|
|
|
|
ssh "$BUILD_HOST" "set -e
|
|
mkdir -p ~/dev/yukart && cd ~/dev/yukart
|
|
for r in svc-core contracts; do
|
|
# Gitea by its tailnet name, so a deploy works away from the home LAN too.
|
|
[ -d \$r ] || git clone -q http://pi5-16:3005/yukart/\$r.git
|
|
git -C \$r remote set-url origin http://pi5-16:3005/yukart/\$r.git
|
|
git -C \$r pull -q --ff-only
|
|
done
|
|
cd svc-core && ~/.cargo/bin/cargo build --release --bin $BIN 2>&1 | tail -1
|
|
git log --oneline -1"
|
|
scp -q "$BUILD_HOST:dev/yukart/svc-core/target/release/$BIN" "$OUT"
|
|
scripts/check-glibc.sh "$OUT"
|
|
|
|
# Binary lives under ~/infra per the host repo's guidelines; /usr/local/bin gets a symlink.
|
|
ssh "$HOST" 'mkdir -p ~/infra/svc-core'
|
|
scp -q "$OUT" "$HOST:infra/svc-core/$BIN.new"
|
|
scp -q "$UNIT" "$HOST:infra/svc-core/yukart-$BIN.service"
|
|
if grep -q /etc/default/yukart-elm "$UNIT"; then
|
|
scp -q deploy/yukart-elm.default "$HOST:infra/svc-core/yukart-elm.default"
|
|
fi
|
|
ssh "$HOST" "set -e
|
|
mv ~/infra/svc-core/$BIN.new ~/infra/svc-core/$BIN
|
|
sudo ln -sfn \"\$HOME/infra/svc-core/$BIN\" /usr/local/bin/yukart-$BIN
|
|
sudo install -m 0644 ~/infra/svc-core/yukart-$BIN.service /etc/systemd/system/yukart-$BIN.service
|
|
if [ -f ~/infra/svc-core/yukart-elm.default ] && [ ! -f /etc/default/yukart-elm ]; then
|
|
sudo install -m 0644 ~/infra/svc-core/yukart-elm.default /etc/default/yukart-elm
|
|
fi
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable yukart-$BIN.service >/dev/null
|
|
sudo systemctl restart yukart-$BIN.service
|
|
sleep 1
|
|
systemctl --no-pager --lines=5 status yukart-$BIN.service"
|