mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-19 12:04:43 +07:00
Release v2-verbose
This commit is contained in:
@ -20,23 +20,23 @@ self_hosted_helper() {
|
||||
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
||||
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
||||
fi
|
||||
sudo mkdir -p /opt/hostedtoolcache >/dev/null 2>&1 || true
|
||||
sudo mkdir -p /opt/hostedtoolcache || true
|
||||
install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
|
||||
}
|
||||
|
||||
# Function to fix broken packages.
|
||||
fix_broken_packages() {
|
||||
sudo apt --fix-broken install >/dev/null 2>&1
|
||||
sudo apt --fix-broken install
|
||||
}
|
||||
|
||||
# Function to install a package
|
||||
install_packages() {
|
||||
packages=("$@")
|
||||
if ! [ -e /etc/dpkg/dpkg.cfg.d/force-confnew ]; then
|
||||
echo "force-confnew" | sudo tee /etc/dpkg/dpkg.cfg.d/force-confnew >/dev/null 2>&1
|
||||
echo "force-confnew" | sudo tee /etc/dpkg/dpkg.cfg.d/force-confnew
|
||||
trap "sudo rm -f /etc/dpkg/dpkg.cfg.d/force-confnew 2>/dev/null" exit
|
||||
fi
|
||||
$apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" >/dev/null 2>&1)
|
||||
$apt_install "${packages[@]}" || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" )
|
||||
}
|
||||
|
||||
# Function to disable an extension.
|
||||
@ -48,10 +48,10 @@ disable_extension_helper() {
|
||||
disable_extension_dependents "$extension"
|
||||
fi
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "${ini_file[@]}" "$pecl_file"
|
||||
sudo find "$ini_dir"/.. -name "*-$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
||||
sudo find "$ini_dir"/.. -name "*-$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete || true
|
||||
sudo rm -f /tmp/php"$version"_extensions
|
||||
mkdir -p /tmp/extdisabled/"$version"
|
||||
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
|
||||
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension"
|
||||
}
|
||||
|
||||
# Function to add PDO extension.
|
||||
@ -64,7 +64,7 @@ add_pdo_extension() {
|
||||
ext_name=$1
|
||||
if shared_extension pdo; then
|
||||
disable_extension_helper pdo
|
||||
echo "extension=pdo.so" | sudo tee "${ini_file[@]/php.ini/conf.d/10-pdo.ini}" >/dev/null 2>&1
|
||||
echo "extension=pdo.so" | sudo tee "${ini_file[@]/php.ini/conf.d/10-pdo.ini}"
|
||||
fi
|
||||
if [ "$ext" = "mysql" ]; then
|
||||
enable_extension "mysqlnd" "extension"
|
||||
@ -72,15 +72,15 @@ add_pdo_extension() {
|
||||
elif [ "$ext" = "dblib" ]; then
|
||||
ext_name="sybase"
|
||||
elif [ "$ext" = "firebird" ]; then
|
||||
install_packages libfbclient2 >/dev/null 2>&1
|
||||
install_packages libfbclient2
|
||||
enable_extension "pdo_firebird" "extension"
|
||||
ext_name="interbase"
|
||||
elif [ "$ext" = "sqlite" ]; then
|
||||
ext="sqlite3"
|
||||
ext_name="sqlite3"
|
||||
fi
|
||||
add_extension "$ext_name" "extension" >/dev/null 2>&1
|
||||
add_extension "$pdo_ext" "extension" >/dev/null 2>&1
|
||||
add_extension "$ext_name" "extension"
|
||||
add_extension "$pdo_ext" "extension"
|
||||
add_extension_log "$pdo_ext" "Enabled"
|
||||
fi
|
||||
}
|
||||
@ -94,7 +94,7 @@ check_package() {
|
||||
add_extension_helper() {
|
||||
local extension=$1
|
||||
packages=(php"$version"-"$extension")
|
||||
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||
add_ppa ondrej/php || update_ppa ondrej/php
|
||||
[ "${debug:?}" = "debug" ] && check_package php"$version"-"$extension"-dbgsym && packages+=(php"$version"-"$extension"-dbgsym)
|
||||
(check_package "${packages[0]}" && install_packages "${packages[@]}") || pecl_install "$extension"
|
||||
add_extension_log "$extension" "Installed and enabled"
|
||||
@ -108,7 +108,7 @@ add_devtools() {
|
||||
install_packages "php$version-dev"
|
||||
fi
|
||||
switch_version "phpize" "php-config"
|
||||
add_extension xml extension >/dev/null 2>&1
|
||||
add_extension xml extension
|
||||
add_log "${tick:?}" "$tool" "Added $tool $semver"
|
||||
}
|
||||
|
||||
@ -129,11 +129,11 @@ setup_cached_versions() {
|
||||
|
||||
# Function to add PECL.
|
||||
add_pecl() {
|
||||
add_devtools phpize >/dev/null 2>&1
|
||||
add_devtools phpize
|
||||
if ! command -v pecl >/dev/null; then
|
||||
install_packages php-pear
|
||||
fi
|
||||
configure_pecl >/dev/null 2>&1
|
||||
configure_pecl
|
||||
pear_version=$(get_tool_version "pecl" "version")
|
||||
add_log "${tick:?}" "PECL" "Added PECL $pear_version"
|
||||
}
|
||||
@ -167,7 +167,7 @@ get_php_packages() {
|
||||
|
||||
# Function to install packaged PHP
|
||||
add_packaged_php() {
|
||||
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||
add_ppa ondrej/php || update_ppa ondrej/php
|
||||
IFS=' ' read -r -a packages <<<"$(get_php_packages)"
|
||||
install_packages "${packages[@]}"
|
||||
}
|
||||
@ -191,7 +191,7 @@ add_php() {
|
||||
setup_php_builder
|
||||
else
|
||||
add_packaged_php
|
||||
switch_version >/dev/null 2>&1
|
||||
switch_version
|
||||
add_pecl
|
||||
fi
|
||||
elif [[ "$version" =~ ${old_versions:?} ]]; then
|
||||
@ -204,7 +204,7 @@ add_php() {
|
||||
|
||||
# Function to ini file for pear and link it to each SAPI.
|
||||
link_pecl_file() {
|
||||
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
||||
echo '' | sudo tee "$pecl_file"
|
||||
for file in "${ini_file[@]}"; do
|
||||
sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d"
|
||||
if [ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ]; then
|
||||
@ -237,9 +237,9 @@ add_php_config() {
|
||||
elif [ "$ini" = "development" ]; then
|
||||
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-development
|
||||
elif [ "$ini" = "none" ]; then
|
||||
echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
|
||||
echo '' | sudo tee "${ini_file[@]}"
|
||||
fi
|
||||
echo "$ini" | sudo tee "$current_ini" >/dev/null 2>&1
|
||||
echo "$ini" | sudo tee "$current_ini"
|
||||
}
|
||||
|
||||
# Function to Setup PHP
|
||||
@ -250,13 +250,13 @@ setup_php() {
|
||||
check_pre_installed
|
||||
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
|
||||
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
|
||||
add_php >/dev/null 2>&1
|
||||
add_php
|
||||
else
|
||||
if ! [[ "$version" =~ ${old_versions:?} ]]; then
|
||||
switch_version >/dev/null 2>&1
|
||||
switch_version
|
||||
fi
|
||||
if [ "${update:?}" = "true" ]; then
|
||||
update_php >/dev/null 2>&1
|
||||
update_php
|
||||
else
|
||||
status="Switched to"
|
||||
fi
|
||||
@ -264,7 +264,7 @@ setup_php() {
|
||||
php_config="$(command -v php-config)"
|
||||
else
|
||||
if [ "$update" = "true" ]; then
|
||||
update_php >/dev/null 2>&1
|
||||
update_php
|
||||
else
|
||||
status="Found"
|
||||
fi
|
||||
@ -284,7 +284,7 @@ setup_php() {
|
||||
link_pecl_file
|
||||
configure_php
|
||||
set_output "php-version" "$semver"
|
||||
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
||||
sudo rm -rf /usr/local/bin/phpunit
|
||||
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
|
||||
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
|
||||
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
|
||||
@ -298,8 +298,8 @@ debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
||||
scripts="$src"/scripts
|
||||
|
||||
add_sudo >/dev/null 2>&1
|
||||
link_apt_fast >/dev/null 2>&1
|
||||
add_sudo
|
||||
link_apt_fast
|
||||
|
||||
. /etc/os-release
|
||||
# shellcheck source=.
|
||||
|
Reference in New Issue
Block a user