#!/usr/bin/make -f

UPSTREAM_GIT = git://github.com/openstack/designate.git
include /usr/share/openstack-pkg-tools/pkgos.make
export OSLO_PACKAGE_VERSION=$(VERSION)

%:
	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/usr/share/designate-common/designate.conf

override_dh_auto_clean:
	dh_auto_clean -O--buildsystem=python_distutils
	rm -f debian/designate-common.postinst debian/designate-common.config debian/designate-api.config debian/designate-api.postinst
	rm -rf doc/build build *.egg-info
	rm -f debian/*.init debian/*.upstart.in debian/*.service

override_dh_auto_build:
	dh_auto_build -O--buildsystem=python_distutils
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func designate-common.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func designate-common.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func designate-api.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func designate-api.postinst

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 || true ; \
		cat $$TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats || true ; \
		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
