#!/usr/bin/make -f

%:
	dh $@

override_dh_install:
	dh_install
	# Remove embedded libraries that we don't use
	cd debian/dolibarr/usr/share/dolibarr/htdocs/includes/ && \
	rm -rf fonts && \
	rm -rf tcpdf && \
	rm -rf nusoap && \
	rm -rf fpdfi && \
	rm -rf adodbtime && \
	rm -rf jquery/css && \
	rm -rf jquery/js && \
	rm -rf jquery/plugins/flot && \
	rm -rf jquery/plugins/multiselect && \
	rm -rf ckeditor && \
	rm -rf odtphp/zip/pclzip
	# Drop unwanted executable permissions
	find debian/dolibarr/usr/share/dolibarr/htdocs -type f -print0 | \
	     xargs -0 chmod 644
	# Add missing executable permissions
	find debian/dolibarr/usr/share/dolibarr/scripts -type f -name '*.php' -print0 | \
	     xargs -0 chmod 755

override_dh_fixperms:
	dh_fixperms
	# Give rights to the webserver on the upload directory
	chown www-data:www-data debian/dolibarr/var/lib/dolibarr/documents
	chmod 2775 debian/dolibarr/var/lib/dolibarr/documents
