#!/usr/bin/make -f

export DH_VERBOSE = 1
export DEB_PYTHON_INSTALL_LAYOUT = deb

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

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
	mkdir -p debian/build
	export HOME=$(CURDIR)/debian/build && ./run-tests
	rm -rf debian/build
endif

PNG_FILES = thumbnail_pocketmod.png thumbnail_sexy.png thumbnail_simple.png thumbnail_statusrpt.png thumbnail_textual.png
execute_after_dh_auto_install:
	# Move script_pocketmod to /usr/bin and create a symbolic link in the export plugin template folder.
	mv $(CURDIR)/debian/gtg/usr/lib/python3/dist-packages/GTG/plugins/export/export_templates/script_pocketmod $(CURDIR)/debian/gtg/usr/bin/gtg_script_pocketmod
	ln -s /usr/bin/gtg_script_pocketmod $(CURDIR)/debian/gtg/usr/lib/python3/dist-packages/GTG/plugins/export/export_templates/script_pocketmod
	
	# Move png files to /usr/share/gtg and create symbolic links
	mkdir -p $(CURDIR)/debian/gtg/usr/share/gtg/export_templates
	for f in $(PNG_FILES); do \
		echo $$f; \
		mv $(CURDIR)/debian/gtg/usr/lib/python3/dist-packages/GTG/plugins/export/export_templates/$$f $(CURDIR)/debian/gtg/usr/share/gtg/export_templates/ ; \
		ln -s /usr/share/gtg/export_templates/$$f $(CURDIR)/debian/gtg/usr/lib/python3/dist-packages/GTG/plugins/export/export_templates/$$f ; \
	done
	
override_dh_fixperms:
	dh_fixperms
	find debian/ -type f -name networkmanager.py -exec chmod -x '{}' \;
