From 9f13187034d5056367818f051ad3acbe97a8d875 Mon Sep 17 00:00:00 2001
From: ArmandBahi <armand.bahi@veremes.com>
Date: Tue, 23 Oct 2018 15:18:56 +0200
Subject: [PATCH] Utilisation des utils sans avoir besoin de libxml2

---
 README.md         |  1 -
 utils/get_deps.sh | 22 ++++++++++------------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index 66a090fa..3a0e032d 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,6 @@ vMap is able to manage business objects while using WMS producing server softwar
 To install the dev version of this project run the following steps:
 
 - Install the app via the VAI setup on var/www/[app name]
-- Run `sudo apt-get install libxml2-utils`
 - Clone this repo on var/wwww/[app name]\_dev
 - Run install.sh and give the var/www/[app name] path when asked to build your tree structure
 - Now you have the correct versioned tree structure, rename var/www/[app name] as var/www/[app name]\_vai and var/www/[app name]\_dev as var/www/[app name]
diff --git a/utils/get_deps.sh b/utils/get_deps.sh
index 92b02739..c9ab93bd 100755
--- a/utils/get_deps.sh
+++ b/utils/get_deps.sh
@@ -1,24 +1,22 @@
 #!/bin/bash
 #
 #	Récupère l'ensemble des dépendances depuis conf/_install/dependency.xml
-#	Nécessite xmllint : sudo apt install libxml2-utils
 #
 #
 #
 #
 
-
 if [ "../conf/_install/dependency.xml" ]; then
 
-	let depsCount=$(xmllint --xpath 'count(//dependenciesCollection/dependency/name)' ../conf/_install/dependency.xml)
 	declare -A aDeps
 	vitisVersion=master
+	dependencies=($(cat "../conf/_install/dependency.xml" | tr -d '\040\011\012\015' | grep -oP '<dependency>([\s\S]*?)<\/dependency>'))
 
-	for (( i=1; i <= $depsCount; i++ )); do
+	for i in ${!dependencies[*]}; do
 
-		sName="$(xmllint --xpath 'string(//dependenciesCollection/dependency['$i']/name)' ../conf/_install/dependency.xml)"
-		sVersion="$(xmllint --xpath 'string(//dependenciesCollection/dependency['$i']/version)' ../conf/_install/dependency.xml)"
-		sNature="$(xmllint --xpath 'string(//dependenciesCollection/dependency['$i']/nature)' ../conf/_install/dependency.xml)"
+		sName=$(grep -oP '(?<=name>)[^<]+' <<< ${dependencies[$i]})
+		sVersion=$(grep -oP '(?<=version>)[^<]+' <<< ${dependencies[$i]})
+		sNature=$(grep -oP '(?<=nature>)[^<]+' <<< ${dependencies[$i]})
 
 		if [ $sName == "vitis" ]; then
 			vitisVersion=$sVersion
@@ -33,16 +31,16 @@ if [ "../conf/_install/dependency.xml" ]; then
 
 	echo "[INFO] dependencies:"
 	echo "vitis : $vitisVersion"
-	for (( i=1; i <= $depsCount; i++ )); do
-
-		echo "name: ${aDeps[$i, name]}"
-		echo "version: ${aDeps[$i, version]}"
-
+	for i in ${!dependencies[*]}; do
+		echo "(${aDeps[$i, nature]}) ${aDeps[$i, name]} : ${aDeps[$i, version]}"
 	done
 
+	depsCount=${#dependencies[@]}
+
 	export vitisVersion
 	export depsCount
 	export aDeps
+
 else
 	echo "[ERROR] ../conf/_install/dependency.xml not found"
 fi
-- 
GitLab