-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-extensions
More file actions
executable file
·59 lines (51 loc) · 1.86 KB
/
Copy pathinstall-extensions
File metadata and controls
executable file
·59 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
builtin_extension_install() {
ext=${1:1:-1}
echo "---> Installing extension ${ext}"
# shellcheck disable=SC2154
if [ ! -e "${php_layer_dir}/ext/${ext}.so" ]; then
php-ext-configure "${ext}" --with-php-config="${php_layer_dir}"/bin/php-config
INSTALL_ROOT="${php_layer_dir}" php-ext-install --ini-name "${php_layer_dir}"/config/php.ini "${ext}"
fi
}
pecl_extension_install() {
ext=${1:1:-1}
echo "---> Installing extension ${ext}"
# shellcheck disable=SC2154
if [ ! -e "${php_layer_dir}/ext/${ext}.so" ]; then
pecl install xdebug
ext_name=$(echo "${ext}" | awk -F "-" '{print $1}')
php-ext-enable --ini-name "${php_layer_dir}"/config/php.ini "${ext_name}"
fi
}
urls_extension_install() {
ext_url=${1:1:-1}
ext_tar=$(echo "${ext_url}" | awk -F "/" '{print $NF}')
ext=$(echo "${ext_tar}" | awk -F "-" '{print $1}')
echo "---> Installing extension ${ext_url}"
curl -fsSL "${ext_url}" -o "${ext_tar}" &&
mkdir -p /tmp/"${ext}" &&
tar -xf "${ext_tar}" -C /tmp/"${ext}" --strip-components=1 &&
rm "${ext_tar}" &&
php-ext-configure /tmp/"${ext}" --enable-"${ext}" --with-php-config="${php_layer_dir}"/bin/php-config &&
INSTALL_ROOT="${php_layer_dir}" php-ext-install --ini-name "${php_layer_dir}"/config/php.ini /tmp/"${ext}" &&
rm -r /tmp/"${ext}"
}
main() {
builtin_length=$(jq '.builtin|length' extensions.json)
for ((i = 0; i < builtin_length; i++)); do
ext=$(jq .builtin[$i] extensions.json)
builtin_extension_install "${ext}"
done
pecl_length=$(jq '.pecl|length' extensions.json)
for ((i = 0; i < pecl_length; i++)); do
ext=$(jq .pecl[$i] extensions.json)
pecl_extension_install "${ext}"
done
urls_length=$(jq '.urls|length' extensions.json)
for ((i = 0; i < urls_length; i++)); do
ext=$(jq .urls[$i] extensions.json)
urls_extension_install "${ext}"
done
}
main "$@"