mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Update ini files for all available SAPI
This commit is contained in:
parent
5a15252e66
commit
f0fb8731a5
@ -24,7 +24,7 @@ describe('Config tests', () => {
|
||||
true
|
||||
);
|
||||
expect(linux).toContain(
|
||||
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata"'
|
||||
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${ini_file[@]}"'
|
||||
);
|
||||
|
||||
linux = await config.addINIValues(
|
||||
@ -40,7 +40,7 @@ describe('Config tests', () => {
|
||||
'darwin'
|
||||
);
|
||||
expect(darwin).toContain(
|
||||
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata"'
|
||||
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${ini_file[@]}"'
|
||||
);
|
||||
|
||||
darwin = await config.addINIValues(
|
||||
|
5
dist/index.js
vendored
5
dist/index.js
vendored
@ -2461,7 +2461,10 @@ async function addINIValuesUnix(ini_values_csv) {
|
||||
script +=
|
||||
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
||||
});
|
||||
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||
return ('echo "' +
|
||||
ini_values.join('\n') +
|
||||
'" | sudo tee -a "${ini_file[@]}" >/dev/null 2>&1' +
|
||||
script);
|
||||
}
|
||||
exports.addINIValuesUnix = addINIValuesUnix;
|
||||
/**
|
||||
|
@ -14,7 +14,12 @@ export async function addINIValuesUnix(
|
||||
script +=
|
||||
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
||||
});
|
||||
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||
return (
|
||||
'echo "' +
|
||||
ini_values.join('\n') +
|
||||
'" | sudo tee -a "${ini_file[@]}" >/dev/null 2>&1' +
|
||||
script
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,7 +106,7 @@ enable_extension() {
|
||||
sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
|
||||
fi
|
||||
if ! check_extension "$1" && [ -e "${ext_dir:?}/$1.so" ]; then
|
||||
echo "$2=${ext_dir:?}/$1.so" >>"${pecl_file:-$ini_file}"
|
||||
echo "$2=${ext_dir:?}/$1.so" >>"${pecl_file:-${ini_file[@]}}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ enable_extension() {
|
||||
configure_pecl() {
|
||||
if ! [ -e /tmp/pecl_config ] && command -v pecl >/dev/null && command -v pear >/dev/null; then
|
||||
for script in pear pecl; do
|
||||
sudo "$script" config-set php_ini "${pecl_file:-$ini_file}"
|
||||
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
|
||||
sudo "$script" channel-update "$script".php.net
|
||||
done
|
||||
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
|
||||
|
@ -5,7 +5,7 @@ add_blackfire() {
|
||||
no_dot_version=${version/./}
|
||||
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
extension_version=$(echo "$extension" | cut -d '-' -f 2)
|
||||
blackfire_ini_file="${scan_dir:?}/50-blackfire.ini"
|
||||
blackfire_ini_file="${pecl_file:-${ini_file[@]}}"
|
||||
if [ ! -e "${ext_dir:?}/blackfire.so" ]; then
|
||||
if [ "$extension_version" = "blackfire" ]; then
|
||||
extension_version=$(get -s -n "" https://blackfire.io/api/v1/releases | grep -Eo 'php":"([0-9]+.[0-9]+.[0-9]+)' | cut -d '"' -f 3)
|
||||
|
@ -9,7 +9,6 @@ add_phalcon_helper() {
|
||||
${apt_install:?} "php${version:?}-$extension"
|
||||
fi
|
||||
else
|
||||
phalcon_ini_file=${ini_file:?}
|
||||
sed -i '' '/extension.*psr/d' "${ini_file:?}"
|
||||
brew tap shivammathur/homebrew-phalcon
|
||||
brew install phalcon@"${version:?}"_"$extension_major_version"
|
||||
@ -58,7 +57,7 @@ add_phalcon() {
|
||||
extension=$1
|
||||
status='Enabled'
|
||||
os_name=$(uname -s)
|
||||
phalcon_ini_file="${scan_dir:?}/50-phalcon.ini"
|
||||
phalcon_ini_file="${pecl_file:-${ini_file[@]}}"
|
||||
extension_major_version=${extension: -1}
|
||||
if [ "$extension_major_version" = "4" ]; then
|
||||
add_phalcon4 >/dev/null 2>&1
|
||||
|
@ -48,9 +48,9 @@ install_packages() {
|
||||
# Function to delete extensions.
|
||||
delete_extension() {
|
||||
extension=$1
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "${ini_file:?}"
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "${pecl_file:?}"
|
||||
sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "${ini_file[@]}"
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$pecl_file"
|
||||
sudo rm -rf "$scan_dir"/*"$extension"* "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||
if [ "${runner:?}" = "self-hosted" ]; then
|
||||
$apt_remove "php-$extension" "php$version-$extension" >/dev/null 2>&1 || true
|
||||
fi
|
||||
@ -79,14 +79,16 @@ add_pdo_extension() {
|
||||
if check_extension "$pdo_ext"; then
|
||||
add_log "${tick:?}" "$pdo_ext" "Enabled"
|
||||
else
|
||||
ext=$1; ext_name=$1;
|
||||
ext=$1
|
||||
ext_name=$1
|
||||
sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1
|
||||
if ! check_extension "pdo" 2>/dev/null; then echo "extension=pdo.so" >>"$ini_file"; fi
|
||||
if ! check_extension "pdo" 2>/dev/null; then echo "extension=pdo.so" | sudo tee -a "${ini_file[@]}"; fi
|
||||
if [ "$ext" = "mysql" ]; then
|
||||
enable_extension "mysqlnd" "extension"
|
||||
ext_name="mysqli"
|
||||
elif [ "$ext" = "sqlite" ]; then
|
||||
ext="sqlite3"; ext_name="sqlite3";
|
||||
ext="sqlite3"
|
||||
ext_name="sqlite3"
|
||||
fi
|
||||
add_extension "$ext_name" "extension" >/dev/null 2>&1
|
||||
add_extension "$pdo_ext" "extension" >/dev/null 2>&1
|
||||
@ -111,7 +113,7 @@ add_extension() {
|
||||
fi
|
||||
add_extension_log "$extension" "Installed and enabled"
|
||||
fi
|
||||
sudo chmod 777 "$ini_file"
|
||||
sudo chmod 777 "${ini_file[@]}"
|
||||
}
|
||||
|
||||
# Function to install a PECL version.
|
||||
@ -232,6 +234,15 @@ add_php() {
|
||||
status="Installed"
|
||||
}
|
||||
|
||||
# Function to ini file for pear and link it to each SAPI.
|
||||
link_pecl_file() {
|
||||
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
||||
for file in "${ini_file[@]}"; do
|
||||
sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d"
|
||||
[ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ] && sudo ln -sf "$pecl_file" "$sapi_scan_dir/99-pecl.ini"
|
||||
done
|
||||
}
|
||||
|
||||
# Function to Setup PHP
|
||||
setup_php() {
|
||||
step_log "Setup PHP"
|
||||
@ -259,11 +270,12 @@ setup_php() {
|
||||
semver=$(php_semver)
|
||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||
ini_dir=$(php --ini | grep "(php.ini)" | sed -e "s|.*: s*||")
|
||||
pecl_file="$scan_dir"/99-pecl.ini
|
||||
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
||||
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
|
||||
link_pecl_file
|
||||
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
||||
sudo chmod 777 "$ini_file" "$pecl_file" "${tool_path_dir:?}"
|
||||
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
|
||||
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||
add_log "${tick:?}" "PHP" "$status PHP $semver"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user