diff --git a/.agents/resume b/.agents/resume new file mode 100755 index 00000000..2be444b3 --- /dev/null +++ b/.agents/resume @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Fast orb resume: ensure Rust is on PATH. Do not install packages here. +set -euo pipefail + +if [[ -f "${HOME}/.cargo/env" ]]; then + # shellcheck disable=SC1091 + source "${HOME}/.cargo/env" +fi + +if ! command -v rustc >/dev/null 2>&1 || ! command -v cargo >/dev/null 2>&1; then + echo "[resume] rustc/cargo missing; run .agents/setup" >&2 + exit 1 +fi diff --git a/.agents/setup b/.agents/setup new file mode 100755 index 00000000..6f5f4449 --- /dev/null +++ b/.agents/setup @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Idempotent orb setup for inauguration: Rust toolchain + in-cli lockfile fetch. +set -euo pipefail + +step() { + local label="$1" + shift + echo "[setup] ${label}" + local start + start="$(date +%s)" + "$@" + echo "[setup] ${label} ($(( $(date +%s) - start ))s)" +} + +need_pkg() { + dpkg -s "$1" >/dev/null 2>&1 +} + +missing=() +for pkg in build-essential pkg-config curl ca-certificates; do + need_pkg "$pkg" || missing+=("$pkg") +done +if ((${#missing[@]})); then + step "apt-get update" sudo apt-get update -qq + step "apt-get install" sudo apt-get install -y -qq "${missing[@]}" +fi + +export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}" +export RUSTUP_HOME="${RUSTUP_HOME:-$HOME/.rustup}" +export PATH="${CARGO_HOME}/bin:${PATH}" + +if ! command -v rustup >/dev/null 2>&1; then + step "install rustup" bash -c 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default --component rustfmt,clippy,rust-src' +fi + +# shellcheck disable=SC1091 +source "${CARGO_HOME}/env" + +step "rustup default stable" rustup default stable +step "rustup components" rustup component add rustfmt clippy rust-src + +profile_marker="# inauguration rustup" +if ! grep -Fqx "$profile_marker" "$HOME/.bash_profile" 2>/dev/null; then + cat >> "$HOME/.bash_profile" <