#!/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/openacs.sh debian/openacs/etc/openacs/

	# Deleting extra licenses       
	rm debian/openacs/usr/share/openacs/license.txt
	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/license.txt
	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/license.txt
	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/license.txt
	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/iconsets/Crystal/LICENSE
	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/plugins/MootoolsFileManager/mootools-filemanager/LICENSE
     
	# Deleting some unneeded files
	rm debian/openacs/var/log/aolserver4/openacs/log.txt
	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/plugins/ImageManager/img/Thumbs.db
 
	# Fixing permissions
	find debian/openacs/usr -type f -exec chmod 0644 {} \;
	find debian/openacs/usr -type d -exec chmod 0755 {} \;
	find debian/openacs/usr -type f -name *.pl -exec chmod 0755 {} \;         # Perl scripts +x
	find debian/openacs/usr -type f -name *.sh -exec chmod 0755 {} \;         # Shell scripts +x
	chmod 0755 debian/openacs/etc/openacs/install/checkout.sh \
		debian/openacs/etc/openacs/install/post-checkout-script.sh \
		debian/openacs/etc/openacs/openacs.sh \
		debian/openacs/usr/share/openacs/bin/create-tablespace.tcl \
		debian/openacs/usr/share/openacs/bin/restart-aolserver \
		debian/openacs/usr/share/openacs/bin/webspell \
		debian/openacs/usr/share/openacs/packages/acs-lang/bin/mygrep \
		debian/openacs/etc/openacs/install/build-release.sh \
		debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/examples/2-areas.cgi \
		debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/examples/test.cgi \
		debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/plugins/SpellChecker/spell-check-logic.cgi \
		debian/openacs/usr/share/openacs/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/openacs/etc/openacs/config.tcl

 
# # 
# # build: build-arch build-indep
# # build-arch: build-stamp
# # build-indep: build-stamp
# # build-stamp:
# # 
# # clean: clean1 unpatch
# # clean1:
# # 	dh_testdir
# # 	dh_testroot
# # 
# # 	dh_clean 
# # 
# # install: patch-stamp
# # 	dh_testdir
# # 	dh_testroot
# # 	dh_prep
# # 	dh_installdirs
# # 
# # # Build architecture-dependent files here.
# # binary-arch: install
# # # We have nothing to do by default.
# # 
# # # Build architecture-independent files here.
# # binary-indep: install
# # 	dh_testdir
# # 	dh_testroot
# # 	dh_installchangelogs
# # 	dh_installdocs
# # 	dh_install
# # 	dh_lintian
# # 
# # 	cp debian/openacs.sh debian/openacs/etc/openacs/
# # 
# # 	# Deleting extra licenses	
# # 	rm debian/openacs/usr/share/openacs/license.txt
# # 	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/license.txt
# # 	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/license.txt
# # 	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/license.txt
# # 	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/iconsets/Crystal/LICENSE
# # 	
# # 	# Deleting some unneeded files
# # 	rm debian/openacs/var/log/aolserver4/openacs/log.txt
# # 	rm debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/plugins/ImageManager/img/Thumbs.db
# # 
# # 	# Setting up correct permissions
# # 	find debian/openacs/usr -type f -exec chmod 0644 {} \;
# # 	find debian/openacs/usr -type d -exec chmod 0755 {} \;
# # 	find debian/openacs/usr -type f -name *.pl -exec chmod 0755 {} \;         # Perl scripts +x
# # 	find debian/openacs/usr -type f -name *.sh -exec chmod 0755 {} \;         # Shell scripts +x
# # 	chmod 0755 debian/openacs/etc/openacs/install/checkout.sh \
# # 		debian/openacs/etc/openacs/install/post-checkout-script.sh \
# # 		debian/openacs/etc/openacs/openacs.sh \
# #  		debian/openacs/usr/share/openacs/bin/create-tablespace.tcl \
# # 		debian/openacs/usr/share/openacs/bin/restart-aolserver \
# # 		debian/openacs/usr/share/openacs/bin/webspell \
# # 		debian/openacs/usr/share/openacs/packages/acs-lang/bin/mygrep \
# # 		debian/openacs/etc/openacs/install/build-release.sh \
# # 		debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/examples/2-areas.cgi \
# # 		debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/examples/test.cgi \
# # 		debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/htmlarea/plugins/SpellChecker/spell-check-logic.cgi \
# # 		debian/openacs/usr/share/openacs/packages/acs-templating/www/resources/xinha-nightly/plugins/SpellChecker/spell-check-logic.cgi
# # 
# # 	dh_installdebconf	
# # 	dh_link
# # 	dh_compress
# # 	dh_fixperms
# # 	chmod o-rwx debian/openacs/etc/openacs/config.tcl                       # config.tcl stores passwords!!
# # 	dh_installdeb
# # 	dh_gencontrol
# # 	dh_md5sums
# # 	dh_builddeb
# # 
# # binary: binary-indep binary-arch
# # .PHONY: build clean binary-indep binary-arch binary install patch unpatch clean1
