#!/usr/bin/make -f

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)

export PYBUILD_NAME=networking_baremetal

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

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

override_dh_auto_clean:
	python3 setup.py clean

override_dh_clean:
	dh_clean
	rm -rf build

override_dh_auto_build:
	set -e ; for i in $(PYTHON3S) ; do \
		PYTHON=python$$i python$$i setup.py build --force ; \
	done

override_dh_auto_install:
	echo "Do nothing..."

override_dh_auto_test:
	echo "Do nothing..."

override_dh_install:
	set -e ; for i in $(PYTHON3S) ; do \
		python$$i setup.py install --install-layout=deb --root $(CURDIR)/debian/tmp ; \
	done
		
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	pkgos-dh_auto_test --no-py2 'networking_baremetal.tests.*'
endif

	mkdir -p $(CURDIR)/debian/ironic-neutron-agent/usr/share/ironic-neutron-agent
	PYTHONPATH=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages oslo-config-generator \
		--output-file $(CURDIR)/debian/ironic-neutron-agent/usr/share/ironic-neutron-agent/ironic_neutron_agent.ini \
		--wrap-width 140 \
		--namespace ironic-neutron-agent \
		--namespace oslo.log

	dh_install
	dh_missing --fail-missing

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