#!/usr/bin/make -f

SHELL := sh -e

VERSION := $(shell dpkg-parsechangelog -SVersion | sed -e 's|~dev|.dev|' -e 's|+.*||')

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

execute_after_dh_auto_clean:
	rm -f RELEASE-VERSION

execute_before_dh_auto_build:
	echo "$(VERSION)" > RELEASE-VERSION

override_dh_auto_test:
	# disabled

execute_after_dh_auto_install:
	# unpacking plugins
	cd debian/tmp/usr/lib/python*/*-packages/deluge/plugins/; \
	for EGG in *.egg; \
	do \
		mkdir -p $${EGG%-py?.*}.egg; \
		unzip $${EGG} -d $${EGG%-py?.*}.egg; \
		rm -f $${EGG}; \
	done

	# removing unused files
	find debian/tmp -type d -name '__pycache__' | xargs rm -rf
