#! /usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export PYBUILD_NAME=gnome-keysign
DATE=$(shell date --date=@$(SOURCE_DATE_EPOCH) '+%d %B %Y')
export LC_ALL=C.UTF-8

MANPAGES=debian/man/gnome-keysign.1 \
         debian/man/gks-qrcode.1

%.1: %.1.txt
	TZ=UTC LC_ALL=C \
	  txt2man -d "$(DATE)" \
	  -s 1 -r "GNOME Keysign $(DEB_VERSION_UPSTREAM)" \
	  -t $(shell basename -a -s.1 $@) \
	  $< > $@

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install
	find $(CURDIR)/debian -name '*.pyc' -delete

override_dh_installman: $(MANPAGES)
	dh_installman

override_dh_auto_clean:
	dh_clean
	rm -rf $(MANPAGES) .pybuild .pytest_cache gnome_keysign.egg-info data/org.gnome.Keysign.appdata.xml data/org.gnome.Keysign.desktop
	find . -name "__pycache__" -type d -exec rm -r {} +
	find . -name "*.mo" -delete
	find . -name "*.pyc" -delete

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	xvfb-run -a python3 -m pytest
endif
