#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/vendor.mk

NULL       =
DH_VERBOSE =1

%:
	dh $@

override_dh_compress:
	dh_compress
	gzip -d debian/gosa/usr/share/doc/gosa/gosa.conf.gz

override_dh_install:

	# Run dh_install first...
	dh_install

	# don't use embedded fonts, use font package files from Debian
	mkdir -p debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSerif-Italic.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSans-Italic.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationMono-Italic.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSerif-BoldItalic.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSans-BoldItalic.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationMono-BoldItalic.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts
	ln -sf /usr/share/fonts/truetype/liberation/LiberationSerif-Bold.ttf debian/gosa/usr/share/gosa/html/themes/classic/fonts

	# symlink to Debian's libjs-scriptaculous package
	mkdir -p debian/gosa/usr/share/gosa/html/include
	ln -sf /usr/share/javascript/scriptaculous/effects.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/controls.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/dragdrop.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/unittest.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/slider.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/scriptaculous.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/sound.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/builder.js debian/gosa/usr/share/gosa/html/include/
	ln -sf /usr/share/javascript/scriptaculous/prototype.js debian/gosa/usr/share/gosa/html/include/

	# symlink the smarty-gettext plugin
	ln -sf /usr/share/php/smarty4/plugins/block.t.php debian/gosa/usr/share/gosa/include/smartyAddons/

	# remove unneeded files
	rm debian/gosa/usr/share/gosa/html/themes/default/LICENSE
	rm debian/gosa/usr/share/gosa/html/themes/default/README.md
	rm debian/gosa/usr/share/gosa/html/themes/default/font/README.md

	# don't ship generated files in the bin:pkg gosa
	rm debian/gosa/usr/share/gosa/html/themes/classic/images/img.png
	rm debian/gosa/usr/share/gosa/html/themes/default/images/img.png
	rm debian/gosa/usr/share/gosa/ihtml/themes/classic/img.styles
	rm debian/gosa/usr/share/gosa/ihtml/themes/default/img.styles

	# Create gosa.version file
	echo "GOsa² 2.8 [gosa $(DEB_VERSION), $(DEB_VENDOR)]" > debian/gosa/usr/share/gosa/gosa.version

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --repack --destdir=..
