2019-12-20 18:29:05 +05:30
|
|
|
# Function to log start of a operation
|
2019-10-17 01:41:13 +05:30
|
|
|
step_log() {
|
|
|
|
message=$1
|
|
|
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
|
|
|
}
|
|
|
|
|
2019-12-20 18:29:05 +05:30
|
|
|
# Function to log result of a operation
|
2019-10-17 01:41:13 +05:30
|
|
|
add_log() {
|
|
|
|
mark=$1
|
|
|
|
subject=$2
|
|
|
|
message=$3
|
|
|
|
if [ "$mark" = "$tick" ]; then
|
|
|
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
|
|
else
|
|
|
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
|
|
fi
|
|
|
|
}
|
2019-12-19 11:29:27 +05:30
|
|
|
|
2021-03-11 03:44:33 +05:30
|
|
|
# Function to backup and cleanup package lists.
|
2020-07-07 16:36:32 +05:30
|
|
|
cleanup_lists() {
|
2021-03-06 01:33:17 +05:30
|
|
|
ppa_prefix=${1-ondrej}
|
2020-07-07 16:36:32 +05:30
|
|
|
if [ ! -e /etc/apt/sources.list.d.save ]; then
|
2021-03-11 03:44:33 +05:30
|
|
|
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save
|
2020-07-07 16:36:32 +05:30
|
|
|
sudo mkdir /etc/apt/sources.list.d
|
2021-03-06 01:33:17 +05:30
|
|
|
sudo mv /etc/apt/sources.list.d.save/*"${ppa_prefix}"*.list /etc/apt/sources.list.d/
|
2020-10-12 12:50:26 +05:30
|
|
|
trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/ 2>/dev/null" exit
|
2020-07-07 16:36:32 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-03-11 03:44:33 +05:30
|
|
|
# Function to add ppa:ondrej/php.
|
|
|
|
add_ppa() {
|
2021-03-06 01:33:17 +05:30
|
|
|
ppa=${1:-ondrej/php}
|
|
|
|
if ! apt-cache policy | grep -q "$ppa"; then
|
|
|
|
cleanup_lists "$(dirname "$ppa")"
|
|
|
|
LC_ALL=C.UTF-8 sudo apt-add-repository ppa:"$ppa" -y
|
2021-03-11 03:44:33 +05:30
|
|
|
if [ "$DISTRIB_RELEASE" = "16.04" ]; then
|
|
|
|
sudo "$debconf_fix" apt-get update
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to update the package lists.
|
2020-06-08 01:51:09 +05:30
|
|
|
update_lists() {
|
2021-03-11 03:44:33 +05:30
|
|
|
if [ ! -e /tmp/setup_php ]; then
|
2021-05-01 16:31:03 +05:30
|
|
|
add_ppa ondrej/php >/dev/null 2>&1
|
2021-03-11 03:44:33 +05:30
|
|
|
cleanup_lists
|
2020-03-20 19:01:35 +05:30
|
|
|
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
2021-03-11 03:44:33 +05:30
|
|
|
echo '' | sudo tee /tmp/setup_php >/dev/null 2>&1
|
2019-12-20 18:29:05 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-05-05 14:57:36 +05:30
|
|
|
# Function to configure PECL
|
2020-01-27 20:06:04 +05:30
|
|
|
configure_pecl() {
|
2021-02-22 10:43:59 +05:30
|
|
|
if ! [ -e /tmp/pecl_config ]; then
|
|
|
|
if ! command -v pecl >/dev/null || ! command -v pear >/dev/null; then
|
|
|
|
add_pecl >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
for script in pear pecl; do
|
2021-02-22 14:39:22 +05:30
|
|
|
sudo "$script" config-set php_ini "${pecl_file:-$ini_file}" >/dev/null 2>&1
|
|
|
|
sudo "$script" channel-update "$script".php.net >/dev/null 2>&1
|
2020-01-27 20:06:04 +05:30
|
|
|
done
|
2021-02-22 10:43:59 +05:30
|
|
|
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
|
2020-01-27 20:06:04 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-10-12 12:50:26 +05:30
|
|
|
# Function to get the PECL version
|
2020-01-30 12:03:30 +05:30
|
|
|
get_pecl_version() {
|
|
|
|
extension=$1
|
2020-11-16 02:55:14 +05:30
|
|
|
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
|
2020-01-30 12:03:30 +05:30
|
|
|
pecl_rest='https://pecl.php.net/rest/r/'
|
2020-08-16 06:38:52 +05:30
|
|
|
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
2020-11-26 11:06:55 +05:30
|
|
|
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
|
2020-01-30 12:03:30 +05:30
|
|
|
if [ ! "$pecl_version" ]; then
|
2020-11-26 11:06:55 +05:30
|
|
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
|
2020-01-30 12:03:30 +05:30
|
|
|
fi
|
|
|
|
echo "$pecl_version"
|
|
|
|
}
|
|
|
|
|
2020-08-03 14:24:54 +05:30
|
|
|
# Function to install PECL extensions and accept default options
|
|
|
|
pecl_install() {
|
|
|
|
local extension=$1
|
|
|
|
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2021-04-19 01:05:21 +05:30
|
|
|
# Function to enable existing extensions.
|
|
|
|
enable_extension() {
|
|
|
|
if [ -e /tmp/setup_php_dismod ] && grep -q "$1" /tmp/setup_php_dismod; then
|
|
|
|
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" | sudo tee -a "$pecl_file" >/dev/null
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-03-01 06:20:48 +05:30
|
|
|
# Function to test if extension is loaded
|
|
|
|
check_extension() {
|
2019-12-19 11:29:27 +05:30
|
|
|
extension=$1
|
2020-03-16 06:38:50 +05:30
|
|
|
if [ "$extension" != "mysql" ]; then
|
|
|
|
php -m | grep -i -q -w "$extension"
|
|
|
|
else
|
|
|
|
php -m | grep -i -q "$extension"
|
|
|
|
fi
|
2019-12-20 18:29:05 +05:30
|
|
|
}
|
|
|
|
|
2020-01-30 12:03:30 +05:30
|
|
|
# Function to delete extensions
|
|
|
|
delete_extension() {
|
2020-01-26 01:04:09 +05:30
|
|
|
extension=$1
|
2020-11-26 11:05:02 +05:30
|
|
|
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$ini_file"
|
|
|
|
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$pecl_file"
|
2020-03-01 06:20:48 +05:30
|
|
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
2020-01-30 12:03:30 +05:30
|
|
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
2020-01-26 01:04:09 +05:30
|
|
|
}
|
|
|
|
|
2020-01-30 12:03:30 +05:30
|
|
|
# Function to disable and delete extensions
|
2019-12-26 18:31:18 +05:30
|
|
|
remove_extension() {
|
|
|
|
extension=$1
|
2019-12-27 06:56:49 +05:30
|
|
|
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
|
|
|
sudo phpdismod -v "$version" "$extension"
|
2021-04-19 01:05:21 +05:30
|
|
|
echo "$extension" | sudo tee -a /tmp/setup_php_dismod >/dev/null 2>&1
|
2019-12-26 18:31:18 +05:30
|
|
|
fi
|
2020-01-30 12:03:30 +05:30
|
|
|
delete_extension "$extension"
|
|
|
|
}
|
|
|
|
|
2020-03-01 06:20:48 +05:30
|
|
|
# Function to setup extensions
|
|
|
|
add_extension() {
|
|
|
|
extension=$1
|
|
|
|
install_command=$2
|
|
|
|
prefix=$3
|
|
|
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
|
|
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
|
|
|
elif check_extension "$extension"; then
|
|
|
|
add_log "$tick" "$extension" "Enabled"
|
|
|
|
elif ! check_extension "$extension"; then
|
2021-02-22 09:19:08 +05:30
|
|
|
eval "$install_command" >/dev/null 2>&1 ||
|
|
|
|
(update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension"
|
2020-03-01 06:20:48 +05:30
|
|
|
(check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") ||
|
|
|
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
|
|
|
fi
|
|
|
|
sudo chmod 777 "$ini_file"
|
|
|
|
}
|
|
|
|
|
2020-01-30 12:03:30 +05:30
|
|
|
# Function to install a PECL version
|
|
|
|
add_pecl_extension() {
|
|
|
|
extension=$1
|
|
|
|
pecl_version=$2
|
2020-03-01 06:20:48 +05:30
|
|
|
prefix=$3
|
2021-02-22 14:39:22 +05:30
|
|
|
configure_pecl
|
2020-11-16 02:55:14 +05:30
|
|
|
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
2020-07-14 14:12:50 +05:30
|
|
|
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
|
|
|
fi
|
2020-03-01 06:20:48 +05:30
|
|
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
2020-05-13 20:48:18 +05:30
|
|
|
echo "$prefix=$ext_dir/$extension.so" >>"$pecl_file"
|
2020-03-01 06:20:48 +05:30
|
|
|
fi
|
|
|
|
ext_version=$(php -r "echo phpversion('$extension');")
|
|
|
|
if [ "$ext_version" = "$pecl_version" ]; then
|
|
|
|
add_log "$tick" "$extension" "Enabled"
|
|
|
|
else
|
|
|
|
delete_extension "$extension"
|
|
|
|
(
|
|
|
|
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
|
|
|
check_extension "$extension" &&
|
|
|
|
add_log "$tick" "$extension" "Installed and enabled"
|
|
|
|
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
|
|
|
fi
|
2020-01-30 12:03:30 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
# Function to pre-release extensions using PECL
|
|
|
|
add_unstable_extension() {
|
|
|
|
extension=$1
|
|
|
|
stability=$2
|
|
|
|
prefix=$3
|
|
|
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
2020-03-01 06:20:48 +05:30
|
|
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
2019-12-27 06:56:49 +05:30
|
|
|
}
|
|
|
|
|
2020-07-07 16:36:32 +05:30
|
|
|
# Function to configure composer
|
|
|
|
configure_composer() {
|
|
|
|
tool_path=$1
|
|
|
|
sudo ln -sf "$tool_path" "$tool_path.phar"
|
|
|
|
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
add_log "$cross" "composer" "Could not download composer"
|
|
|
|
exit 1;
|
|
|
|
fi
|
2021-02-22 12:01:59 +05:30
|
|
|
if ! [ -e "$composer_json" ]; then
|
2021-04-19 00:38:14 +05:30
|
|
|
sudo mkdir -p "$(dirname "$composer_json")"
|
2021-02-22 12:01:59 +05:30
|
|
|
echo '{}' | tee "$composer_json" >/dev/null 2>&1
|
|
|
|
sudo chmod 644 "$composer_json"
|
|
|
|
fi
|
2021-02-22 11:24:41 +05:30
|
|
|
composer -q config -g process-timeout 0
|
2020-11-16 02:09:15 +05:30
|
|
|
echo "$composer_bin" >> "$GITHUB_PATH"
|
2020-07-07 16:36:32 +05:30
|
|
|
if [ -n "$COMPOSER_TOKEN" ]; then
|
2021-02-22 11:24:41 +05:30
|
|
|
composer -q config -g github-oauth.github.com "$COMPOSER_TOKEN"
|
2020-07-07 16:36:32 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to setup a remote tool.
|
2019-12-27 06:56:49 +05:30
|
|
|
add_tool() {
|
|
|
|
url=$1
|
|
|
|
tool=$2
|
2020-03-01 06:20:48 +05:30
|
|
|
tool_path="$tool_path_dir/$tool"
|
2020-02-02 23:51:44 +05:30
|
|
|
if [ ! -e "$tool_path" ]; then
|
|
|
|
rm -rf "$tool_path"
|
2019-12-27 06:56:49 +05:30
|
|
|
fi
|
2020-08-16 06:38:52 +05:30
|
|
|
if [ "$tool" = "composer" ]; then
|
|
|
|
IFS="," read -r -a urls <<< "$url"
|
|
|
|
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
|
|
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
|
|
|
else
|
|
|
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
2020-11-16 03:01:31 +05:30
|
|
|
fi
|
|
|
|
if [ "$status_code" != "200" ] && [[ "$url" =~ .*github.com.*releases.*latest.* ]]; then
|
2020-11-26 11:17:48 +05:30
|
|
|
url="${url//releases\/latest\/download/releases/download/$(curl "${curl_opts[@]}" "$(echo "$url" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "$url" | sed -e "s/.*\///")" | cut -d '/' -f 1)}"
|
2020-11-16 03:01:31 +05:30
|
|
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
2020-08-16 06:38:52 +05:30
|
|
|
fi
|
2020-01-07 08:06:14 +05:30
|
|
|
if [ "$status_code" = "200" ]; then
|
2020-02-02 23:51:44 +05:30
|
|
|
sudo chmod a+x "$tool_path"
|
2020-01-30 12:03:30 +05:30
|
|
|
if [ "$tool" = "composer" ]; then
|
2020-07-07 16:36:32 +05:30
|
|
|
configure_composer "$tool_path"
|
2020-02-02 23:51:44 +05:30
|
|
|
elif [ "$tool" = "cs2pr" ]; then
|
|
|
|
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
2020-01-30 12:03:30 +05:30
|
|
|
elif [ "$tool" = "phive" ]; then
|
2020-03-01 06:20:48 +05:30
|
|
|
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1
|
|
|
|
add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1
|
|
|
|
add_extension xml "$apt_install php$version-xml" extension >/dev/null 2>&1
|
2020-01-30 12:03:30 +05:30
|
|
|
fi
|
2020-01-07 08:06:14 +05:30
|
|
|
add_log "$tick" "$tool" "Added"
|
|
|
|
else
|
|
|
|
add_log "$cross" "$tool" "Could not setup $tool"
|
2020-08-16 06:38:52 +05:30
|
|
|
[ "$tool" = "composer" ] && exit 1
|
2020-01-07 08:06:14 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-01-30 12:03:30 +05:30
|
|
|
# Function to setup a tool using composer
|
2020-03-01 06:20:48 +05:30
|
|
|
add_composertool() {
|
2020-01-07 08:06:14 +05:30
|
|
|
tool=$1
|
|
|
|
release=$2
|
|
|
|
prefix=$3
|
|
|
|
(
|
2021-02-22 12:01:59 +05:30
|
|
|
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
2020-01-30 12:03:30 +05:30
|
|
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
|
|
|
add_log "$tick" "$tool" "Added"
|
2020-01-07 08:06:14 +05:30
|
|
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
2020-11-16 02:09:15 +05:30
|
|
|
if [ -e "$composer_bin/composer" ]; then
|
|
|
|
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
|
|
|
|
fi
|
2021-02-22 14:39:22 +05:30
|
|
|
if [ "$tool" = "codeception" ]; then
|
2021-02-28 19:08:35 +05:30
|
|
|
sudo ln -s "$composer_bin"/codecept "$composer_bin"/codeception
|
2021-02-22 14:39:22 +05:30
|
|
|
fi
|
2019-12-26 18:31:18 +05:30
|
|
|
}
|
|
|
|
|
2020-01-17 12:58:28 +05:30
|
|
|
# Function to setup phpize and php-config
|
|
|
|
add_devtools() {
|
|
|
|
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
|
2020-06-08 01:51:09 +05:30
|
|
|
update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
2020-01-17 12:58:28 +05:30
|
|
|
fi
|
|
|
|
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
|
|
|
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
2020-01-27 20:06:04 +05:30
|
|
|
configure_pecl
|
2020-01-17 12:58:28 +05:30
|
|
|
}
|
|
|
|
|
2019-12-20 18:29:05 +05:30
|
|
|
# Function to setup the nightly build from master branch
|
|
|
|
setup_master() {
|
2020-08-16 06:38:52 +05:30
|
|
|
curl "${curl_opts[@]}" https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "github"
|
2019-12-19 11:29:27 +05:30
|
|
|
}
|
|
|
|
|
2021-03-11 03:44:33 +05:30
|
|
|
add_packaged_php() {
|
|
|
|
if [ "${use_package_cache:-true}" = "false" ]; then
|
|
|
|
update_lists
|
|
|
|
IFS=' ' read -r -a packages <<<"$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
|
|
|
|
$apt_install "${packages[@]}"
|
|
|
|
else
|
|
|
|
curl "${curl_opts[@]}" https://github.com/shivammathur/php-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-12-20 18:29:05 +05:30
|
|
|
# Function to setup PECL
|
2019-12-27 06:56:49 +05:30
|
|
|
add_pecl() {
|
2020-01-17 12:58:28 +05:30
|
|
|
add_devtools
|
2020-01-30 12:03:30 +05:30
|
|
|
if [ ! -e /usr/bin/pecl ]; then
|
|
|
|
$apt_install php-pear >/dev/null 2>&1
|
|
|
|
fi
|
2020-01-27 20:06:04 +05:30
|
|
|
configure_pecl
|
2019-12-27 06:56:49 +05:30
|
|
|
add_log "$tick" "PECL" "Added"
|
2019-12-20 18:29:05 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
# Function to switch versions of PHP binaries
|
|
|
|
switch_version() {
|
|
|
|
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
|
|
|
|
if [ -e "/usr/bin/$tool$version" ]; then
|
2020-06-08 01:51:09 +05:30
|
|
|
sudo update-alternatives --set $tool /usr/bin/"$tool$version"
|
2019-12-20 18:29:05 +05:30
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-03-01 06:20:48 +05:30
|
|
|
# Function to get PHP version in semver format
|
|
|
|
php_semver() {
|
|
|
|
if [ ! "$version" = "8.0" ]; then
|
|
|
|
php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-'
|
|
|
|
else
|
|
|
|
php -v | head -n 1 | cut -f 2 -d ' '
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-02-22 09:19:08 +05:30
|
|
|
# Function to configure PHP
|
|
|
|
configure_php() {
|
|
|
|
(
|
|
|
|
echo -e "date.timezone=UTC\nmemory_limit=-1"
|
|
|
|
[[ "$version" =~ 8.0 ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235"
|
|
|
|
[[ "$version" =~ 7.[2-4]|8.0 ]] && echo -e "xdebug.mode=coverage"
|
|
|
|
) | sudo tee -a "$pecl_file" >/dev/null
|
|
|
|
}
|
|
|
|
|
2019-12-20 18:29:05 +05:30
|
|
|
# Variables
|
|
|
|
tick="✓"
|
|
|
|
cross="✗"
|
|
|
|
version=$1
|
2020-10-05 13:06:12 +05:30
|
|
|
dist=$2
|
2020-03-01 06:20:48 +05:30
|
|
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
2020-11-16 01:56:09 +05:30
|
|
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
2020-03-01 06:20:48 +05:30
|
|
|
tool_path_dir="/usr/local/bin"
|
2020-08-16 06:38:52 +05:30
|
|
|
curl_opts=(-sL)
|
2020-11-16 02:09:15 +05:30
|
|
|
composer_bin="$HOME/.composer/vendor/bin"
|
2021-02-22 12:01:59 +05:30
|
|
|
composer_json="$HOME/.composer/composer.json"
|
|
|
|
composer_lock="$HOME/.composer/composer.lock"
|
2020-05-13 20:36:57 +05:30
|
|
|
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
2019-12-20 18:29:05 +05:30
|
|
|
|
|
|
|
# Setup PHP
|
2019-12-27 06:56:49 +05:30
|
|
|
step_log "Setup PHP"
|
2020-11-16 02:09:15 +05:30
|
|
|
sudo mkdir -m 777 -p "$HOME/.composer" /var/run /run/php
|
2020-07-03 15:18:11 +05:30
|
|
|
. /etc/lsb-release
|
2019-12-20 18:29:05 +05:30
|
|
|
|
|
|
|
if [ "$existing_version" != "$version" ]; then
|
|
|
|
if [ ! -e "/usr/bin/php$version" ]; then
|
2020-01-30 12:03:30 +05:30
|
|
|
if [ "$version" = "8.0" ]; then
|
2020-06-08 01:51:09 +05:30
|
|
|
setup_master >/dev/null 2>&1
|
2019-12-20 18:29:05 +05:30
|
|
|
else
|
2021-03-11 03:44:33 +05:30
|
|
|
add_packaged_php >/dev/null 2>&1
|
2019-12-20 18:29:05 +05:30
|
|
|
fi
|
2020-03-01 06:20:48 +05:30
|
|
|
status="Installed"
|
2019-12-20 18:29:05 +05:30
|
|
|
else
|
2020-03-01 06:20:48 +05:30
|
|
|
status="Switched to"
|
2019-12-20 18:29:05 +05:30
|
|
|
fi
|
|
|
|
|
2020-06-08 01:51:09 +05:30
|
|
|
switch_version >/dev/null 2>&1
|
2019-11-30 05:58:14 +05:30
|
|
|
else
|
2020-03-01 06:20:48 +05:30
|
|
|
status="Found"
|
2019-10-17 01:41:13 +05:30
|
|
|
fi
|
|
|
|
|
2021-02-22 10:38:50 +05:30
|
|
|
if ! command -v php"$version" >/dev/null; then
|
|
|
|
add_log "$cross" "PHP" "Could not setup PHP $version"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-01 06:20:48 +05:30
|
|
|
semver=$(php_semver)
|
2020-05-13 20:48:18 +05:30
|
|
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
2019-10-17 01:41:13 +05:30
|
|
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
2020-03-01 06:20:48 +05:30
|
|
|
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
2020-05-13 20:48:18 +05:30
|
|
|
pecl_file="$scan_dir"/99-pecl.ini
|
2020-05-26 06:41:18 +05:30
|
|
|
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
2021-02-22 09:19:08 +05:30
|
|
|
configure_php
|
2020-08-13 00:04:00 +05:30
|
|
|
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
2020-05-26 06:41:18 +05:30
|
|
|
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
|
2020-10-17 05:01:32 +05:30
|
|
|
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
2020-03-01 06:20:48 +05:30
|
|
|
add_log "$tick" "PHP" "$status PHP $semver"
|