mirror of
https://codeberg.org/Toasterson/solstice-ci.git
synced 2026-04-10 13:20:41 +00:00
This commit updates the Solstice job script to install the Rust toolchain (`developer/rustc`) via the IPS package manager on Solaris-based systems (SunOS). It also adjusts the `ensure_rust` function to prioritize system package installation before falling back to `rustup`.
94 lines
3.4 KiB
Bash
Executable file
94 lines
3.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
# Solstice CI VM job script: build this repository inside the guest.
|
|
# The runner clones the repo at the requested commit and executes this script.
|
|
# It attempts to ensure required tools (git, curl, protobuf compiler, Rust) exist.
|
|
|
|
log() { printf "[job] %s\n" "$*" >&2; }
|
|
|
|
detect_pm() {
|
|
if command -v apt-get >/dev/null 2>&1; then echo apt; return; fi
|
|
if command -v dnf >/dev/null 2>&1; then echo dnf; return; fi
|
|
if command -v yum >/dev/null 2>&1; then echo yum; return; fi
|
|
if command -v zypper >/dev/null 2>&1; then echo zypper; return; fi
|
|
if command -v apk >/dev/null 2>&1; then echo apk; return; fi
|
|
if command -v pacman >/dev/null 2>&1; then echo pacman; return; fi
|
|
if command -v pkg >/dev/null 2>&1; then echo pkg; return; fi
|
|
if command -v pkgin >/dev/null 2>&1; then echo pkgin; return; fi
|
|
echo none
|
|
}
|
|
|
|
install_linux() {
|
|
PM=$(detect_pm)
|
|
case "$PM" in
|
|
apt)
|
|
sudo -n true 2>/dev/null || true
|
|
sudo apt-get update -y || apt-get update -y || true
|
|
sudo apt-get install -y --no-install-recommends curl ca-certificates git build-essential pkg-config libssl-dev protobuf-compiler || true
|
|
;;
|
|
dnf)
|
|
sudo dnf install -y curl ca-certificates git gcc gcc-c++ make pkgconf-pkg-config openssl-devel protobuf-compiler || true
|
|
;;
|
|
yum)
|
|
sudo yum install -y curl ca-certificates git gcc gcc-c++ make pkgconfig openssl-devel protobuf-compiler || true
|
|
;;
|
|
zypper)
|
|
sudo zypper --non-interactive install curl ca-certificates git gcc gcc-c++ make pkg-config libopenssl-devel protobuf || true
|
|
;;
|
|
apk)
|
|
sudo apk add --no-cache curl ca-certificates git build-base pkgconfig openssl-dev protoc || true
|
|
;;
|
|
pacman)
|
|
sudo pacman -Sy --noconfirm curl ca-certificates git base-devel pkgconf openssl protobuf || true
|
|
;;
|
|
*)
|
|
log "unknown package manager ($PM); skipping linux deps install"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
install_illumos() {
|
|
if command -v pkg >/dev/null 2>&1; then
|
|
# OpenIndiana IPS packages (best-effort)
|
|
sudo pkg refresh || true
|
|
sudo pkg install -v developer/build/gnu-make developer/gcc-13 git developer/protobuf developer/rustc || true
|
|
elif command -v pkgin >/dev/null 2>&1; then
|
|
sudo pkgin -y install git gcc gmake protobuf || true
|
|
else
|
|
log "no known package manager found on illumos"
|
|
fi
|
|
}
|
|
|
|
ensure_rust() {
|
|
if command -v cargo >/dev/null 2>&1; then return 0; fi
|
|
OS=$(uname -s 2>/dev/null || echo unknown)
|
|
if [ "$OS" = "SunOS" ] && command -v pkg >/dev/null 2>&1; then
|
|
log "installing Rust toolchain via IPS package manager (developer/rustc)"
|
|
sudo pkg refresh || true
|
|
sudo pkg install -v developer/rustc || true
|
|
if command -v cargo >/dev/null 2>&1; then return 0; fi
|
|
fi
|
|
log "installing Rust toolchain with rustup"
|
|
curl -fsSL https://sh.rustup.rs | sh -s -- -y
|
|
# shellcheck disable=SC1091
|
|
source "$HOME/.cargo/env"
|
|
}
|
|
|
|
main() {
|
|
OS=$(uname -s 2>/dev/null || echo unknown)
|
|
case "$OS" in
|
|
Linux) install_linux ;;
|
|
SunOS) install_illumos ;;
|
|
esac
|
|
ensure_rust
|
|
# Ensure protoc available in PATH
|
|
if ! command -v protoc >/dev/null 2>&1; then
|
|
log "WARNING: protoc not found; prost/tonic build may fail"
|
|
fi
|
|
# Build a representative subset to avoid known sea-orm-cli issues in full workspace builds
|
|
log "building workflow-runner"
|
|
cargo build -p workflow-runner --release || cargo build -p workflow-runner
|
|
log "done"
|
|
}
|
|
|
|
main "$@"
|