Files
lucisv/tools/audit_artifacts.sh
T
lucioandClaude Fable 5 a399f81ad9
ci / checks (push) Successful in 41s
ci / corpus (push) Successful in 19s
Platform-specific VSIXs: five packages with the binaries inside
release.sh --cross now cuts a .vsix per platform — darwin-arm64,
darwin-x64, linux-x64, linux-arm64 (new aarch64-musl cross target),
win32-x64 — each carrying lucisv and lucisv-server under bin/, staged
transiently with an EXIT trap and content-asserted with unzip. The
extension resolves a user-set lucisv.serverPath, then the bundled
server (chmod'ed on activation; VSIX extraction drops the exec bit),
then PATH; the universal no-binary .vsix stays as the fallback. The
host package's embedded server is smoke-tested out of the zip on every
release. docs/features/editor-platform-vsix has the full round.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-27 00:55:53 -07:00

113 lines
3.7 KiB
Bash
Executable File

#!/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 / aarch64), statically linked
# *-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)
#
# The .vsix packages (platform-specific ones included) are skipped here:
# tools/release.sh asserts their contents as it builds them
# (docs/features/editor-platform-vsix).
#
# 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
;;
*aarch64-unknown-linux-musl)
# Two independent opinions, because the objdump here is a binutils
# configured for x86-64: it does parse aarch64 ELFs (verified on this
# machine -- "file format elf64-little", program headers and all), but
# the dynamic-section read is the one thing that would fail quietly if a
# future binutils stopped doing so. `file` reporting "statically linked"
# is the honest cross-check, and it also names the architecture, which
# objdump's generic elf64-little does not.
case $kind in
*ELF*aarch64*) ;;
*) fail "$name: not an aarch64 ELF: $kind" ;;
esac
case $kind in
*"statically linked"*) ;;
*) fail "$name: musl build is not statically linked: $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