From 066628754c6d5ee66f2582ed711dd0ebf1c89e62 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Sat, 25 Jun 2011 19:41:35 +0000
Subject: [PATCH] Work on APS package

---
 build/aps/APP-META-1.1.xml | 121 ++++++++++++++++++
 build/aps/APP-META-1.2.xml | 120 ++++++++++++++++++
 build/aps/APP-META.xml     | 247 +++++++++++++++++++------------------
 build/aps/README           |  20 +++
 build/aps/configure.php    | 120 ++++++++++++++++++
 build/makepack-dolibarr.pl | 156 ++++++++++++-----------
 6 files changed, 598 insertions(+), 186 deletions(-)
 create mode 100755 build/aps/APP-META-1.1.xml
 create mode 100755 build/aps/APP-META-1.2.xml
 create mode 100755 build/aps/README
 create mode 100755 build/aps/configure.php

diff --git a/build/aps/APP-META-1.1.xml b/build/aps/APP-META-1.1.xml
new file mode 100755
index 00000000000..e4714b13da9
--- /dev/null
+++ b/build/aps/APP-META-1.1.xml
@@ -0,0 +1,121 @@
+<!-- Application namespaces and APS version (step 9) -->
+<application xmlns="http://apstandard.com/ns/1" version="1.1">
+	<!-- Application common properties (step 9) -->
+	<name>Dolibarr</name>
+	<version>__VERSION__</version>
+	<release>__RELEASE__</release>
+	<homepage>http://www.dolibarr.org/</homepage>
+	<vendor>
+		<name>Dolibarr</name>
+		<homepage>http://www.dolibarr.org/</homepage>
+		<icon path="images/appicon_64.png" />
+	</vendor>
+	<packager>
+		<name>Laurent Destailleur</name>
+		<homepage>http://www.nltechno.com</homepage>
+		<uri>uuid:714f0a7b-85d6-4eb8-b68e-40f9acbb3103</uri>
+	</packager>
+	<presentation>
+		<summary>Dolibarr ERP - CRM, the easy to use software to manage small or medium companies, freelancers or foundations</summary>
+		<description>
+Dolibarr is a free modular software (you see only
+features you need) to manage small and medium companies, freelancers
+or foundations.
+This OpenSource software is designed to provide all features you need to
+manage information on many aspects of your business
+into an intuitive and user-friendly graphical interface
+It's an OpenSource software you can install on a web server or as a
+standalone software. Dolibarr is designed to provide simplicity to end-user.
+        </description>
+		<icon path="images/appicon_64.png" />
+		<screenshot path="images/dolibarr_screenshot1.png">
+			<description>Screenshot 1</description>
+		</screenshot>
+		<changelog>
+			<version version="3.1.0" release="0">
+				<entry>See http://www.dolibarr.org/files/ChangeLog</entry>
+			</version>
+		</changelog>
+		<categories>
+			<category>Back office/Billing</category>
+			<category>Back office/Accounting and Financial</category>
+			<category>Back office/Customer Relationship Management</category>
+			<category>Back office/Enterprise Resource Planning</category>
+		</categories>
+		<languages>
+			<language>en</language>
+			<language>fr</language>
+			<language>es</language>
+			<language>de</language>
+			<language>pt</language>
+		</languages>
+	</presentation>
+	<upgrade match="/application/version = '3.0'" />
+	<!-- Application service (step 4) -->
+	<service id="dolibarr">
+		<!-- Service presentation properties (step 7) -->
+		<license must-accept="true">
+			<text>
+				<name>GPLv2</name>
+				<file>COPYING</file>
+			</text>
+		</license>
+		<presentation>
+			<name>Dolibarr instance</name>
+            <summary>Dolibarr services</summary>
+			<entry-points>
+				<entry class="frontpage" dst="/">
+					<label>Application entry point</label>
+				</entry>
+			</entry-points>
+		</presentation>
+		<!-- Service settings (step 7) -->
+		<settings>
+			<group>
+				<name>Administrator's preferences</name>
+				<setting id="admin_name" type="string" default-value="admin"
+					min-length="1" max-length="32" regex="^[a-zA-Z][0-9a-zA-Z_\-]*">
+					<name>Administrator's login</name>
+					<error-message>
+Please make sure the text you entered starts with a	letter and continues with either numbers, letters, underscores or hyphens.
+                    </error-message>
+				</setting>
+				<setting id="admin_password" type="password" min-length="1">
+					<name>Password</name>
+				</setting>
+			</group>
+		</settings>
+		<!-- Service used technologies (step 6) -->
+		<requirements xmlns:php="http://apstandard.com/ns/1/php"
+			xmlns:db="http://apstandard.com/ns/1/db">
+			<php:version min="4.2.0" />
+			<php:extension>mysql</php:extension>
+			<php:extension>mbstring</php:extension>
+			<php:safe-mode>false</php:safe-mode>
+			<db:db>
+				<db:id>main</db:id>
+				<db:default-name>dolibarr</db:default-name>
+				<db:can-use-tables-prefix>false</db:can-use-tables-prefix>
+				<db:server-type>mysql</db:server-type>
+				<db:server-min-version>4.1.0</db:server-min-version>
+			</db:db>
+		</requirements>
+		<!-- Content delivery settings (step 8) -->
+		<provision>
+			<url-mapping>
+				<default-prefix>dolibarr</default-prefix>
+				<installed-size>35000000</installed-size>
+				<mapping url="/" path="htdocs" xmlns:php="http://apstandard.com/ns/1/php">
+					<php:handler>
+						<php:extension>php</php:extension>
+					</php:handler>
+				</mapping>
+			</url-mapping>
+			<!-- Service configuration script declaration (step 10) -->
+            <configuration-script name="configure.php">
+                <configuration-script-language>php</configuration-script-language>
+                <status-control/>
+			</configuration-script>
+		</provision>
+	</service>
+</application>
\ No newline at end of file
diff --git a/build/aps/APP-META-1.2.xml b/build/aps/APP-META-1.2.xml
new file mode 100755
index 00000000000..2d27c591c07
--- /dev/null
+++ b/build/aps/APP-META-1.2.xml
@@ -0,0 +1,120 @@
+<!-- Application namespaces and APS version (step 9) -->
+<application xmlns="http://apstandard.com/ns/1" version="1.2">
+	<!-- Application common properties (step 9) -->
+	<id>dolibarr</id>
+	<name>Dolibarr</name>
+	<version>__VERSION__</version>
+	<release>__RELEASE__</release>
+	<homepage>http://www.dolibarr.org/</homepage>
+	<vendor>
+		<name>Dolibarr</name>
+		<homepage>http://www.dolibarr.org/</homepage>
+		<icon path="images/icon.png" />
+	</vendor>
+	<packager>
+        <name>Laurent Destailleur</name>
+        <homepage>http://www.nltechno.com</homepage>
+		<uri>uuid:714f0a7b-85d6-4eb8-b68e-40f9acbb3103</uri>
+	</packager>
+	<presentation>
+		<summary>Dolibarr ERP - CRM, the easy to use software to manage small or medium companies, freelancers or foundations</summary>
+		<description>
+Dolibarr is a free modular software (you see only
+features you need) to manage small and medium companies, freelancers
+or foundations.
+This OpenSource software is designed to provide all features you need to
+manage information on many aspects of your business
+into an intuitive and user-friendly graphical interface
+It's an OpenSource software you can install on a web server or as a
+standalone software. Dolibarr is designed to provide simplicity to end-user.
+</description>
+		<icon path="doc/images/appicon_64.png" />
+		<screenshot path="doc/images/dolibarr_screenshot1.jpg">
+			<description>Screenshot 1</description>
+		</screenshot>
+		<changelog>
+			<version version="3.1.0" release="0">
+				<entry>See http://www.dolibarr.org/files/ChangeLog</entry>
+			</version>
+		</changelog>
+		<categories>
+			<category>Back office/Billing</category>
+			<category>Back office/Accounting and Financial</category>
+			<category>Back office/Customer Relationship Management</category>
+			<category>Back office/Enterprise Resource Planning</category>
+		</categories>
+		<languages>
+			<language>en</language>
+			<language>fr</language>
+			<language>es</language>
+			<language>de</language>
+			<language>pt</language>
+		</languages>
+	</presentation>
+	<upgrade match="/application/version = '3.0'" />
+	<!-- Application service (step 4) -->
+	<service id="dolibarr">
+		<!-- Service presentation properties (step 7) -->
+		<license must-accept="true">
+			<text xml:lang="">
+				<name>GPLv2</name>
+				<file>COPYING</file>
+			</text>
+		</license>
+		<presentation>
+			<name>Dolibarr instance</name>
+			<entry-points>
+				<entry class="frontpage" dst="/">
+					<label>Application entry point</label>
+				</entry>
+			</entry-points>
+		</presentation>
+		<!-- Service settings (step 7) -->
+		<settings>
+			<group>
+				<name>Administrator's preferences</name>
+				<setting id="admin_name" type="string" default-value="admin"
+					min-length="1" max-length="32" regex="^[a-zA-Z][0-9a-zA-Z_\-]*">
+					<name>Administrator's login</name>
+					<error-message>
+Please make sure the text you entered starts with a letter and continues with either numbers, letters, underscores or hyphens.
+                    </error-message>
+				</setting>
+				<setting id="admin_password" type="password" min-length="1">
+					<name>Password</name>
+				</setting>
+			</group>
+		</settings>
+		<!-- Service used technologies (step 6) -->
+		<requirements xmlns:php="http://apstandard.com/ns/1/php"
+			xmlns:db="http://apstandard.com/ns/1/db">
+			<php:version min="4.2.0" />
+			<php:extension>mysql</php:extension>
+			<php:extension>mbstring</php:extension>
+			<php:safe-mode>false</php:safe-mode>
+			<db:db>
+				<db:id>main</db:id>
+				<db:default-name>dolibarr</db:default-name>
+				<db:can-use-tables-prefix>false</db:can-use-tables-prefix>
+				<db:server-type>mysql</db:server-type>
+				<db:server-min-version>4.1.0</db:server-min-version>
+			</db:db>
+		</requirements>
+		<!-- Content delivery settings (step 8) -->
+		<provision>
+			<url-mapping>
+				<default-prefix>dolibarr</default-prefix>
+				<installed-size>35000000</installed-size>
+				<mapping url="/" path="htdocs" xmlns:php="http://apstandard.com/ns/1/php">
+					<php:handler>
+						<php:extension>php</php:extension>
+					</php:handler>
+				</mapping>
+			</url-mapping>
+			<!-- Service configuration script declaration (step 10) -->
+			<configuration-script name="configure">
+				<script-language>php</script-language>
+			</configuration-script>
+		</provision>
+	</service>
+</application>
\ No newline at end of file
diff --git a/build/aps/APP-META.xml b/build/aps/APP-META.xml
index f4c877aa961..a7e8fe23dd8 100755
--- a/build/aps/APP-META.xml
+++ b/build/aps/APP-META.xml
@@ -1,119 +1,132 @@
 <!-- Application namespaces and APS version (step 9) -->
