#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpatch/dpatch.make

build:

clean: clean1 unpatch
clean1:
	dh_testdir
	dh_testroot

	dh_clean 

install: patch-stamp
	dh_testdir
	dh_testroot
	dh_clean -k 
	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_installinit
#	dh_installcron
	dh_lintian

	# 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
	
	# 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/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