Skip to content
This repository was archived by the owner on Aug 9, 2021. It is now read-only.

WIP Add requirement checks on install from CLI #784

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tests/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

11 changes: 11 additions & 0 deletions tools/cli_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@

$plugin = new Plugin();

// Check plugin's requirements
try {
if (!$plugin->checkVersions('flyvemdm')) {
echo PHP_EOL;
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");
Expand Down