-<application xmlns="http://apstandard.com/ns/1" version="1.2">
-<!-- Application common properties (step 9) -->
-<id>http://www.dolibarr.org/</id>
-<name>Dolibarr</name>
-<version>__VERSION__</version>
-<release>__RELEASE__</release>
-<homepage>http://www.dolibarr.org/</homepage>
-<vendor>
-<name>Dolibarr</name>
-<homepage>http://www.dolibarr.org/</homepage>
-<icon path="images/icon.png"/>
-</vendor>
-<packager>
-<name>Parallels</name>
-<homepage>http://parallels.com</homepage>
-<uri>uuid:714f0a7b-85d6-4eb8-b68e-40f9acbb3103</uri>
-</packager>
-<presentation>
-<summary>Dolibarr ERP - CRM, the easy to use software to manage small or medium companies, freelancers or foundations</summary>
-<description>
-Dolibarr is a free modular software (you see only features you need) to manage small and medium companies, freelancers or foundations.
-This Opensource software is designed to provide all features you need to manage information on many aspects of your business
-into an intuitive and user-friendly graphical interface 
-It's an OpenSource software you can install on a web server or as a standalone software. Dolibarr is designed to provide simplicity:
-* Simple to use (any module can be disabled to removed not required features, only the permissions features can not be disabled).
-* Simple to install (with DoliWamp the auto-installer for Windows, DoliBuntu, the auto-installer for Ubuntu/Debian or DoliMamp the auto-installer for Mac OS X, for those who do not know how to install an Apache server, MySQL, PHP. A web assistant is available for others, no additional components required, no Java, no Python, no Perl, no PEARL PHP modules, no other exotic library).
-* Simple for development (no heavy frameworks). Dolibarr, developed in PHP object, incorporates its own natural code, allowing every developer to be immediately operational, with no other knowledge than PHP).
-</description>
-<icon path="doc/images/appicon_64.png"/>
-<screenshot path="doc/images/dolibarr_screenshot1.jpg">
-<description>Screenshot 1</description>
-</screenshot>
-<changelog>
-<version version="3.1.0" release="0">
-<entry>See http://www.dolibarr.org/files/ChangeLog</entry>
-</version>
-</changelog>
-<categories>
-<category>Back office/Customer Relationship Management</category>
-</categories>
-<languages>
-<language>en</language>
-<language>fr</language>
-<language>es</language>
-<language>de</language>
-<language>pt</language>
-</languages>
-</presentation>
-<upgrade match="/application/version = '3.0'"/>
-<!-- Application service (step 4) -->
-<service id="blog">
-<!-- Service presentation properties (step 7) -->
-<license must-accept="true">
-<text>
-<name>GPLv2</name>
-<file>COPYING</file>
-</text>
-</license>
-<presentation>
-<name>Dolibarr instance</name>
-<entry-points>
-<entry class="frontpage" dst="/">
-Application entry point
-</entry>
-</entry-points>
-</presentation>
-<!-- Service settings (step 7) -->
-<settings>
-<group>
-<name>Administrator's preferences</name>
-<setting id="admin_name" type="string"
-default-value="admin" min-length="1"
-max-length="32" regex="^[a-zA-Z][0-9a-zA-Z_\-]*">
-<name>Administrator's login</name>
-<error-message>Please make sure the text you entered
-starts with a letter and continues with either numbers,
-letters, underscores or hyphens.</error-message>
-</setting>
-<setting id="admin_password"
-type="password" min-length="1" >
-<name>Password</name>
-</setting>
-</group>
-</settings>
-<!-- Service used technologies (step 6) -->
-<requirements xmlns:php="http://apstandard.com/ns/1/php"
-xmlns:db="http://apstandard.com/ns/1/db">
-<php:version min="4.2.0"/>
-<php:extension>mysql</php:extension>
-<php:extension>mbstring</php:extension>
-<php:safe-mode>false</php:safe-mode>
-<db:db>
-<db:id>main</db:id>
-<db:default-name>dolibarr</db:default-name>
-<db:can-use-tables-prefix>false</db:can-use-tables-prefix>
-<db:server-type>mysql</db:server-type>
-<db:server-min-version>4.1.0</db:server-min-version>
-</db:db>
-</requirements>
-<!-- Content delivery settings (step 8) -->
-<provision>
-<url-mapping>
-<default-prefix>dolibarr</default-prefix>
-<installed-size>35000000</installed-size>
-<mapping url="/" path="htdocs"
-xmlns:php="http://apstandard.com/ns/1/php">
-<php:handler>
-<php:extension>php</php:extension>
-</php:handler>
-</mapping>
-</url-mapping>
-<!-- Service configuration script declaration (step 10) -->
-<configuration-script name="configure">
-<script-language>php</script-language>
-</configuration-script>
-</provision>
-</service>
+<application xmlns="http://apstandard.com/ns/1" version="1.1">
+    <!-- Application common properties (step 9) -->
+    <name>Dolibarr</name>
+    <version>__VERSION__</version>
+    <release>__RELEASE__</release>
+    <homepage>http://www.dolibarr.org/</homepage>
+    <vendor>
+        <name>Dolibarr</name>
+        <homepage>http://www.dolibarr.org/</homepage>
+        <icon path="images/appicon_64.png" />
+    </vendor>
+    <packager>
+        <name>Laurent Destailleur</name>
+        <homepage>http://www.nltechno.com</homepage>
+        <uri>uuid:714f0a7b-85d6-4eb8-b68e-40f9acbb3103</uri>
+    </packager>
+    <presentation>
+        <summary>Dolibarr ERP - CRM, the easy to use software to manage small or medium companies, freelancers or foundations</summary>
+        <description>
+Dolibarr is a free modular software (you see only
+features you need) to manage small and medium companies, freelancers
+or foundations.
+This Opensource software is designed to provide all features you need to
+manage information on many aspects of your business
+into an intuitive and user-friendly graphical interface
+It's an OpenSource software you can install on a web server or as a
+standalone software. Dolibarr is designed to provide simplicity:
+* Simple to use (any module can be disabled to removed not required
+features, only the permissions features can not be disabled).
+* Simple to install (with DoliWamp the auto-installer for Windows,
+DoliBuntu, the auto-installer for Ubuntu/Debian or DoliMamp the
+auto-installer for Mac OS X, for those who do not know how to install
+an Apache server, MySQL, PHP. A web assistant is available for
+others, no additional components required, no Java, no Python, no
+Perl, no PEARL PHP modules, no other exotic library).
+* Simple for development (no heavy frameworks). Dolibarr, developed in
+PHP object, incorporates its own natural code, allowing every
+developer to be immediately operational, with no other knowledge than
+PHP).
+        </description>
+        <icon path="images/appicon_64.png" />
+        <screenshot path="images/dolibarr_screenshot1.png">
+            <description>Screenshot 1</description>
+        </screenshot>
+        <changelog>
+            <version version="3.1.0" release="0">
+                <entry>See http://www.dolibarr.org/files/ChangeLog</entry>
+            </version>
+        </changelog>
+        <categories>
+            <category>Back office/Billing</category>
+            <category>Back office/Accounting and Financial</category>
+            <category>Back office/Customer Relationship Management</category>
+            <category>Back office/Enterprise Resource Planning</category>
+        </categories>
+        <languages>
+            <language>en</language>
+            <language>fr</language>
+            <language>es</language>
+            <language>de</language>
+            <language>pt</language>
+        </languages>
+    </presentation>
+    <upgrade match="/application/version = '3.0'" />
+    <!-- Application service (step 4) -->
+    <service id="dolibarr">
+        <!-- Service presentation properties (step 7) -->
+        <license must-accept="true">
+            <text>
+                <name>GPLv2</name>
+                <file>COPYING</file>
+            </text>
+        </license>
+        <presentation>
+            <name>Dolibarr instance</name>
+            <entry-points>
+                <entry class="frontpage" dst="/">
+                    <label>Application entry point</label>
+                </entry>
+            </entry-points>
+        </presentation>
+        <!-- Service settings (step 7) -->
+        <settings>
+            <group>
+                <name>Administrator's preferences</name>
+                <setting id="admin_name" type="string" default-value="admin"
+                    min-length="1" max-length="32" regex="^[a-zA-Z][0-9a-zA-Z_\-]*">
+                    <name>Administrator's login</name>
+                    <error-message>
+Please make sure the text you entered starts with a letter and continues with either numbers, letters, underscores or hyphens.
+                    </error-message>
+                </setting>
+                <setting id="admin_password" type="password" min-length="1">
+                    <name>Password</name>
+                </setting>
+            </group>
+        </settings>
+        <!-- Service used technologies (step 6) -->
+        <requirements xmlns:php="http://apstandard.com/ns/1/php"
+            xmlns:db="http://apstandard.com/ns/1/db">
+            <php:version min="4.2.0" />
+            <php:extension>mysql</php:extension>
+            <php:extension>mbstring</php:extension>
+            <php:safe-mode>false</php:safe-mode>
+            <db:db>
+                <db:id>main</db:id>
+                <db:default-name>dolibarr</db:default-name>
+                <db:can-use-tables-prefix>false</db:can-use-tables-prefix>
+                <db:server-type>mysql</db:server-type>
+                <db:server-min-version>4.1.0</db:server-min-version>
+            </db:db>
+        </requirements>
+        <!-- Content delivery settings (step 8) -->
+        <provision>
+            <url-mapping>
+                <default-prefix>dolibarr</default-prefix>
+                <installed-size>35000000</installed-size>
+                <mapping url="/" path="htdocs" xmlns:php="http://apstandard.com/ns/1/php">
+                    <php:handler>
+                        <php:extension>php</php:extension>
+                    </php:handler>
+                </mapping>
+            </url-mapping>
+            <!-- Service configuration script declaration (step 10) -->
+            <configuration-script name="configure.php">
+                <configuration-script-language>php</configuration-script-language>
+                <status-control/>
+			</configuration-script>
+        </provision>
+    </service>
 </application>
