#!/usr/bin/make -f

EXTENSION := $(shell awk -F\" '/"uuid": / { print $$4 }' metadata.json)

%:
	dh ${@}

override_dh_auto_build:
	$(MAKE) zip

override_dh_auto_install:
	mkdir -p debian/gnome-shell-extension-vertical-workspaces/usr/share/gnome-shell/extensions/$(EXTENSION)
	unzip -d debian/gnome-shell-extension-vertical-workspaces/usr/share/gnome-shell/extensions/$(EXTENSION) *.zip

	# removing unused files
	rm -f debian/gnome-shell-extension-vertical-workspaces/usr/share/gnome-shell/extensions/$(EXTENSION)/LICENSE
	rm -f debian/gnome-shell-extension-vertical-workspaces/usr/share/gnome-shell/extensions/$(EXTENSION)/schemas/meson.build

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']))")
