#!/usr/bin/make -f

DEBVERSION:=$(shell dpkg-parsechangelog | sed -n -e 's/Version: //p')
DEB_SRC_VERSION:=$(shell echo $(DEBVERSION) | sed -e 's/-[^-]\+$$//')
UPVERSION:=$(shell echo $(DEB_SRC_VERSION) | sed -e 's/[.~]dfsg//' -e 's/~\(\(rc\|beta\)[0-9]\)/-\1/')

FILENAME := starpy_$(DEB_SRC_VERSION).orig.tar.gz
URL := https://github.com/downloads/asterisk-org/starpy/starpy-$(UPVERSION).tar.gz

%:
	dh $@ --with python2

print-version:
	@@echo "Debian version:          $(DEBVERSION)"
	@@echo "Upstream version:        $(UPVERSION)"

get-orig-source:
	@@dh_testdir
	@@[ -d ../tarballs/. ] || mkdir -p ../tarballs
	@@if [ ! -f ../tarballs/$(FILENAME) ]; then \
		echo Downloading $(FILENAME) from $(URL) ...; \
		wget -nv -T10 -t3 -O ../tarballs/$(FILENAME) $(URL); \
	fi
