#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

PACKAGE=roundup

export DH_VERBOSE=1

UPSTREAM_VERSION=1.4.1

DEB_SRCDIR=$(CURDIR)
ROOT=$(DEB_SRCDIR)/debian/$(PACKAGE)
DEB_BUILDDIR=debian/$(PACKAGE)
DOC=$(DEB_SRCDIR)/debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)


DEB_PYTHON_SYSTEM=pycentral

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk
include /usr/share/cdbs/1/rules/dpatch.mk

binary-install/roundup::
	cp -a debian/service $(ROOT)/etc/roundup
	chown -R root:root $(ROOT)/etc/roundup
	chmod -R 0755 $(ROOT)/etc/roundup/service
	install -m 755 -o root -g bin debian/roundup-ctl $(ROOT)/usr/bin
	install -m 644 -o root -g bin debian/roundup-server.ini debian/cgiconf.py $(ROOT)/etc/roundup
	perl debian/dh_installoverrides
	rm -f $(DOC)/*.1

	: # Replace all '#!' calls to python with /usr/bin/python
	: # and make them executable
	for i in `find debian/roundup -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

clean::
	rm -fr build home

