#!/usr/bin/make -f

#export DH_VERBOSE=1

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

export OSLO_PACKAGE_VERSION=$(VERSION)

%:
	dh $@  --with python2

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	./run_tests.sh -u
endif


override_dh_clean:
	dh_clean
	rm -rf heat.egg-info
	rm -rf doc/build
	find . -iname '*.pyc' -delete
	rm -f \
		debian/heat-api-cfn.config \
		debian/heat-api-cfn.postinst \
		debian/heat-api-cloudwatch.config \
		debian/heat-api-cloudwatch.postinst \
		debian/heat-api.config \
		debian/heat-api.postinst \
		debian/heat-common.postinst \
		debian/heat-engine.config \
		debian/heat-engine.postinst

override_dh_install:
	dh_install
	sed -i 's/^[ \t]*rpc_backend[ \t]*=[ \t]*heat.openstack.common.rpc.impl_qpid/rpc_backend=heat.openstack.common.rpc.impl_kombu/' $(CURDIR)/debian/heat-engine/usr/share/heat-engine/heat-engine.conf
	sed -i 's/^[ \t]*rpc_backend[ \t]*=[ \t]*heat.openstack.common.rpc.impl_qpid/rpc_backend=heat.openstack.common.rpc.impl_kombu/' $(CURDIR)/debian/heat-api-cloudwatch/etc/heat/heat-api-cloudwatch.conf
	sed -i 's/^[ \t]*rpc_backend[ \t]*=[ \t]*heat.openstack.common.rpc.impl_qpid/rpc_backend=heat.openstack.common.rpc.impl_kombu/' $(CURDIR)/debian/heat-api-cfn/etc/heat/heat-api-cfn.conf
	sed -i 's/^[ \t]*rpc_backend[ \t]*=[ \t]*heat.openstack.common.rpc.impl_qpid/rpc_backend=heat.openstack.common.rpc.impl_kombu/' $(CURDIR)/debian/heat-api/etc/heat/heat-api.conf

override_dh_auto_build:
	dh_auto_build
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-common.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-api-cfn.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-api-cfn.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-api-cloudwatch.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-api-cloudwatch.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-api.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-api.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-common.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-engine.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func heat-engine.postinst

override_dh_installman:
	python setup.py build
	make -C doc man
	dh_installman
