mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add patch for old random headers on PHP 8.4
This commit is contained in:
parent
2ee6851e7b
commit
6d7209f44a
@ -176,12 +176,20 @@ pecl_install() {
|
|||||||
local extension=$1
|
local extension=$1
|
||||||
local prefix=${2:-extension}
|
local prefix=${2:-extension}
|
||||||
add_pecl >/dev/null 2>&1
|
add_pecl >/dev/null 2>&1
|
||||||
|
disable_extension_helper "${extension%-*}" >/dev/null 2>&1
|
||||||
|
# Compare version with 8.3 so it runs only on 8.4 and above
|
||||||
|
# Install using the source interface as it allows for patching.
|
||||||
|
if [[ $(printf "%s\n%s" "${version:?}" "8.3" | sort -V | head -n1) != "$version" ]]; then
|
||||||
|
extension_version=${extension##*-};
|
||||||
|
[ "$extension_version" = "${extension%-*}" ] && extension_version=$(get_pecl_version "$extension" "stable")
|
||||||
|
add_extension_from_source "${extension%-*}" https://pecl.php.net "${extension%-*}" "${extension%-*}" "$extension_version" "$prefix" pecl
|
||||||
|
check_extension "${extension%-*}" && return 0 || return 1;
|
||||||
|
else
|
||||||
cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')"
|
cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')"
|
||||||
prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS) MAKEFLAGS='-j $cpu_count'"
|
prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS) MAKEFLAGS='-j $cpu_count'"
|
||||||
suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
|
suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
|
||||||
IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
||||||
(( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1
|
(( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1
|
||||||
disable_extension_helper "${extension%-*}" >/dev/null 2>&1
|
|
||||||
if [ "$version" = "5.3" ]; then
|
if [ "$version" = "5.3" ]; then
|
||||||
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1
|
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
@ -191,6 +199,7 @@ pecl_install() {
|
|||||||
sudo pecl info "$extension" | grep -iq 'zend extension' && prefix=zend_extension
|
sudo pecl info "$extension" | grep -iq 'zend extension' && prefix=zend_extension
|
||||||
enable_extension "${extension%-*}" "$prefix"
|
enable_extension "${extension%-*}" "$prefix"
|
||||||
return "$exit_code"
|
return "$exit_code"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install a specific version of PECL extension.
|
# Function to install a specific version of PECL extension.
|
||||||
|
12
src/scripts/extensions/patches/common.sh
Normal file
12
src/scripts/extensions/patches/common.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
process_file() {
|
||||||
|
local file=$1
|
||||||
|
sed -i '0,/#include.*\(php_lcg.h\|php_mt_rand.h\|php_rand.h\|standard\/php_random\.h\).*/s//\#include <ext\/random\/php_random.h>/' "$file"
|
||||||
|
sed -i '/#include.*\(php_lcg.h\|php_mt_rand.h\|php_rand.h\|standard\/php_random\.h\)/d' "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f process_file
|
||||||
|
|
||||||
|
# Compare with 8.3 so it runs only on 8.4 and above
|
||||||
|
if [[ $(printf "%s\n%s" "${version:?}" "8.3" | sort -V | head -n1) != "$version" ]]; then
|
||||||
|
find . -type f \( -name "*.c" -o -name "*.h" \) -exec bash -c 'process_file "$0"' {} \;
|
||||||
|
fi
|
@ -89,6 +89,8 @@ run_group() {
|
|||||||
|
|
||||||
patch_extension() {
|
patch_extension() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
|
# shellcheck source=.
|
||||||
|
. "${scripts:?}"/extensions/patches/common.sh
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user