From 890ea4bca9182dac3ea6debfbb5a055bc0a239e7 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sun, 7 Mar 2021 04:05:41 +0530 Subject: [PATCH] Fix enable extension --- src/scripts/common.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/scripts/common.sh b/src/scripts/common.sh index 47bcb0a3..3cd01572 100644 --- a/src/scripts/common.sh +++ b/src/scripts/common.sh @@ -104,12 +104,34 @@ check_extension() { fi } +# Function to enable cached extensions. +enable_cache_extension() { + deps=() + for ext in /tmp/extcache/"$1"/*; do + deps+=("$(basename "$ext")") + done + if [ "x${deps[*]}" = "x" ]; then + sudo rm -rf /tmp/extcache/"$1" + enable_extension "$1" "$2" + else + deps+=("$1") + if php "${deps[@]/#/-d ${2}=}" -m 2>/dev/null | grep -i -q "$1"; then + for ext in "${deps[@]}"; do + sudo rm -rf /tmp/extcache/"$ext" + enable_extension "$ext" "$2" + done + fi + fi +} + # Function to enable existing extensions. enable_extension() { if [ -e /tmp/setup_php_dismod ] && grep -q "$1" /tmp/setup_php_dismod; then sudo phpenmod -v "$version" "$1" >/dev/null 2>&1 fi - if ! check_extension "$1" && [ -e "${ext_dir:?}/$1.so" ]; then + if [ -d /tmp/extcache/"$1" ]; then + enable_cache_extension "$1" "$2" + elif ! check_extension "$1" && [ -e "${ext_dir:?}/$1.so" ]; then echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null fi }