#!/usr/bin/make -f
export DH_VERBOSE = 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export PYBUILD_NAME = mailman3-core
export PYBUILD_DESTDIR = debian/mailman3-core

MM3_BIN_DIR=/usr/lib/mailman3/bin/
export PYBUILD_INSTALL_ARGS ?= \
	--install-scripts=${MM3_BIN_DIR}/

%:
	dh $@ --with python3,systemd,sphinxdoc --buildsystem=pybuild

override_dh_installinit:
	dh_installinit --error-handler=init_service_failed

override_dh_auto_test:
	# Running the test suite at build time is not supported for now.
	# See upstream bug #400 for further information.
	#PYTHONPATH="." python3 -m nose2 --verbose

override_dh_auto_build:
	PYTHONPATH=. sphinx-build -b html -c ./ -E -N . build/sphinx/html
	dh_auto_build

override_dh_auto_install:
	dh_auto_install
	#find debian/mailman3-core/usr -type d -name "tests" -print0 | xargs -0 rm -r

override_dh_installdocs:
	dh_installdocs
	mv debian/mailman3-core-doc/usr/share/doc/mailman3-core-doc/html \
	   debian/mailman3-core-doc/usr/share/doc/mailman3-core/html

override_dh_installchangelogs:
	dh_installchangelogs src/mailman/docs/NEWS.rst

override_dh_fixperms:
	dh_fixperms
	chown list:list debian/mailman3-core/var/lib/mailman3 \
	                debian/mailman3-core/var/log/mailman3
