Fix command and PHP module checks in build system - closes #178

This commit is contained in:
Starbeamrainbowlabs 2019-12-24 17:32:45 +00:00
parent 05615b4c81
commit 2171da1df8
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 26 additions and 2 deletions

View File

@ -48,6 +48,24 @@ if [[ "$#" -lt 1 ]]; then
exit 1;
fi
# Tests to see if a PHP module is installed.
# $1 - The name of the module to check for
# $2 - The mode of operation. Values: optional, required
# $3 - The error message to show
test_php_module() {
module_name="${1}";
mode="${2}";
reason="${3}";
subtask_begin "Checking for ${module_name} PHP module";
php -m | grep -q "${module_name}";
exit_code="${?}";
if [[ "${mode}" = "optional" ]] && [[ "${exit_code}" -ne 0 ]]; then
echo "${FYEL}${HC}Warning: The PHP module ${module} was not found. It is needed to ${reason}.${RS}";
fi
subtask_end "${exit_code}";
}
###############################################################################
task_setup() {
@ -55,7 +73,13 @@ task_setup() {
check_command git true;
check_command npm true;
check_command npm true;
check_command php true;
test_php_module "mbstring" "required" "handle utf-8 characters correctly";
test_php_module "imagick" "optional" "generate image previews";
test_php_module "fileinfo" "optional" "properly check the mime type of uploaded files";
test_php_module "zip" "optional" "compressing exports";
test_php_module "intl" "required" "transliteration in the search engine and when sending emails when utf-8 is disabled";
test_php_module "sqlite" "optional" "store the inverted search index";
check_command jq true optional;
[[ "$?" -eq 0 ]] || echo -e "${FYEL}${HC}Warning: jq is required to update the theme index.${RS}";
check_command firefox true optional;

View File

@ -8,7 +8,7 @@
- `imagick` (for preview generation)
- `fileinfo` (for proper mime type checking of uploaded files)
- `zip` (for compressing exports)
- `intl` (for Unicode text normalization when searching and in the id index)
- `intl` (for Unicode text normalization when searching and in the id index, and when sending emails when utf-8 mode is disabled)
- `sqlite` (for search index storage; uses [PDO](https://www.php.net/manual/en/ref.pdo-sqlite.php))
- Write access to Pepperminty Wiki's own folder (only for editing)
- Recommended: Block access to `peppermint.json`, where it stores it's settings