setup-php 1.11.2 → 1.11.6
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 +433 -458
- 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 +4 -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 +188 -200
- package/lib/extensions.js.map +1 -1
- package/lib/install.d.ts +2 -0
- package/lib/install.js +96 -81
- package/lib/install.js.map +1 -1
- package/lib/tools.d.ts +18 -0
- package/lib/tools.js +306 -386
- package/lib/tools.js.map +1 -1
- package/lib/utils.d.ts +15 -0
- package/lib/utils.js +205 -291
- package/lib/utils.js.map +1 -1
- package/package.json +66 -56
- package/src/config.ts +82 -82
- package/src/configs/brew_extensions +28 -0
- package/src/configs/php-versions.json +5 -5
- package/src/configs/phpunit.json +24 -24
- package/src/coverage.ts +146 -146
- package/src/extensions.ts +235 -233
- package/src/install.ts +104 -104
- package/src/scripts/darwin.sh +341 -339
- package/src/scripts/ext/gearman.sh +22 -22
- package/src/scripts/ext/phalcon.ps1 +55 -55
- package/src/scripts/ext/phalcon.sh +70 -70
- package/src/scripts/linux.sh +361 -361
- package/src/scripts/win32.ps1 +326 -333
- package/src/tools.ts +472 -469
- package/src/utils.ts +319 -316
- package/.eslintrc.json +0 -16
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/CONTRIBUTING.md +0 -69
- package/.github/FUNDING.yml +0 -7
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -38
- package/.github/SECURITY.md +0 -29
- package/.github/workflows/main-workflow.yml +0 -56
- package/.github/workflows/node-workflow.yml +0 -47
- 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 -120
- package/__tests__/install.test.ts +0 -181
- package/__tests__/tools.test.ts +0 -476
- package/__tests__/utils.test.ts +0 -213
- package/action.yml +0 -38
- package/dist/index.js +0 -2854
- package/examples/bedrock.yml +0 -32
- 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 -56
- package/examples/symfony-postgres.yml +0 -54
- 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/tsconfig.json +0 -18
package/src/scripts/darwin.sh
CHANGED
|
@@ -1,339 +1,341 @@
|
|
|
1
|
-
# Function to log start of a operation
|
|
2
|
-
step_log() {
|
|
3
|
-
message=$1
|
|
4
|
-
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
# Function to log result of a operation
|
|
8
|
-
add_log() {
|
|
9
|
-
mark=$1
|
|
10
|
-
subject=$2
|
|
11
|
-
message=$3
|
|
12
|
-
if [ "$mark" = "$tick" ]; then
|
|
13
|
-
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
14
|
-
else
|
|
15
|
-
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
16
|
-
fi
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
# Function to remove extensions
|
|
20
|
-
remove_extension() {
|
|
21
|
-
extension=$1
|
|
22
|
-
sudo sed -Ei '' "/=(.*\/)?\"?$extension/d" "$ini_file"
|
|
23
|
-
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
|
24
|
-
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
# Function to test if extension is loaded
|
|
28
|
-
check_extension() {
|
|
29
|
-
extension=$1
|
|
30
|
-
if [ "$extension" != "mysql" ]; then
|
|
31
|
-
php -m | grep -i -q -w "$extension"
|
|
32
|
-
else
|
|
33
|
-
php -m | grep -i -q "$extension"
|
|
34
|
-
fi
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
# Function to install PECL extensions and accept default options
|
|
38
|
-
pecl_install() {
|
|
39
|
-
local extension=$1
|
|
40
|
-
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
# Function to get the PECL version
|
|
44
|
-
get_pecl_version() {
|
|
45
|
-
extension=$1
|
|
46
|
-
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
|
|
47
|
-
pecl_rest='https://pecl.php.net/rest/r/'
|
|
48
|
-
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
|
49
|
-
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
|
|
50
|
-
if [ ! "$pecl_version" ]; then
|
|
51
|
-
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
|
|
52
|
-
fi
|
|
53
|
-
echo "$pecl_version"
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
# Function to install a PECL version
|
|
57
|
-
add_pecl_extension() {
|
|
58
|
-
extension=$1
|
|
59
|
-
pecl_version=$2
|
|
60
|
-
prefix=$3
|
|
61
|
-
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
|
62
|
-
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
|
63
|
-
fi
|
|
64
|
-
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
65
|
-
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
|
66
|
-
fi
|
|
67
|
-
ext_version=$(php -r "echo phpversion('$extension');")
|
|
68
|
-
if [ "$ext_version" = "$pecl_version" ]; then
|
|
69
|
-
add_log "$tick" "$extension" "Enabled"
|
|
70
|
-
else
|
|
71
|
-
remove_extension "$extension"
|
|
72
|
-
(
|
|
73
|
-
pecl_install "$extension-$pecl_version" >/dev/null 2>&1 &&
|
|
74
|
-
check_extension "$extension" &&
|
|
75
|
-
add_log "$tick" "$extension" "Installed and enabled"
|
|
76
|
-
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
|
77
|
-
fi
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# Function to fetch a brew tap
|
|
81
|
-
fetch_brew_tap() {
|
|
82
|
-
tap=$1
|
|
83
|
-
tap_user=$(dirname "$tap")
|
|
84
|
-
tap_name=$(basename "$tap")
|
|
85
|
-
mkdir -p "$tap_dir/$tap_user"
|
|
86
|
-
sudo curl "${curl_opts[@]}" "https://github.com/$tap/archive/master.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
|
|
87
|
-
if [ -d "$tap_dir/$tap_user/$tap_name-master" ]; then
|
|
88
|
-
sudo mv "$tap_dir/$tap_user/$tap_name-master" "$tap_dir/$tap_user/$tap_name"
|
|
89
|
-
fi
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
# Function to add a brew tap.
|
|
93
|
-
add_brew_tap() {
|
|
94
|
-
tap=$1
|
|
95
|
-
if ! [ -d "$tap_dir/$tap" ]; then
|
|
96
|
-
fetch_brew_tap "$tap" >/dev/null 2>&1
|
|
97
|
-
if ! [ -d "$tap_dir/$tap" ]; then
|
|
98
|
-
brew tap
|
|
99
|
-
fi
|
|
100
|
-
fi
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
# Function to install a php extension from shivammathur/extensions tap.
|
|
104
|
-
add_brew_extension() {
|
|
105
|
-
formula=$1
|
|
106
|
-
extension=$
|
|
107
|
-
|
|
108
|
-
add_brew_tap shivammathur/homebrew-
|
|
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
|
-
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
add_extension
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
add_extension
|
|
195
|
-
add_extension
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
sudo
|
|
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
|
-
sudo "$tool"
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
brew
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
[[ "$version" =~
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
export
|
|
315
|
-
export
|
|
316
|
-
export
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
status="
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
1
|
+
# Function to log start of a operation
|
|
2
|
+
step_log() {
|
|
3
|
+
message=$1
|
|
4
|
+
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
# Function to log result of a operation
|
|
8
|
+
add_log() {
|
|
9
|
+
mark=$1
|
|
10
|
+
subject=$2
|
|
11
|
+
message=$3
|
|
12
|
+
if [ "$mark" = "$tick" ]; then
|
|
13
|
+
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
14
|
+
else
|
|
15
|
+
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
16
|
+
fi
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Function to remove extensions
|
|
20
|
+
remove_extension() {
|
|
21
|
+
local extension=$1
|
|
22
|
+
sudo sed -Ei '' "/=(.*\/)?\"?$extension/d" "$ini_file"
|
|
23
|
+
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
|
24
|
+
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Function to test if extension is loaded
|
|
28
|
+
check_extension() {
|
|
29
|
+
local extension=$1
|
|
30
|
+
if [ "$extension" != "mysql" ]; then
|
|
31
|
+
php -m | grep -i -q -w "$extension"
|
|
32
|
+
else
|
|
33
|
+
php -m | grep -i -q "$extension"
|
|
34
|
+
fi
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Function to install PECL extensions and accept default options
|
|
38
|
+
pecl_install() {
|
|
39
|
+
local extension=$1
|
|
40
|
+
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# Function to get the PECL version
|
|
44
|
+
get_pecl_version() {
|
|
45
|
+
local extension=$1
|
|
46
|
+
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
|
|
47
|
+
pecl_rest='https://pecl.php.net/rest/r/'
|
|
48
|
+
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
|
49
|
+
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
|
|
50
|
+
if [ ! "$pecl_version" ]; then
|
|
51
|
+
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
|
|
52
|
+
fi
|
|
53
|
+
echo "$pecl_version"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# Function to install a PECL version
|
|
57
|
+
add_pecl_extension() {
|
|
58
|
+
local extension=$1
|
|
59
|
+
pecl_version=$2
|
|
60
|
+
prefix=$3
|
|
61
|
+
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
|
62
|
+
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
|
63
|
+
fi
|
|
64
|
+
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
65
|
+
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
|
66
|
+
fi
|
|
67
|
+
ext_version=$(php -r "echo phpversion('$extension');")
|
|
68
|
+
if [ "$ext_version" = "$pecl_version" ]; then
|
|
69
|
+
add_log "$tick" "$extension" "Enabled"
|
|
70
|
+
else
|
|
71
|
+
remove_extension "$extension"
|
|
72
|
+
(
|
|
73
|
+
pecl_install "$extension-$pecl_version" >/dev/null 2>&1 &&
|
|
74
|
+
check_extension "$extension" &&
|
|
75
|
+
add_log "$tick" "$extension" "Installed and enabled"
|
|
76
|
+
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Function to fetch a brew tap
|
|
81
|
+
fetch_brew_tap() {
|
|
82
|
+
tap=$1
|
|
83
|
+
tap_user=$(dirname "$tap")
|
|
84
|
+
tap_name=$(basename "$tap")
|
|
85
|
+
mkdir -p "$tap_dir/$tap_user"
|
|
86
|
+
sudo curl "${curl_opts[@]}" "https://github.com/$tap/archive/master.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
|
|
87
|
+
if [ -d "$tap_dir/$tap_user/$tap_name-master" ]; then
|
|
88
|
+
sudo mv "$tap_dir/$tap_user/$tap_name-master" "$tap_dir/$tap_user/$tap_name"
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Function to add a brew tap.
|
|
93
|
+
add_brew_tap() {
|
|
94
|
+
tap=$1
|
|
95
|
+
if ! [ -d "$tap_dir/$tap" ]; then
|
|
96
|
+
fetch_brew_tap "$tap" >/dev/null 2>&1
|
|
97
|
+
if ! [ -d "$tap_dir/$tap" ]; then
|
|
98
|
+
brew tap "$tap" >/dev/null 2>&1
|
|
99
|
+
fi
|
|
100
|
+
fi
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# Function to install a php extension from shivammathur/extensions tap.
|
|
104
|
+
add_brew_extension() {
|
|
105
|
+
formula=$1
|
|
106
|
+
extension=$(grep "$formula=" "$dist"/../src/configs/brew_extensions | cut -d '=' -f 2)
|
|
107
|
+
[[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|[0-9]//g")"
|
|
108
|
+
add_brew_tap shivammathur/homebrew-php
|
|
109
|
+
add_brew_tap shivammathur/homebrew-extensions
|
|
110
|
+
sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$formula"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true
|
|
111
|
+
brew install "$formula@$version"
|
|
112
|
+
sudo cp "$brew_prefix/opt/$formula@$version/$extension.so" "$ext_dir"
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# Function to setup extensions
|
|
116
|
+
add_extension() {
|
|
117
|
+
local extension=$1
|
|
118
|
+
install_command=$2
|
|
119
|
+
prefix=$3
|
|
120
|
+
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
121
|
+
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
|
122
|
+
elif check_extension "$extension"; then
|
|
123
|
+
add_log "$tick" "$extension" "Enabled"
|
|
124
|
+
elif ! check_extension "$extension"; then
|
|
125
|
+
(
|
|
126
|
+
eval "$install_command" >/dev/null 2>&1 &&
|
|
127
|
+
check_extension "$extension" &&
|
|
128
|
+
add_log "$tick" "$extension" "Installed and enabled"
|
|
129
|
+
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
|
130
|
+
fi
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# Function to pre-release extensions using PECL
|
|
134
|
+
add_unstable_extension() {
|
|
135
|
+
local extension=$1
|
|
136
|
+
stability=$2
|
|
137
|
+
prefix=$3
|
|
138
|
+
pecl_version=$(get_pecl_version "$extension" "$stability")
|
|
139
|
+
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
# Function to configure composer
|
|
143
|
+
configure_composer() {
|
|
144
|
+
tool_path=$1
|
|
145
|
+
sudo ln -sf "$tool_path" "$tool_path.phar"
|
|
146
|
+
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
|
|
147
|
+
if [ $? -eq 1 ]; then
|
|
148
|
+
add_log "$cross" "composer" "Could not download composer"
|
|
149
|
+
exit 1;
|
|
150
|
+
fi
|
|
151
|
+
if ! [ -d "$composer_home" ]; then
|
|
152
|
+
sudo -u "$(id -un)" -g "$(id -gn)" mkdir -p -m=00755 "$composer_home"
|
|
153
|
+
else
|
|
154
|
+
sudo chown -R "$(id -un)":"$(id -gn)" "$composer_home"
|
|
155
|
+
fi
|
|
156
|
+
if ! [ -e "$composer_json" ]; then
|
|
157
|
+
echo '{}' | tee "$composer_json" >/dev/null
|
|
158
|
+
chmod 644 "$composer_json"
|
|
159
|
+
fi
|
|
160
|
+
composer -q config -g process-timeout 0
|
|
161
|
+
echo "$composer_bin" >> "$GITHUB_PATH"
|
|
162
|
+
if [ -n "$COMPOSER_TOKEN" ]; then
|
|
163
|
+
composer -q config -g github-oauth.github.com "$COMPOSER_TOKEN"
|
|
164
|
+
fi
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
# Function to setup a remote tool.
|
|
168
|
+
add_tool() {
|
|
169
|
+
url=$1
|
|
170
|
+
tool=$2
|
|
171
|
+
tool_path="$tool_path_dir/$tool"
|
|
172
|
+
if [ ! -e "$tool_path" ]; then
|
|
173
|
+
rm -rf "$tool_path"
|
|
174
|
+
fi
|
|
175
|
+
if [ "$tool" = "composer" ]; then
|
|
176
|
+
IFS="," read -r -a urls <<< "$url"
|
|
177
|
+
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
|
178
|
+
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
|
179
|
+
else
|
|
180
|
+
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
|
181
|
+
fi
|
|
182
|
+
if [ "$status_code" != "200" ] && [[ "$url" =~ .*github.com.*releases.*latest.* ]]; then
|
|
183
|
+
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)}"
|
|
184
|
+
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
|
185
|
+
fi
|
|
186
|
+
if [ "$status_code" = "200" ]; then
|
|
187
|
+
sudo chmod a+x "$tool_path"
|
|
188
|
+
if [ "$tool" = "composer" ]; then
|
|
189
|
+
configure_composer "$tool_path"
|
|
190
|
+
elif [ "$tool" = "phan" ]; then
|
|
191
|
+
add_extension fileinfo "pecl_install fileinfo" extension >/dev/null 2>&1
|
|
192
|
+
add_extension ast "pecl_install ast" extension >/dev/null 2>&1
|
|
193
|
+
elif [ "$tool" = "phive" ]; then
|
|
194
|
+
add_extension curl "pecl_install curl" extension >/dev/null 2>&1
|
|
195
|
+
add_extension mbstring "pecl_install mbstring" extension >/dev/null 2>&1
|
|
196
|
+
add_extension xml "pecl_install xml" extension >/dev/null 2>&1
|
|
197
|
+
elif [ "$tool" = "cs2pr" ]; then
|
|
198
|
+
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
|
199
|
+
tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"
|
|
200
|
+
sudo chmod a+x "$tool_path"
|
|
201
|
+
fi
|
|
202
|
+
add_log "$tick" "$tool" "Added"
|
|
203
|
+
else
|
|
204
|
+
add_log "$cross" "$tool" "Could not setup $tool"
|
|
205
|
+
fi
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# Function to add a tool using composer
|
|
209
|
+
add_composertool() {
|
|
210
|
+
tool=$1
|
|
211
|
+
release=$2
|
|
212
|
+
prefix=$3
|
|
213
|
+
(
|
|
214
|
+
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
|
215
|
+
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
|
216
|
+
add_log "$tick" "$tool" "Added"
|
|
217
|
+
) || add_log "$cross" "$tool" "Could not setup $tool"
|
|
218
|
+
if [ -e "$composer_bin/composer" ]; then
|
|
219
|
+
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
|
|
220
|
+
fi
|
|
221
|
+
if [ "$tool" = "codeception" ]; then
|
|
222
|
+
sudo ln -s "$composer_bin"/codecept "$composer_bin"/codeception
|
|
223
|
+
fi
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
# Function to configure PECL
|
|
227
|
+
configure_pecl() {
|
|
228
|
+
for tool in pear pecl; do
|
|
229
|
+
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
|
230
|
+
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
|
231
|
+
done
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
# Function to log PECL, it is installed along with PHP
|
|
235
|
+
add_pecl() {
|
|
236
|
+
add_log "$tick" "PECL" "Added"
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
# Function to backup all libraries of a formula
|
|
240
|
+
link_libraries() {
|
|
241
|
+
formula=$1
|
|
242
|
+
formula_prefix="$(brew --prefix "$formula")"
|
|
243
|
+
sudo mkdir -p "$formula_prefix"/lib
|
|
244
|
+
for lib in "$formula_prefix"/lib/*.dylib; do
|
|
245
|
+
[ -f "$lib" ] || break
|
|
246
|
+
lib_name=$(basename "$lib")
|
|
247
|
+
sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
|
|
248
|
+
done
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
patch_brew() {
|
|
252
|
+
sudo sed -i '' "s/ keg.link(verbose: verbose?)/ keg.link(verbose: verbose?, overwrite: true)/" "$brew_repo"/Library/Homebrew/formula_installer.rb
|
|
253
|
+
# shellcheck disable=SC2064
|
|
254
|
+
trap "git -C $brew_repo stash >/dev/null 2>&1" exit
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
# Function to update dependencies
|
|
258
|
+
update_dependencies() {
|
|
259
|
+
if [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
|
|
260
|
+
patch_brew
|
|
261
|
+
while read -r formula; do
|
|
262
|
+
(
|
|
263
|
+
curl -o "$tap_dir/homebrew/homebrew-core/Formula/$formula.rb" "${curl_opts[@]}" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb"
|
|
264
|
+
link_libraries "$formula"
|
|
265
|
+
) &
|
|
266
|
+
to_wait+=( $! )
|
|
267
|
+
done < "$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
|
268
|
+
wait "${to_wait[@]}"
|
|
269
|
+
fi
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
# Function to get PHP version if it is already installed using Homebrew.
|
|
273
|
+
get_brewed_php() {
|
|
274
|
+
php_cellar="$brew_prefix"/Cellar/php
|
|
275
|
+
if [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
|
|
276
|
+
php-config --version 2>/dev/null | cut -c 1-3
|
|
277
|
+
else
|
|
278
|
+
echo 'false';
|
|
279
|
+
fi
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
# Function to setup PHP and composer
|
|
283
|
+
setup_php() {
|
|
284
|
+
add_brew_tap shivammathur/homebrew-php
|
|
285
|
+
update_dependencies
|
|
286
|
+
brew upgrade shivammathur/php/php@"$version" 2>/dev/null || brew install shivammathur/php/php@"$version"
|
|
287
|
+
brew link --force --overwrite php@"$version"
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
# Function to configure PHP
|
|
291
|
+
configure_php() {
|
|
292
|
+
(
|
|
293
|
+
echo -e "date.timezone=UTC\nmemory_limit=-1"
|
|
294
|
+
[[ "$version" =~ 8.0 ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235"
|
|
295
|
+
[[ "$version" =~ 7.[2-4]|8.0 ]] && echo -e "xdebug.mode=coverage"
|
|
296
|
+
) | sudo tee -a "$ini_file" >/dev/null
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
# Variables
|
|
300
|
+
tick="✓"
|
|
301
|
+
cross="✗"
|
|
302
|
+
version=$1
|
|
303
|
+
dist=$2
|
|
304
|
+
tool_path_dir="/usr/local/bin"
|
|
305
|
+
curl_opts=(-sL)
|
|
306
|
+
composer_home="$HOME/.composer"
|
|
307
|
+
composer_bin="$composer_home/vendor/bin"
|
|
308
|
+
composer_json="$composer_home/composer.json"
|
|
309
|
+
composer_lock="$composer_home/composer.lock"
|
|
310
|
+
brew_prefix="$(brew --prefix)"
|
|
311
|
+
brew_repo="$(brew --repository)"
|
|
312
|
+
tap_dir="$brew_repo"/Library/Taps
|
|
313
|
+
existing_version=$(get_brewed_php)
|
|
314
|
+
export HOMEBREW_CHANGE_ARCH_TO_ARM=1
|
|
315
|
+
export HOMEBREW_DEVELOPER=1
|
|
316
|
+
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
|
317
|
+
export HOMEBREW_NO_AUTO_UPDATE=1
|
|
318
|
+
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
|
319
|
+
|
|
320
|
+
# Setup PHP
|
|
321
|
+
step_log "Setup PHP"
|
|
322
|
+
if [ "$existing_version" != "$version" ]; then
|
|
323
|
+
setup_php >/dev/null 2>&1
|
|
324
|
+
status="Installed"
|
|
325
|
+
else
|
|
326
|
+
status="Found"
|
|
327
|
+
fi
|
|
328
|
+
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
329
|
+
sudo chmod 777 "$ini_file" "$tool_path_dir"
|
|
330
|
+
configure_php
|
|
331
|
+
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
|
332
|
+
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
|
333
|
+
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
|
334
|
+
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
|
335
|
+
if [ "${semver%.*}" != "$version" ]; then
|
|
336
|
+
add_log "$cross" "PHP" "Could not setup PHP $version"
|
|
337
|
+
exit 1
|
|
338
|
+
fi
|
|
339
|
+
configure_pecl
|
|
340
|
+
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
|
341
|
+
add_log "$tick" "PHP" "$status PHP $semver"
|