#!/usr/bin/make -f
#DH_VERBOSE = 1

%:
	dh $@ --with python2

PACKAGE=nova-compute-lxd
SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.gz

export OSLO_PACKAGE_VERSION=$(shell dpkg-parsechangelog | grep Version: | cut -d' ' -f2 | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~/.0/')

override_dh_auto_test:
	ostestr

get-orig-source:
	rm -rf get-orig-source $(TARBALL)
	mkdir get-orig-source
	git clone git://github.com/lxc/$(PACKAGE).git get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig
	cd get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig
	rm -rf get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig/.git
	GZIP=--best tar czf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION).orig
	rm -rf get-orig-source
	echo " "$(TARBALL)" created; move it to the right destination to build the package"

BRANCH = master
DATE=$(shell date +%Y%m%d%H%M)
get-orig-snapshot:
	rm -Rf nova-compute-lxd-upstream
	git clone https://github.com/lxc/nova-compute-lxd nova-compute-lxd-upstream
	cd nova-compute-lxd-upstream && \
		export COMMIT=`git rev-parse --short HEAD` && \
		export UPSTREAM_VERSION=`grep version setup.cfg | cut -d ' ' -f 3` && \
		git archive --format tgz --prefix=nova-compute-lxd-$$UPSTREAM_VERSION~git$(DATE)/ \
			-o ../../nova-compute-lxd_$$UPSTREAM_VERSION~git$(DATE).$$COMMIT.orig.tar.gz $(BRANCH)
	rm -Rf nova-compute-lxd-upstream
