setup-php 2.16.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -141
- package/lib/config.d.ts +3 -0
- package/lib/config.js +76 -0
- package/lib/config.js.map +1 -0
- package/lib/coverage.d.ts +5 -0
- package/lib/coverage.js +102 -0
- package/lib/coverage.js.map +1 -0
- package/lib/extensions.d.ts +4 -0
- package/lib/extensions.js +219 -0
- package/lib/extensions.js.map +1 -0
- package/lib/fetch.d.ts +1 -0
- package/lib/fetch.js +67 -0
- package/lib/fetch.js.map +1 -0
- package/lib/install.d.ts +2 -0
- package/lib/install.js +80 -0
- package/lib/install.js.map +1 -0
- package/lib/tools.d.ts +23 -0
- package/lib/tools.js +378 -0
- package/lib/tools.js.map +1 -0
- package/lib/utils.d.ts +21 -0
- package/lib/utils.js +266 -0
- package/lib/utils.js.map +1 -0
- package/package.json +21 -20
- package/src/config.ts +8 -8
- package/src/configs/brew_extensions +1 -0
- package/src/configs/composer.env +2 -0
- package/src/configs/ini/jit.ini +3 -0
- package/src/configs/ini/php.ini +2 -0
- package/src/configs/ini/xdebug.ini +1 -0
- package/src/configs/os_releases.csv +2 -0
- package/src/configs/php_packages +12 -0
- package/src/configs/tools.json +48 -26
- package/src/configs/tools_schema.json +11 -0
- package/src/coverage.ts +24 -49
- package/src/extensions.ts +28 -24
- package/src/fetch.ts +54 -0
- package/src/install.ts +28 -41
- package/src/scripts/darwin.sh +81 -33
- package/src/scripts/extensions/add_extensions.ps1 +194 -0
- package/src/scripts/extensions/add_extensions.sh +198 -0
- package/src/scripts/{ext → extensions}/blackfire.ps1 +0 -0
- package/src/scripts/{ext → extensions}/blackfire.sh +0 -0
- package/src/scripts/{ext → extensions}/couchbase.sh +0 -0
- package/src/scripts/{ext → extensions}/cubrid.sh +3 -3
- package/src/scripts/{ext → extensions}/extension_map.php +36 -13
- package/src/scripts/{ext → extensions}/firebird.ps1 +0 -0
- package/src/scripts/{ext → extensions}/firebird.sh +0 -0
- package/src/scripts/{ext → extensions}/gearman.sh +0 -0
- package/src/scripts/{ext → extensions}/geos.sh +0 -0
- package/src/scripts/{ext → extensions}/http.ps1 +1 -0
- package/src/scripts/{ext → extensions}/http.sh +13 -20
- package/src/scripts/{ext → extensions}/intl.sh +0 -0
- package/src/scripts/{ext → extensions}/ioncube.ps1 +2 -2
- package/src/scripts/{ext → extensions}/ioncube.sh +2 -2
- package/src/scripts/{ext → extensions}/oci.ps1 +39 -14
- package/src/scripts/{ext → extensions}/oci.sh +3 -3
- package/src/scripts/{ext → extensions}/patches/firebird.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/geos.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/http.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/pdo_oci.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/phpize.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/protobuf.sh +0 -0
- package/src/scripts/{ext → extensions}/phalcon.ps1 +0 -0
- package/src/scripts/{ext → extensions}/phalcon.sh +4 -5
- package/src/scripts/{ext → extensions}/source.sh +36 -22
- package/src/scripts/extensions/sqlsrv.sh +15 -0
- package/src/scripts/linux.sh +76 -36
- package/src/scripts/tools/add_tools.ps1 +220 -10
- package/src/scripts/tools/add_tools.sh +164 -17
- package/src/scripts/tools/grpc_php_plugin.ps1 +4 -4
- package/src/scripts/tools/grpc_php_plugin.sh +3 -3
- package/src/scripts/tools/ppa.sh +12 -9
- package/src/scripts/tools/protoc.ps1 +2 -2
- package/src/scripts/tools/protoc.sh +2 -2
- package/src/scripts/tools/symfony.ps1 +18 -0
- package/src/scripts/tools/symfony.sh +18 -0
- package/src/scripts/unix.sh +186 -0
- package/src/scripts/win32.ps1 +137 -336
- package/src/tools.ts +62 -82
- package/src/utils.ts +57 -145
- package/src/scripts/common.sh +0 -366
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Function to log license information.
|
|
2
2
|
Function Add-LicenseLog() {
|
|
3
|
-
printf "
|
|
3
|
+
printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information"
|
|
4
4
|
printf "Oracle Instant Client package is required for %s extension.\n" $extension
|
|
5
5
|
printf "It is provided under the Oracle Technology Network Development and Distribution License.\n"
|
|
6
6
|
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
|
|
7
|
-
Write-Output "
|
|
7
|
+
Write-Output "$env:END_GROUP"
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
# Function to get instantclinet.
|
|
@@ -20,6 +20,36 @@ Function Add-InstantClient() {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
# Function to oci8 extension URL.
|
|
24
|
+
Function Get-Oci8Url() {
|
|
25
|
+
if($version -lt '8.0') {
|
|
26
|
+
$ociVersion = '2.2.0'
|
|
27
|
+
if ($version -eq '7.0') {
|
|
28
|
+
$ociVersion = '2.1.8'
|
|
29
|
+
} elseif ($version -lt '7.0') {
|
|
30
|
+
$ociVersion = '2.0.12'
|
|
31
|
+
}
|
|
32
|
+
return Get-PeclArchiveUrl oci8 $ociVersion $installed
|
|
33
|
+
} else {
|
|
34
|
+
$ociUrl = '';
|
|
35
|
+
Get-PeclPackageVersion oci8 -MinimumStability stable -MaximumStability stable | ForEach-Object {
|
|
36
|
+
$ociUrl = Get-PeclArchiveUrl oci8 $_ $installed
|
|
37
|
+
if($ociUrl) {
|
|
38
|
+
return $ociUrl
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Function to get OCI8 DLL.
|
|
45
|
+
Function Get-Oci8DLL() {
|
|
46
|
+
Get-ChildItem $ext_dir\php_oci8*.dll | ForEach-Object {
|
|
47
|
+
if((Get-PhpExtension -Path $_).PhpVersion -eq $version) {
|
|
48
|
+
return $_
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
23
53
|
# Function to install oci8 and pdo_oci.
|
|
24
54
|
Function Add-Oci() {
|
|
25
55
|
Param (
|
|
@@ -36,19 +66,14 @@ Function Add-Oci() {
|
|
|
36
66
|
Enable-PhpExtension pdo_oci -Path $php_dir
|
|
37
67
|
} else {
|
|
38
68
|
if(-not(Test-Path $ext_dir\php_oci8.dll)) {
|
|
39
|
-
$
|
|
40
|
-
$
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
$ociVersion = '2.2.0'
|
|
69
|
+
$oci8DLL = Get-Oci8DLL
|
|
70
|
+
if($oci8DLL) {
|
|
71
|
+
Copy-Item -Path $oci8DLL -Destination $ext_dir\php_oci8.dll
|
|
72
|
+
} else {
|
|
73
|
+
$status = 'Installed and enabled'
|
|
74
|
+
Invoke-WebRequest -Uri (Get-Oci8Url) -OutFile $php_dir\oci8.zip
|
|
75
|
+
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
|
|
47
76
|
}
|
|
48
|
-
$ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed
|
|
49
|
-
Invoke-WebRequest -Uri $ociUrl -OutFile $php_dir\oci8.zip
|
|
50
|
-
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
|
|
51
|
-
|
|
52
77
|
}
|
|
53
78
|
Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini
|
|
54
79
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Function to log result of a operation.
|
|
2
2
|
add_license_log() {
|
|
3
|
-
printf "
|
|
3
|
+
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
|
|
4
4
|
printf "Oracle Instant Client package is required for %s extension.\n" "$ext"
|
|
5
5
|
printf "It is provided under the Oracle Technology Network Development and Distribution License.\n"
|
|
6
6
|
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
|
|
7
|
-
echo "
|
|
7
|
+
echo "$END_GROUP"
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
# Function to install instantclient and SDK.
|
|
@@ -62,4 +62,4 @@ add_oci() {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
# shellcheck source=.
|
|
65
|
-
. "${scripts:?}"/
|
|
65
|
+
. "${scripts:?}"/extensions/patches/phpize.sh
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,11 +4,10 @@ add_phalcon_helper() {
|
|
|
4
4
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
5
5
|
add_brew_extension "$extension" extension
|
|
6
6
|
else
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fi
|
|
7
|
+
packages=("php${version:?}-$extension")
|
|
8
|
+
[ "$extension" = "phalcon4" ] && packages+=("php${version:?}-psr")
|
|
9
|
+
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
10
|
+
check_package "${packages[0]}" && install_packages "${packages[@]}"
|
|
12
11
|
fi
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Function to parse extension environment variables
|
|
2
2
|
parse_args() {
|
|
3
|
-
extension=$1
|
|
3
|
+
local extension=${1%-*}
|
|
4
4
|
suffix=$(echo "$2" | tr '[:lower:]' '[:upper:]')
|
|
5
5
|
up_ext_name=$(echo "$extension" | tr '[:lower:]' '[:upper:]')
|
|
6
6
|
var="${extension}_${suffix}"
|
|
@@ -10,9 +10,22 @@ parse_args() {
|
|
|
10
10
|
echo "$output" | xargs -n 1 | sort | uniq | xargs
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
# Function to parse configure options for pecl
|
|
14
|
+
# Make sure we have all options in name="value" form i.e XML properties.
|
|
15
|
+
parse_pecl_configure_options() {
|
|
16
|
+
configure_opts=$(echo "$1" | sed -r -e "s#['\"]|--##g")
|
|
17
|
+
IFS=' ' read -r -a opts_array <<< "$configure_opts"
|
|
18
|
+
output_opts=()
|
|
19
|
+
for opt in "${opts_array[@]}"; do
|
|
20
|
+
[ "${opt##*=}" != "${opt%=*}" ] && value="${opt##*=}" || value=yes
|
|
21
|
+
output_opts+=("${opt%=*}=\"$value\"")
|
|
22
|
+
done
|
|
23
|
+
echo "${output_opts[@]}"
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
# Function to log if a library is installed
|
|
14
27
|
add_lib_log() {
|
|
15
|
-
lib=$1
|
|
28
|
+
local lib=$1
|
|
16
29
|
if check_lib "$lib"; then
|
|
17
30
|
add_log "${tick:?}" "$lib" "Installed"
|
|
18
31
|
else
|
|
@@ -22,7 +35,7 @@ add_lib_log() {
|
|
|
22
35
|
|
|
23
36
|
# Function to check if a library is installed
|
|
24
37
|
check_lib() {
|
|
25
|
-
lib=$1
|
|
38
|
+
local lib=$1
|
|
26
39
|
if [ "$(uname -s)" = "Linux" ]; then
|
|
27
40
|
[ "x$(dpkg -s "$lib" 2>/dev/null | grep Status)" != "x" ]
|
|
28
41
|
else
|
|
@@ -32,7 +45,7 @@ check_lib() {
|
|
|
32
45
|
|
|
33
46
|
# Function to add a library on linux
|
|
34
47
|
add_linux_libs() {
|
|
35
|
-
lib=$1
|
|
48
|
+
local lib=$1
|
|
36
49
|
if ! check_lib "$lib"; then
|
|
37
50
|
install_packages "$lib" >/dev/null 2>&1 || true
|
|
38
51
|
fi
|
|
@@ -41,7 +54,7 @@ add_linux_libs() {
|
|
|
41
54
|
|
|
42
55
|
# Function to add a library on macOS
|
|
43
56
|
add_darwin_libs() {
|
|
44
|
-
lib=$1
|
|
57
|
+
local lib=$1
|
|
45
58
|
if ! check_lib "$lib"; then
|
|
46
59
|
brew install "$lib" >/dev/null 2>&1 || true
|
|
47
60
|
if [[ "$lib" = *@* ]]; then
|
|
@@ -53,7 +66,7 @@ add_darwin_libs() {
|
|
|
53
66
|
|
|
54
67
|
# Function to add required libraries
|
|
55
68
|
add_libs() {
|
|
56
|
-
all_libs=("$@")
|
|
69
|
+
local all_libs=("$@")
|
|
57
70
|
for lib in "${all_libs[@]}"; do
|
|
58
71
|
if [ "$(uname -s)" = "Linux" ]; then
|
|
59
72
|
add_linux_libs "$lib"
|
|
@@ -65,26 +78,27 @@ add_libs() {
|
|
|
65
78
|
|
|
66
79
|
# Function to run command in a group
|
|
67
80
|
run_group() {
|
|
68
|
-
command=$1
|
|
69
|
-
log=$2
|
|
81
|
+
local command=$1
|
|
82
|
+
local log=$2
|
|
70
83
|
echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
|
|
71
|
-
echo "
|
|
84
|
+
echo "$GROUP$log"
|
|
72
85
|
. ./run_group.sh
|
|
73
86
|
rm ./run_group.sh
|
|
74
|
-
echo "
|
|
87
|
+
echo "$END_GROUP"
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
patch_extension() {
|
|
78
|
-
extension=$1
|
|
79
|
-
if [ -e "${scripts:?}"/
|
|
91
|
+
local extension=$1
|
|
92
|
+
if [ -e "${scripts:?}"/extensions/patches/"$extension".sh ]; then
|
|
80
93
|
# shellcheck source=.
|
|
81
|
-
. "${scripts:?}"/
|
|
94
|
+
. "${scripts:?}"/extensions/patches/"$extension".sh
|
|
82
95
|
patch_"${extension}"
|
|
83
96
|
fi
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
fetch_extension() {
|
|
87
|
-
|
|
100
|
+
local extension=$1
|
|
101
|
+
local fetch=$2
|
|
88
102
|
if [ "$fetch" = "clone" ]; then
|
|
89
103
|
run_group "git clone -nv $url/$org/$repo /tmp/$repo-$release" "git clone"
|
|
90
104
|
cd /tmp/"$repo-$release" || exit 1
|
|
@@ -109,13 +123,13 @@ fetch_extension() {
|
|
|
109
123
|
|
|
110
124
|
# Function to install extension from a git repository
|
|
111
125
|
add_extension_from_source() {
|
|
112
|
-
extension="${1/pecl_/}"
|
|
113
|
-
url=$2
|
|
114
|
-
org=$3
|
|
115
|
-
repo=$4
|
|
116
|
-
release=$5
|
|
117
|
-
prefix=$6
|
|
118
|
-
fetch=${7:-clone}
|
|
126
|
+
local extension="${1/pecl_/}"
|
|
127
|
+
local url=$2
|
|
128
|
+
local org=$3
|
|
129
|
+
local repo=$4
|
|
130
|
+
local release=$5
|
|
131
|
+
local prefix=$6
|
|
132
|
+
local fetch=${7:-clone}
|
|
119
133
|
slug="$extension-$release"
|
|
120
134
|
source="$url/$org/$repo"
|
|
121
135
|
libraries="$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
|
@@ -127,7 +141,7 @@ add_extension_from_source() {
|
|
|
127
141
|
(
|
|
128
142
|
add_devtools phpize >/dev/null 2>&1
|
|
129
143
|
disable_extension_helper "$extension"
|
|
130
|
-
fetch_extension "$fetch"
|
|
144
|
+
fetch_extension "$extension" "$fetch"
|
|
131
145
|
if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then
|
|
132
146
|
add_log "${cross:?}" "$source" "$source does not have a PHP extension"
|
|
133
147
|
else
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Function to get sqlsrv and pdo_sqlsrv version.
|
|
2
|
+
get_sqlsrv_version() {
|
|
3
|
+
if [[ "${version:?}" =~ 7.[0-3] ]]; then
|
|
4
|
+
echo '5.9.0'
|
|
5
|
+
else
|
|
6
|
+
echo '5.10.0'
|
|
7
|
+
fi
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
# Function to install sqlsrv and pdo_sqlsrv.
|
|
11
|
+
add_sqlsrv() {
|
|
12
|
+
ext=$1
|
|
13
|
+
ext_version=$(get_sqlsrv_version)
|
|
14
|
+
add_pecl_extension "$ext" "$ext_version" extension
|
|
15
|
+
}
|
package/src/scripts/linux.sh
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
# Function to
|
|
2
|
-
|
|
1
|
+
# Function to add sudo
|
|
2
|
+
add_sudo() {
|
|
3
3
|
if ! command -v sudo >/dev/null; then
|
|
4
|
-
apt-get update
|
|
5
|
-
apt-get install -y sudo
|
|
4
|
+
check_package sudo || apt-get update
|
|
5
|
+
apt-get install -y sudo
|
|
6
6
|
fi
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
# Function to setup environment for self-hosted runners.
|
|
10
|
+
self_hosted_helper() {
|
|
7
11
|
if ! command -v apt-fast >/dev/null; then
|
|
8
12
|
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
|
9
13
|
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
|
@@ -21,11 +25,15 @@ install_packages() {
|
|
|
21
25
|
disable_extension_helper() {
|
|
22
26
|
local extension=$1
|
|
23
27
|
local disable_dependents=${2:-false}
|
|
28
|
+
get_extension_map
|
|
24
29
|
if [ "$disable_dependents" = "true" ]; then
|
|
25
30
|
disable_extension_dependents "$extension"
|
|
26
31
|
fi
|
|
27
32
|
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}" "$pecl_file"
|
|
28
|
-
sudo find "$ini_dir"/.. -name "*$extension.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
|
33
|
+
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
|
|
34
|
+
sudo rm -f /tmp/php"$version"_extensions
|
|
35
|
+
mkdir -p /tmp/extdisabled/"$version"
|
|
36
|
+
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
# Function to add PDO extension.
|
|
@@ -61,22 +69,16 @@ add_pdo_extension() {
|
|
|
61
69
|
|
|
62
70
|
# Function to check if a package exists
|
|
63
71
|
check_package() {
|
|
64
|
-
|
|
72
|
+
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
#
|
|
68
|
-
|
|
75
|
+
# Helper function to add an extension.
|
|
76
|
+
add_extension_helper() {
|
|
69
77
|
local extension=$1
|
|
70
|
-
prefix=$2
|
|
71
78
|
package=php"$version"-"$extension"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
else
|
|
76
|
-
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
77
|
-
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
|
78
|
-
add_extension_log "$extension" "Installed and enabled"
|
|
79
|
-
fi
|
|
79
|
+
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
80
|
+
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
|
81
|
+
add_extension_log "$extension" "Installed and enabled"
|
|
80
82
|
sudo chmod 777 "${ini_file[@]}"
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -84,8 +86,9 @@ add_extension() {
|
|
|
84
86
|
add_devtools() {
|
|
85
87
|
tool=$1
|
|
86
88
|
if ! command -v "$tool$version" >/dev/null; then
|
|
87
|
-
install_packages "php$version-dev"
|
|
89
|
+
install_packages "php$version-dev"
|
|
88
90
|
fi
|
|
91
|
+
add_extension xml extension >/dev/null 2>&1
|
|
89
92
|
switch_version "phpize" "php-config"
|
|
90
93
|
add_log "${tick:?}" "$tool" "Added $tool $semver"
|
|
91
94
|
}
|
|
@@ -113,8 +116,14 @@ add_pecl() {
|
|
|
113
116
|
|
|
114
117
|
# Function to switch versions of PHP binaries.
|
|
115
118
|
switch_version() {
|
|
116
|
-
tools=("$@")
|
|
119
|
+
tools=("$@")
|
|
117
120
|
to_wait=()
|
|
121
|
+
if ! (( ${#tools[@]} )); then
|
|
122
|
+
tools+=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg)
|
|
123
|
+
[ -e /usr/lib/cgi-bin/php"$version" ] && sudo update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php"$version" & to_wait+=($!)
|
|
124
|
+
[ -e /usr/sbin/php-fpm"$version" ] && sudo update-alternatives --set php-fpm /usr/sbin/php-fpm"$version" & to_wait+=($!)
|
|
125
|
+
[ -e /run/php/php"$version"-fpm.sock ] && sudo update-alternatives --set php-fpm.sock /run/php/php"$version"-fpm.sock & to_wait+=($!)
|
|
126
|
+
fi
|
|
118
127
|
for tool in "${tools[@]}"; do
|
|
119
128
|
if [ -e "/usr/bin/$tool$version" ]; then
|
|
120
129
|
sudo update-alternatives --set "$tool" /usr/bin/"$tool$version" &
|
|
@@ -128,8 +137,9 @@ switch_version() {
|
|
|
128
137
|
add_packaged_php() {
|
|
129
138
|
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
|
130
139
|
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
131
|
-
IFS=' ' read -r -a packages <<<"$(
|
|
140
|
+
IFS=' ' read -r -a packages <<<"$(sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ')"
|
|
132
141
|
install_packages "${packages[@]}"
|
|
142
|
+
add_pecl
|
|
133
143
|
else
|
|
134
144
|
run_script "php-ubuntu" "$version"
|
|
135
145
|
fi
|
|
@@ -165,7 +175,10 @@ link_pecl_file() {
|
|
|
165
175
|
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
|
166
176
|
for file in "${ini_file[@]}"; do
|
|
167
177
|
sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d"
|
|
168
|
-
[ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ]
|
|
178
|
+
if [ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ]; then
|
|
179
|
+
sudo mkdir -p "$sapi_scan_dir"
|
|
180
|
+
sudo ln -sf "$pecl_file" "$sapi_scan_dir/99-pecl.ini"
|
|
181
|
+
fi
|
|
169
182
|
done
|
|
170
183
|
}
|
|
171
184
|
|
|
@@ -176,12 +189,34 @@ php_extra_version() {
|
|
|
176
189
|
fi
|
|
177
190
|
}
|
|
178
191
|
|
|
192
|
+
# Function to set php.ini
|
|
193
|
+
add_php_config() {
|
|
194
|
+
php_lib_dir=/usr/lib/php/"$version"
|
|
195
|
+
current_ini="$php_lib_dir"/php.ini-current
|
|
196
|
+
current=$(cat "$current_ini" 2>/dev/null)
|
|
197
|
+
if [ "$current" = "$ini" ]; then
|
|
198
|
+
return;
|
|
199
|
+
fi
|
|
200
|
+
if [[ "$ini" = "production" && "x$current" != "xproduction" ]]; then
|
|
201
|
+
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-production
|
|
202
|
+
if [ -e "$php_lib_dir"/php.ini-production.cli ]; then
|
|
203
|
+
sudo cp "$php_lib_dir"/php.ini-production.cli "$ini_dir"/php.ini
|
|
204
|
+
fi
|
|
205
|
+
elif [ "$ini" = "development" ]; then
|
|
206
|
+
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-development
|
|
207
|
+
elif [ "$ini" = "none" ]; then
|
|
208
|
+
echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
|
|
209
|
+
fi
|
|
210
|
+
echo "$ini" | sudo tee "$current_ini" >/dev/null 2>&1
|
|
211
|
+
}
|
|
212
|
+
|
|
179
213
|
# Function to Setup PHP
|
|
180
214
|
setup_php() {
|
|
181
215
|
step_log "Setup PHP"
|
|
182
216
|
sudo mkdir -m 777 -p /var/run /run/php
|
|
183
|
-
|
|
184
|
-
|
|
217
|
+
php_config="$(command -v php-config)"
|
|
218
|
+
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
|
|
219
|
+
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
|
|
185
220
|
add_php >/dev/null 2>&1
|
|
186
221
|
else
|
|
187
222
|
if ! [[ "$version" =~ ${old_versions:?} ]]; then
|
|
@@ -193,6 +228,7 @@ setup_php() {
|
|
|
193
228
|
status="Switched to"
|
|
194
229
|
fi
|
|
195
230
|
fi
|
|
231
|
+
php_config="$(command -v php-config)"
|
|
196
232
|
else
|
|
197
233
|
if [ "$update" = "true" ]; then
|
|
198
234
|
update_php >/dev/null 2>&1
|
|
@@ -201,39 +237,43 @@ setup_php() {
|
|
|
201
237
|
fi
|
|
202
238
|
fi
|
|
203
239
|
if ! command -v php"$version" >/dev/null; then
|
|
204
|
-
add_log "$cross" "PHP" "Could not setup PHP $version"
|
|
240
|
+
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
|
205
241
|
exit 1
|
|
206
242
|
fi
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
|
211
|
-
ini_dir=$(php --ini | grep "(php.ini)" | sed -e "s|.*: s*||")
|
|
243
|
+
ext_dir="/usr/$(grep -Po "extension_dir=..[^/]*/\K[^'\"]*" "$php_config")"
|
|
244
|
+
ini_dir="$(php_ini_path)"
|
|
245
|
+
scan_dir="$ini_dir"/conf.d
|
|
212
246
|
pecl_file="$scan_dir"/99-pecl.ini
|
|
247
|
+
semver="$(php_semver)"
|
|
248
|
+
extra_version="$(php_extra_version)"
|
|
213
249
|
export ext_dir
|
|
214
250
|
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
|
|
215
251
|
link_pecl_file
|
|
216
252
|
configure_php
|
|
253
|
+
set_output "php-version" "$semver"
|
|
217
254
|
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
|
218
255
|
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
|
|
219
|
-
sudo cp "$
|
|
220
|
-
echo "::set-output name=php-version::$semver"
|
|
256
|
+
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
|
|
221
257
|
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
|
|
222
258
|
}
|
|
223
259
|
|
|
224
260
|
# Variables
|
|
225
|
-
version=$1
|
|
226
|
-
|
|
261
|
+
version=${1:-'8.1'}
|
|
262
|
+
ini=${2:-'production'}
|
|
263
|
+
src=${0%/*}/..
|
|
227
264
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
|
228
265
|
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
|
229
|
-
scripts="$
|
|
266
|
+
scripts="$src"/scripts
|
|
267
|
+
|
|
268
|
+
add_sudo >/dev/null 2>&1
|
|
230
269
|
|
|
231
270
|
. /etc/os-release
|
|
232
271
|
# shellcheck source=.
|
|
233
|
-
. "${scripts:?}"/
|
|
272
|
+
. "${scripts:?}"/unix.sh
|
|
234
273
|
. "${scripts:?}"/tools/ppa.sh
|
|
235
274
|
. "${scripts:?}"/tools/add_tools.sh
|
|
236
|
-
. "${scripts:?}"/
|
|
275
|
+
. "${scripts:?}"/extensions/source.sh
|
|
276
|
+
. "${scripts:?}"/extensions/add_extensions.sh
|
|
237
277
|
read_env
|
|
238
278
|
self_hosted_setup
|
|
239
279
|
setup_php
|