From 563947f0b0a2ee76fcc659bd7d627cab3f0a4b12 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sun, 29 Jan 2012 20:56:40 +0100
Subject: [PATCH] Work on debian package

---
 ChangeLog                                 |   1 +
 build/debian/README.debian                | 103 --------
 build/debian/{README => README.howto}     |   0
 build/debian/control                      |   2 +-
 build/debian/copyright                    |  60 +----
 {doc/images => build/debian}/dolibarr.xpm |   0
 build/debian/install                      |  14 +-
 build/debian/rules                        |  30 ++-
 build/debian/wash                         |   3 +
 build/launchpad/README                    |  33 ++-
 build/makepack-dolibarr.pl                | 289 ++++++++++------------
 build/rpm/dolibarr-forrpm.patch           |   6 +-
 htdocs/filefunc.inc.php                   |   2 +-
 htdocs/install/inc.php                    |  37 +--
 htdocs/support/inc.php                    |  42 ++--
 15 files changed, 248 insertions(+), 374 deletions(-)
 delete mode 100755 build/debian/README.debian
 rename build/debian/{README => README.howto} (100%)
 rename {doc/images => build/debian}/dolibarr.xpm (100%)
 mode change 100644 => 100755 build/debian/rules

diff --git a/ChangeLog b/ChangeLog
index 1fcea7ca587..f5140e17a10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,7 @@ For users:
 - New: Chart are faster to build
 - New: Value of data into charts are visible on mouse hover.
 - New: Import wizard can import contacts.
+- New: Install process is now two times faster.
 - Fix: Can use POS module with several concurrent users.
 
 For developers:
diff --git a/build/debian/README.debian b/build/debian/README.debian
deleted file mode 100755
index a4dacc288af..00000000000
--- a/build/debian/README.debian
+++ /dev/null
@@ -1,103 +0,0 @@
-README (english)
---------------------------------
-Starter documentation
---------------------------------
-
-1) Install Dolibarr
-2) Upgrade Dolibarr from an older version
-3) What's new in this version
-4) What Dolibarr can do
-5) What Dolibarr can't do yet, todo list
-
-
-I - DOLIBARR INSTALL
---------------------
-
-Dolibarr files and its dependencies are automatically installed when you install
-the dolibarr Debian package.
-  
-Once package is installed, go on menu entry called Dolibarr or use your web browser
-to call page http://localhost/dolibarr
-
-
-
-II - DOLIBARR UPGRADE
----------------------
-
-Dolibarr files and its dependencies are automatically upgraded when you install
-the dolibarr Debian package.
-
-Once new package is installed, go on menu entry called Dolibarr or use your web browser
-to call page http://localhost/dolibarr
-If a database upgrade is required, you will be prompted to. 
-
-  
-
-III - WHAT'S NEW
-----------------
-
-See ChangeLog file.
-
-
-
-IV - WHAT DOLIBARR CAN DO
--------------------------
-
-Main modules/features:
-- Products and services catalog
-- Customers, Prospects or Suppliers directory
-- Address book
-- Stock management
-- Bank accounts management
-- Orders management with PDF export
-- Commercial proposals management with PDF export
-- Contracts management
-- Invoices management with PDF export
-- Payments management
-- Standing orders management
-- Shipping management
-- ECM (Electronic Content Management)
-- EMailings
-- Agenda with ical,vcal export for third tools integration
-- Management of foundation members
-- Donation management
-
-Other modules:
-- Bookmarks management
-- Can reports Dolibarr events inside Webcalendar or Phenix
-- Data export tools
-- LDAP connectivity
-- Third parties or products categories 
-- ClickToDial phone numbers
-- RSS
-
-Miscellanous:
-- Mutli-user, with several permissions levels for each feature.
-- Serveral menu managers (can be used by internal users, as a back-office,
-  with a particular menu, or by external users, as a front-office, with
-  another menu and permissions).
-- Very user friendly and easy to use.
-- Optional WYSIWYG forms, optional Ajax forms.
-- Several skins.
-- Code is highly customizable (a lot of use of modules and submodules).
-- Works with Mysql 3.1 or higher, experimental support for PostgreSql.
-- Works with PHP 4.3 or higher.
-- An easy to understand and maintain code (PHP with no heavy frameworks).
-- A trigger architecture to allow you to make Dolibarr business events run
-  PHP code to update your own information system.
-- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM 
-  called "Non Perçue Récupérable").
-
-
-
-V - WHAT DOLIBARR CAN'T DO YET (TODO LIST)
-------------------------------------------
-This is features that Dolibarr does not support completely yet:
-- Accountancy.
-- Dolibarr can manage only one currency.
-- Dolibarr does not support the double Canadian Tax.
-- Dolibarr does not make coffee (not yet).
-- Stock management with option increase/decrease on invoice works on
-  warehouse number one only (no way to choose warehouse).
-- Stock management with option increase/decrease on orders works on
-  warehouse number one only (no way to choose warehouse).
diff --git a/build/debian/README b/build/debian/README.howto
similarity index 100%
rename from build/debian/README
rename to build/debian/README.howto
diff --git a/build/debian/control b/build/debian/control
index 551cb4841db..e10b43f392d 100755
--- a/build/debian/control
+++ b/build/debian/control
@@ -4,7 +4,7 @@ Standards-Version: 3.9.2
 Section: web
 Priority: optional
 Homepage: http://www.dolibarr.org