\ No newline at end of file
diff --git a/build/aps/README b/build/aps/README
new file mode 100755
index 00000000000..dc9b3d500d8
--- /dev/null
+++ b/build/aps/README
@@ -0,0 +1,20 @@
+README (English)
+##################################################
+This directory is dedicated to APS package building
+##################################################
+
+Docs for APS format 1.1:
+http://www.apsstandard.org/r/doc/aps-format-1.1-packaging-guide/index.htm
+
+Docs for APS format 1.2 (need APP-LIST.xml):
+http://www.apsstandard.org/r/doc/aps-format-1.2-packaging-guide/index.htm
+
+
+To check an APS package on Debian:
+* Install libgdiplus with 
+apt-get install libgdiplus
+* Install apslint.exe
+tar -xvf xxxx.tgz 
+* Go into directory of apslint and run command
+mono ./apslint.exe '/media/DATA/Mes Developpements/dolibarr/build/dolibarr-3.1.0-dev.app.zip' 
+
diff --git a/build/aps/configure.php b/build/aps/configure.php
new file mode 100755
index 00000000000..d3a37fe827b
--- /dev/null
+++ b/build/aps/configure.php
@@ -0,0 +1,120 @@
+<?php
+
+if(count($_SERVER['argv']) < 2)
+
+{
+
+    print "Usage: configure (install | upgrade <version> | configure | remove)\n";
+
+    exit(1);
+
+}
+
+$command = $_SERVER['argv'][1];
+
+//$command stores the argument with which the script was invoked.
+
+if($command == "install")
+
+{
+
+$db_id = 'dolibarr';
+
+
+
+//The database identifier value is to be substituted by the value
+
+//defined in the application requirements section of the
+
+//metadata file.For details, see the 6.3.1.1. Database requirement
+
+//type section of the Specification.
+
+
+
+$query_file = 'schema.sql'; //File containing list of SQL queries.
+
+
+
+//List of database-related variables that are passed to the configuration
+
+//script. See the 6.3.1.1.1. Environment variables section of the
+
+//Specification for details.
+
+$db_address = getenv("DB_${db_id}_HOST");
+
+
+
+/*if (fetch_env_var("DB_${db_id}_PORT") !== False)
+
+    $db_address .= ':' . fetch_env_var("DB_${db_id}_PORT");
+*/
+
+
+$dblogin = getenv("DB_${db_id}_LOGIN");
+
+$dbpassword = getenv("DB_${db_id}_PASSWORD");
+
+$dbname = getenv("DB_${db_id}_NAME");
+
+
+
+//PHP functions for connecting to the mysql server and
+
+//executing SQL queries.
+
+mysql_connect($dbaddress, $dblogin, $dbpassword);
+
+mysql_select_db($dbname);
+
+/*
+$sql_queries = file($query_file);
+
+foreach ($sql_queries as $query) mysql_query($query);
+*/
+
+
+//Other code to be executed on invoking configure with
+
+//the install argument.
+
+exit(0);
+
+}
+
+if($command == "remove")
+
+{
+
+//Code to be executed on invoking configure with the remove argument
+
+exit(0);
+
+}
+
+if($command == "upgrade")
+
+{
+
+//Code to be executed on invoking configure with the upgrade argument
+
+exit(0);
+
+}
+
+if($command == "configure")
+
+{
+
+//Code to be executed on invoking configure with the configure argument
+
+exit(0);
+
+}
+
+print "Error: unknown command $command.\n";
+
+exit(1);
+
+?>
\ No newline at end of file
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index ea265d1c0d4..f7999ac2a7c 100644
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -1,8 +1,8 @@
 #!/usr/bin/perl
 #----------------------------------------------------------------------------
 # \file         build/makepack-dolibarr.pl
