#!/usr/bin/make -f

#export DH_VERBOSE=1

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

export OSLO_PACKAGE_VERSION=$(VERSION)

%:
	dh $@ --buildsystem=python_distutils --with python2,sphinxdoc,systemd

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	./run_tests.sh -P -N || true
	#nosetests || true
endif

override_dh_auto_build:
	dh_auto_build

	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func glance-common.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func glance-common.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func glance-api.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func glance-api.postinst

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	sphinx-build -b html doc/source $(CURDIR)/debian/python-glance-doc/usr/share/doc/python-glance-doc/html
	dh_sphinxdoc -O--buildsystem=python_distutils
endif

override_dh_installman:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	sphinx-build -b man doc/source doc/build/man
	dh_installman -O--buildsystem=python_distutils
endif

override_dh_auto_configure:
	echo $(VERSION) > glance/versioninfo
	dh_auto_configure


override_dh_auto_clean:
	echo $(VERSION) > glance/versioninfo
	# dh_auto_clean
	# debconf-updatepo
	find . -iname '*.pyc' -delete
	rm -rf glance.egg-info
	rm -rf doc/build
	rm -rf glance.sqlite
	rm -f glance/versioninfo
	rm -f debian/glance-common.config debian/glance-common.postinst
	rm -f debian/*.init debian/*.service debian/*.upstart

.PHONY: override_dh_auto_clean override_dh_auto_configure override_dh_builddeb override_dh_installman override_dh_auto_build
