72 lines
3.6 KiB
Bash
Executable File
72 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
source "$(dirname -- "${BASH_SOURCE[0]}")/lib.sh"
|
|
[[ $# == 0 ]] || die 'Usage: tools/build-dasungd'
|
|
cd "$FDS_ROOT"
|
|
fds_version=$(tools/version)
|
|
use_xbps
|
|
check_void_pin
|
|
mkdir -p out/logs out/manifests out/packages
|
|
# These are build-container tools; no Arch packages or host services are changed.
|
|
missing=()
|
|
for package in cross-aarch64-linux-musl pkg-config s6-rc python3 git; do
|
|
if ! XBPS_ARCH=x86_64 xbps-query -r "$FDS_VOID/masterdir-x86_64" "$package" >/dev/null 2>&1; then
|
|
missing+=("$package")
|
|
fi
|
|
done
|
|
if (( ${#missing[@]} )); then
|
|
tools/in-void xbps-install -y "${missing[@]}"
|
|
fi
|
|
# Fetch pinned crates once, then keep the actual build offline.
|
|
fetch_rust_inputs
|
|
# libusb's vendored backend must not discover host libudev or shared libusb.
|
|
tools/in-void env LIBUSB_NO_PKG_CONFIG=1 LIBUDEV_NO_PKG_CONFIG=1 \
|
|
CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc \
|
|
AR_aarch64_unknown_linux_musl=aarch64-linux-musl-ar \
|
|
"$FDS_ROOT/tools/cargo-build" --locked --offline --release --target aarch64-unknown-linux-musl \
|
|
-p dasungd --features vendored
|
|
binary=target/aarch64-unknown-linux-musl/release/dasungd
|
|
tools/verify-elf "$binary" aarch64 static
|
|
cp -- "$binary" out/dasungd
|
|
input="$FDS_VOID/hostdir/sources/fds-dasungd-${fds_version}"
|
|
mkdir -p "$input"
|
|
cp -- "$binary" "$input/dasungd"
|
|
cp rust/dasungd/LICENSE rust/dasungd/profiles/paperlike13k-37hz.edid "$input/"
|
|
cp fds-os.wiki/Dasung.md "$input/dasung.md"
|
|
# Cargo's vendored libusb license accompanies the static binary.
|
|
fds_cargo_home=${CARGO_HOME:-$HOME/.cargo}
|
|
license=$(find "$fds_cargo_home/registry/src" -path '*/libusb1-sys-0.7.0/libusb/COPYING' -print -quit)
|
|
[[ -f $license ]] || die 'Pinned libusb license missing from Cargo source cache'
|
|
cp "$license" "$input/libusb-COPYING"
|
|
# Replace only our generated service payload, preserving older builds as archives.
|
|
if [[ -d $input/s6-source ]]; then
|
|
previous=$(mktemp -d "$FDS_ROOT/out/dasung-services.XXXXXX")
|
|
mv "$input/s6-source" "$previous/"
|
|
fi
|
|
mkdir -p "$input/s6-source/boot/contents.d"
|
|
cp -a s6/source/{dasungd,dasungd-log,dasungd-runtime} "$input/s6-source/"
|
|
cp s6/source/boot/type "$input/s6-source/boot/"
|
|
cp s6/source/boot/contents.d/dasungd "$input/s6-source/boot/contents.d/"
|
|
# The init package supplies this cross-package dependency. The standalone
|
|
# display graph remains runnable in the existing private-container test.
|
|
rm -f "$input/s6-source/dasungd-runtime/dependencies.d/runtime-fs"
|
|
(
|
|
cd "$input"
|
|
find . -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum >SHA256SUMS
|
|
)
|
|
# Compile the actual service source now, never during target boot.
|
|
compiled_parent=$(mktemp -d "$FDS_ROOT/out/dasung-s6.XXXXXX")
|
|
tools/in-void s6-rc-compile "$compiled_parent/compiled" "$input/s6-source"
|
|
printf '%s\n' "$compiled_parent/compiled" >out/manifests/dasung-s6-database.txt
|
|
# xbps-src otherwise reuses a same-version package after local source changes.
|
|
tools/prepare-void
|
|
(
|
|
cd "$FDS_VOID"
|
|
xbps_src -f -a aarch64 pkg fds-dasungd
|
|
) 2>&1 | tee out/logs/xbps-fds-dasungd.log
|
|
package="fds-dasungd-${fds_version}_1.aarch64.xbps"
|
|
tools/export-package "$FDS_VOID/hostdir/binpkgs/$package"
|
|
sha256sum out/dasungd "out/packages/$package" >out/manifests/dasung-artifacts.sha256
|
|
XBPS_ARCH=x86_64 xbps-query -r "$FDS_VOID/masterdir-x86_64" -l >out/manifests/dasung-build-packages.txt
|
|
sha256sum tools/version tools/fds_version.py tools/version-build.rs Cargo.toml Cargo.lock rust-toolchain.toml .cargo/config.toml tools/cargo-build tools/lib.sh tools/build-dasungd >out/manifests/dasung-rust-inputs.sha256
|
|
printf 'PASS: Dasung static ARM executable, base package, and s6 database built\n'
|