#!/usr/bin/make -f

%:
	dh $@ --with python2 -Spython_distutils

override_dh_fixperms:
	chmod +x `grep '^#!' debian/ansible/usr/share/ansible/* -n | grep ':1:' | cut -d: -f 1`
	dh_fixperms

override_dh_auto_build:
	dh_auto_build
	cp -a docsite html
	cp debian/missing-files/ansible_arch.png html
	PYTHONPATH=../lib make docs -C html
	rm -rf html/.gitignore \
	    html/_themes \
	    html/rst \
	    html/*.png \
	    html/*.jpg \
	    html/*.py \
	    html/Makefile \
	    html/.buildinfo

override_dh_auto_clean:
	rm -rf html
	dh_auto_clean

override_dh_installchangelogs:
	dh_installchangelogs CHANGELOG.md

DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^+]+).*,\1,p')
get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=.
	rm -rf ansible-$(DEB_UPSTREAM_VERSION)
	tar -xf ansible_$(DEB_UPSTREAM_VERSION).orig.tar.gz
	rm ansible_$(DEB_UPSTREAM_VERSION).orig.tar.gz
	rm ansible-$(DEB_UPSTREAM_VERSION)/docsite/_static/jquery.js
	rm ansible-$(DEB_UPSTREAM_VERSION)/docsite/_static/underscore.js
	GZIP=--best tar -cz --owner root --group root --mode a+rX \
		-f ansible_$(DEB_UPSTREAM_VERSION)+dfsg.orig.tar.gz \
		ansible-$(DEB_UPSTREAM_VERSION)
	rm -r ansible-$(DEB_UPSTREAM_VERSION)
