#!/usr/bin/make -f

%:
	dh $@

get-orig-source::
	version=$$(dpkg-parsechangelog -c1 | grep ^Version: | sed -e 's/Version: //'); \
	shorthash=$$(echo $${version} | sed -e 's/0~git[0-9]\{14\}+\([0-9a-f]\{7\}\).*/\1/'); \
	tmpdir=$$(mktemp -d); \
	cd $${tmpdir}; \
	git clone git://git.altlinux.org/people/at/packages/sqlite3-pcre.git; \
	cd sqlite3-pcre; \
	git checkout $${shorthash} 2> /dev/null; \
	stamp=$$(date --date="$$(git log -n1 --date=rfc | grep Date | sed -e 's/Date: *//')" +%Y%m%d%H%M%S); \
	cd ..; \
	tar --exclude=.git -czf ${CURDIR}/sqlite3-pcre_0~git$${stamp}+$${shorthash}.orig.tar.gz sqlite3-pcre; \
	cd ${CURDIR}; \
	rm -rf $${tmpdir}
