#!/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
core=debian/littlebird-tc-core
common=debian/littlebird-tc-common
sql=debian/littlebird-tc-sql

%:
	dh $@ 

override_dh_install:
#	@dh_install --exclude=.gitignore
	dh_install
	@cd ${core}/usr/share/littlebird-tc/CA/certs \
	&& { \
	   test -f Trustcenter_CA_LB.pem || cp -av Test_Trustcenter_CA_LB.pem Trustcenter_CA_LB.pem; \
	   test -f Trustcenter_CA.pem || cp -av Test_Trustcenter_CA.pem Trustcenter_CA.pem; \
	   }
	# moving logs and data to var/
	mv ${core}/usr/share/littlebird-tc/TrustCenter/data/logs ${core}/var/log/littlebird-tc 
	mv ${core}/usr/share/littlebird-tc/TrustCenter/data/* ${core}/var/lib/littlebird-tc/

	# fix permissions
	chmod +x ${core}/usr/share/littlebird-tc/TrustCenter/scripts/install_update_db

#	find ${core} ${common} ${sql} -type f -exec chmod a-x {} +
#	find ${core} ${common} ${sql} -type f \
#		\( -name '*.sh' -o -path '*/scripts/*' \) \
#		-exec ${SHELL} -c 'file {} | grep -q executable' \; -exec chmod +x {} \;

override_dh_link:
	@dh_link
	for dir in ${core}/var/lib/littlebird-tc/*; do \
	    dir=`basename $$dir`; \
	    dh_link --package littlebird-tc-core /var/lib/littlebird-tc/$$dir /usr/share/littlebird-tc/TrustCenter/data/$$dir ;\
	done
		



# to speed up things during build process
override_dh_strip: ; true
override_dh_shlibdeps: ; true
