#!/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)

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

%:
	dh $@  --with python2,systemd

override_dh_install:
	PYTHONPATH=$(CURDIR) $(CURDIR)/tools/generate_config_file_samples.sh
	find $(CURDIR)/etc -type f | xargs rename 's/\.sample$$//'a
	crudini --merge $(CURDIR)/etc/neutron.conf < $(CURDIR)/debian/neutron.conf.defaults
	dh_install --fail-missing -X/usr/etc

override_dh_systemd_enable:
	dh_systemd_enable -pneutron-openvswitch-agent --name=neutron-ovs-cleanup \
		neutron-ovs-cleanup.service
	dh_systemd_enable -pneutron-linuxbridge-agent --name=neutron-linuxbridge-cleanup \
		neutron-linuxbridge-cleanup.service
	dh_systemd_enable

override_dh_installinit:
	dh_installinit -pneutron-openvswitch-agent --no-start \
        --name=neutron-ovs-cleanup
	dh_installinit -pneutron-linuxbridge-agent --no-start \
        --name=neutron-linuxbridge-cleanup
	dh_installinit --error-handler=true

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/*.upstart debian/*.init debian/*.service .testrepository

get-orig-source:
	uscan --verbose --force-download --rename --destdir=../build-area

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