#!/usr/bin/env bash # Audit the cross-built release artifacts in a dist directory. # # Usage: tools/audit_artifacts.sh [dist-dir] # # There is no Linux or Windows machine in the release loop, so the # non-macOS artifacts are never executed; this automates the audit # tools/RELEASING.md documented as manual, and the release fails if any # check does: # *-linux-musl ELF x86-64, statically linked (zero NEEDED entries) # *-linux-gnu ELF x86-64, glibc symbol ceiling <= 2.28 (RHEL 8) # *-windows-gnu.exe PE32+ x86-64 # *-apple-darwin Mach-O 64-bit (arm64 / x86_64 per triple) # # Needs the messense x86_64-unknown-linux-gnu toolchain's objdump for the # ELF checks (the same toolchain the linux-gnu build itself needs). set -eu dist=${1:-dist} objdump=x86_64-unknown-linux-gnu-objdump glibc_max=2.28 command -v "$objdump" >/dev/null || { echo "no $objdump on PATH" >&2; exit 2; } [ -d "$dist" ] || { echo "no dist directory at $dist" >&2; exit 2; } status=0 fail() { echo "FAIL: $*" >&2; status=1; } checked=0 for f in "$dist"/lucisv-*; do [ -f "$f" ] || continue name=$(basename "$f") case $name in *.vsix | SHA256SUMS | RELEASE_NOTES.md) continue ;; esac kind=$(file -b "$f") case $name in *x86_64-unknown-linux-musl) case $kind in *ELF*x86-64*) ;; *) fail "$name: not an x86-64 ELF: $kind" ;; esac if "$objdump" -p "$f" | grep -q NEEDED; then fail "$name: musl build has dynamic dependencies (must be static)" fi ;; *x86_64-unknown-linux-gnu) case $kind in *ELF*x86-64*) ;; *) fail "$name: not an x86-64 ELF: $kind" ;; esac top=$("$objdump" -T "$f" | grep -o 'GLIBC_[0-9.]*' | sort -Vu | tail -1) top=${top#GLIBC_} highest=$(printf '%s\n%s\n' "$top" "$glibc_max" | sort -V | tail -1) if [ "$highest" != "$glibc_max" ]; then fail "$name: glibc ceiling $top exceeds $glibc_max (breaks RHEL 8)" fi ;; *x86_64-pc-windows-gnu.exe) case $kind in *PE32+*x86-64*) ;; *) fail "$name: not a PE32+ x86-64 executable: $kind" ;; esac ;; *aarch64-apple-darwin) case $kind in *Mach-O*arm64*) ;; *) fail "$name: not a Mach-O arm64 binary: $kind" ;; esac ;; *x86_64-apple-darwin) case $kind in *Mach-O*x86_64*) ;; *) fail "$name: not a Mach-O x86_64 binary: $kind" ;; esac ;; *) fail "$name: unrecognized artifact name — teach this script about it" ;; esac checked=$((checked + 1)) echo "ok: $name" done [ "$checked" -gt 0 ] || { echo "no binaries found under $dist" >&2; exit 2; } echo "audited $checked binaries" exit $status