#!/usr/bin/make -f

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

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

override_dh_auto_clean:
	echo "Do nothing..."

override_dh_auto_build:
	echo "Do nothing..."

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	NOSE_WITH_OPENSTACK=1 \
		NOSE_OPENSTACK_COLOR=1 \
		NOSE_OPENSTACK_RED=0.05 \
		NOSE_OPENSTACK_YELLOW=0.025 \
		NOSE_OPENSTACK_SHOW_ELAPSED=1 \
		DJANGO_SETTINGS_MODULE=mistraldashboard.test.settings \
		python3-coverage run \
		$(CURDIR)/manage.py test mistraldashboard --settings=mistraldashboard.test.settings
endif

override_dh_clean:
	dh_clean
	rm -rf .coverage*

override_dh_auto_install:
	python3 setup.py install --install-layout=deb --root $(CURDIR)/debian/python3-mistral-dashboard

	# Activates the mistral-dashboard plugin in Horizon
	mkdir -p $(CURDIR)/debian/python3-mistral-dashboard/usr/lib/python3/dist-packages/openstack_dashboard/enabled ; \
	cp $(CURDIR)/mistraldashboard/enabled/_50_mistral.py $(CURDIR)/debian/python3-mistral-dashboard/usr/lib/python3/dist-packages/openstack_dashboard/enabled/_50_mistral.py ; \

	mkdir -p $(CURDIR)/debian/python3-mistral-dashboard/usr/share/openstack-dashboard/openstack_dashboard/enabled
	cp $(CURDIR)/mistraldashboard/enabled/_50_mistral.py $(CURDIR)/debian/python3-mistral-dashboard/usr/share/openstack-dashboard/openstack_dashboard/enabled/_50_mistral.py
