#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Prevent setuptools/distribute from accessing the internet.
export http_proxy = http://127.0.9.1:9

DB2MAN = /usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/manpages/docbook.xsl
XP     = xsltproc -''-nonet -''-param man.charmap.use.subset "0"

# This has to be exported to make some magic below work.
export DH_OPTIONS

export PYBUILD_INSTALL_ARGS=--install-script /usr/sbin

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

override_dh_installinit:
	dh_systemd_enable -ppdudaemon --name=pdudaemon share/pdudaemon.service
	dh_installinit -ppdudaemon --no-start --noscripts
	dh_systemd_start -ppdudaemon --no-restart-on-upgrade

override_dh_auto_install:
	dh_auto_install
	$(XP) $(DB2MAN) debian/pdudaemon.xml
	$(XP) $(DB2MAN) debian/pduclient.xml
	dh_installman -ppdudaemon pdudaemon.8
	dh_installman -ppdudaemon-client pduclient.1

override_dh_auto_clean:
	dh_auto_clean
	find . -name '__pycache__/*.pyc' -delete
	$(RM) -r pdudaemon.egg-info setup.cfg dist/ pdudaemon.8
	$(RM) -r build/ pduclient.1 debian/pdudeamon
