#!/usr/bin/make -f
# -*- makefile -*-

NAME = stats-server
ROOT = $(CURDIR)/debian/stats-server

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	# Install /usr/bin/wrapper - we rename it, so it can't go to *.install
	install -m 755 $(CURDIR)/debian/stats-server.sh $(ROOT)/usr/bin/stats-server
	dh_pysupport /usr/share/$(NAME)
	# Move config files
	mv $(ROOT)/usr/share/pyshared/ogra_server/settings.py $(ROOT)/usr/share/stats-server/settings.py.example
	ln -s /etc/$(NAME)/settings.py $(ROOT)/usr/share/pyshared/ogra_server/settings.py
	mv ogra_server/stats_settings_local.py.example $(ROOT)/usr/share/stats-server/stats_settings.py.example
	ln -s /etc/$(NAME)/stats_settings.py $(ROOT)/usr/share/pyshared/ogra_server/stats_settings_local.py

override_dh_pysupport:
	dh_pysupport /usr/share/$(NAME)


#install: build
#
#	python setup.py install \
#		--no-check-deps \
#		--no-update-setupcfg \
#		--no-record \
#		--root=$(CURDIR)/debian/fred-stats \
#		--preservepath \
#		--sysconfdir=/etc \
#		--appconfdir=fred \
#		--purelibdir=/usr/share/python-support \
#		--install-lib=/usr/share/python-support/stats-collector \
#		--prefix=/usr \
#		--localstatedir=/var \
#		--no-pycpyo \
#		--no-compile
#
#	# Move some files around
#	mv $(CURDIR)/debian/stats-collector/usr/bin/stats_one_day.py $(CURDIR)/debian/stats-collector/usr/share/stats-collector/stats_one_day.py
#
#	# Make some changes in config file
#	sed -e "s{'./fred_stats.log'{'/var/log/fred-stats/fred_stats.log'{" \
#	< $(CURDIR)/debian/stats-collector/etc/fred/stats_cfg.py \
#	> $(CURDIR)/debian/stats-collector/usr/share/doc/stats-collector/examples/stats_cfg.py
#
#	rm $(CURDIR)/debian/stats-collector/etc/fred/stats_cfg.py
#
#	# Remove strange cruft
#	rm -rf $(CURDIR)/debian/fred-stats/usr/share/doc/fred_stats/
#
#	# Install /usr/bin/wrapper
#	install -m 755 $(CURDIR)/debian/stats-collector.sh $(CURDIR)/debian/stats-collector/usr/bin/stats-collector

