#!/usr/bin/make -f
# -*- makefile -*-
VER=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-+]+).*,\1,p')

clean:
# Deleting the upstream setup.py, because it is windows only, 
# and breaks the build
	rm -f setup.py
	find ./ -name '*.pyc' -delete
	dh_clean

override_dh_auto_build:
	for i in $(shell find -executable -type f);do chmod 644 $$i; done
	chmod 755 pype.py
	chmod 755 debian/rules

# Adapted from the rules file of the python-werkzeug package
get-orig-source:
	mkdir -p get-orig-source
	uscan --force-download --rename --destdir=get-orig-source --upstream-version=$(VER) &&\
	cd get-orig-source &&\
	unzip ./PyPE-*.zip &&\
	cd PyPE-$(VER) &&\
	find ./ -executable -type f -exec chmod 644 '{}' \;&&\
	dos2unix * plugins/* &&\
	bomstrip-files pype.py &&\
	chmod 755 pype.py &&\
	rm -f pype.py.bom &&\
	cd .. &&\
	tar Jcf ../pype_$(VER).orig.tar.xz PyPE-$(VER)
	rm -rf get-orig-source

%:
	dh $@ --with python2

