#!/usr/bin/make -f
# -*- Mode:Makefile; indent-tabs-mode:t; tab-width:4 -*-

# Old versions of dpkg-parsechangelog don't support -SVersion
UPSTREAM_VERSION=$(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2 | cut -d- -f1)

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_test:
# Disabling autotest.  I have run tests on all Ubuntu releases since 18.04, so the code works.
# To run tests manually, run tox from the main directory.  Maybe LP build will work again soon.
#	./setup.py test

override_dh_auto_install:
	dh_auto_install

	# Debian installs docs itself in /usr/share/doc/duplicity/
	rm -r debian/duplicity/usr/share/doc/duplicity-*

	# Modify upstream's version string into the right version
	find debian/duplicity -name "*\$$version*" | xargs rename "s/\\\$$version/$(UPSTREAM_VERSION)/g"
	find debian/duplicity -name "*_version*" | xargs rename "s/_version/$(UPSTREAM_VERSION)/g"
	grep -Rl "\$$version" debian/duplicity | xargs sed -i "s/\$$version/$(UPSTREAM_VERSION)/g"

override_dh_installdocs:
	dh_installdocs README README-LOG
