From 1404ed0ad704abec89918f8af79c99a489710fa7 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Fri, 19 Oct 2018 09:53:43 +0200 Subject: [PATCH 1/2] feat(install): add requirement checks on install from CLI Signed-off-by: Thierry Bugier --- tools/cli_install.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/cli_install.php b/tools/cli_install.php index 618681b5..c2f81a76 100644 --- a/tools/cli_install.php +++ b/tools/cli_install.php @@ -151,6 +151,16 @@ $plugin = new Plugin(); +// Check plugin's requirements +try { + if (!$plugin->checkVersions('flyvemdm')) { + exit(1); + } +} catch (LogicException $e) { + echo $e->getMessage(); + exit(2); +} + // Install the plugin $plugin->getFromDBbyDir("flyvemdm"); print("Installing Plugin Id: " . $plugin->fields['id'] . " version " . $plugin->fields['version'] . "\n"); From d921a4e63f276ae7d9f58b41bca09b17efba9ab2 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Wed, 17 Oct 2018 21:26:38 +0200 Subject: [PATCH 2/2] refactor(travis): factorize patch arguments Also prevents patch to detect already applied patch and revert them Signed-off-by: Thierry Bugier --- tests/before_script.sh | 12 +++++++----- tools/cli_install.php | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/before_script.sh b/tests/before_script.sh index 4a835f1d..b3d4ea74 100755 --- a/tests/before_script.sh +++ b/tests/before_script.sh @@ -34,18 +34,20 @@ mkdir plugins/fusioninventory && git clone --depth=35 $FI_SOURCE -b $FI_BRANCH p IFS=/ read -a repo <<< $TRAVIS_REPO_SLUG mv ../${repo[1]} plugins/flyvemdm +# patch settings +PATCH_ARGS="-p1 -N --batch" + # patch Fusion Inventory when needed cd plugins/fusioninventory -if [[ $FI_BRANCH == "master" ]] ; then patch -p1 --batch < ../flyvemdm/tests/patches/fusioninventory/fi-raise-max-version.patch; fi -if [[ $FI_BRANCH == "master" ]] ; then patch -p1 --batch < ../flyvemdm/tests/patches/fusioninventory/compat-glpi-9-3-2.diff; fi -if [[ $FI_BRANCH == "glpi9.3" ]] ; then patch -p1 --batch < ../flyvemdm/tests/patches/fusioninventory/compat-glpi-9-3-2.diff; fi +if [[ $FI_BRANCH == "master" ]] ; then patch $PATCH_ARGS < ../flyvemdm/tests/patches/fusioninventory/fi-raise-max-version.patch; fi +if [[ $FI_BRANCH == "master" ]] ; then patch $PATCH_ARGS < ../flyvemdm/tests/patches/fusioninventory/compat-glpi-9-3-2.diff; fi +if [[ $FI_BRANCH == "glpi9.3" ]] ; then patch $PATCH_ARGS < ../flyvemdm/tests/patches/fusioninventory/compat-glpi-9-3-2.diff; fi cd ../.. # patch GLPI when needed -# if [[ $GLPI_BRANCH == "9.2.1" ]] ; then patch -p1 --batch < plugins/flyvemdm/tests/patches/glpi/10f8dabfc5e20bb5a4e7d4ba4b93706871156a8a.diff; fi # prepare plugin to test cd plugins/flyvemdm -if [[ $GLPI_BRANCH == "master" ]] ; then patch -p1 --batch < tests/patches/allow-test-on-master-branch.patch; fi +if [[ $GLPI_BRANCH == "master" ]] ; then patch $PATCH_ARGS < tests/patches/allow-test-on-master-branch.patch; fi composer install --no-interaction diff --git a/tools/cli_install.php b/tools/cli_install.php index c2f81a76..1059fb55 100644 --- a/tools/cli_install.php +++ b/tools/cli_install.php @@ -154,6 +154,7 @@ // Check plugin's requirements try { if (!$plugin->checkVersions('flyvemdm')) { + echo PHP_EOL; exit(1); } } catch (LogicException $e) {