#!/usr/bin/make -f

UPSTREAM_GIT = https://github.com/openstack/neutron-dynamic-routing.git
include /usr/share/openstack-pkg-tools/pkgos.make

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

override_dh_auto_install:
	pkgos-dh_auto_install --no-py2

override_dh_install:
	# NOTE: generate configuration files directly
	mkdir -p $(CURDIR)/etc/neutron
	for file in `ls etc/oslo-config-generator/*`; do \
	     PYTHONPATH=$(CURDIR) oslo-config-generator --config-file=$$file \
	        --output-file=etc/neutron/`basename $$file`; \
	done
	rm -rf $(CURDIR)/debian/python*-neutron-dynamic-routing/usr/etc
	dh_install -O--buildsystem=python_distutils --fail-missing

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	# https://bugs.launchpad.net/neutron/+bug/1803745
	pkgos-dh_auto_test --no-py2 'neutron_dynamic_routing\.tests\.unit.(?!(.*TestRescheduleBgpSpeaker.*))'
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/*.init debian/*.service debian/*.upstart
	for file in `ls etc/oslo-config-generator/*`; do rm -f etc/neutron/`basename $$file`; done
	rm -rf $(CURDIR)/etc/neutron

override_dh_clean:
	dh_clean
	find . -type f -name "*.pyc" -delete
	rm -rf build

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3
