#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

b := $(shell pwd)/debian

%:
	dh --with quilt --buildsystem=autoconf $@

override_dh_auto_configure:
	./configure --prefix=/usr \
	--bindir=/usr/lib/icinga-web/bin \
	--sysconfdir=/etc/icinga-web \
	--datarootdir=/usr/share/icinga-web \
	--docdir=/usr/share/doc/icinga-web \
	--libdir=/usr/lib/icinga-web \
	--with-web-absolute-path=/usr/share/icinga-web/pub \
	--with-web-apache-path="/etc/apache2/conf.d" \
	--with-web-user="www-data" --with-web-group="www-data" \
	--with-cache-dir=/var/cache/icinga-web \
	--with-log-dir=/var/log/icinga-web \
	--with-conf-dir=/etc/icinga-web/conf.d \
	--with-icinga-bin="/usr/sbin/icinga" \
	--with-icinga-cfg="/etc/icinga/icinga.cfg" \
	--with-icinga-objects-dir="/etc/icinga/objects" \
	--with-api-cmd-file="/var/lib/icinga/rw/icinga.cmd"

override_dh_auto_build:
	echo "no build necessary..."

override_dh_install:
	# removed INSTALL for policy
	rm ${b}/tmp/usr/doc/INSTALL
	# remove LICENSE files for packages - see debian/copyright
	rm ${b}/tmp/usr/doc/LICENSE
	# Upstream CHANGELOG by debian policy
	cat ${b}/tmp/usr/doc/CHANGELOG-1.7 ${b}/tmp/usr/doc/CHANGELOG-1.6 ${b}/tmp/usr/doc/CHANGELOG-1.x > ${b}/tmp/usr/doc/changelog
	rm ${b}/tmp/usr/doc/CHANGELOG-1.7 ${b}/tmp/usr/doc/CHANGELOG-1.6 ${b}/tmp/usr/doc/CHANGELOG-1.x
	# Install the rest
	dh_install
	# MySQL schema for dbconfig-common
	cp etc/schema/mysql.sql ${b}/icinga-web/usr/share/dbconfig-common/data/icinga-web/install/mysql
	cp etc/schema/updates/mysql_v1-6-2_to_v1-7.sql ${b}/icinga-web/usr/share/dbconfig-common/data/icinga-web/upgrade/mysql/1.7.0-1
	# PGSQL schema for dbconfig-common
	cp etc/schema/pgsql.sql ${b}/icinga-web/usr/share/dbconfig-common/data/icinga-web/install/pgsql
	cp etc/schema/updates/pgsql_v1-7-0_to_v1-7-1.sql ${b}/icinga-web/usr/share/dbconfig-common/data/icinga-web/upgrade/pgsql/1.7.1-1
	###
	# PNP
	###
	# Remove CHANGELOG from icinga-web-pnp
	rm ${b}/icinga-web-pnp/usr/share/doc/icinga-web-pnp/CHANGELOG
	# remove LICENSE files for packages - see debian/copyright
	rm ${b}/icinga-web-pnp/usr/share/doc/icinga-web-pnp/LICENSE
