From efb60ab9eac3c3051416f9273c67990b58ac9db2 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Mon, 1 Aug 2011 18:22:25 +0000
Subject: [PATCH] Work on debian package

---
 build/deb/README                     |   5 +-
 build/deb/config                     |  11 ++-
 build/deb/control.debian             |  10 ++-
 build/deb/copyright                  |   7 +-
 build/deb/dolibarr.lintian-overrides |   9 +++
 build/deb/install                    |   1 +
 build/deb/lighttpd.conf              |  22 +++++
 build/deb/po/fr.po                   |  22 ++++-
 build/deb/po/templates.pot           |  20 ++++-
 build/deb/postinst                   | 108 +++++++++++++++----------
 build/deb/postrm                     | 117 +++++++++++++--------------
 build/deb/templates                  |   7 ++
 build/makepack-dolibarr.pl           |  36 ++++++---
 13 files changed, 248 insertions(+), 127 deletions(-)
 create mode 100755 build/deb/dolibarr.lintian-overrides
 create mode 100755 build/deb/lighttpd.conf

diff --git a/build/deb/README b/build/deb/README
index edb46ffd5a3..d73d7a99219 100644
--- a/build/deb/README
+++ b/build/deb/README
@@ -22,12 +22,13 @@ with format .DEB (for Debian, Ubuntu, ...).
 # lintian --pedantic -E -I package.deb   To test a package   
 #
 # dpkg -l                                List all packages
-# dpkg -b                                To build package
+# dpkg -b                                To build binary only package
 # dpkg -c package.deb                    List content of package
 # dpkg -I package.deb                    Give informations on package
 # dpkg -i package.deb                    Install a package
-#
+# dpkg-reconfigure -plow package		 Reconfigure package
 # dpkg -L packagename                    List content of installed package 
+# dpkg -r packagename                    Remove config files and interactive saved answers
 # dpkg --purge                           Remove config files and interactive saved answers
 #
 # dpkg-buildpackage -us -uc              Build a source and binary package
diff --git a/build/deb/config b/build/deb/config
index 1965ef73cc5..fd5ea96491b 100644
--- a/build/deb/config
+++ b/build/deb/config
@@ -22,7 +22,16 @@ if [ "$1" = "reconfigure" ] ; then
 	done
 	mv ${config} ${config}.0
 fi
-
+# Rotate old configuration
+if [ "$1" = "reconfigure" ] ; then
+	config="/etc/dolibarr/lighttpd.conf"
+	for i in $(seq 8 -1 0) ; do
+		if [ -f ${config}.$i ] ; then
+			mv ${config}.$i ${config}.$(($i +1))
+		fi
+	done
+	mv ${config} ${config}.0
+fi
 
 
 db_capb backup
diff --git a/build/deb/control.debian b/build/deb/control.debian
index 91f0705c001..e28258d8dbc 100755
--- a/build/deb/control.debian
+++ b/build/deb/control.debian
@@ -4,10 +4,16 @@ Standards-Version: 3.9.1
 Section: web
 Priority: optional
 Homepage: http://www.dolibarr.org
-Build-Depends: debhelper, po-debconf
+Build-Depends: debhelper (>= 7), po-debconf
 
 Package: dolibarr
-Depends: ${misc:Depends}, xdg-utils, apache2, libapache2-mod-php5, php5, php5-cli, php5-cgi, php5-curl, php5-gd, php5-ldap, php5-mysql, php-pear, php-mail-mime, mysql-server, perl
+Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | php5,
+    php5-mysql | php5-mysqli, 
+    php5-cli, php5-cgi, php5-curl, php5-gd, php5-ldap, php-pear, php-mail-mime,
+    ${misc:Depends}, xdg-utils,
+    mysql-server, perl
+Recommends: apache2 | lighttpd | httpd, mysql-client
+Suggests: www-browser
 Architecture: all
 Section: web
 Priority: optional
