Packaging Issues
I've noticed a handful of issues with the build system that makes this a tiny bit difficult to package. We package a lot of Rust applications and libraries on Pop!_OS with great success using simple Makefiles and vendoring, though it seems this project is using a combination of Meson and shell scripts.
Some things to consider for reproducible builds:
- POSIX sh does not support arrays, which makes it difficult to construct the
cargo
command for building vendored dependencies. - The build system should check for the existence of the
vendor
directory, and add--frozen
to the list of arguments.
If you switch your cargo.sh
script to use bash, you could do the following:
set -ex
DEBUG=${DEBUG:-0}
ARGS=()
TARGET=debug
if test "${DEBUG}" -ne 0; then
echo "RELEASE MODE"
ARGS+=('--release')
TARGET=release
fi
if test -d vendor; then
echo "VENDORED"
ARGS+=('--frozen')
fi
cargo build ${ARGS[@]} -p podcasts-gtk
cp $1/target/${TARGET}/podcasts-gtk $2
May be nice to mention how vendoring is performed:
mkdir -p .cargo
cargo vendor | head -n -1 > .cargo/config
echo 'directory = "vendor"' >> .cargo/config
It's also important to tarball the dependencies, as reproducible build systems often strip critical artifacts that cargo-vendor
relies on to validate the vendored sources.
vendor.tar.xz:
mkdir -p .cargo
cargo vendor | head -n -1 > .cargo/config
echo 'directory = "vendor"' >> .cargo/config
tar pcfJ vendor.tar.xz vendor
rm -rf vendor
Then extract just before running the build:
build:
tar pxf vendor.tar.xz
meson -C build
Example debian/rules Makefile:
#!/usr/bin/make -f
%:
dh $@ --buildsystem=meson
override_dh_auto_clean:
dh_auto_clean
if ! ischroot; then \
rm -rf .cargo vendor vendor.tar.xz; \
mkdir -p .cargo; \
cargo vendor | head -n -1 > .cargo/config; \
echo 'directory = "vendor"' >> .cargo/config; \
tar pcfJ vendor.tar.xz vendor; \
rm -rf vendor; \
fi
override_dh_auto_build:
tar pxf vendor.tar.xz
dh_auto_build
Edited by Michael Aaron Murphy