#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
  
PACKAGE_MYSQL=tt-rss-mysql
PACKAGE_PGSQL=tt-rss-pgsql

define install_rule
	cp debian/$1/usr/share/doc/$1/config.php-dist debian/$1/etc/$1/config.php
	mkdir -p debian/$1/usr/share/tt-rss/www/
	ln -sf /etc/$1/config.php debian/$1/usr/share/tt-rss/www/
	patch debian/$1/etc/$1/config.php < debian/config.php-dist-$1.diff
endef

binary-install/tt-rss-mysql::
	$(call install_rule,$(PACKAGE_MYSQL))
	mkdir -p debian/$(PACKAGE_MYSQL)/usr/share/dbconfig-common/data/$(PACKAGE_MYSQL)/install
	cp debian/$(PACKAGE_MYSQL)/usr/share/tt-rss/www/schema/ttrss_schema_mysql.sql debian/$(PACKAGE_MYSQL)/usr/share/dbconfig-common/data/$(PACKAGE_MYSQL)/install/mysql

binary-install/tt-rss-pgsql::
	$(call install_rule,$(PACKAGE_PGSQL))
	mkdir -p debian/$(PACKAGE_PGSQL)/usr/share/dbconfig-common/data/$(PACKAGE_PGSQL)/install
	cp debian/$(PACKAGE_PGSQL)/usr/share/tt-rss/www/schema/ttrss_schema_pgsql.sql debian/$(PACKAGE_PGSQL)/usr/share/dbconfig-common/data/$(PACKAGE_PGSQL)/install/pgsql

