#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

%:
	dh  $@

get-orig-source:
	if [ -d "../../tarballs" ]; then \
		uscan --download-current-version --force-download --rename --destdir ../../tarballs/ ; \
        else \
		uscan --download-current-version --force-download --rename ; \
	fi;

override_dh_installdebconf:
	cp debian/dotlrn.sh debian/dotlrn/etc/dotlrn/
 
	# Deleting extra licenses	
	rm debian/dotlrn/usr/share/dotlrn/license.txt
	rm debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/htmlarea/license.txt
	rm debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/xinha-nightly/license.txt
	rm debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/license.txt
	rm debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/xinha-nightly/iconsets/Crystal/LICENSE

	# Deleting some unneeded files
	rm debian/dotlrn/var/log/aolserver4/dotlrn/log.txt
	rm debian/dotlrn/usr/share/dotlrn/packages/theme-selva/www/resources/Selva/default/images/.DS_Store
	rm debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/xinha-nightly/plugins/ImageManager/img/Thumbs.db

	# Fixing permissions
	find debian/dotlrn/usr -type f -exec chmod 0644 {} \;
	find debian/dotlrn/usr -type d -exec chmod 0755 {} \;
	find debian/dotlrn/usr -type f -name *.pl -exec chmod 0755 {} \;         # Perl scripts +x
	find debian/dotlrn/usr -type f -name *.sh -exec chmod 0755 {} \;         # Shell scripts +x
	chmod 0755 debian/dotlrn/etc/dotlrn/install/checkout.sh \
		debian/dotlrn/etc/dotlrn/install/post-checkout-script.sh \
		debian/dotlrn/usr/share/dotlrn/bin/create-tablespace.tcl \
		debian/dotlrn/usr/share/dotlrn/bin/restart-aolserver \
		debian/dotlrn/usr/share/dotlrn/bin/webspell \
		debian/dotlrn/usr/share/dotlrn/packages/acs-lang/bin/mygrep \
		debian/dotlrn/etc/dotlrn/dotlrn.sh \
		debian/dotlrn/etc/dotlrn/install/build-release.sh \
		debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/htmlarea/examples/2-areas.cgi \
		debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/htmlarea/examples/test.cgi \
		debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/htmlarea/plugins/SpellChecker/spell-check-logic.cgi \
		debian/dotlrn/usr/share/dotlrn/packages/acs-templating/www/resources/xinha-nightly/plugins/SpellChecker/spell-check-logic.cgi

	# Continue as normal... 
	dh_installdebconf	

override_dh_fixperms:
	dh_fixperms
	# config.tcl stores passwords!
	chmod o-rwx debian/dotlrn/etc/dotlrn/config.tcl                  