-Build-Depends: debhelper (>= 7), po-debconf
+Build-Depends: debhelper (>= 7), po-debconf, dpatch
 
 Package: dolibarr
 Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | php5,
diff --git a/build/debian/copyright b/build/debian/copyright
index ac9bb33a07f..e63fa08b5db 100644
--- a/build/debian/copyright
+++ b/build/debian/copyright
@@ -36,39 +36,8 @@ License: GPL-2+
  PURPOSE.  See the GNU General Public License for more
  details.
  .
- You should have received a copy of the GNU General Public
- License along with this package; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA  02110-1301 USA
- .
- 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'.
-  
-Files: htdocs/includes/artichow/*
-Copyright: Artichow team
-License: Public Domain
- This work is not subject to copyright in any jurisdiction
-
-Files: htdocs/includes/ckeditor/*
-Copyright: CKeditor team
-License: GPL-2+
- This program is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later
- version.
- .
- This program is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE.  See the GNU General Public License for more
- details.
- .
- You should have received a copy of the GNU General Public
- License along with this package; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA  02110-1301 USA
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
  .
  On Debian systems, the full text of the GNU General Public
  License version 2 can be found in the file
@@ -89,10 +58,8 @@ License: GPL-2+
  PURPOSE.  See the GNU General Public License for more
  details.
  .
- You should have received a copy of the GNU General Public
- License along with this package; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA  02110-1301 USA
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
  .
  On Debian systems, the full text of the GNU General Public
  License version 2 can be found in the file
@@ -113,10 +80,8 @@ License: MIT or GPL-2+
  PURPOSE.  See the GNU General Public License for more
  details.
  .
- You should have received a copy of the GNU General Public
- License along with this package; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA  02110-1301 USA
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
  .
  On Debian systems, the full text of the GNU General Public
  License version 2 can be found in the file
@@ -160,10 +125,8 @@ License: GPL-2+
  PURPOSE.  See the GNU General Public License for more
  details.
  .
- You should have received a copy of the GNU General Public
- License along with this package; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA  02110-1301 USA
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
  .
  On Debian systems, the full text of the GNU General Public
  License version 2 can be found in the file
@@ -191,10 +154,8 @@ License: GPL-2+
  PURPOSE.  See the GNU General Public License for more
  details.
  .
- You should have received a copy of the GNU General Public
- License along with this package; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA  02110-1301 USA
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
  .
  On Debian systems, the full text of the GNU General Public
  License version 2 can be found in the file
@@ -204,4 +165,3 @@ Files: htdocs/includes/tcpdf/*
 Copyright: TCPDF team
 License: LGPL 3.0
   See http://www.gnu.org/licenses/old-licenses/lgpl-3.0-standalone.html
- 
\ No newline at end of file
diff --git a/doc/images/dolibarr.xpm b/build/debian/dolibarr.xpm
similarity index 100%
rename from doc/images/dolibarr.xpm
rename to build/debian/dolibarr.xpm
diff --git a/build/debian/install b/build/debian/install
index d3566d3a59e..6562bda4a37 100755
--- a/build/debian/install
+++ b/build/debian/install
@@ -1,6 +1,8 @@
-etc/dolibarr/apache.conf
-etc/dolibarr/lighttpd.conf
-usr/share/applications/dolibarr.desktop
-usr/share/dolibarr
-usr/share/doc/dolibarr
-usr/share/pixmaps
+debian/dolibarr.desktop usr/share/applications
+debian/dolibarr.xpm usr/share/pixmaps
+build/debian/apache.conf etc/dolibarr
+build/debian/lighttpd.conf etc/dolibarr
+build usr/share/dolibarr
+dev usr/share/dolibarr
+htdocs usr/share/dolibarr
+scripts usr/share/dolibarr
\ No newline at end of file
diff --git a/build/debian/rules b/build/debian/rules
old mode 100644
new mode 100755
index 9a3f9a98c7a..280ba8fde47
--- a/build/debian/rules
+++ b/build/debian/rules
@@ -6,5 +6,31 @@ export DH_OPTIONS=-v
 
 #export DH_COMPAT=7    # This is the debhelper compatability version to use, now defined into compat file
 
-%:
-	dh $@
\ No newline at end of file
+
+# use dpatch
+include /usr/share/dpatch/dpatch.make
+
+
+configure:
+	dh $@
+
+build: patch
+	dh $@
+
+build-arch: patch
+	dh $@
+
+build-indep: patch
+	dh $@
+
+binary:
+	dh $@
+
+binary-indep:
+	dh $@
+	
+clean:
+	dh $@
+
+binary-arch:
+	
\ No newline at end of file
diff --git a/build/debian/wash b/build/debian/wash
index e69de29bb2d..7d3ec07d7a5 100644
--- a/build/debian/wash
+++ b/build/debian/wash
@@ -0,0 +1,3 @@
+# watch control file for uscan
+#version=3
+#http://http://sourceforge.net/projects/dolibarr/files/Dolibarr%20installer%20for%20Debian-Ubuntu%20%28DoliDeb%29/ debian uupdate
diff --git a/build/launchpad/README b/build/launchpad/README
index 92bb699a8b0..b4428216dd5 100644
--- a/build/launchpad/README
+++ b/build/launchpad/README
@@ -17,22 +17,35 @@ To submit a package on LaunchPad:
 - Create Project
 - Link project to official SCM server
 - Upload SSH public key onto account
-- Run from command line: bzr launchpad-login yourlogin
-
-- Create a debian directory and upload it onto bzr branch ~yourlogin/dolibarr/debian
-
-- Create an empty directory dolibarr and go into it.
+- Run from command line: 
+    bzr launchpad-login yourlogin
+    bzr whoami "Your Name <email@email.com>"
+- Create a Bazzar directory
+    mkdir bzr
+- Create debian directory and upload it onto bzr branch ~yourlogin/dolibarr/debian
+    cd bzr
+    mkdir debian
+    cd debian
+    bzr init
+    cp -pr dolibarr_root/debian bzr/debian
+    bzr add debian
+    bzr commit
+    bzr push lp:~eldy/dolibarr/debian
+  or download it from launchpad bazaar:
+    cd bzr
+    bzr branch lp:~eldy/dolibarr/debian
 - Create a file dolibarr.recipe with content
-    # bzr-builder format 0.3 deb-version {debupstream}+{revno}+{revno:packaging}
-    lp:dolibarr
-    merge packaging lp:~eldy/dolibarr/debian
+    cd bzr
+    vi dolibarr.recipe
+        # bzr-builder format 0.3 deb-version {debupstream}+{revno}+{revno:packaging}
+        lp:dolibarr
+        merge packaging lp:~eldy/dolibarr/debian
 - Run command
+    cd bzr
     bzr dailydeb dolibarr.recipe working-dir
   This will create a directory "working-dir" with dolibarr sources and will add sources from ~eldy/dolibarr/debian
-
 - Create a file /.pbuilderrc with content
     $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build
-
 - Create chroot ubuntu env
     sudo pbuilder create
 - Test package sources
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index 2012f603ae3..64bfbc60b9c 100644
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -301,6 +301,8 @@ if ($nboftargetok) {
         $ret=`rm -fr $BUILDROOT/$PROJECT/dev/test`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/dev/uml`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/dev/xdebug`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/dev/dolibarr_changes.txt`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/dev/README`;
         $ret=`rm -f  $BUILDROOT/$PROJECT/doc/images/dolibarr_screenshot2.png`;
         $ret=`rm -f  $BUILDROOT/$PROJECT/doc/images/dolibarr_screenshot3.png`;
         $ret=`rm -f  $BUILDROOT/$PROJECT/doc/images/dolibarr_screenshot4.png`;
@@ -318,8 +320,6 @@ if ($nboftargetok) {
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom*`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/test`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/Thumbs.db $BUILDROOT/$PROJECT/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/*/Thumbs.db`;
-	    #$ret=`rm -fr $BUILDROOT/$PROJECT/CVS* $BUILDROOT/$PROJECT/*/CVS* $BUILDROOT/$PROJECT/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/*/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/*/*/*/*/*/CVS*  $BUILDROOT/$PROJECT/*/*/*/*/*/*/*/*/*/*/CVS*`;
-	    #$ret=`rm -fr $BUILDROOT/$PROJECT/.svn $BUILDROOT/$PROJECT/*/.svn $BUILDROOT/$PROJECT/*/*/.svn $BUILDROOT/$PROJECT/*/*/*/.svn $BUILDROOT/$PROJECT/*/*/*/*/.svn`;
 	    $ret=`rm -f  $BUILDROOT/$PROJECT/.cvsignore $BUILDROOT/$PROJECT/*/.cvsignore $BUILDROOT/$PROJECT/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.cvsignore`;
 	    $ret=`rm -f  $BUILDROOT/$PROJECT/.gitignore $BUILDROOT/$PROJECT/*/.gitignore $BUILDROOT/$PROJECT/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.gitignore`;
    	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/fckeditor`;
@@ -347,7 +347,8 @@ if ($nboftargetok) {
     
         print "\nBuild package for target $target\n";
 
-    	if ($target eq 'SNAPSHOT') {
+    	if ($target eq 'SNAPSHOT') 
+    	{
     		$NEWDESTI=$DESTI;
 
     		print "Remove target $FILENAMESNAPSHOT.tgz...\n";
@@ -371,7 +372,8 @@ if ($nboftargetok) {
     		next;
     	}
 
-    	if ($target eq 'TGZ') {
+    	if ($target eq 'TGZ') 
+    	{
     		$NEWDESTI=$DESTI;
 			if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } 
 
@@ -396,7 +398,8 @@ if ($nboftargetok) {
     		next;
     	}
 
-    	if ($target eq 'ZIP') {
+    	if ($target eq 'ZIP') 
+    	{
     		$NEWDESTI=$DESTI;
 			if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } 
 
@@ -459,9 +462,6 @@ if ($nboftargetok) {
 
     		print "Create directory $BUILDROOT/$FILENAMETGZ2\n";
     		$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2`;
-    		#$ret=`mkdir -p "$BUILDROOT/$FILENAMETGZ2"`;
-    		#print "Create directory $BUILDROOT/$FILENAMETGZ2/usr/share\n";
-    		#$ret=`mkdir -p "$BUILDROOT/$FILENAMETGZ2/usr/share"`;
             print "Copy $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMETGZ2\n";
     		$cmd="cp -pr '$BUILDROOT/$PROJECT' '$BUILDROOT/$FILENAMETGZ2'";
             $ret=`$cmd`;
@@ -553,157 +553,101 @@ if ($nboftargetok) {
     		print "Remove target ${FILENAMEDEB}.changes...\n";
     		unlink("$NEWDESTI/${FILENAMEDEB}.changes");
 
-            #rmdir "$BUILDROOT/$PROJECT.tmp";
     		$ret=`rm -fr $BUILDROOT/$PROJECT.tmp`;
     		$ret=`rm -fr $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build`;
     		
-    		print "Create directory $BUILDROOT/$PROJECT.tmp/usr/share\n";
-    		$ret=`mkdir -p "$BUILDROOT/$PROJECT.tmp/usr/share"`;
-    		print "Copy $BUILDROOT/$PROJECT to $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT\n";
-    		$cmd="cp -pr \"$BUILDROOT/$PROJECT\" \"$BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT\"";
-            $ret=`$cmd`;
-            
-			print "Fix filefunc.inc.php, install/inc.php, support/inc.php\n";
-			$cmd="cat \"$BUILDROOT/$PROJECT/htdocs/filefunc.inc.php\" | 
-					sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
-					sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
-					sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/filefunc.inc.php\"";
-			$ret=`$cmd`;
-			$cmd="cat \"$BUILDROOT/$PROJECT/htdocs/install/inc.php\" | 
-					sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
-					sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
-					sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/install/inc.php\"";
-			$ret=`$cmd`;
-			$cmd="cat \"$BUILDROOT/$PROJECT/htdocs/support/inc.php\" | 
-					sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
-					sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
-					sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/support/inc.php\"";
+			print "Copy $BUILDROOT/$PROJECT to $BUILDROOT/$PROJECT.tmp\n";
+			$cmd="cp -pr \"$BUILDROOT/$PROJECT\" \"$BUILDROOT/$PROJECT.tmp\"";
 			$ret=`$cmd`;
 
+#			print "Fix filefunc.inc.php, install/inc.php, support/inc.php\n";
+#			$cmd="cat \"$BUILDROOT/$PROJECT/htdocs/filefunc.inc.php\" | 
+#					sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
+#					sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
+#					sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$PROJECT.tmp/htdocs/filefunc.inc.php\"";
+#			$ret=`$cmd`;
+#			$cmd="cat \"$BUILDROOT/$PROJECT/htdocs/install/inc.php\" | 
+#					sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
+#					sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
+#					sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$PROJECT.tmp/htdocs/install/inc.php\"";
+#			$ret=`$cmd`;
+#			$cmd="cat \"$BUILDROOT/$PROJECT/htdocs/support/inc.php\" | 
+#					sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
+#					sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
+#					sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$PROJECT.tmp/htdocs/support/inc.php\"";
+#			$ret=`$cmd`;
+
  			print "Remove other files\n";
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/ChangeLog`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/COPYING`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/COPYRIGHT`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/INSTALL`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/README`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/README-FR`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/README`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/README-FR`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/aps`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/dmg`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/pad/README`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/tgz/README`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/README`;
-            #$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/po`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/source`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/changelog`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/compat`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/config`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/control*`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/copyright`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/dolibarr.desktop`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/dolibarr.lintian-overrides`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/format`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/install`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/menu`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/postrm`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/postinst`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/rules`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/README.debian`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/templates`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/templates.futur`;
-            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/debian/wash`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/doap`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/exe`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/launchpad`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/live`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/patch`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/perl`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/rpm`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/zip`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/README-FR`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/README`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/README-FR`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/aps`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/dmg`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/pad/README`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/tgz/README`;
+            #$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/debian`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/debian/po`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/debian/source`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/changelog`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/compat`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/config`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/control*`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/copyright`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/dolibarr.desktop`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/dolibarr.lintian-overrides`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/format`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/install`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/menu`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/postrm`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/postinst`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/rules`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/README.howto`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/templates`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/templates.futur`;
+            $ret=`rm -f  $BUILDROOT/$PROJECT.tmp/build/debian/wash`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/doap`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/exe`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/launchpad`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/live`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/patch`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/perl`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/rpm`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/zip`;
             # We remove embedded libraries or fonts
-	   	    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/ckeditor`;
-			$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/fonts`,
-	   	    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/geoip`;
-	   	    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/nusoap`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip`;
-
-			# 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/debian/apache.conf" "$BUILDROOT/$PROJECT.tmp/etc/$PROJECT/apache.conf"`;
-    		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/debian/lighttpd.conf" "$BUILDROOT/$PROJECT.tmp/etc/$PROJECT/lighttpd.conf"`;
-
-			# dolibarr.desktop
-	   		print "Create directory $BUILDROOT/$PROJECT.tmp/usr/share/applications\n";
-    		$ret=`mkdir -p "$BUILDROOT/$PROJECT.tmp/usr/share/applications"`;
-    		print "Copy desktop file into $BUILDROOT/$PROJECT.tmp/usr/share/applications/dolibarr.desktop\n";
-    		$ret=`cp "$SOURCE/build/debian/dolibarr.desktop" "$BUILDROOT/$PROJECT.tmp/usr/share/applications/dolibarr.desktop"`;
-            
-            # pixmap
-	   		print "Create directory $BUILDROOT/$PROJECT.tmp/usr/share/pixmaps\n";
-    		$ret=`mkdir -p "$BUILDROOT/$PROJECT.tmp/usr/share/pixmaps"`;
-    		print "Copy pixmap file into $BUILDROOT/$PROJECT.tmp/usr/share/pixmaps/dolibarr.xpm\n";
-    		$ret=`cp "$SOURCE/doc/images/dolibarr.xpm" "$BUILDROOT/$PROJECT.tmp/usr/share/pixmaps/dolibarr.xpm"`;
-
-            print "Create directory $BUILDROOT/$PROJECT.tmp/usr/share/doc/$PROJECT\n";
-            $ret=`mkdir -p "$BUILDROOT/$PROJECT.tmp/usr/share/doc/$PROJECT"`;
-            
-            # changelog (to build binary package directly without sources. Useless if we build from sources)
-            $ret=`gzip -9 -c "$SOURCE/build/debian/changelog" > $BUILDROOT/$PROJECT.tmp/usr/share/doc/$PROJECT/changelog.gz`;
-
-			# Set owners
-            print "Set owners on files/dir\n";
-		    $ret=`chown -R root.root $BUILDROOT/$PROJECT.tmp`;
+	   	    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor`;
+			$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/fonts`,
+	   	    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/geoip`;
+	   	    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/nusoap`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/odtphp/zip/pclzip`;
 
-			# Set permissions
-            print "Set permissions on files/dir\n";
-		    $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp`;
-		    $cmd="find $BUILDROOT/$PROJECT.tmp -type f -exec chmod 644 {} \\; ";
-            $ret=`$cmd`;
-            $cmd="find $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build -name '*.php' -type f -exec chmod 755 {} \\; ";
-            $ret=`$cmd`;
-            $cmd="find $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build -name '*.pl' -type f -exec chmod 755 {} \\; ";
-            $ret=`$cmd`;
-            $cmd="find $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev -name '*.php' -type f -exec chmod 755 {} \\; ";
-            $ret=`$cmd`;
-            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/translation/autotranslator.class.php`;
-            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/skeletons/modMyModule.class.php`;
-            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/skeletons/skeleton_class.class.php`;
-            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/skeletons/skeleton_page.php`;
-            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/skeletons/skeleton_webservice_server.php`;
-            $cmd="find $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/scripts -name '*.php' -type f -exec chmod 755 {} \\; ";
-            $ret=`$cmd`;
-            
-            
             # Prepare binary package (init DEBIAN dir)
-    		print "Create directory $BUILDROOT/$PROJECT.tmp/DEBIAN\n";
-    		$ret=`mkdir "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
-    		print "Copy $SOURCE/build/debian/xxx to $BUILDROOT/$PROJECT.tmp/DEBIAN\n";
-            $ret=`cp -f  "$SOURCE/build/debian/config"           "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
-            $ret=`cp -f  "$SOURCE/build/debian/postinst"         "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
-            $ret=`cp -f  "$SOURCE/build/debian/postrm"           "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
-            $ret=`cp -f  "$SOURCE/build/debian/templates"        "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
-            $ret=`cp -fr "$SOURCE/build/debian/po"               "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
+    		#print "Create directory $BUILDROOT/$PROJECT.tmp/DEBIAN\n";
+    		#$ret=`mkdir "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
+    		#print "Copy $SOURCE/build/debian/xxx to $BUILDROOT/$PROJECT.tmp/DEBIAN\n";
+            #$ret=`cp -f  "$SOURCE/build/debian/config"           "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
+            #$ret=`cp -f  "$SOURCE/build/debian/postinst"         "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
+            #$ret=`cp -f  "$SOURCE/build/debian/postrm"           "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
+            #$ret=`cp -f  "$SOURCE/build/debian/templates"        "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
+            #$ret=`cp -fr "$SOURCE/build/debian/po"               "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
             
-            print "Edit version in file $BUILDROOT/$PROJECT.tmp/DEBIAN/control\n";
-            open (SPECFROM,"<$SOURCE/build/debian/control.debianbin") || die "Error";
-            open (SPECTO,">$BUILDROOT/$PROJECT.tmp/DEBIAN/control") || die "Error";
-            while (<SPECFROM>) {
-                $_ =~ s/__VERSION__/$MAJOR.$MINOR.$newbuild/;
-                print SPECTO $_;
-            }
-            close SPECFROM;
-            close SPECTO;
-            print "Version set to $MAJOR.$MINOR.$newbuild\n";
+            # changelog (to build binary package directly without sources. Useless if we build from sources)
+            #$ret=`gzip -9 -c "$SOURCE/build/debian/changelog" > $BUILDROOT/$PROJECT.tmp/usr/share/doc/$PROJECT/changelog.gz`;
+
+            #print "Edit version in file $BUILDROOT/$PROJECT.tmp/DEBIAN/control\n";
+            #open (SPECFROM,"<$SOURCE/build/debian/control.debianbin") || die "Error";
+            #open (SPECTO,">$BUILDROOT/$PROJECT.tmp/DEBIAN/control") || die "Error";
+            #while (<SPECFROM>) {
+            #    $_ =~ s/__VERSION__/$MAJOR.$MINOR.$newbuild/;
+            #    print SPECTO $_;
+            #}
+            #close SPECFROM;
+            #close SPECTO;
+            #print "Version set to $MAJOR.$MINOR.$newbuild\n";
             
-            $cmd="find $BUILDROOT/$PROJECT.tmp/DEBIAN -type f -exec chmod 755 {} \\; ";
-            $ret=`$cmd`;
-            $ret=`chmod 644 $BUILDROOT/$PROJECT.tmp/DEBIAN/control`;
-            $ret=`chmod 644 $BUILDROOT/$PROJECT.tmp/DEBIAN/templates`;
+            #$cmd="find $BUILDROOT/$PROJECT.tmp/DEBIAN -type f -exec chmod 755 {} \\; ";
+            #$ret=`$cmd`;
+            #$ret=`chmod 644 $BUILDROOT/$PROJECT.tmp/DEBIAN/control`;
+            #$ret=`chmod 644 $BUILDROOT/$PROJECT.tmp/DEBIAN/templates`;
 
             # Creation of binary package (to build without sources)
             # Enable this to build a binary package without building sources first
@@ -713,33 +657,60 @@ if ($nboftargetok) {
     		#print "Launch DEB build ($cmd)\n";
     		#$ret=`$cmd`;
     		#print $ret."\n";
+            #$ret=`rm -fr "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
+            #$ret=`rm -fr "$BUILDROOT/$PROJECT.tmp/doc"`;
     		#exit;
-    		
-            $ret=`rm -fr "$BUILDROOT/$PROJECT.tmp/DEBIAN"`;
-            $ret=`rm -fr "$BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/doc"`;
-
+   		
             # Prepare source package (init debian dir)
             print "Create directory $BUILDROOT/$PROJECT.tmp/debian\n";
             $ret=`mkdir "$BUILDROOT/$PROJECT.tmp/debian"`;
             print "Copy $SOURCE/build/debian/xxx to $BUILDROOT/$PROJECT.tmp/debian\n";
             # Add files for dpkg-source
-            $ret=`cp -f  "$SOURCE/ChangeLog"                "$BUILDROOT/$PROJECT.tmp/usr/share/doc/dolibarr/UserChangeLog"`;
-            $ret=`cp -f  "$SOURCE/build/debian/README.debian"  "$BUILDROOT/$PROJECT.tmp/usr/share/doc/dolibarr/README"`;
             $ret=`cp -f  "$SOURCE/build/debian/changelog"      "$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -f  "$SOURCE/build/debian/compat"         "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`cp -f  "$SOURCE/build/debian/control"        "$BUILDROOT/$PROJECT.tmp/debian"`;
-            $ret=`cp -f  "$SOURCE/build/debian/dolibarr.lintian-overrides"        "$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -f  "$SOURCE/build/debian/copyright"      "$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -f  "$SOURCE/build/debian/dolibarr.xpm"  		      	"$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -f  "$SOURCE/build/debian/dolibarr.desktop"        	"$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -f  "$SOURCE/build/debian/dolibarr.lintian-overrides"  "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`cp -f  "$SOURCE/build/debian/install"        "$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -fr "$SOURCE/build/debian/patches"        "$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -fr "$SOURCE/build/debian/po"             "$BUILDROOT/$PROJECT.tmp/debian"`;
+            $ret=`cp -f  "$SOURCE/build/debian/README.source"  "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`cp -f  "$SOURCE/build/debian/rules"          "$BUILDROOT/$PROJECT.tmp/debian"`;
-            $ret=`cp -f  "$SOURCE/build/debian/copyright"      "$BUILDROOT/$PROJECT.tmp/debian"`;
-            $ret=`cp -f  "$SOURCE/build/debian/compat"         "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`cp -fr "$SOURCE/build/debian/source"         "$BUILDROOT/$PROJECT.tmp/debian"`;
-            $ret=`cp -fr "$SOURCE/build/debian/po"             "$BUILDROOT/$PROJECT.tmp/debian"`;
-            # Add files also required to build binary package with dpkg-buildpackages
+            # Add files also required to build binary package
             $ret=`cp -f  "$SOURCE/build/debian/config"         "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`cp -f  "$SOURCE/build/debian/postinst"       "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`cp -f  "$SOURCE/build/debian/postrm"         "$BUILDROOT/$PROJECT.tmp/debian"`;
             $ret=`cp -f  "$SOURCE/build/debian/templates"      "$BUILDROOT/$PROJECT.tmp/debian"`;
             
+            
+			# Set owners and permissions
+            print "Set owners on files/dir\n";
+		    $ret=`chown -R root.root $BUILDROOT/$PROJECT.tmp`;
+            print "Set permissions on files/dir\n";
+		    $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp`;
+		    $cmd="find $BUILDROOT/$PROJECT.tmp -type f -exec chmod 644 {} \\; ";
+            $ret=`$cmd`;
+            $cmd="find $BUILDROOT/$PROJECT.tmp/build -name '*.php' -type f -exec chmod 755 {} \\; ";
+            $ret=`$cmd`;
+            $cmd="find $BUILDROOT/$PROJECT.tmp/build -name '*.dpatch' -type f -exec chmod 755 {} \\; ";
+            $ret=`$cmd`;
+            $cmd="find $BUILDROOT/$PROJECT.tmp/build -name '*.pl' -type f -exec chmod 755 {} \\; ";
+            $ret=`$cmd`;
+            $cmd="find $BUILDROOT/$PROJECT.tmp/dev -name '*.php' -type f -exec chmod 755 {} \\; ";
+            $ret=`$cmd`;
+            $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`;
+            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`;
+            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/modMyModule.class.php`;
+            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_class.class.php`;
+            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_page.php`;
+            $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_webservice_server.php`;
+            $cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.php' -type f -exec chmod 755 {} \\; ";
+            $ret=`$cmd`;
+            
+          
             print "Rename directory $BUILDROOT/$PROJECT.tmp into $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build\n";
             $cmd="mv $BUILDROOT/$PROJECT.tmp $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build";
             $ret=`$cmd`;
diff --git a/build/rpm/dolibarr-forrpm.patch b/build/rpm/dolibarr-forrpm.patch
index f1627beb897..06dd71a8987 100755
--- a/build/rpm/dolibarr-forrpm.patch
+++ b/build/rpm/dolibarr-forrpm.patch
@@ -1,7 +1,7 @@
 diff -up htdocs/filefunc.inc.php.patch htdocs/filefunc.inc.php
 --- htdocs/filefunc.inc.php.patch	2011-09-03 02:32:48.666952000 +0200
 +++ htdocs/filefunc.inc.php	2011-09-03 02:33:00.510952001 +0200
-@@ -64,8 +64,8 @@ $conffiletoshowshort = "conf.php";
+@@ -64,8 +64,8 @@ 
  $conffile = "conf/conf.php";
  $conffiletoshow = "htdocs/conf/conf.php";
  // For debian/redhat like systems
@@ -15,7 +15,7 @@ diff -up htdocs/filefunc.inc.php.patch htdocs/filefunc.inc.php
 diff -up htdocs/install/inc.php.patch htdocs/install/inc.php
 --- htdocs/install/inc.php.patch	2011-09-03 02:33:26.450952000 +0200
 +++ htdocs/install/inc.php	2011-09-03 02:33:36.286952001 +0200
-@@ -75,8 +75,8 @@ $conffiletoshowshort = "conf.php";
+@@ -84,8 +84,8 @@
  $conffile = "../conf/conf.php";
  $conffiletoshow = "htdocs/conf/conf.php";
  // For debian/redhat like systems
@@ -29,7 +29,7 @@ diff -up htdocs/install/inc.php.patch htdocs/install/inc.php
 diff -up htdocs/support/inc.php.patch htdocs/support/inc.php
 --- htdocs/support/inc.php.patch	2011-09-03 02:34:39.606952000 +0200
 +++ htdocs/support/inc.php	2011-09-03 02:33:59.814952000 +0200
-@@ -69,8 +69,8 @@ $conffiletoshowshort = "conf.php";
+@@ -79,8 +79,8 @@
  $conffile = "../conf/conf.php";
  $conffiletoshow = "htdocs/conf/conf.php";
  // For debian/redhat like systems
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index ee1a2d94f88..54046659566 100755
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -32,7 +32,7 @@
 if (! defined('DOL_VERSION')) define('DOL_VERSION','3.2.0-alpha');	// Also defined in htdocs/install/inc.php (Ex: x.y.z-alpha, x.y.z)
 if (! defined('EURO')) define('EURO',chr(128));
 
-// Definition des constantes syslog
+// Define syslog constants
 if (! defined('LOG_DEBUG'))
 {
     if (function_exists("define_syslog_variables"))
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index dddff4a1298..fafb001bd18 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -18,9 +18,10 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-/**	    \file       htdocs/install/inc.php
- * 		\ingroup	core
- *		\brief      File that define environment for install pages
+/**
+ * 	\file       htdocs/install/inc.php
+ * 	\ingroup	core
+ *	\brief      File that define environment for support pages
  */
 
 define('DOL_VERSION','3.2.0-alpha');	// Also defined in htdocs/master.inc.php (Ex: x.y.z-alpha, x.y.z)
