mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Fix variable scope
This commit is contained in:
parent
57662657e0
commit
c1285cc7f3
@ -55,7 +55,7 @@ get_extension_map() {
|
|||||||
# Function to enable extension dependencies which are also extensions.
|
# Function to enable extension dependencies which are also extensions.
|
||||||
enable_extension_dependencies() {
|
enable_extension_dependencies() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
prefix=$2
|
local prefix=$2
|
||||||
[ -e /tmp/extdisabled/"$version"/"$extension" ] || return;
|
[ -e /tmp/extdisabled/"$version"/"$extension" ] || return;
|
||||||
get_extension_map
|
get_extension_map
|
||||||
for dependency in $(grep "$extension:" /tmp/map"$version".orig | cut -d ':' -f 2 | tr '\n' ' '); do
|
for dependency in $(grep "$extension:" /tmp/map"$version".orig | cut -d ':' -f 2 | tr '\n' ' '); do
|
||||||
@ -115,7 +115,7 @@ configure_pecl() {
|
|||||||
# Function to add an extension.
|
# Function to add an extension.
|
||||||
add_extension() {
|
add_extension() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
prefix=$2
|
local prefix=$2
|
||||||
enable_extension "$extension" "$prefix"
|
enable_extension "$extension" "$prefix"
|
||||||
if check_extension "$extension"; then
|
if check_extension "$extension"; then
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
@ -147,8 +147,8 @@ pecl_install() {
|
|||||||
# Function to install a specific version of PECL extension.
|
# Function to install a specific version of PECL extension.
|
||||||
add_pecl_extension() {
|
add_pecl_extension() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
pecl_version=$2
|
local pecl_version=$2
|
||||||
prefix=$3
|
local prefix=$3
|
||||||
enable_extension "$extension" "$prefix"
|
enable_extension "$extension" "$prefix"
|
||||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
||||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||||
@ -166,8 +166,8 @@ add_pecl_extension() {
|
|||||||
# Function to setup pre-release extensions using PECL.
|
# Function to setup pre-release extensions using PECL.
|
||||||
add_unstable_extension() {
|
add_unstable_extension() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
stability=$2
|
local stability=$2
|
||||||
prefix=$3
|
local prefix=$3
|
||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Function to parse extension environment variables
|
# Function to parse extension environment variables
|
||||||
parse_args() {
|
parse_args() {
|
||||||
extension=$1
|
local extension=$1
|
||||||
suffix=$(echo "$2" | tr '[:lower:]' '[:upper:]')
|
suffix=$(echo "$2" | tr '[:lower:]' '[:upper:]')
|
||||||
up_ext_name=$(echo "$extension" | tr '[:lower:]' '[:upper:]')
|
up_ext_name=$(echo "$extension" | tr '[:lower:]' '[:upper:]')
|
||||||
var="${extension}_${suffix}"
|
var="${extension}_${suffix}"
|
||||||
@ -12,7 +12,7 @@ parse_args() {
|
|||||||
|
|
||||||
# Function to log if a library is installed
|
# Function to log if a library is installed
|
||||||
add_lib_log() {
|
add_lib_log() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if check_lib "$lib"; then
|
if check_lib "$lib"; then
|
||||||
add_log "${tick:?}" "$lib" "Installed"
|
add_log "${tick:?}" "$lib" "Installed"
|
||||||
else
|
else
|
||||||
@ -22,7 +22,7 @@ add_lib_log() {
|
|||||||
|
|
||||||
# Function to check if a library is installed
|
# Function to check if a library is installed
|
||||||
check_lib() {
|
check_lib() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if [ "$(uname -s)" = "Linux" ]; then
|
if [ "$(uname -s)" = "Linux" ]; then
|
||||||
[ "x$(dpkg -s "$lib" 2>/dev/null | grep Status)" != "x" ]
|
[ "x$(dpkg -s "$lib" 2>/dev/null | grep Status)" != "x" ]
|
||||||
else
|
else
|
||||||
@ -32,7 +32,7 @@ check_lib() {
|
|||||||
|
|
||||||
# Function to add a library on linux
|
# Function to add a library on linux
|
||||||
add_linux_libs() {
|
add_linux_libs() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if ! check_lib "$lib"; then
|
if ! check_lib "$lib"; then
|
||||||
install_packages "$lib" >/dev/null 2>&1 || true
|
install_packages "$lib" >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
@ -41,7 +41,7 @@ add_linux_libs() {
|
|||||||
|
|
||||||
# Function to add a library on macOS
|
# Function to add a library on macOS
|
||||||
add_darwin_libs() {
|
add_darwin_libs() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if ! check_lib "$lib"; then
|
if ! check_lib "$lib"; then
|
||||||
brew install "$lib" >/dev/null 2>&1 || true
|
brew install "$lib" >/dev/null 2>&1 || true
|
||||||
if [[ "$lib" = *@* ]]; then
|
if [[ "$lib" = *@* ]]; then
|
||||||
@ -53,7 +53,7 @@ add_darwin_libs() {
|
|||||||
|
|
||||||
# Function to add required libraries
|
# Function to add required libraries
|
||||||
add_libs() {
|
add_libs() {
|
||||||
all_libs=("$@")
|
local all_libs=("$@")
|
||||||
for lib in "${all_libs[@]}"; do
|
for lib in "${all_libs[@]}"; do
|
||||||
if [ "$(uname -s)" = "Linux" ]; then
|
if [ "$(uname -s)" = "Linux" ]; then
|
||||||
add_linux_libs "$lib"
|
add_linux_libs "$lib"
|
||||||
@ -65,8 +65,8 @@ add_libs() {
|
|||||||
|
|
||||||
# Function to run command in a group
|
# Function to run command in a group
|
||||||
run_group() {
|
run_group() {
|
||||||
command=$1
|
local command=$1
|
||||||
log=$2
|
local log=$2
|
||||||
echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
|
echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
|
||||||
echo "$GROUP$log"
|
echo "$GROUP$log"
|
||||||
. ./run_group.sh
|
. ./run_group.sh
|
||||||
@ -75,7 +75,7 @@ run_group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
patch_extension() {
|
patch_extension() {
|
||||||
extension=$1
|
local extension=$1
|
||||||
if [ -e "${scripts:?}"/extensions/patches/"$extension".sh ]; then
|
if [ -e "${scripts:?}"/extensions/patches/"$extension".sh ]; then
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/extensions/patches/"$extension".sh
|
. "${scripts:?}"/extensions/patches/"$extension".sh
|
||||||
@ -84,7 +84,8 @@ patch_extension() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetch_extension() {
|
fetch_extension() {
|
||||||
fetch=$1
|
local extension=$1
|
||||||
|
local fetch=$2
|
||||||
if [ "$fetch" = "clone" ]; then
|
if [ "$fetch" = "clone" ]; then
|
||||||
run_group "git clone -nv $url/$org/$repo /tmp/$repo-$release" "git clone"
|
run_group "git clone -nv $url/$org/$repo /tmp/$repo-$release" "git clone"
|
||||||
cd /tmp/"$repo-$release" || exit 1
|
cd /tmp/"$repo-$release" || exit 1
|
||||||
@ -109,13 +110,13 @@ fetch_extension() {
|
|||||||
|
|
||||||
# Function to install extension from a git repository
|
# Function to install extension from a git repository
|
||||||
add_extension_from_source() {
|
add_extension_from_source() {
|
||||||
extension="${1/pecl_/}"
|
local extension="${1/pecl_/}"
|
||||||
url=$2
|
local url=$2
|
||||||
org=$3
|
local org=$3
|
||||||
repo=$4
|
local repo=$4
|
||||||
release=$5
|
local release=$5
|
||||||
prefix=$6
|
local prefix=$6
|
||||||
fetch=${7:-clone}
|
local fetch=${7:-clone}
|
||||||
slug="$extension-$release"
|
slug="$extension-$release"
|
||||||
source="$url/$org/$repo"
|
source="$url/$org/$repo"
|
||||||
libraries="$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
libraries="$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
||||||
@ -127,7 +128,7 @@ add_extension_from_source() {
|
|||||||
(
|
(
|
||||||
add_devtools phpize >/dev/null 2>&1
|
add_devtools phpize >/dev/null 2>&1
|
||||||
disable_extension_helper "$extension"
|
disable_extension_helper "$extension"
|
||||||
fetch_extension "$fetch"
|
fetch_extension "$extension" "$fetch"
|
||||||
if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then
|
if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then
|
||||||
add_log "${cross:?}" "$source" "$source does not have a PHP extension"
|
add_log "${cross:?}" "$source" "$source does not have a PHP extension"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user