#!/usr/bin/make -f

#export DH_VERBOSE=1

export PYBUILD_NAME=ironic

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

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	pkgos-dh_auto_test --no-py2
endif

override_dh_auto_install:
	pkgos-dh_auto_install --no-py2
	rm -rf $(CURDIR)/debian/python3-ironic/usr/etc

override_dh_install:
	PYTHONPATH=$(CURDIR) oslo-config-generator --config-file=tools/config/ironic-config-generator.conf
	cp etc/ironic/ironic.conf.sample etc/ironic/ironic.conf
	crudini --set $(CURDIR)/etc/ironic/ironic.conf DEFAULT log_dir /var/log/ironic
	crudini --set $(CURDIR)/etc/ironic/ironic.conf database connection sqlite:////var/lib/ironic/ironic.db
	dh_install
	dh_missing --fail-missing -Xusr/etc

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

override_dh_clean:
	dh_clean
	rm -f debian/*.init debian/*.service debian/*.upstart .testrepository
