#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Rust is provided by rustup in the VesperOS build environment
export PATH := $(HOME)/.cargo/bin:$(PATH)

PY_DIST_DIR = $(CURDIR)/debian/hyfetch/usr/lib/python3/dist-packages

%:
	dh $@

override_dh_auto_build:
	cargo build --release --manifest-path Cargo.toml

override_dh_auto_install:
	# Python package
	install -d $(PY_DIST_DIR)
	cp -r hyfetch $(PY_DIST_DIR)/hyfetch
	# Rust binary inside the Python package (hyfetch looks for it at hyfetch/rust/hyfetch)
	install -d $(PY_DIST_DIR)/hyfetch/rust
	install -m 755 target/release/hyfetch $(PY_DIST_DIR)/hyfetch/rust/hyfetch
	# Entry point wrappers
	install -d debian/hyfetch/usr/bin
	install -m 755 debian/hyfetch.wrapper debian/hyfetch/usr/bin/hyfetch
	# Man pages
	install -d debian/hyfetch/usr/share/man/man1
	install -m 644 docs/hyfetch.1 debian/hyfetch/usr/share/man/man1/hyfetch.1
	# neowofetch package
	install -d debian/neowofetch/usr/bin
	install -m 755 hyfetch/scripts/neowofetch debian/neowofetch/usr/bin/neowofetch
	ln -sf neowofetch debian/neowofetch/usr/bin/neofetch
	install -d debian/neowofetch/usr/share/man/man1
	install -m 644 docs/neofetch.1 debian/neowofetch/usr/share/man/man1/neowofetch.1
	ln -sf neowofetch.1.gz debian/neowofetch/usr/share/man/man1/neofetch.1.gz
	# Bash completion
	install -d debian/hyfetch/usr/share/bash-completion/completions
	install -m 644 hyfetch/scripts/autocomplete.bash \
		debian/hyfetch/usr/share/bash-completion/completions/hyfetch
	# Zsh completion
	install -d debian/hyfetch/usr/share/zsh/vendor-completions
	install -m 644 hyfetch/scripts/autocomplete.zsh \
		debian/hyfetch/usr/share/zsh/vendor-completions/_hyfetch

override_dh_auto_test:
	# skip tests
