#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

# Parse version from debian changelog (or pbr will try to use Git commit)
export PBR_VERSION=$(DEB_VERSION_UPSTREAM)
export PYBUILD_NAME=jeepyb
export PYBUILD_INSTALL_ARGS=--install-scripts=/usr/share/jeepyb

VER_PARSED=$(shell echo 20170923|awk -F '' '{printf $$1$$2$$3$$4 "-" $$5$$6 "-" $$7$$8}')

%:
	dh $@ --with python2 --buildsystem=pybuild

get-orig-source:
	git clone https://github.com/openstack-infra/jeepyb.git $(PYBUILD_NAME)-$(DEB_VERSION_UPSTREAM)
	(cd $(PYBUILD_NAME)-$(DEB_VERSION_UPSTREAM) && git checkout `git rev-list -n 1 --before="$(VER_PARSED) 23:59" master`)
	tar czvf ../$(PYBUILD_NAME)_$(DEB_VERSION_UPSTREAM).orig.tar.gz $(PYBUILD_NAME)-$(DEB_VERSION_UPSTREAM)/*
	rm -rf $(PYBUILD_NAME)-$(DEB_VERSION_UPSTREAM)
