#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PYBUILD_NAME=neutron_vpnaas

SHELL := /bin/sh -e

DEBVERS ?= $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
VERSION ?= $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/[+].*//' -e 's/~git.*//g' -e 's/~/./g')
export PBR_VERSION=$(VERSION)

include /usr/share/openstack-pkg-tools/pkgos.make

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_install:
	# NOTE: generate configuration files directly
	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 debian/python3-neutron-vpnaas/usr/etc
	dh_install

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	OS_TEST_PATH=./neutron_vpnaas/tests/unit pkgos-dh_auto_test --no-py2
endif

override_dh_auto_clean:
	rm -rf .testrepository build
	for file in `ls etc/oslo-config-generator/*`; do rm -f etc/neutron/`basename $$file`; done
	dh_auto_clean

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