setup-php 2.13.0 → 2.17.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/LICENSE +21 -21
- package/README.md +990 -922
- package/lib/config.d.ts +3 -0
- package/lib/config.js +71 -71
- package/lib/config.js.map +1 -1
- package/lib/coverage.d.ts +5 -0
- package/lib/coverage.js +97 -87
- package/lib/coverage.js.map +1 -1
- package/lib/extensions.d.ts +4 -0
- package/lib/extensions.js +214 -200
- package/lib/extensions.js.map +1 -1
- package/lib/fetch.d.ts +1 -0
- package/lib/fetch.js +63 -0
- package/lib/fetch.js.map +1 -0
- package/lib/install.d.ts +2 -0
- package/lib/install.js +75 -81
- package/lib/install.js.map +1 -1
- package/lib/tools.d.ts +23 -0
- package/lib/tools.js +367 -386
- package/lib/tools.js.map +1 -1
- package/lib/utils.d.ts +21 -0
- package/lib/utils.js +261 -291
- package/lib/utils.js.map +1 -1
- package/package.json +67 -56
- package/src/config.ts +82 -82
- package/src/configs/brew_extensions +31 -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 +19 -17
- package/src/configs/php-versions.json +6 -5
- package/src/configs/php_packages +12 -0
- package/src/configs/{php.json → pm/php.json} +29 -29
- package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
- package/src/configs/tools.json +278 -235
- package/src/configs/tools_schema.json +125 -114
- package/src/coverage.ts +144 -142
- package/src/extensions.ts +367 -349
- package/src/fetch.ts +54 -0
- package/src/install.ts +66 -82
- package/src/scripts/darwin.sh +285 -249
- package/src/scripts/extensions/add_extensions.ps1 +194 -0
- package/src/scripts/extensions/add_extensions.sh +184 -0
- package/src/scripts/{ext → extensions}/blackfire.ps1 +32 -32
- package/src/scripts/{ext → extensions}/blackfire.sh +22 -21
- package/src/scripts/{ext → extensions}/couchbase.sh +43 -43
- package/src/scripts/{ext → extensions}/cubrid.sh +60 -60
- package/src/scripts/extensions/extension_map.php +132 -0
- package/src/scripts/{ext → extensions}/firebird.ps1 +19 -19
- package/src/scripts/{ext → extensions}/firebird.sh +39 -35
- package/src/scripts/{ext → extensions}/gearman.sh +22 -22
- package/src/scripts/{ext → extensions}/geos.sh +17 -17
- package/src/scripts/{ext → extensions}/http.ps1 +54 -54
- package/src/scripts/{ext → extensions}/http.sh +109 -120
- package/src/scripts/{ext → extensions}/intl.sh +23 -23
- package/src/scripts/{ext → extensions}/ioncube.ps1 +33 -32
- package/src/scripts/{ext → extensions}/ioncube.sh +21 -19
- package/src/scripts/{ext → extensions}/oci.ps1 +85 -60
- package/src/scripts/{ext → extensions}/oci.sh +65 -63
- package/src/scripts/{ext → extensions}/patches/firebird.sh +11 -11
- package/src/scripts/{ext → extensions}/patches/geos.sh +7 -7
- package/src/scripts/{ext → extensions}/patches/http.sh +11 -11
- package/src/scripts/{ext → extensions}/patches/pdo_oci.sh +6 -6
- package/src/scripts/{ext → extensions}/patches/phpize.sh +26 -26
- package/src/scripts/{ext → extensions}/patches/protobuf.sh +4 -4
- package/src/scripts/{ext → extensions}/phalcon.ps1 +54 -54
- package/src/scripts/{ext → extensions}/phalcon.sh +58 -58
- package/src/scripts/{ext → extensions}/source.sh +145 -144
- package/src/scripts/extensions/sqlsrv.sh +15 -0
- package/src/scripts/linux.sh +269 -256
- package/src/scripts/tools/add_tools.ps1 +239 -26
- package/src/scripts/tools/add_tools.sh +175 -20
- package/src/scripts/tools/blackfire.ps1 +19 -19
- package/src/scripts/tools/blackfire.sh +40 -39
- package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
- package/src/scripts/tools/grpc_php_plugin.sh +58 -58
- package/src/scripts/tools/ppa.sh +192 -151
- package/src/scripts/tools/protoc.ps1 +38 -38
- package/src/scripts/tools/protoc.sh +28 -28
- package/src/scripts/tools/symfony.ps1 +14 -0
- package/src/scripts/tools/symfony.sh +13 -0
- package/src/scripts/unix.sh +186 -0
- package/src/scripts/win32.ps1 +352 -494
- package/src/tools.ts +512 -538
- package/src/utils.ts +415 -500
- package/.eslintrc.json +0 -16
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/CONTRIBUTING.md +0 -70
- package/.github/FUNDING.yml +0 -7
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
- package/.github/SECURITY.md +0 -29
- package/.github/workflows/docs.yml +0 -77
- package/.github/workflows/node-workflow.yml +0 -51
- package/.github/workflows/workflow.yml +0 -78
- package/.idea/workspace.xml +0 -113
- package/.prettierrc.json +0 -12
- package/__tests__/config.test.ts +0 -52
- package/__tests__/coverage.test.ts +0 -110
- package/__tests__/extensions.test.ts +0 -263
- package/__tests__/install.test.ts +0 -175
- package/__tests__/tools.test.ts +0 -524
- package/__tests__/utils.test.ts +0 -307
- package/action.yml +0 -29
- package/dist/index.js +0 -3051
- package/examples/bedrock.yml +0 -32
- package/examples/blackfire-player.yml +0 -31
- package/examples/blackfire.yml +0 -31
- package/examples/cakephp-mysql.yml +0 -114
- package/examples/cakephp-postgres.yml +0 -112
- package/examples/cakephp.yml +0 -92
- package/examples/codeigniter.yml +0 -34
- package/examples/laravel-mysql.yml +0 -74
- package/examples/laravel-postgres.yml +0 -74
- package/examples/laravel.yml +0 -42
- package/examples/lumen-mysql.yml +0 -74
- package/examples/lumen-postgres.yml +0 -74
- package/examples/lumen.yml +0 -38
- package/examples/phalcon-mysql.yml +0 -74
- package/examples/phalcon-postgres.yml +0 -73
- package/examples/sage.yml +0 -57
- package/examples/slim-framework.yml +0 -34
- package/examples/symfony-mysql.yml +0 -57
- package/examples/symfony-postgres.yml +0 -55
- package/examples/symfony.yml +0 -39
- package/examples/yii2-mysql.yml +0 -73
- package/examples/yii2-postgres.yml +0 -71
- package/examples/zend-framework.yml +0 -36
- package/jest.config.js +0 -12
- package/lib/sapi.js +0 -64
- package/src/scripts/common.sh +0 -314
- package/tsconfig.json +0 -18
package/src/scripts/linux.sh
CHANGED
|
@@ -1,256 +1,269 @@
|
|
|
1
|
-
# Function to
|
|
2
|
-
|
|
3
|
-
if ! command -v sudo >/dev/null; then
|
|
4
|
-
apt-get update
|
|
5
|
-
apt-get install -y sudo
|
|
6
|
-
fi
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
install_packages
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
sudo
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ext
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
# Function to
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
1
|
+
# Function to add sudo
|
|
2
|
+
add_sudo() {
|
|
3
|
+
if ! command -v sudo >/dev/null; then
|
|
4
|
+
check_package sudo || apt-get update
|
|
5
|
+
apt-get install -y sudo
|
|
6
|
+
fi
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
# Function to setup environment for self-hosted runners.
|
|
10
|
+
self_hosted_helper() {
|
|
11
|
+
if ! command -v apt-fast >/dev/null; then
|
|
12
|
+
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
|
13
|
+
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
|
14
|
+
fi
|
|
15
|
+
install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
# Function to install a package
|
|
19
|
+
install_packages() {
|
|
20
|
+
packages=("$@")
|
|
21
|
+
$apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && $apt_install "${packages[@]}" >/dev/null 2>&1)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Function to disable an extension.
|
|
25
|
+
disable_extension_helper() {
|
|
26
|
+
local extension=$1
|
|
27
|
+
local disable_dependents=${2:-false}
|
|
28
|
+
get_extension_map
|
|
29
|
+
if [ "$disable_dependents" = "true" ]; then
|
|
30
|
+
disable_extension_dependents "$extension"
|
|
31
|
+
fi
|
|
32
|
+
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}" "$pecl_file"
|
|
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
|
+
mkdir -p /tmp/extdisabled/"$version"
|
|
35
|
+
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Function to add PDO extension.
|
|
39
|
+
add_pdo_extension() {
|
|
40
|
+
pdo_ext="pdo_$1"
|
|
41
|
+
if check_extension "$pdo_ext"; then
|
|
42
|
+
add_log "${tick:?}" "$pdo_ext" "Enabled"
|
|
43
|
+
else
|
|
44
|
+
ext=$1
|
|
45
|
+
ext_name=$1
|
|
46
|
+
if shared_extension pdo; then
|
|
47
|
+
disable_extension_helper pdo
|
|
48
|
+
echo "extension=pdo.so" | sudo tee "${ini_file[@]/php.ini/conf.d/10-pdo.ini}" >/dev/null 2>&1
|
|
49
|
+
fi
|
|
50
|
+
if [ "$ext" = "mysql" ]; then
|
|
51
|
+
enable_extension "mysqlnd" "extension"
|
|
52
|
+
ext_name='mysqli'
|
|
53
|
+
elif [ "$ext" = "dblib" ]; then
|
|
54
|
+
ext_name="sybase"
|
|
55
|
+
elif [ "$ext" = "firebird" ]; then
|
|
56
|
+
install_packages libfbclient2 >/dev/null 2>&1
|
|
57
|
+
enable_extension "pdo_firebird" "extension"
|
|
58
|
+
ext_name="interbase"
|
|
59
|
+
elif [ "$ext" = "sqlite" ]; then
|
|
60
|
+
ext="sqlite3"
|
|
61
|
+
ext_name="sqlite3"
|
|
62
|
+
fi
|
|
63
|
+
add_extension "$ext_name" "extension" >/dev/null 2>&1
|
|
64
|
+
add_extension "$pdo_ext" "extension" >/dev/null 2>&1
|
|
65
|
+
add_extension_log "$pdo_ext" "Enabled"
|
|
66
|
+
fi
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# Function to check if a package exists
|
|
70
|
+
check_package() {
|
|
71
|
+
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Helper function to add an extension.
|
|
75
|
+
add_extension_helper() {
|
|
76
|
+
local extension=$1
|
|
77
|
+
package=php"$version"-"$extension"
|
|
78
|
+
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
79
|
+
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
|
80
|
+
add_extension_log "$extension" "Installed and enabled"
|
|
81
|
+
sudo chmod 777 "${ini_file[@]}"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Function to setup phpize and php-config.
|
|
85
|
+
add_devtools() {
|
|
86
|
+
tool=$1
|
|
87
|
+
if ! command -v "$tool$version" >/dev/null; then
|
|
88
|
+
install_packages "php$version-dev"
|
|
89
|
+
fi
|
|
90
|
+
add_extension xml extension >/dev/null 2>&1
|
|
91
|
+
switch_version "phpize" "php-config"
|
|
92
|
+
add_log "${tick:?}" "$tool" "Added $tool $semver"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Function to setup the nightly build from shivammathur/php-builder
|
|
96
|
+
setup_nightly() {
|
|
97
|
+
run_script "php-builder" "${runner:?}" "$version"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
|
|
101
|
+
setup_old_versions() {
|
|
102
|
+
run_script "php5-ubuntu" "$version"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# Function to add PECL.
|
|
106
|
+
add_pecl() {
|
|
107
|
+
add_devtools phpize >/dev/null 2>&1
|
|
108
|
+
if ! command -v pecl >/dev/null; then
|
|
109
|
+
install_packages php-pear
|
|
110
|
+
fi
|
|
111
|
+
configure_pecl >/dev/null 2>&1
|
|
112
|
+
pear_version=$(get_tool_version "pecl" "version")
|
|
113
|
+
add_log "${tick:?}" "PECL" "Added PECL $pear_version"
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Function to switch versions of PHP binaries.
|
|
117
|
+
switch_version() {
|
|
118
|
+
tools=("$@") && ! (( ${#tools[@]} )) && tools+=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg)
|
|
119
|
+
to_wait=()
|
|
120
|
+
for tool in "${tools[@]}"; do
|
|
121
|
+
if [ -e "/usr/bin/$tool$version" ]; then
|
|
122
|
+
sudo update-alternatives --set "$tool" /usr/bin/"$tool$version" &
|
|
123
|
+
to_wait+=($!)
|
|
124
|
+
fi
|
|
125
|
+
done
|
|
126
|
+
wait "${to_wait[@]}"
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
# Function to install packaged PHP
|
|
130
|
+
add_packaged_php() {
|
|
131
|
+
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
|
132
|
+
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
133
|
+
IFS=' ' read -r -a packages <<<"$(sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ')"
|
|
134
|
+
install_packages "${packages[@]}"
|
|
135
|
+
add_pecl
|
|
136
|
+
else
|
|
137
|
+
run_script "php-ubuntu" "$version"
|
|
138
|
+
fi
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# Function to update PHP.
|
|
142
|
+
update_php() {
|
|
143
|
+
initial_version="$(php_semver)$(php_extra_version)"
|
|
144
|
+
add_php
|
|
145
|
+
updated_version="$(php_semver)$(php_extra_version)"
|
|
146
|
+
if [ "$updated_version" != "$initial_version" ]; then
|
|
147
|
+
status="Updated to"
|
|
148
|
+
else
|
|
149
|
+
status="Found"
|
|
150
|
+
fi
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# Function to install PHP.
|
|
154
|
+
add_php() {
|
|
155
|
+
if [[ "$version" =~ ${nightly_versions:?} ]]; then
|
|
156
|
+
setup_nightly
|
|
157
|
+
elif [[ "$version" =~ ${old_versions:?} ]]; then
|
|
158
|
+
setup_old_versions
|
|
159
|
+
else
|
|
160
|
+
add_packaged_php
|
|
161
|
+
switch_version >/dev/null 2>&1
|
|
162
|
+
fi
|
|
163
|
+
status="Installed"
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
# Function to ini file for pear and link it to each SAPI.
|
|
167
|
+
link_pecl_file() {
|
|
168
|
+
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
|
169
|
+
for file in "${ini_file[@]}"; do
|
|
170
|
+
sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d"
|
|
171
|
+
[ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ] && sudo ln -sf "$pecl_file" "$sapi_scan_dir/99-pecl.ini"
|
|
172
|
+
done
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# Function to get extra version.
|
|
176
|
+
php_extra_version() {
|
|
177
|
+
if [ -e /etc/php/"$version"/COMMIT ]; then
|
|
178
|
+
echo " ($(cat "/etc/php/$version/COMMIT"))"
|
|
179
|
+
fi
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
# Function to set php.ini
|
|
183
|
+
add_php_config() {
|
|
184
|
+
php_lib_dir=/usr/lib/php/"$version"
|
|
185
|
+
current_ini="$php_lib_dir"/php.ini-current
|
|
186
|
+
current=$(cat "$current_ini" 2>/dev/null)
|
|
187
|
+
if [ "$current" = "$ini" ]; then
|
|
188
|
+
return;
|
|
189
|
+
fi
|
|
190
|
+
if [[ "$ini" = "production" && "x$current" != "xproduction" ]]; then
|
|
191
|
+
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-production
|
|
192
|
+
if [ -e "$php_lib_dir"/php.ini-production.cli ]; then
|
|
193
|
+
sudo cp "$php_lib_dir"/php.ini-production.cli "$ini_dir"/php.ini
|
|
194
|
+
fi
|
|
195
|
+
elif [ "$ini" = "development" ]; then
|
|
196
|
+
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-development
|
|
197
|
+
elif [ "$ini" = "none" ]; then
|
|
198
|
+
echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
|
|
199
|
+
fi
|
|
200
|
+
echo "$ini" | sudo tee "$current_ini" >/dev/null 2>&1
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
# Function to Setup PHP
|
|
204
|
+
setup_php() {
|
|
205
|
+
step_log "Setup PHP"
|
|
206
|
+
sudo mkdir -m 777 -p /var/run /run/php
|
|
207
|
+
php_config="$(command -v php-config)"
|
|
208
|
+
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
|
|
209
|
+
if [ ! -e "/usr/bin/php$version" ]; then
|
|
210
|
+
add_php >/dev/null 2>&1
|
|
211
|
+
else
|
|
212
|
+
if ! [[ "$version" =~ ${old_versions:?} ]]; then
|
|
213
|
+
switch_version >/dev/null 2>&1
|
|
214
|
+
fi
|
|
215
|
+
if [ "${update:?}" = "true" ]; then
|
|
216
|
+
update_php >/dev/null 2>&1
|
|
217
|
+
else
|
|
218
|
+
status="Switched to"
|
|
219
|
+
fi
|
|
220
|
+
fi
|
|
221
|
+
php_config="$(command -v php-config)"
|
|
222
|
+
else
|
|
223
|
+
if [ "$update" = "true" ]; then
|
|
224
|
+
update_php >/dev/null 2>&1
|
|
225
|
+
else
|
|
226
|
+
status="Found"
|
|
227
|
+
fi
|
|
228
|
+
fi
|
|
229
|
+
if ! command -v php"$version" >/dev/null; then
|
|
230
|
+
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
|
231
|
+
exit 1
|
|
232
|
+
fi
|
|
233
|
+
ext_dir="/usr/$(grep -Po "extension_dir=..[^/]*/\K[^'\"]*" "$php_config")"
|
|
234
|
+
ini_dir="$(php_ini_path)"
|
|
235
|
+
scan_dir="$ini_dir"/conf.d
|
|
236
|
+
pecl_file="$scan_dir"/99-pecl.ini
|
|
237
|
+
semver="$(php_semver)"
|
|
238
|
+
extra_version="$(php_extra_version)"
|
|
239
|
+
export ext_dir
|
|
240
|
+
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
|
|
241
|
+
link_pecl_file
|
|
242
|
+
configure_php
|
|
243
|
+
set_output "php-version" "$semver"
|
|
244
|
+
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
|
245
|
+
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
|
|
246
|
+
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
|
|
247
|
+
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
# Variables
|
|
251
|
+
version=${1:-'8.1'}
|
|
252
|
+
ini=${2:-'production'}
|
|
253
|
+
src=${0%/*}/..
|
|
254
|
+
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
|
255
|
+
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
|
256
|
+
scripts="$src"/scripts
|
|
257
|
+
|
|
258
|
+
add_sudo >/dev/null 2>&1
|
|
259
|
+
|
|
260
|
+
. /etc/os-release
|
|
261
|
+
# shellcheck source=.
|
|
262
|
+
. "${scripts:?}"/unix.sh
|
|
263
|
+
. "${scripts:?}"/tools/ppa.sh
|
|
264
|
+
. "${scripts:?}"/tools/add_tools.sh
|
|
265
|
+
. "${scripts:?}"/extensions/source.sh
|
|
266
|
+
. "${scripts:?}"/extensions/add_extensions.sh
|
|
267
|
+
read_env
|
|
268
|
+
self_hosted_setup
|
|
269
|
+
setup_php
|