Files
Xen-Orchestra-xen-orchestra…/@xen-orchestra/vmware-explorer/vectura/scripts/build.sh
Mathieu 025f6eb533 feat(vectura): bump and build in the pull request, not at release (#10573)
The binary in git is now the build of its sources. build.sh keeps the paths
of the machine out of the binary and refuses another zig or cargo-zigbuild
version, and the Vectura workflow fails when its build differs from the
committed binary. The binary is rebuilt with this build.sh: only its paths
change, the version stays 0.1.2.

vectura is no longer released on its own. release.sh runs once at the end of
the pull request which changes vectura and no longer commits. bump-pkg,
gen-deps-list.js and check-changed-pkgs.js drop the vectura pseudo-package: a
change under vectura/ requires a release of @xen-orchestra/vmware-explorer,
which ships the committed binary as is. release.sh puts Cargo.toml and
Cargo.lock back when the build or the check of the binary fails.
2026-10-15 10:43:00 +02:00

45 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# Builds the vectura binary into the directory given as the only argument.
#
# zig links the binary against glibc 2.31 whatever the glibc of the build
# machine, so it runs on Debian 11 and Ubuntu 20.04 wherever it is built:
# XOA appliances still run Debian 11.
# Needs zig and cargo-zigbuild, see the README. The Vectura workflow and
# release.sh run it.
#
# The build is reproducible: with the zig and cargo-zigbuild below and the
# toolchain of rust-toolchain.toml, any machine builds the binary in git byte
# for byte, which the Vectura workflow checks.
set -eu
out=$(mkdir -p "$1" && cd "$1" && pwd)
cd "$(dirname "$0")/.."
# the versions the Vectura workflow installs: another one may build another
# binary
zig=0.16.0
zigbuild=0.23.4
if [ "$(zig version)" != "$zig" ]; then
echo "needs zig $zig, found $(zig version)" >&2
exit 1
fi
if [ "$(cargo-zigbuild --version)" != "cargo-zigbuild $zigbuild" ]; then
echo "needs cargo-zigbuild $zigbuild, found $(cargo-zigbuild --version)" >&2
exit 1
fi
# rustc writes the paths of the sources in the panic messages. Those of the
# dependencies lie in CARGO_HOME, those of std in the sysroot when the rust-src
# component is installed, /rustc/<commit> otherwise: both become what a
# machine without rust-src writes. RUSTFLAGS from the environment would change
# the binary, they are replaced.
sysroot=$(rustc --print sysroot)
commit=$(rustc -vV | sed -n 's/^commit-hash: //p')
RUSTFLAGS="--remap-path-prefix=${CARGO_HOME:-$HOME/.cargo}=/cargo --remap-path-prefix=$sysroot/lib/rustlib/src/rust=/rustc/$commit"
export RUSTFLAGS
unset CARGO_ENCODED_RUSTFLAGS
cargo zigbuild --locked --release --target x86_64-unknown-linux-gnu.2.31
# the glibc suffix is for zig only: the binary lands under the plain triple
install -m 755 target/x86_64-unknown-linux-gnu/release/vectura "$out"