#!/usr/bin/make -f

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

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$$//'
	patch -p1 < debian/patches/fix-neutron-configuration.patch
	dh_install --fail-missing -X/usr/etc -X/usr/bin/neutron-vpn-agent \
		-X/usr/bin/neutron-lbaas-agent -X/usr/bin/neutron-hyperv-agent
	patch -p1 -R < debian/patches/fix-neutron-configuration.patch

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:
	ostestr
endif
