#!/usr/bin/make -f

# Ignore graphics and .mo files in addition to the default debian files
DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^(locale/.*/.*\.mo|data/dark/.*\.png|icons/.*\.png|LICENSE|debian/(changelog|copyright(|_hints|_newhints)|electrum.translations))$

%:
	dh $@ --buildsystem=pybuild

execute_before_dh_auto_build::
	# Generate paymentrequest_pb2.py from paymentrequest.proto.
	contrib/generate_payreqpb2.sh

override_dh_installchangelogs::
	# Move RELEASE-NOTES to changelog.
	dh_installchangelogs RELEASE-NOTES

execute_after_dh_auto_install::
	# Remove redundant license files whose information has been copied to debian/copyright.
	rm debian/tmp/usr/lib/python3*/dist-packages/electrum/_vendor/distutils/LICENSE
	rm debian/tmp/usr/lib/python3*/dist-packages/electrum/plugins/payserver/www/LICENCE
	rm debian/tmp/usr/lib/python3*/dist-packages/electrum/plugins/revealer/SIL\ Open\ Font\ License.txt

	# Remove Kivy and QML, which are only used for Android.
	rm -r debian/tmp/usr/lib/python3*/dist-packages/electrum/gui/kivy/
	rm -r debian/tmp/usr/lib/python3*/dist-packages/electrum/gui/qml/

	# Remove a payserver file to correct for an upstream tarball packaging problem.  <https://github.com/spesmilo/electrum/issues/8030>
	rm debian/tmp/usr/lib/python3*/dist-packages/electrum/plugins/payserver/www/pay

	# Remove upstream cruft.
	rm debian/tmp/usr/lib/python3*/dist-packages/electrum/plugins/payserver/www/.editorconfig
	rm debian/tmp/usr/lib/python3*/dist-packages/electrum/plugins/payserver/www/.gitignore

	# Remove bundled executable in the python directory.
	rm debian/tmp/usr/lib/python3*/dist-packages/electrum/electrum

execute_before_dh_python3::
	# The dependency is inconvenient and unnecessary.  In the future it might make more sense to move the editing of this file to debian/patches.
	sed -Ei -e '/^qdarkstyle/d' debian/python3-electrum/usr/lib/python3*/dist-packages/*.egg-info/requires.txt