@@ -53,25 +54,25 @@ if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
 }
 
 
-// Definition des constantes syslog
-if (function_exists("define_syslog_variables"))
+// Define syslog constants
+if (! defined('LOG_DEBUG'))
 {
-    if (version_compare(PHP_VERSION, '5.3.0', '<'))
+    if (function_exists("define_syslog_variables"))
     {
         define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
     }
-}
-else
-{
-    // Pour PHP sans syslog (comme sous Windows)
-    define('LOG_EMERG',0);
-    define('LOG_ALERT',1);
-    define('LOG_CRIT',2);
-    define('LOG_ERR',3);
-    define('LOG_WARNING',4);
-    define('LOG_NOTICE',5);
-    define('LOG_INFO',6);
-    define('LOG_DEBUG',7);
+    else
+    {
+        // Pour PHP sans syslog (comme sous Windows)
+        define('LOG_EMERG',0);
+        define('LOG_ALERT',1);
+        define('LOG_CRIT',2);
+        define('LOG_ERR',3);
+        define('LOG_WARNING',4);
+        define('LOG_NOTICE',5);
+        define('LOG_INFO',6);
+        define('LOG_DEBUG',7);
+    }
 }
 
 $includeconferror='';
diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php
index d07f3e1f852..a8a6a0c1ffb 100644
--- a/htdocs/support/inc.php
+++ b/htdocs/support/inc.php
@@ -19,8 +19,9 @@
  */
 
 /**
- * 	    \file       htdocs/support/inc.php
- *		\brief      File that define environment for support pages
+ * 	\file       htdocs/support/inc.php
+ * 	\ingroup	core
+ *	\brief      File that define environment for support pages
  */
 
 define('DOL_VERSION','3.2.0-alpha');	// Also defined in htdocs/master.inc.php
