#!/usr/bin/make -f

UPSTREAM_GIT = git://github.com/openstack/designate.git
include /usr/share/openstack-pkg-tools/pkgos.make

%:
	dh $@ --buildsystem=python_distutils --with python2,sphinxdoc,systemd

override_dh_auto_install:
	dh_auto_install -O--buildsystem=python_distutils
	install -D -m 0664 $(CURDIR)/etc/designate/rootwrap.conf.sample $(CURDIR)/debian/designate-common/etc/designate/rootwrap.conf
	install -D -m 0664 $(CURDIR)/etc/designate/designate.conf.sample $(CURDIR)/debian/designate-common/etc/designate/designate.conf

override_dh_auto_clean:
	dh_auto_clean -O--buildsystem=python_distutils
	rm -rf doc/build build
	rm -f debian/*.init debian/*.upstart debian/*.service
	rm -rf .eggs

override_dh_install:
	dh_install -O--buildsystem=python_distutils --fail-missing -Xusr/etc

override_dh_auto_build:
	dh_auto_build -O--buildsystem=python_distutils

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	rm -rf .testrepository
	testr init
	set -e ; \
		TEMP_REZ=`mktemp -t` ; \
		PYTHONPATH=$(CURDIR) testr run --subunit | tee $$TEMP_REZ | subunit2pyunit ; \
		cat $$TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats ; \
		rm -f $$TEMP_REZ ;
	testr slowest
endif

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. sphinx-build -b html doc/source $(CURDIR)/debian/designate-doc/usr/share/doc/designate-doc/html
	dh_sphinxdoc -O--buildsystem=python_distutils
endif
