#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk

clean::
	find $(BUILDDIR) -name '*.pyc' -exec rm \{\} \;

binary-install/gapti::
	dh_python -p$(cdbs_curpkg)
	sed -i -e 's/python2.4//' debian/gapti.substvars
	dh_desktop -p$(cdbs_curpkg) $(DEB_DH_DESKTOP_ARGS)
	dh_installmime -p$(cdbs_curpkg) $(DEB_DH_DESKTOP_ARGS)

	: # Replace all '#!' calls to python with /usr/bin/python
	: # and make them executable
	for i in `find debian/gapti -type f`; do \
	  sed '1s,#!.*python[^ ]*\(.*\),#! /usr/bin/python\1,' \
		$$i > $$i.temp; \
	  if cmp --quiet $$i $$i.temp; then \
	    rm -f $$i.temp; \
	  else \
	    mv -f $$i.temp $$i; \
	    chmod 755 $$i; \
	    echo "fixed interpreter: $$i"; \
	  fi; \
	done