@@ -49,27 +50,26 @@ if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
 }
 
 
-// Definition des constantes syslog
-if (function_exists("define_syslog_variables"))
+// Define syslog constants
+if (! defined('LOG_DEBUG'))
 {
-	if (version_compare(PHP_VERSION, '5.3.0', '<'))
-	{
-		define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
-	}
+    if (function_exists("define_syslog_variables"))
+    {
+    	define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
+    }
+    else
+    {
+    	// Pour PHP sans syslog (comme sous Windows)
+    	define('LOG_EMERG',0);
+    	define('LOG_ALERT',1);
+    	define('LOG_CRIT',2);
+    	define('LOG_ERR',3);
+    	define('LOG_WARNING',4);
+    	define('LOG_NOTICE',5);
+    	define('LOG_INFO',6);
+    	define('LOG_DEBUG',7);
+    }
 }
-else
-{
-	// Pour PHP sans syslog (comme sous Windows)
-	define('LOG_EMERG',0);
-	define('LOG_ALERT',1);
-	define('LOG_CRIT',2);
-	define('LOG_ERR',3);
-	define('LOG_WARNING',4);
-	define('LOG_NOTICE',5);
-	define('LOG_INFO',6);
-	define('LOG_DEBUG',7);
-}
-
 
 $includeconferror='';
 
-- 
GitLab