#!/usr/bin/make -f

UPSTREAM_GIT := https://opendev.org/openstack/magnum-capi-helm.git
include /usr/share/openstack-pkg-tools/pkgos.make

export PYBUILD_NAME=magnum-capi-helm

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

override_dh_auto_clean:
	rm -rf build .stestr
	for i in $$(find . -type d -iname __pycache__) ; do rm -rf $$i ; done
	find . -iname '*.pyc' -delete

override_dh_auto_test:
	echo "Do nothing..."

override_dh_auto_install:
	echo "Do nothing..."

override_dh_install:
	set -e ; set -x ; for i in $(PYTHON3S) ; do \
		python$$i setup.py install --install-layout=deb --root $(CURDIR)/debian/tmp ; \
	done

# TestMagnumDriverLoads resolves the driver through magnum's stevedore
# registry, which requires a fully initialized magnum service environment
# (with a magnum.conf): not available at package build time.
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	pkgos-dh_auto_test 'magnum_capi_helm.tests\.(?!test_magnum_capi_helm\.TestMagnumDriverLoads.*)'
endif

	dh_install
	mkdir -p $(CURDIR)/debian/python3-magnum-capi-helm/etc/magnum
	PYTHONPATH=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages oslo-config-generator \
		--output-file $(CURDIR)/debian/python3-magnum-capi-helm/etc/magnum/capi_helm.conf \
		--namespace capi_helm \
		--namespace capi_helm_cluster_labels \
		--wrap-width 140
