#!/usr/bin/make -f

# Get version information from changelog file
DEB_VERSION:=$(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
DEB_UPSTREAM_VERSION:=$(shell echo $(DEB_VERSION) | cut -f 1 -d - | sed 's/+dfsg\.[0-9]\+$$//')

DFSG_VERSION:=1

%:
	dh $@ --with python2 -Spython_distutils

override_dh_fixperms:
	dh_fixperms
	find debian/series60-remote/usr/share/series60-remote -type f -print0 | xargs -r -0 chmod 644

get-orig-source:
	rm -rf get-orig-source-temp
	mkdir get-orig-source-temp
	mkdir get-orig-source-temp/repack
	uscan --force-download --download-version $(DEB_UPSTREAM_VERSION) --rename --destdir get-orig-source-temp
	tar xvf get-orig-source-temp/*.tar.gz -C get-orig-source-temp/repack
	wget http://sourceforge.net/projects/pys60/files/pys60/1.4.5/pys60-1.4.5_src.zip/download -O get-orig-source-temp/repack/series60-remote-$(DEB_UPSTREAM_VERSION)/mobile/pys60-1.4.5_src.zip
	tar cfz ../tarballs/series60-remote_$(DEB_UPSTREAM_VERSION)+dfsg.$(DFSG_VERSION).orig.tar.gz -C get-orig-source-temp/repack series60-remote-$(DEB_UPSTREAM_VERSION)
	rm -rf get-orig-source-temp
