Proof of concept mechanical port of ircnet/ircd to Rust as part of a bit about C being insecure for network services
0

Configure Feed

Select the types of activity you want to include in your feed.

ircd.rs / scripts / generate-release-assets.sh
3.0 kB 85 lines
1#!/usr/bin/env bash 2# 3# generate-release-assets.sh — build leveva for x86_64 + aarch64 and emit 4# .deb and .rpm packages for each architecture. 5# 6# Cross-compilation is handled by cargo-zigbuild (zig as the linker/sysroot), 7# so no per-arch C toolchain is required. Both targets are static musl builds. 8# Packaging is pure-Rust: cargo-deb and cargo-generate-rpm read the 9# [package.metadata.deb] / [package.metadata.generate-rpm] tables in 10# leveva/Cargo.toml. Passing --target to each rewrites the `target/release/` 11# asset prefix to `target/<triple>/release/`, so they pick up the cross binary. 12# 13# Outputs (relative to the workspace root): 14# target/<triple>/debian/leveva_<ver>_<arch>.deb 15# target/<triple>/generate-rpm/leveva-<ver>-1.<arch>.rpm 16# and a copy of every artifact collected under dist/release/. 17set -euo pipefail 18 19# Resolve the workspace root (parent of this script's directory) so the script 20# works regardless of the caller's cwd; cargo-deb/-rpm resolve asset paths 21# relative to it. 22SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 23ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" 24cd "${ROOT_DIR}" 25 26TARGETS=( 27 x86_64-unknown-linux-musl 28 aarch64-unknown-linux-musl 29 riscv64gc-unknown-linux-musl 30 powerpc64le-unknown-linux-musl 31 powerpc64-unknown-linux-musl 32) 33 34OUT_DIR="${ROOT_DIR}/var/dist/release" 35 36require() { 37 command -v "$1" >/dev/null 2>&1 || { 38 echo "error: required tool '$1' not found in PATH" >&2 39 echo " install with: $2" >&2 40 exit 1 41 } 42} 43 44require cargo "https://rustup.rs" 45require zig "https://ziglang.org/download/ (or: brew install zig)" 46require cargo-zigbuild "cargo install cargo-zigbuild" 47require cargo-deb "cargo install cargo-deb" 48require cargo-generate-rpm "cargo install cargo-generate-rpm" 49 50# Ensure the rustup std component is present for each target; zigbuild links the 51# objects but rustc still needs the precompiled std for the triple. 52for triple in "${TARGETS[@]}"; do 53 if ! rustup target list --installed 2>/dev/null | grep -qx "${triple}"; then 54 echo ">> adding rust target ${triple}" 55 rustup target add "${triple}" 56 fi 57done 58 59mkdir -p "${OUT_DIR}" 60 61for triple in "${TARGETS[@]}"; do 62 echo 63 echo "==> ${triple}" 64 65 echo ">> cargo zigbuild --release" 66 cargo zigbuild --quiet --release --target "${triple}" -p leveva 67 68 # --no-build: reuse the zigbuild artifact above (cargo-deb would otherwise 69 # invoke a plain `cargo build` that lacks the zig cross linker). 70 # --no-strip: the host `strip` can't process a foreign-arch binary; the 71 # musl release binary is already lean enough to ship unstripped. 72 echo ">> cargo deb" 73 cargo deb -p leveva --target "${triple}" --no-build --no-strip 74 75 echo ">> cargo generate-rpm" 76 cargo generate-rpm -p leveva --target "${triple}" 77 78 # Collect the artifacts into one place for convenience. 79 cp -v "target/${triple}/debian/"*.deb "${OUT_DIR}/" 80 cp -v "target/${triple}/generate-rpm/"*.rpm "${OUT_DIR}/" 81done 82 83echo 84echo "==> release assets collected in ${OUT_DIR}:" 85ls -1 "${OUT_DIR}"