-# \brief        Dolibarr package builder (tgz, zip, rpm, deb, exe)
-# \version      $Id: makepack-dolibarr.pl,v 1.103 2011/06/24 23:10:52 eldy Exp $
+# \brief        Dolibarr package builder (tgz, zip, rpm, deb, exe, aps)
+# \version      $Id: makepack-dolibarr.pl,v 1.104 2011/06/25 19:41:36 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.103 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
+$REVISION='$Revision: 1.104 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
 $VERSION="1.0 (build $REVISION)";
 
 
@@ -171,14 +171,18 @@ foreach my $target (keys %CHOOSEDTARGET) {
     foreach my $req (split(/[,\s]/,$REQUIREMENTTARGET{$target})) {
         # Test    
         print "Test requirement for target $target: Search '$req'... ";
-        $ret=`"$req" 2>&1`;
+        $newreq=$req; $newparam='';
+        if ($newreq eq 'zip') { $newparam.='-h'; }
+        $cmd="\"$newreq\" $newparam 2>&1";
+        print "Test command ".$cmd."... ";
+        $ret=`$cmd`;
         $coderetour=$?; $coderetour2=$coderetour>>8;
         if ($coderetour != 0 && (($coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i) || ($coderetour2 == 127 && $OS !~ /windows/)) && $PROGPATH) { 
             # Not found error, we try in PROGPATH
             $ret=`"$PROGPATH/$ALTERNATEPATH{$req}/$req\" 2>&1`;
             $coderetour=$?; $coderetour2=$coderetour>>8;
             $REQUIREMENTTARGET{$target}="$PROGPATH/$ALTERNATEPATH{$req}/$req";
-        }    
+        } 
 
         if ($coderetour != 0 && (($coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i) || ($coderetour2 == 127 && $OS !~ /windows/))) {
             # Not found error
@@ -240,11 +244,25 @@ if ($nboftargetok) {
 	    	$ret=`cp -pr "$SOURCE" "$BUILDROOT/$PROJECT"`;
 	    }
 	    print "Clean $BUILDROOT\n";
+        $ret=`rm -f  $BUILDROOT/$PROJECT/index.php`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/.cache`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/.project`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/.settings`;
-	    $ret=`rm -fr $BUILDROOT/$PROJECT/index.php`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/build/html`;
+
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/DoliWamp-*`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/DoliMamp-*`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/dolibarr-*.deb`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/dolibarr-*.rpm`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/dolibarr-*.tar`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/dolibarr-*.tgz`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/dolibarr-*.zip`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/build/doxygen/doxygen_warnings.log`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/conf/conf.php.mysql`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/conf/conf.php.old`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/conf/conf.php.postgres`;
+        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/conf/conf*sav*`;
+	    
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/documents`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/document`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/conf/conf.php`;
@@ -370,6 +388,8 @@ if ($nboftargetok) {
             # now newbuild is 0-0 or 0-3 for example
             $REL1 = $newbuild; $REL1 =~ s/-.*$//gi;
             if ($RPMSUBVERSION eq 'auto') { $RPMSUBVERSION = $newbuild; $RPMSUBVERSION =~ s/^.*-//gi; }
+            print "Version is $MAJOR.$MINOR.$REL1-$RPMSUBVERSION\n";
+
             $FILENAMETGZ2="$PROJECT-$MAJOR.$MINOR.$REL1";
 			
     		print "Remove target ".$FILENAMETGZ2."-".$RPMSUBVERSION.".".$ARCH.".rpm...\n";
@@ -415,6 +435,14 @@ if ($nboftargetok) {
     	}
     	
     	if ($target eq 'DEB') {
+            $newbuild = $BUILD;
+            $newbuild =~ s/(dev|alpha)/0/gi;                # dev
+            $newbuild =~ s/beta/1/gi;                       # beta
+            $newbuild =~ s/rc./2/gi;                        # rc
+            if ($newbuild !~ /-/) { $newbuild.='-3'; }      # finale
+            # now newbuild is 0-0 or 0-3 for example
+            print "Version is $MAJOR.$MINOR.$newbuild\n";
+    		
     		print "Remove target $FILENAMEDEB.deb...\n";
     		unlink("$DESTI/$FILENAMEDEB.deb");
 			
@@ -433,14 +461,6 @@ if ($nboftargetok) {
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/DEBIAN/CVS`;
  
  			print "Remove other files\n";
-		    $ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/DoliWamp-*`;
-		    $ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/DoliMamp-*`;
-		    $ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/dolibarr-*.tar`;
-		    $ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/dolibarr-*.tgz`;
-		    $ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/dolibarr-*.zip`;
-		    $ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/dolibarr-*.deb`;
-		    $ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/doxygen/doxygen_warnings.log`;
-		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/html`;
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/dbmodel`;
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/fpdf`;
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/dev/initdata`;
@@ -454,10 +474,6 @@ if ($nboftargetok) {
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/doc/font`;
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/doc/tshirt`;
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/doc/rollup`;
-		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/conf/conf.php.mysql`;
-		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/conf/conf.php.old`;
-		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/conf/conf.php.postgres`;
-		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/conf/conf*sav*`;
 		    $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/test`;
             # To remove once stable
             $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/htdocs/theme/bureau2crea`;
@@ -466,12 +482,6 @@ if ($nboftargetok) {
             open (SPECFROM,"<$SOURCE/build/deb/control") || die "Error";
             open (SPECTO,">$BUILDROOT/$PROJECT.tmp/DEBIAN/control") || die "Error";
             while (<SPECFROM>) {
-            	$newbuild = $BUILD;
-                $newbuild =~ s/(dev|alpha)/0/gi;				# dev
-                $newbuild =~ s/beta/1/gi;						# beta
-                $newbuild =~ s/rc./2/gi;						# rc
-                if ($newbuild !~ /-/) { $newbuild.='-3'; }		# finale
-                # now newbuild is 0-0 or 0-3 for example
                 $_ =~ s/__VERSION__/$MAJOR.$MINOR.$newbuild/;
                 print SPECTO $_;
             }
@@ -489,21 +499,12 @@ if ($nboftargetok) {
     		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/etc/$PROJECT\n";
-    		#$ret=`mkdir -p "$BUILDROOT/$PROJECT/etc/$PROJECT"`;
-
-    		#print "Copy changelog file into $BUILDROOT/$PROJECT/DEBIAN\n";
-    		#$ret=`cp "$SOURCE/ChangeLog" "$BUILDROOT/$PROJECT/DEBIAN/changelog"`;
-
     		print "Copy README file into $BUILDROOT/$PROJECT.tmp/DEBIAN\n";
     		$ret=`cp "$SOURCE/README" "$BUILDROOT/$PROJECT.tmp/DEBIAN/README"`;
 
     		print "Copy copyright file into $BUILDROOT/$PROJECT.tmp/DEBIAN\n";
     		$ret=`cp "$SOURCE/COPYRIGHT" "$BUILDROOT/$PROJECT.tmp/DEBIAN/copyright"`;
 
-    		#print "Copy apache conf file into $BUILDROOT/$PROJECT/etc/$PROJECT\n";
-    		#$ret=`cp "$SOURCE/build/deb/apache.conf" "$BUILDROOT/$PROJECT/etc/$PROJECT"`;
-
     		print "Create directory $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/documents\n";
     		$ret=`mkdir -p "$BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/documents"`;
 
@@ -539,6 +540,16 @@ if ($nboftargetok) {
         }
         
     	if ($target eq 'APS') {
+            $newbuild = $BUILD;
+            $newbuild =~ s/(dev|alpha)/0/gi;                # dev
+            $newbuild =~ s/beta/1/gi;                       # beta
+            $newbuild =~ s/rc./2/gi;                        # rc
+            if ($newbuild !~ /-/) { $newbuild.='-3'; }      # finale
+            # now newbuild is 0-0 or 0-3 for example
+            $REL1 = $newbuild; $REL1 =~ s/-.*$//gi;
+            if ($RPMSUBVERSION eq 'auto') { $RPMSUBVERSION = $newbuild; $RPMSUBVERSION =~ s/^.*-//gi; }
+            print "Version is $MAJOR.$MINOR.$REL1-$RPMSUBVERSION\n";
+    		
      		print "Remove target $FILENAMEAPS.zip...\n";
     		unlink "$DESTI/$FILENAMEAPS.zip";
  
@@ -551,63 +562,70 @@ if ($nboftargetok) {
             $ret=`$cmd`;
 
             print "Remove other files\n";
-            $ret=`rm -f $BUILDROOT/$PROJECT.tmp/build/DoliWamp-*`;
-            $ret=`rm -f $BUILDROOT/$PROJECT.tmp/build/DoliMamp-*`;
-            $ret=`rm -f $BUILDROOT/$PROJECT.tmp/build/dolibarr-*.tar`;
-            $ret=`rm -f $BUILDROOT/$PROJECT.tmp/build/dolibarr-*.tgz`;
-            $ret=`rm -f $BUILDROOT/$PROJECT.tmp/build/dolibarr-*.zip`;
-            $ret=`rm -f $BUILDROOT/$PROJECT.tmp/build/dolibarr-*.deb`;
-            $ret=`rm -f $BUILDROOT/$PROJECT.tmp/build/doxygen/doxygen_warnings.log`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/html`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/dbmodel`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/fpdf`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/initdata`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/iso-normes`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/phpcheckstyle`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/phpunit`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/spec`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/uml`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/dev/xdebug`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/doc/flyer`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/doc/font`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/doc/tshirt`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/doc/rollup`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/conf/conf.php.mysql`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/conf/conf.php.old`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/conf/conf.php.postgres`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/conf/conf*sav*`;
-            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/test`;
-
-            print "Create APS files\n";
-            $cmd="cp -pr \"$BUILDROOT/$PROJECT/build/aps/APP-META.xml\" \"$BUILDROOT/$PROJECT.tmp/$PROJECT/APP-META.xml\"";
-            $ret=`$cmd`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/dbmodel`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/fpdf`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/initdata`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/iso-normes`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/phpcheckstyle`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/phpunit`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/spec`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/uml`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/xdebug`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/doc/flyer`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/doc/font`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/doc/tshirt`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/doc/rollup`;
+            $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/test`;
+
+            $APSVERSION="1.1";
+            print "Create APS files $BUILDROOT/$PROJECT.tmp/$PROJECT/APP-META.xml\n";
+            open (SPECFROM,"<$BUILDROOT/$PROJECT/build/aps/APP-META-$APSVERSION.xml") || die "Error";
+            open (SPECTO,">$BUILDROOT/$PROJECT.tmp/$PROJECT/APP-META.xml") || die "Error";
+            while (<SPECFROM>) {
+                $newbuild = $BUILD;
+                $newbuild =~ s/(dev|alpha)/0/gi;                # dev
+                $newbuild =~ s/beta/1/gi;                       # beta
+                $newbuild =~ s/rc./2/gi;                        # rc
+                if ($newbuild !~ /-/) { $newbuild.='-3'; }      # finale
+                # now newbuild is 0-0 or 0-3 for example
+                $_ =~ s/__VERSION__/$MAJOR.$MINOR.$REL1/;
+                $_ =~ s/__RELEASE__/$RPMSUBVERSION/;
+                print SPECTO $_;
+            }
+            close SPECFROM;
+            close SPECTO;
+            print "Version set to $MAJOR.$MINOR.$newbuild\n";
             $cmd="cp -pr \"$BUILDROOT/$PROJECT/build/aps/configure\" \"$BUILDROOT/$PROJECT.tmp/$PROJECT/scripts/configure\"";
             $ret=`$cmd`;
+            $cmd="cp -pr \"$BUILDROOT/$PROJECT/build/aps/configure.php\" \"$BUILDROOT/$PROJECT.tmp/$PROJECT/scripts/configure.php\"";
+            $ret=`$cmd`;
             $cmd="cp -pr \"$BUILDROOT/$PROJECT/doc/images\" \"$BUILDROOT/$PROJECT.tmp/$PROJECT/images\"";
             $ret=`$cmd`;
  
+            print "Remove other files\n";
             $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev`;
             $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/doc`;
             
+            print "Build APP-LIST.xml files\n";
+            
             print "Compress $BUILDROOT/$PROJECT.tmp/$PROJECT into $FILENAMEAPS.zip...\n";
  
-            print "Go to directory $BUILDROOT/$PROJECT.tmp\n";
+            print "Go to directory $BUILDROOT/$PROJECT.tmp\/$PROJECT\n";
             $olddir=getcwd();
-            chdir("$BUILDROOT\/$PROJECT.tmp");
-            #$cmd= "7z a -r -tzip -xr\@\"$BUILDROOT\/$PROJECT.tmp\/$PROJECT\/build\/zip\/zip_exclude.txt\" -mx $BUILDROOT/$FILENAMEAPS.zip $BUILDROOT/$PROJECT.tmp/$PROJECT\\*";
-            $cmd= "zip -9 -r $BUILDROOT/$FILENAMEAPS.zip $PROJECT\\*";
+            chdir("$BUILDROOT\/$PROJECT.tmp\/$PROJECT");
+            $cmd= "zip -9 -r $BUILDROOT/$FILENAMEAPS.zip \*";
             print $cmd."\n";
             $ret= `$cmd`;
             chdir("$olddir");
                         
             if ($OS =~ /windows/i)
             {
-                print "Move $FILENAMEAPS.zip to $DESTI/$FILENAMEAPS.zip\n";
+                print "Move $BUILDROOT/$FILENAMEAPS.zip to $DESTI/$FILENAMEAPS.zip\n";
                 $ret=`mv "$BUILDROOT/$FILENAMEAPS.zip" "$DESTI/$FILENAMEAPS.zip"`;
             }
             else
             {
-                print "Move $FILENAMEAPS.zip to $DESTI/$FILENAMEAPS.zip\n";
+                print "Move $BUILDROOT/$FILENAMEAPS.zip to $DESTI/$FILENAMEAPS.zip\n";
                 $ret=`mv "$BUILDROOT/$FILENAMEAPS.zip" "$DESTI/$FILENAMEAPS.zip"`;
             }
             next;
-- 
GitLab