#!/usr/bin/make -f

PYTHONS:=$(shell pyversions -vr)
#PYTHON3S:=$(shell py3versions -vr)


include /usr/share/openstack-pkg-tools/pkgos.make
export OSLO_PACKAGE_VERSION=$(VERSION)

# buildd provides a build environment where $HOME is not writable,
# which causes unit tests to fail.
export HOME = $(CURDIR)/debian/home

%:
	dh $@  --with python2

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(CURDIR) py.test tests/unit
endif

override_dh_auto_build:
	dh_auto_build
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func rally.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func rally.postinst

override_dh_clean:
	dh_clean
	rm -rf build debian/rally.config debian/rally.postinst

override_dh_install:
	dh_install --fail-missing -Xetc/bash_completion.d/rally.bash_completion
	
	install -D -m 0644 $(CURDIR)/etc/rally.bash_completion $(CURDIR)/debian/rally/usr/share/bash-completion/completions/rally
	install -D -m 0644 $(CURDIR)/etc/rally/rally.conf.sample $(CURDIR)/debian/rally/usr/share/rally/rally.conf
	sed -i 's|^[ \t#]connection[ \t]*=|connection=sqlite:///var/lib/rally/rally.db|' $(CURDIR)/debian/rally/usr/share/rally/rally.conf

	# This shells script is broken, so I'm removing it.
	rm $(CURDIR)/debian/rally/usr/share/rally/samples/tasks/support/instance_linpack.sh