diff --git a/build/deb/copyright b/build/deb/copyright
index c69ae11a4a6..7a7e752fe43 100644
--- a/build/deb/copyright
+++ b/build/deb/copyright
@@ -44,7 +44,9 @@ Copyright: 2002-2009, Rodolphe Quiedeville   <rodolphe@quiedeville.org>
  On Debian systems, the full text of the GNU General Public
  License version 2 can be found in the file
  `/usr/share/common-licenses/GPL-2'.
- 
+ Full text of Lesser General Public Licence version 3 can be 
+ found in the file
+ `/usr/share/common-licenses/LGPL-3'.
  
 Files: htdocs/includes/artichow/*
 License: Public Domain
@@ -64,6 +66,9 @@ License: GPL-2+
 Files: htdocs/includes/jquery/*
 License: GPL-2+ or MIT
 
+Files: htdocs/includes/jquery/plugins/flot/*
+License: Public Domain
+
 Files: htdocs/includes/jsgantt/*
 License: GPL-2+
 
diff --git a/build/deb/dolibarr.lintian-overrides b/build/deb/dolibarr.lintian-overrides
new file mode 100755
index 00000000000..9022acc3e75
--- /dev/null
+++ b/build/deb/dolibarr.lintian-overrides
@@ -0,0 +1,9 @@
+# embedded libraries, which don't seem to be available in Debian in correct version
+# or because they were modified and are specific dolibarr code
+embedded-javascript-library usr/share/dolibarr/htdocs/includes/ckeditor/adapters/jquery.js
+embedded-javascript-library usr/share/dolibarr/htdocs/includes/ckeditor/ckeditor.js
+embedded-javascript-library usr/share/dolibarr/htdocs/includes/fckeditor/fckeditor.js
+embedded-php-library usr/share/dolibarr/htdocs/includes/magpierss/extlib/Snoopy.class.inc
+embedded-php-library usr/share/dolibarr/htdocs/includes/magpierss/rss_parse.inc
+embedded-php-library usr/share/dolibarr/htdocs/includes/nusoap/lib/nusoap.php
+embedded-php-library usr/share/dolibarr/htdocs/includes/odtphp/zip/pclzip/pclzip.lib.php
\ No newline at end of file
diff --git a/build/deb/install b/build/deb/install
index 4d41fd52c65..2928d378abc 100755
--- a/build/deb/install
+++ b/build/deb/install
@@ -1,4 +1,5 @@
 etc/dolibarr/apache.conf
+etc/dolibarr/lighttpd.conf
 usr/share/applications/dolibarr.desktop
 usr/share/doc/dolibarr
 usr/share/dolibarr
diff --git a/build/deb/lighttpd.conf b/build/deb/lighttpd.conf
new file mode 100755
index 00000000000..e3d1bdfce7e
--- /dev/null
+++ b/build/deb/lighttpd.conf
@@ -0,0 +1,22 @@
+# Alias for dolibarr directory
+alias.url += ( 
+	"/dolibarr" => "/usr/share/dolibarr/htdocs",
+)
+
+# Disallow access to libraries
+#$HTTP["url"] =~ "^/dolibarr/libraries" { 
+#    url.access-deny = ( "" ) 
+#}
+
+# Limit access to setup script
+#$HTTP["url"] =~ "^/dolibarr/setup" {
+#	auth.backend = "htpasswd"
+#	auth.backend.htpasswd.userfile = "/etc/dolibarr/htpasswd.setup"
+#	auth.require = (
+#		"/" => (
+#			"method" => "basic",
+#			"realm" => "Dolibarr Setup",
+#			"require" => "valid-user"
+#		)
+#	)
+#}
diff --git a/build/deb/po/fr.po b/build/deb/po/fr.po
index 13b8030ed0d..3bbe762283a 100755
--- a/build/deb/po/fr.po
+++ b/build/deb/po/fr.po
@@ -15,7 +15,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 1.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-27 19:49+0200\n"
+"POT-Creation-Date: 2011-08-01 18:17+0200\n"
 "PO-Revision-Date: 2011-07-29 22:45+0100\n"
 "Last-Translator: Laurent Destailleur <eldy@users.sourceforge.net>\n"
 "Language-Team: Laurent Destailleur <eldy@users.sourceforge.net>\n"
@@ -25,10 +25,26 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Project-Id: dolibarr\n"
 
+#. Type: multiselect
+#. Description
+#: ../templates:1001
+msgid "Web server to reconfigure automatically:"
+msgstr "Seveur web à reconfigurer automatiquement:"
+
+#. Type: multiselect
+#. Description
+#: ../templates:1001
+msgid ""
+"Please choose the web server that should be automatically configured to run "
+"dolibarr."
+msgstr ""
+"Selectionnez le serveur web à configurer automatiquement pour utiliser "
+"dolibarr."
+
 #
 #. Type: boolean
 #. Description
-#: ../templates:1001
+#: ../templates:2001
 #, fuzzy
 msgid "Delete database and uploaded files ?"
 msgstr "Effacer la base de donnée et les fichiers uploadés ?"
@@ -36,7 +52,7 @@ msgstr "Effacer la base de donnée et les fichiers uploadés ?"
 #
 #. Type: boolean
 #. Description
-#: ../templates:1001
+#: ../templates:2001
 #, fuzzy
 msgid ""
 "Answer if you want to removed the Dolibarr MySQL database and all other "
diff --git a/build/deb/po/templates.pot b/build/deb/po/templates.pot
index 32c92a97cc4..d65e5d8b7f6 100755
--- a/build/deb/po/templates.pot
+++ b/build/deb/po/templates.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-27 19:52+0200\n"
+"POT-Creation-Date: 2011-08-01 18:17+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,15 +17,29 @@ msgstr ""
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#. Type: boolean
+#. Type: multiselect
+#. Description
+#: ../templates:1001
+msgid "Web server to reconfigure automatically:"
+msgstr ""
+
+#. Type: multiselect
 #. Description
 #: ../templates:1001
+msgid ""
+"Please choose the web server that should be automatically configured to run "
+"dolibarr."
+msgstr ""
+
+#. Type: boolean
+#. Description
+#: ../templates:2001
 msgid "Delete database and uploaded files ?"
 msgstr ""
 
 #. Type: boolean
 #. Description
-#: ../templates:1001
+#: ../templates:2001
 msgid ""
 "Answer if you want to removed the Dolibarr MySQL database and all other "
 "datas (datas related to this question are the Dolibarr DBMS account, all "
diff --git a/build/deb/postinst b/build/deb/postinst
index ca5fd1645dd..9f103d8876d 100644
--- a/build/deb/postinst
+++ b/build/deb/postinst
@@ -1,7 +1,5 @@
 #!/bin/sh
 # postinst script for dolibarr
-#
-# see: dh_installdeb(1)
 
 set -e
 
@@ -16,6 +14,31 @@ set -e
 # for details, see /usr/share/doc/packaging-manual/
 
 
+
+
+lighttpd_install() {
+	if [ ! -f /etc/lighttpd/conf-available/50-dolibarr.conf ] ; then
+		if which lighty-enable-mod >/dev/null 2>&1 ; then
+			echo "Add link for Lighttpd config file"
+			ln -s /etc/dolibarr/lighttpd.conf /etc/lighttpd/conf-available/50-dolibarr.conf
+			# We enabled it
+			lighty-enable-mod dolibarr fastcgi-php
+		else
+			echo "Lighttpd not installed, skipping"
+		fi
+	fi
+}
+
+apache_install() {
+	webserver=$1
+	if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/dolibarr.conf ]; then
+		echo "Add link for Apache config file"
+		ln -s /etc/dolibarr/apache.conf /etc/$webserver/conf.d/dolibarr.conf
+	fi
+}
+
+
+
 . /usr/share/debconf/confmodule
 
 db_version 2.0
@@ -27,8 +50,6 @@ echo Run the dolibarr postinst script
 # Define vars
 docdir='/var/lib/dolibarr/documents'
 #docdir='/usr/share/dolibarr/documents'
-apachefileorig="/usr/share/dolibarr/build/deb/apache.conf"
-apacheconfig="/etc/dolibarr/apache.conf"
 installfileorig="/usr/share/dolibarr/build/deb/install.forced.php.install"
 installconfig="/etc/dolibarr/install.forced.php"
 #config="/usr/share/dolibarr/htdocs/conf/conf.php"
@@ -44,10 +65,6 @@ case "$1" in
         chmod -R 775 $docdir
         chmod -R g+s $docdir
 
-		# Copy apache.conf file into target directory
-		#mkdir -p /etc/dolibarr
-		#cp -p $apachefileorig $apacheconfig
-
 		# Copy install config file (with matching Debian) values into target directory
 		superuserlogin=''
 		superuserpassword=''
@@ -74,21 +91,23 @@ case "$1" in
 	    	chmod -R 660 $config
 		fi
 
-		# Get the web server type (use db_get for interactive mode).
-		#db_reset "dolibarr/webserver"
-		#db_get "dolibarr/webserver"		# Read value for webserver.
-		#webserver="$RET"
-
-		case $webserver in
-			Apache)		webservers="apache2" ;;
-			Apache-SSL)	webservers="apache2-ssl" ;;
-			Both)		webservers="apache2 apache2-ssl" ;;
-			*)		    webservers="apache2 apache2-ssl" ;;
-		esac
-
+	
+		# Reconfigure web server
+		db_reset dolibarr/reconfigure-webserver
+		
+		# Ask if we must delete database
+		echo "Ask for web server to setup"
+		db_input critical dolibarr/reconfigure-webserver || true
+		db_go || true
+		
+		db_get dolibarr/reconfigure-webserver
+	
+		webservers="$RET"
+	
 		# Set up web server.
-		for server in $webservers ; do
-			echo Complete config of server $server
+		for webserver in $webservers ; do
+			webserver=${webserver%,}
+			echo Complete config of server $webserver
 			
 			# Detect webuser and webgroup
 			webuser=
@@ -106,26 +125,31 @@ case "$1" in
 			# Set permissions to web server
 			chown -R $webuser:$webgroup /usr/share/dolibarr
             chown -R root:$webgroup $config
-
-			# Add link to config file
-            echo Setup web server $server to add dolibarr config file
-			ln -fs /etc/dolibarr/apache.conf /etc/apache2/conf.d/dolibarr.conf
-			
 		done
 
-		# Restart servers
-		servers="apache2-ssl apache2 mysql"
-		# Another way to restart
-		for server in $servers ; do
-    		if [ -x /usr/sbin/invoke-rc.d ]; then
-                echo Restart web server $server using invoke-rc.d
-    		    # This works with Debian (5.05,...) and Ubuntu (9.10,10.04,...)
-    	    	invoke-rc.d $server reload || true
-    		else
-                echo Restart web server $server using $server reload
-    	    	/etc/init.d/$server reload || true
-    		fi
+		# Restart web server.
+		for webserver in $webservers; do
+			webserver=${webserver%,}
+			if [ "$webserver" = "lighttpd" ] ; then
+				lighttpd_install
+			else
+				apache_install $webserver
+			fi
+			# Reload webserver in any case, configuration might have changed
+			# Redirection of 3 is needed because Debconf uses it and it might 
+			# be inherited by webserver. See bug #446324.
+	        if [ -f /etc/init.d/$webserver ] ; then
+	            if [ -x /usr/sbin/invoke-rc.d ]; then
+    	            echo Restart web server $server using invoke-rc.d
+	    		    # This works with Debian (5.05,...) and Ubuntu (9.10,10.04,...)
+	                invoke-rc.d $webserver reload 3>/dev/null || true
+	            else
+	                echo Restart web server $server using $server reload
+	                /etc/init.d/$webserver reload 3>/dev/null || true
+	            fi
+	        fi
 		done
+
 		
 		echo ----------
 		echo "Call Dolibarr page http://localhost/dolibarr/ to complete the installation and use Dolibarr."
@@ -136,13 +160,13 @@ case "$1" in
 	;;
 
 	*)
-		echo "postinst called with unknown argument \`$1'" >&2
+		echo "postinst called with unknown argument $1" >&2
 		exit 0
 	;;
 esac
 
-db_stop
-
 #DEBHELPER#
 
+db_stop
+
 exit 0
diff --git a/build/deb/postrm b/build/deb/postrm
index 9eae81b022b..dd05ee90379 100644
--- a/build/deb/postrm
+++ b/build/deb/postrm
@@ -17,7 +17,36 @@ set -e
 # for details, see /usr/share/doc/packaging-manual/
 
 
-. /usr/share/debconf/confmodule
+
+lighttpd_remove() {
+	if [ -f /etc/lighttpd/conf-available/50-dolibarr.conf ] ; then
+		echo "Remove link for Lighttpd config file"
+		rm -f /etc/lighttpd/conf-available/50-dolibarr.conf
+		if which lighty-enable-mod >/dev/null 2>&1 ; then
+			lighty-disable-mod dolibarr
+		else
+			echo "Lighttpd not installed, skipping"
+		fi
+		# See bug #448682
+		if [ -h /etc/lighttpd/conf-enabled/50-dolibarr.conf ] ; then
+		    echo 'Manually deleting lighttpd/dolibarr configuration link'
+		    rm /etc/lighttpd/conf-enabled/50-dolibarr.conf
+		fi
+	fi
+}
+
+apache_remove() {
+	if [ -d /etc/$webserver/conf.d ] && [ -L /etc/$webserver/conf.d/dolibarr.conf ]; then
+		echo "Remove link for Apache config file"
+		rm -f /etc/$webserver/conf.d/dolibarr.conf
+	fi
+}
+
+
+
+if [ -f /usr/share/debconf/confmodule ]; then
+    . /usr/share/debconf/confmodule
+fi
 
 db_version 2.0
 
@@ -26,22 +55,11 @@ echo Run the dolibarr postrm script
 
 docdir='/var/lib/dolibarr/documents'
 #docdir='/usr/share/dolibarr/documents'
-apachefileorig="/usr/share/dolibarr/build/deb/apache.conf"
-apacheconfig="/etc/dolibarr/apache.conf"
 #config="/usr/share/dolibarr/htdocs/conf/conf.php"
 config="/etc/dolibarr/conf.php"
 lockfile="/usr/share/dolibarr/install.lock"
 
 
-export webserver=""
-# Allows us to loop and substitute in one pass
-case $webserver in
-	Apache)		webservers="apache2" ;;
-	Apache-SSL)	webservers="apache2-ssl" ;;
-	Both)		webservers="apache2 apache2-ssl" ;;
-	*)		    webservers="apache2 apache2-ssl" ;;
-esac
-
 
 case "$1" in
 
@@ -53,36 +71,44 @@ case "$1" in
 	remove)
 		rm -f $lockfile
 
-		# Remove include files
-		export restart=""
-		for server in $webservers ; do
-			export conffile="/etc/$server/conf.d/dolibarr.conf"
-            if [ -f $conffile ] ;
-            then
-               echo Delete link $conffile
-	           rm -f $conffile
-	           status=purge
-		    fi
-			
-			if [ "x$status" = "xpurge" ] ;
-				then restart="$restart $server"
+		# Reconfigure web server
+		db_get dolibarr/reconfigure-webserver
+
+		webservers="$RET"
+
+		# Restart web servers
+		for webserver in $webservers; do
+			webserver=${webserver%,}
+			if [ "$webserver" = "lighttpd" ] ; then
+				lighttpd_remove
+			else
+				apache_remove $webserver
+			fi
+			# Redirection of 3 is needed because Debconf uses it and it might 
+			# be inherited by webserver. See bug #446324.
+			if [ -f /etc/init.d/$webserver ] ; then
+				if [ -x /usr/sbin/invoke-rc.d ]; then
+					invoke-rc.d $webserver reload 3>/dev/null || true
+				else
+					/etc/init.d/$webserver reload 3>/dev/null || true
+				fi
 			fi
 		done
 	;;
 
     # Call when we uninstall and purge
 	purge)
-		echo "postrm purge webservers=$webservers apacheconfig=$apacheconfig"
+		echo "postrm purge webservers=$webservers"
 
 		# Ask if we must delete database
 		echo "postrm db_input dolibarr/postrm"
-		db_input critical "dolibarr/postrm" || true
+		db_input critical dolibarr/postrm || true
 		db_go || true
 
 		echo "postrm db_get dolibarr/postrm"
 		# We disable set -e to avoid premature end of script if error
 		set +e
-		db_get "dolibarr/postrm"
+		db_get dolibarr/postrm
 		set -e
 	
 		if [ "$RET" = "true" ] ; then
@@ -185,41 +211,12 @@ case "$1" in
 			echo "postrm Delete of dolibarr database and uploaded files not wanted" 
 		fi
 	
-		# Remove include files
-		export restart=""
-		for server in $webservers ; do
-			export conffile="/etc/$server/conf.d/dolibarr.conf"
-            if [ -f $conffile ] ;
-            then
-               echo Delete file $conffile
-	           rm -f $conffile
-	           status=purge
-		    fi
-			
-			if [ "x$status" = "xpurge" ] ;
-				then restart="$restart $server"
-			fi
-		done
-
 		rm -rf /etc/dolibarr
 
-		# Restart servers
-		for server in $restart ; do
-            # We disable blocking errors
-            set +e
-            echo "Restart server $server if exists"
-    		if [ -x /usr/sbin/invoke-rc.d ]; then
-    		     invoke-rc.d $server reload || true
-    		else
-    		     /etc/init.d/$server reload || true
-    		fi
-    		# We restore blocking errors
-    		set -e
-		done
-		
 		# We clean variable (we ignore errors because db_reset can fails if var was never set)
         set +e
-		db_reset "dolibarr/postrm"
+		db_reset dolibarr/reconfigure-webserver
+		db_reset dolibarr/postrm
         set -e
 
 		#db_purge
@@ -229,7 +226,7 @@ case "$1" in
 	;;
 
 	*)
-		echo "postrm called with unknown argument \`$1'" >&2
+		echo "postrm called with unknown argument $1" >&2
 		exit 0
 	;;
 esac
diff --git a/build/deb/templates b/build/deb/templates
index 5c06afd8ccd..b96325a4e64 100644
--- a/build/deb/templates
+++ b/build/deb/templates
@@ -1,3 +1,10 @@
+Template: dolibarr/reconfigure-webserver
+Type: multiselect
+Choices: apache2, lighttpd
+_Description: Web server to reconfigure automatically:
+ Please choose the web server that should be automatically configured
+ to run dolibarr.
+
 Template: dolibarr/postrm
 Type: boolean
 Default: true
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index d3c47e6b28d..20c5ba415e9 100644
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -2,7 +2,7 @@
 #----------------------------------------------------------------------------
 # \file         build/makepack-dolibarr.pl
 # \brief        Dolibarr package builder (tgz, zip, rpm, deb, exe, aps)
-# \version      $Id: makepack-dolibarr.pl,v 1.128 2011/07/31 22:08:13 eldy Exp $
+# \version      $Id: makepack-dolibarr.pl,v 1.129 2011/08/01 18:22:26 eldy Exp $
 # \author       (c)2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
 #----------------------------------------------------------------------------
 
@@ -48,7 +48,7 @@ if (-d "/usr/src/RPM") {
 
 
 use vars qw/ $REVISION $VERSION /;
-$REVISION='$Revision: 1.128 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
+$REVISION='$Revision: 1.129 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
 $VERSION="1.0 (build $REVISION)";
 
 
@@ -318,6 +318,9 @@ if ($nboftargetok) {
         $ret=`rm -fr  $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`;
         #$ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils/pfm2afm`;
         #$ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils/ttf2ufm`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/flot/jquery.js`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/flot/jquery.min.js`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/jcrop/js/jquery.min.js`;
 	}
     
     # Build package for each target
@@ -569,6 +572,8 @@ if ($nboftargetok) {
     	
     	if ($target eq 'DEB') 
     	{
+            $olddir=getcwd();
+
             $newbuild = $BUILD;
             $newbuild =~ s/(dev|alpha)/1/gi;                # dev
             $newbuild =~ s/beta/2/gi;                       # beta
@@ -671,19 +676,22 @@ if ($nboftargetok) {
             $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/.svn`;
             $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip/.svn`;
             $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/smarty`;
-		    
+		    $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/fckeditor/license.txt`;
+		    $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/jquery/plugins/flot/LICENSE.txt`;
+		    $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/php_writeexcel/LICENSE`;
+		    $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/tcpdf/LICENSE.TXT`;
             $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/COPYING`;
             $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/barcode/php-barcode/genbarcode/genbarcode`;
             # To remove once stable
             $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/htdocs/theme/bureau2crea`;
 
-			# Apache conf files
+			# Apache and lighttpd conf files
     		print "Copy apache.conf file into $BUILDROOT/$PROJECT.tmp/etc/$PROJECT/apache.conf\n";
     		$ret=`mkdir -p "$BUILDROOT/$PROJECT.tmp/etc/$PROJECT"`;
     		$ret=`cp "$SOURCE/build/deb/apache.conf" "$BUILDROOT/$PROJECT.tmp/etc/$PROJECT/apache.conf"`;
-
-			# Dolibarr conf files
-			# TODO
+    		print "Copy lighttpd.conf file into $BUILDROOT/$PROJECT.tmp/etc/$PROJECT/lighttpd.conf\n";
+    		$ret=`mkdir -p "$BUILDROOT/$PROJECT.tmp/etc/$PROJECT"`;
+    		$ret=`cp "$SOURCE/build/deb/lighttpd.conf" "$BUILDROOT/$PROJECT.tmp/etc/$PROJECT/lighttpd.conf"`;
 
 			# dolibarr.desktop
 	   		print "Create directory $BUILDROOT/$PROJECT.tmp/usr/share/applications\n";
@@ -729,17 +737,15 @@ if ($nboftargetok) {
             $cmd="find $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts -name '*.pl' -type f -exec chmod 755 {} \\; ";
             $ret=`$cmd`;
             
-     		print "Go to directory $BUILDROOT\n";
-            $olddir=getcwd();
-     		chdir("$BUILDROOT");
- 
-            # Creation of binary package (to build without sources)
+             # Creation of binary package (to build without sources)
+     		#print "Go to directory $BUILDROOT\n";
+     		#chdir("$BUILDROOT");
     		#$cmd="dpkg -b $BUILDROOT/$PROJECT.tmp $BUILDROOT/${FILENAMEDEB}_all.deb";
     		#print "Launch DEB build ($cmd)\n";
     		#$ret=`$cmd`;
     		#print $ret."\n";
 
-            # Creation of source package
+            # Prepare source package
             print "Create directory $BUILDROOT/$PROJECT.tmp/debian\n";
             $ret=`mkdir "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`mkdir "$BUILDROOT/$PROJECT.tmp/debian/source"`;
@@ -751,6 +757,7 @@ if ($nboftargetok) {
             $ret=`cp -f  "$SOURCE/build/deb/README.debian"  "$BUILDROOT/$PROJECT.tmp/usr/share/doc/dolibarr/README"`;
             $ret=`cp -f  "$SOURCE/build/deb/changelog"      "$BUILDROOT/$PROJECT.tmp/debian/changelog"`;
             $ret=`cp -f  "$SOURCE/build/deb/control.debian" "$BUILDROOT/$PROJECT.tmp/debian/control"`;
+            $ret=`cp -f  "$SOURCE/build/deb/dolibarr.lintian-overrides"        "$BUILDROOT/$PROJECT.tmp/debian/dolibarr.lintian-overrides"`;
             $ret=`cp -f  "$SOURCE/build/deb/install"        "$BUILDROOT/$PROJECT.tmp/debian/install"`;
             $ret=`cp -f  "$SOURCE/build/deb/rules"          "$BUILDROOT/$PROJECT.tmp/debian/rules"`;
             $ret=`cp -f  "$SOURCE/build/deb/copyright"      "$BUILDROOT/$PROJECT.tmp/debian/copyright"`;
@@ -766,6 +773,9 @@ if ($nboftargetok) {
             
             $cmd="mv $BUILDROOT/$PROJECT.tmp $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build";
             $ret=`$cmd`;
+
+			# Creation of source package          
+     		print "Go to directory $BUILDROOT\n";
             chdir("$BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build");
             #$cmd="dpkg-source -b $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build";
             $cmd="dpkg-buildpackage -us -uc";
-- 
GitLab