#!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE = 1 # This has to be exported to make some magic below work. export DH_OPTIONS # Build system configuration export CARGO_HOME = $(CURDIR)/debian/cargo export CARGO_TARGET_DIR = $(CURDIR)/debian/cargo/target # Detect architecture for cross-compilation DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) # Rust target for cross-compilation (simplified) RUST_TARGET := $(DEB_HOST_ARCH) # Build flags CARGO_FLAGS := --release override_dh_auto_build: @echo "Building apt-ostree for $(DEB_HOST_ARCH)..." # Ensure cargo is available @which cargo > /dev/null || (echo "Error: cargo not found. Please install Rust toolchain." && exit 1) # Ensure both binaries are built @echo "Building apt-ostree CLI..." cargo build $(CARGO_FLAGS) --bin apt-ostree @echo "Building apt-ostreed daemon..." cargo build $(CARGO_FLAGS) --bin apt-ostreed dh_auto_build override_dh_auto_install: @echo "Installing apt-ostree binary..." # Check if binary exists @if [ ! -f "debian/cargo/target/release/apt-ostree" ]; then \ echo "Error: apt-ostree binary not found. Build failed."; \ exit 1; \ fi # Install the apt-ostree binary to the correct location install -D -m 755 debian/cargo/target/release/apt-ostree \ debian/apt-ostree/usr/bin/apt-ostree # Create additional directories mkdir -p debian/apt-ostree/usr/share/doc/apt-ostree mkdir -p debian/apt-ostree/usr/share/man/man1 mkdir -p debian/apt-ostree/usr/share/bash-completion/completions mkdir -p debian/apt-ostree/usr/share/zsh/vendor-completions mkdir -p debian/apt-ostree/usr/share/apt-ostree @echo "apt-ostree package directories created successfully" # Install man page if it exists @if [ -f "debian/apt-ostree.1" ]; then \ install -D -m 644 debian/apt-ostree.1 debian/apt-ostree/usr/share/man/man1/apt-ostree.1; \ fi # Install bash completion if it exists @if [ -f "debian/apt-ostree.bash-completion" ]; then \ install -D -m 644 debian/apt-ostree.bash-completion \ debian/apt-ostree/usr/share/bash-completion/completions/apt-ostree; \ fi # Install zsh completion if it exists @if [ -f "debian/apt-ostree.zsh-completion" ]; then \ install -D -m 644 debian/apt-ostree.zsh-completion \ debian/apt-ostree/usr/share/zsh/vendor-completions/_apt-ostree; \ fi @echo "Installing apt-ostreed daemon..." # Check if binary exists @if [ ! -f "debian/cargo/target/release/apt-ostreed" ]; then \ echo "Error: apt-ostreed binary not found. Build failed."; \ exit 1; \ fi # Install the apt-ostreed binary install -D -m 755 debian/cargo/target/release/apt-ostreed \ debian/apt-ostreed/usr/libexec/apt-ostreed # Check and install systemd service files @if [ ! -f "daemon/systemd/apt-ostreed.service" ]; then \ echo "Error: apt-ostreed.service not found."; \ exit 1; \ fi @if [ ! -f "daemon/systemd/apt-ostreed.socket" ]; then \ echo "Error: apt-ostreed.socket not found."; \ exit 1; \ fi install -D -m 644 daemon/systemd/apt-ostreed.service \ debian/apt-ostreed/lib/systemd/system/apt-ostreed.service install -D -m 644 daemon/systemd/apt-ostreed.socket \ debian/apt-ostreed/lib/systemd/system/apt-ostreed.socket # Check and install polkit policy @if [ ! -f "daemon/polkit/apt-ostree.policy" ]; then \ echo "Error: apt-ostree.policy not found."; \ exit 1; \ fi install -D -m 644 daemon/polkit/apt-ostree.policy \ debian/apt-ostreed/usr/share/polkit-1/actions/org.projectatomic.aptostree1.policy # Check and install configuration files @if [ ! -f "src/daemon/apt-ostreed.conf" ]; then \ echo "Error: apt-ostreed.conf not found."; \ exit 1; \ fi install -d -m 755 debian/apt-ostreed/etc/apt-ostreed install -D -m 644 src/daemon/apt-ostreed.conf \ debian/apt-ostreed/etc/apt-ostreed/apt-ostreed.conf # Create additional directories mkdir -p debian/apt-ostreed/usr/share/doc/apt-ostreed # Create log directory mkdir -p debian/apt-ostreed/var/log # Create cache directory mkdir -p debian/apt-ostreed/var/cache/apt-ostree # Create state directory mkdir -p debian/apt-ostreed/var/lib/apt-ostree @echo "apt-ostreed package directories created successfully" # Skip dh_auto_install since we've handled installation manually @echo "Package installation completed successfully!" override_dh_auto_clean: @echo "Cleaning cargo build artifacts..." # Clean cargo build artifacts rm -rf debian/cargo dh_auto_clean override_dh_strip: # Strip debug symbols from binary dh_strip override_dh_shlibdeps: # Handle shared library dependencies dh_shlibdeps override_dh_fixperms: # Fix file permissions dh_fixperms %: dh $@