#!/usr/bin/make -f

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

export PYBUILD_NAME=neutron_fwaas

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
	# NOTE: scrub usr/etc folder from install.
	rm -rf debian/python3-neutron-fwaas/usr/etc
	dh_install

override_dh_fixperms:
	find debian/python3-neutron-fwaas -name __init__.py -exec chmod a-x {} \;
	dh_fixperms

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	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
