#!/usr/bin/make -f

%:
	dh $@

# Better Deepin: instead of the Debian system-crate stack (dh-cargo and
# the librust-*-dev build-dependencies), the Rust dependencies are
# downloaded at build time against crates.io while strictly honoring the
# upstream Cargo.lock. debian/rules fetches first (cargo fetch --locked
# into CARGO_HOME) and then compiles and tests strictly --offline, so
# dependencies never affect version resolution. Nothing is vendored in
# the repository; point CARGO_HOME at a persistent directory (make
# CARGO_HOME=/path/to/cargo-home) to reuse downloads between builds.
CARGO_HOME ?= $(CURDIR)/debian/cargo-home
export CARGO_HOME

override_dh_auto_configure:
	cargo fetch --locked

override_dh_auto_build:
	cargo build --release --locked --offline

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cargo test --release --locked --offline
endif

override_dh_auto_install:
	mkdir -p debian/aardvark-dns/usr/lib/podman
	install -m755 target/release/aardvark-dns debian/aardvark-dns/usr/lib/podman/

override_dh_auto_clean:
	cargo clean
	rm -rf debian/cargo-home .cargo vendor
