#!/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 $@

override_dh_auto_build:
	dh_auto_build -Spython_distutils

override_dh_auto_clean:
	dh_auto_clean -Spython_distutils

override_dh_auto_configure:
	dh_auto_configure -Spython_distutils

override_dh_auto_install:
	dh_auto_install -Spython_distutils
	for f in INSTALL LICENSE HACKING Changelog LICENSE.icons-oxygen TODO README.icons-oxygen ; do \
		rm -f debian/series60-remote/usr/lib/python*/*-packages/series60_remote/$$f; \
	done

override_dh_auto_test:
	dh_auto_test -Spython_distutils

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
