#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk

SOURCE_PACKAGE = $(shell dpkg-parsechangelog|sed -n '/^Source/{s/Source: \(.*\)/\1/p}')
MAIN_VERSION = $(shell dpkg-parsechangelog|sed -n '/^Version/{s/Version: \(.*\)/\1/p}')
VER = $(shell echo $(MAIN_VERSION)|sed -n 's/\([0-9.]*\)[-+].*/\1/p')

get-orig-source:
	dh_testdir
	mkdir -p ../tarballs
	uscan --force-download --rename --destdir ../tarballs

get-git-source:
	dh_testdir
	rm -rfv .upstream ../$(SOURCE_PACKAGE)_$(VER).orig.tar.bz2
	mkdir .upstream
	mkdir -p ../tarballs
	cd .upstream && git clone git://github.com/jonashaag/gpyconf --depth 1 $(SOURCE_PACKAGE)-$(VER)
	find .upstream -type f | while read F; do chmod -x "$$F"; done
	cd .upstream && tar --exclude .git -jvcf ../../tarballs/$(SOURCE_PACKAGE)_$(VER).orig.tar.bz2 $(SOURCE_PACKAGE)-$(VER)
	rm -rfv .upstream
