#!/usr/bin/make -f

%:
	dh $@

execute_after_dh_install:
	rm -fv debian/*/usr/share/gnome-shell/extensions/EasyScreenCast@iacopodeenosee.gmail.com/locale/*.po~

override_dh_gencontrol:
	dh_gencontrol -- \
		-Vgnome:MinimumVersion=$(shell python3 -c "import json; print(min(int(x) for x in json.load(open('metadata.json', 'rt'))['shell-version']))") \
		-Vgnome:MaximumVersion=$(shell python3 -c "import json; print(1+max(int(x) for x in json.load(open('metadata.json', 'rt'))['shell-version']))")

# This is required because upstream regenerates .po files from the .pot during
# the build, modifying upstream source files. As a result, rebuilding the
# package is not reproducible and triggers an FTBFS, see bug #1044793.
execute_after_dh_auto_clean:
	find locale/ -type f -name '*.po~' | \
	while read -r f; do \
		mv -v "$$f" "$$(dirname "$$f")/$$(basename "$$f" "~")"; \
	done
