From 304555d580ffba58ca75155d2ec91d0524a40fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Mon, 24 Feb 2020 14:03:45 +0100 Subject: [PATCH] added check_composer.sh --- scripts/check_composer.sh | 51 +++++++++++++++++++++++++++++++++++++++ scripts/update-all.sh | 7 +++++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 scripts/check_composer.sh diff --git a/scripts/check_composer.sh b/scripts/check_composer.sh new file mode 100644 index 0000000..d518593 --- /dev/null +++ b/scripts/check_composer.sh @@ -0,0 +1,51 @@ +#! /usr/bin/env bash + +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +vercomp () { + if [[ $1 == $2 ]] + then + return 1 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + done + return 0 +} + +composer_version_string=`composer --version` +composer_version=`echo $composer_version_string | awk 'BEGIN { FS="[ ]" } ; { print $3 }'` + +if [[ $(vercomp $composer_version 1.9.0 ; echo $?) -eq 0 ]]; then + echo -e "${RED}Please update your version of composer.${NC} The minimum requirements is 1.9.0." + echo -e "The minimum requirement is 1.9.0. You can use the following to update your composer installation:" + + cat << EOF + + $ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" + $ php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" + $ php composer-setup.php --install-dir=/tmp --filename=composer + $ mv /tmp/composer /usr/local/bin/composer +EOF + + exit 1 + +fi diff --git a/scripts/update-all.sh b/scripts/update-all.sh index 7218e99..78fdf36 100755 --- a/scripts/update-all.sh +++ b/scripts/update-all.sh @@ -52,7 +52,12 @@ if [ $? != 0 ]; then exit 1 fi -composer install -o +./scripts/check_composer.sh +if [[ $? -eq 1 ]]; then + exit 1 +fi + +composer install -o --no-dev pathCore="module/Monarc/Core" pathBO="module/Monarc/BackOffice"