#!/usr/bin/make -f

# Verbose mode
#export DH_VERBOSE=1

%:
	dh $@ --with python2

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	bash run_tests.sh -N || true
endif

override_dh_auto_build:
	dh_auto_build
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	mkdir -p doc/build
	python setup.py build_sphinx
else
	mkdir -p doc/build/html
endif

override_dh_auto_clean:
	dh_auto_clean
	debconf-updatepo
	rm -rf build doc/build glance.egg-info po/glance.pot glance/vcsversion.py
	rm -rf glance.sqlite

get-vcs-source:
	git remote add upstream git://github.com/openstack/glance.git || true
	git fetch upstream
	if ! [ -f ../glance_2012.1.orig.tar.xz ] ; then git archive --prefix=glance-2012.1/ 2012.1 | xz >../glance_2012.1.orig.tar.xz ; fi
	if ! git checkout master ; then \
		echo "No upstream branch: checking out" ; \
		git checkout -b master upstream/master ; \
	fi
	git checkout debian/unstable
