#!/usr/bin/make -f

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

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

%:
	dh $@ --with python2 --buildsystem=python_distutils

override_dh_install:
	PYTHONPATH=$(CURDIR) $(CURDIR)/tools/generate_config_file_samples.sh
	find $(CURDIR)/etc -type f | xargs rename 's/\.sample$$//'
	# NOTE: scrub usr/etc and usr/bin folder from install.
	rm -rf debian/python-neutron-fwaas/usr/etc debian/python-neutron-fwaas/usr/bin
	dh_install

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

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	ostestr
endif

override_dh_auto_clean:
	rm -rf .testrepository
	dh_auto_clean
