#!/usr/bin/make -f

export DH_VERBOSE = 1

export VERSION = $(shell head -n1 debian/changelog | cut -d' ' -f2 | tr -d '()')
export BUILDBOT_VERSION = $(VERSION)

override_dh_auto_clean \
override_dh_auto_configure \
override_dh_auto_build:
	$(@:override_%=%) --buildsystem=pybuild --sourcedirectory=master \
		--package=python3-buildbot -- --name=buildbot
	$(@:override_%=%) --buildsystem=pybuild --sourcedirectory=worker \
		--package=python3-buildbot-worker -- --name=buildbot_worker

space :=
space +=
test_pythonpath = \
	$(CURDIR)/pkg \
	$(CURDIR)/debian/python3-buildbot/{install_dir} \
	$(CURDIR)/debian/python3-buildbot-worker/{install_dir}
test_command = PYTHONPATH=$(subst $(space),:,$(test_pythonpath)) LC_ALL=C.UTF-8 \
	trial3 --reporter=text buildbot.test buildbot_worker.test

override_dh_auto_install:
	dh_auto_install --buildsystem=pybuild --sourcedirectory=master \
		--package=python3-buildbot -- --name=buildbot \
		--after-install='rm {destdir}/usr/bin/buildbot_windows_service'
	dh_auto_install --buildsystem=pybuild --sourcedirectory=worker \
		--package=python3-buildbot-worker -- --name=buildbot_worker \
		--after-install='rm {destdir}/usr/bin/buildbot_worker_windows_service'

override_dh_auto_test:
	:

override_dh_installinit:
	dh_installinit --package=python3-buildbot --name=buildmaster
	dh_installinit --package=python3-buildbot-worker --name=buildbot-worker

%:
	dh $@ --with python3,bash-completion,sphinxdoc
