#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
#export DH_OPTIONS=-v
export PYBUILD_NAME=gramps
export PYBUILD_INSTALL_ARGS_python3=--packaging

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

# Override auto test because upstream do not use the standard unittest discover
override_dh_auto_test:

# Override of auto_install to remove information from package
override_dh_auto_install:
	dh_auto_install
	# Remove install file as it is not needed by package users
	rm $(CURDIR)/debian/gramps/usr/share/doc/gramps/INSTALL
	#Remove duplicate license information
	rm $(CURDIR)/debian/gramps/usr/share/doc/gramps/LICENSE
	#Remove license information in COPYING file & link to system license
	rm $(CURDIR)/debian/gramps/usr/share/doc/gramps/COPYING
	ln -s /usr/share/common-licenses/GPL-2 $(CURDIR)/debian/gramps/usr/share/doc/gramps/COPYING

# Make css style sheets and png icons non-executable
override_dh_fixperms:
	dh_fixperms
	chmod a-x $(CURDIR)/debian/gramps/usr/share/gramps/css/Web_*.css
	chmod a-x $(CURDIR)/debian/gramps/usr/share/gramps/images/22x22/gramps*.png
	chmod a-x $(CURDIR)/debian/gramps/usr/share/gramps/images/16x16/gramps*.png

# Fix clean target
override_dh_clean:
	rm -rf data/tips.xml
	rm -rf gramps/plugins/lib/holidays.xml
	rm -rf po/.intltool-merge-cache
	dh_clean

get-orig-source:
	# To get ~dfsg, need to rename orig.tar after uscan
	uscan --verbose --destdir . --force-download
	rename 's/\+/\~/' gramps*.orig.tar.gz
	mv gramps*.orig.tar.gz ../
	rm gramps*.tar.gz
