mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support for self-hosted ubuntu runners
This commit is contained in:
parent
5915f05b06
commit
0f3f604249
@ -24,10 +24,31 @@ update_ppa() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to setup environment for self-hosted runners
|
||||||
|
pre_setup() {
|
||||||
|
sudo mkdir -p /var/run /run/php
|
||||||
|
if [ "$runner" = "self-hosted" ]; then
|
||||||
|
if [[ "$version" =~ $old_versions ]] || [ "$version" = "5.3" ]; then
|
||||||
|
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! command -v apt-fast >/dev/null; then
|
||||||
|
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
||||||
|
fi
|
||||||
|
update_ppa && $apt_install curl make lsb-release software-properties-common unzip
|
||||||
|
if ! apt-cache policy | grep -q ondrej/php; then
|
||||||
|
LC_ALL=C.UTF-8 sudo apt-add-repository ppa:ondrej/php -y && update_ppa
|
||||||
|
fi
|
||||||
|
if [ "$version" = "8.0" ]; then
|
||||||
|
$apt_install libcurl4-gnutls-dev libtidy-dev libpng-dev libjpeg-dev libicu-dev libzip-dev
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to configure PECL
|
# Function to configure PECL
|
||||||
configure_pecl() {
|
configure_pecl() {
|
||||||
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
||||||
sudo touch "$scan_dir"/99-pecl.ini >/dev/null 2>&1
|
|
||||||
for tool in pear pecl; do
|
for tool in pear pecl; do
|
||||||
sudo "$tool" config-set php_ini "$scan_dir"/99-pecl.ini >/dev/null 2>&1
|
sudo "$tool" config-set php_ini "$scan_dir"/99-pecl.ini >/dev/null 2>&1
|
||||||
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
@ -64,6 +85,7 @@ check_extension() {
|
|||||||
delete_extension() {
|
delete_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
sudo sed -i "/$extension/d" "$ini_file"
|
sudo sed -i "/$extension/d" "$ini_file"
|
||||||
|
sudo sed -i "/$extension/d" "$pecl_file"
|
||||||
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
@ -80,7 +102,7 @@ remove_extension() {
|
|||||||
# Function to enable existing extension
|
# Function to enable existing extension
|
||||||
enable_extension() {
|
enable_extension() {
|
||||||
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
|
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
|
||||||
echo "$2=$1.so" >>"$ini_file"
|
echo "$2=$1.so" >>"$pecl_file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +152,7 @@ add_pecl_extension() {
|
|||||||
pecl_version=$2
|
pecl_version=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
echo "$prefix=$ext_dir/$extension.so" >>"$pecl_file"
|
||||||
fi
|
fi
|
||||||
ext_version=$(php -r "echo phpversion('$extension');")
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
if [ "$ext_version" = "$pecl_version" ]; then
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
@ -243,9 +265,16 @@ setup_master() {
|
|||||||
install_dir=~/php/"$version"
|
install_dir=~/php/"$version"
|
||||||
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
|
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
|
||||||
sudo mkdir -m 777 -p ~/php
|
sudo mkdir -m 777 -p ~/php
|
||||||
|
if [ ! "$(whoami)" = "runner" ]; then
|
||||||
|
sudo rm -rf /home/runner && sudo ln -sf ~/ /home/runner;
|
||||||
|
fi
|
||||||
curl -o /tmp/"$tar_file" -sSL "$bintray_url"
|
curl -o /tmp/"$tar_file" -sSL "$bintray_url"
|
||||||
sudo tar xf /tmp/"$tar_file" -C ~/php
|
sudo tar xf /tmp/"$tar_file" -C ~/php
|
||||||
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
|
for tool_path in "$install_dir"/bin/*; do
|
||||||
|
tool=$(basename "$tool_path")
|
||||||
|
sudo cp "$tool_path" /usr/bin/"$tool$version"
|
||||||
|
sudo update-alternatives --install /usr/bin/"$tool" "$tool" /usr/bin/"$tool$version" 50
|
||||||
|
done
|
||||||
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
|
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,12 +343,14 @@ debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
|||||||
apt_install="sudo $debconf_fix apt-fast install -y"
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||||
tool_path_dir="/usr/local/bin"
|
tool_path_dir="/usr/local/bin"
|
||||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||||
[[ -z "${update}" ]] && update='false' || update="${update}"
|
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
|
||||||
|
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
|
||||||
|
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
|
||||||
|
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
|
||||||
|
|
||||||
# Setup PHP
|
# Setup PHP
|
||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
sudo mkdir -p /var/run /run/php
|
pre_setup >/dev/null 2>&1
|
||||||
|
|
||||||
if [ "$existing_version" != "$version" ]; then
|
if [ "$existing_version" != "$version" ]; then
|
||||||
if [ ! -e "/usr/bin/php$version" ]; then
|
if [ ! -e "/usr/bin/php$version" ]; then
|
||||||
if [ "$version" = "8.0" ]; then
|
if [ "$version" = "8.0" ]; then
|
||||||
@ -328,7 +359,7 @@ if [ "$existing_version" != "$version" ]; then
|
|||||||
setup_old_versions >/dev/null 2>&1
|
setup_old_versions >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
update_ppa
|
update_ppa
|
||||||
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml php"$version"-intl >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
status="Installed"
|
status="Installed"
|
||||||
else
|
else
|
||||||
@ -349,12 +380,17 @@ else
|
|||||||
update_php
|
update_php
|
||||||
else
|
else
|
||||||
status="Found"
|
status="Found"
|
||||||
|
if [ "$version" = "8.0" ]; then
|
||||||
|
switch_version
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
semver=$(php_semver)
|
semver=$(php_semver)
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
||||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
sudo chmod 777 "$ini_file" "$tool_path_dir"
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
pecl_file="$scan_dir"/99-pecl.ini
|
||||||
|
sudo touch "$pecl_file" >/dev/null 2>&1
|
||||||
|
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
|
||||||
add_log "$tick" "PHP" "$status PHP $semver"
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
Loading…
Reference in New Issue
Block a user