setup-php 2.12.0 → 2.16.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 +977 -936
- package/package.json +66 -56
- package/src/config.ts +82 -82
- package/src/configs/brew_extensions +30 -0
- package/src/configs/os_releases.csv +17 -0
- package/src/configs/php-versions.json +6 -5
- 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 +256 -234
- package/src/configs/tools_schema.json +114 -103
- package/src/coverage.ts +169 -142
- package/src/extensions.ts +363 -349
- package/src/install.ts +79 -82
- package/src/scripts/common.sh +366 -314
- package/src/scripts/darwin.sh +257 -248
- package/src/scripts/ext/blackfire.ps1 +32 -32
- package/src/scripts/ext/blackfire.sh +22 -21
- package/src/scripts/ext/couchbase.sh +43 -43
- package/src/scripts/ext/cubrid.sh +60 -60
- package/src/scripts/ext/extension_map.php +109 -0
- package/src/scripts/ext/firebird.ps1 +19 -19
- package/src/scripts/ext/firebird.sh +39 -35
- package/src/scripts/ext/gearman.sh +22 -22
- package/src/scripts/ext/geos.sh +17 -17
- package/src/scripts/ext/http.ps1 +54 -54
- package/src/scripts/ext/http.sh +120 -120
- package/src/scripts/ext/intl.sh +23 -23
- package/src/scripts/ext/ioncube.ps1 +33 -32
- package/src/scripts/ext/ioncube.sh +21 -19
- package/src/scripts/ext/oci.ps1 +60 -60
- package/src/scripts/ext/oci.sh +65 -63
- package/src/scripts/ext/patches/firebird.sh +11 -11
- package/src/scripts/ext/patches/geos.sh +7 -7
- package/src/scripts/ext/patches/http.sh +11 -11
- package/src/scripts/ext/patches/pdo_oci.sh +6 -6
- package/src/scripts/ext/patches/phpize.sh +26 -26
- package/src/scripts/ext/patches/protobuf.sh +4 -4
- package/src/scripts/ext/phalcon.ps1 +54 -55
- package/src/scripts/ext/phalcon.sh +59 -59
- package/src/scripts/ext/source.sh +144 -144
- package/src/scripts/linux.sh +239 -280
- package/src/scripts/tools/add_tools.ps1 +28 -25
- package/src/scripts/tools/add_tools.sh +27 -19
- package/src/scripts/tools/blackfire.ps1 +19 -21
- package/src/scripts/tools/blackfire.sh +40 -35
- package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
- package/src/scripts/tools/grpc_php_plugin.sh +58 -61
- package/src/scripts/tools/ppa.sh +189 -0
- package/src/scripts/tools/protoc.ps1 +38 -38
- package/src/scripts/tools/protoc.sh +28 -28
- package/src/scripts/win32.ps1 +566 -471
- package/src/tools.ts +538 -509
- package/src/utils.ts +503 -497
- 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 -261
- package/__tests__/install.test.ts +0 -175
- package/__tests__/tools.test.ts +0 -490
- package/__tests__/utils.test.ts +0 -303
- package/action.yml +0 -29
- package/dist/index.js +0 -3001
- 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/config.js +0 -72
- package/lib/config.js.map +0 -1
- package/lib/coverage.js +0 -88
- package/lib/coverage.js.map +0 -1
- package/lib/extensions.js +0 -201
- package/lib/extensions.js.map +0 -1
- package/lib/install.js +0 -82
- package/lib/install.js.map +0 -1
- package/lib/sapi.js +0 -64
- package/lib/tools.js +0 -387
- package/lib/tools.js.map +0 -1
- package/lib/utils.js +0 -292
- package/lib/utils.js.map +0 -1
- package/tsconfig.json +0 -18
package/src/scripts/win32.ps1
CHANGED
|
@@ -1,471 +1,566 @@
|
|
|
1
|
-
param (
|
|
2
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
3
|
-
[ValidateNotNull()]
|
|
4
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
5
|
-
[string]
|
|
6
|
-
$version = '
|
|
7
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
8
|
-
[ValidateNotNull()]
|
|
9
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
10
|
-
[string]
|
|
11
|
-
$dist
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
# Function to log start of a operation.
|
|
15
|
-
Function Step-Log($message) {
|
|
16
|
-
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
# Function to log result of a operation.
|
|
20
|
-
Function Add-Log($mark, $subject, $message) {
|
|
21
|
-
if ($mark -eq $tick) {
|
|
22
|
-
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
|
|
23
|
-
} else {
|
|
24
|
-
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
|
|
25
|
-
if($env:fail_fast -eq 'true') {
|
|
26
|
-
exit 1;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
# Function to add a line to a powershell profile safely.
|
|
32
|
-
Function Add-ToProfile {
|
|
33
|
-
param(
|
|
34
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
35
|
-
[ValidateNotNull()]
|
|
36
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
37
|
-
[string]
|
|
38
|
-
$input_profile,
|
|
39
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
40
|
-
[ValidateNotNull()]
|
|
41
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
42
|
-
[string]
|
|
43
|
-
$search,
|
|
44
|
-
[Parameter(Position = 2, Mandatory = $true)]
|
|
45
|
-
[ValidateNotNull()]
|
|
46
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
47
|
-
[string]
|
|
48
|
-
$value
|
|
49
|
-
)
|
|
50
|
-
if($null -eq (Get-Content $input_profile | findstr $search)) {
|
|
51
|
-
Add-Content -Path $input_profile -Value $value
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
# Function to fetch PATH from the registry.
|
|
56
|
-
Function Get-PathFromRegistry {
|
|
57
|
-
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","User") + ";" +
|
|
58
|
-
[System.Environment]::GetEnvironmentVariable("Path","Machine")
|
|
59
|
-
Add-ToProfile $current_profile 'Get-PathFromRegistry' 'Function Get-PathFromRegistry { $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine") }; Get-PathFromRegistry'
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
# Function to add a location to PATH.
|
|
63
|
-
Function Add-Path {
|
|
64
|
-
param(
|
|
65
|
-
[string]$PathItem
|
|
66
|
-
)
|
|
67
|
-
$newPath = (Get-ItemProperty -Path 'hkcu:\Environment' -Name PATH).Path.replace("$PathItem;", '')
|
|
68
|
-
$newPath = $PathItem + ';' + $newPath
|
|
69
|
-
Set-ItemProperty -Path 'hkcu:\Environment' -Name Path -Value $newPath
|
|
70
|
-
Get-PathFromRegistry
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
# Function to make sure printf is in PATH.
|
|
74
|
-
Function Add-Printf {
|
|
75
|
-
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
|
|
76
|
-
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
|
|
77
|
-
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe
|
|
78
|
-
} else {
|
|
79
|
-
Invoke-WebRequest -Uri "$github/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip"
|
|
80
|
-
Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
# Function to get a clean Powershell profile.
|
|
88
|
-
Function Get-CleanPSProfile {
|
|
89
|
-
if(-not(Test-Path -LiteralPath $profile)) {
|
|
90
|
-
New-Item -Path $profile -ItemType "file" -Force
|
|
91
|
-
}
|
|
92
|
-
Set-Content $current_profile -Value ''
|
|
93
|
-
Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile"
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
# Function to install a powershell package from GitHub.
|
|
97
|
-
Function Install-PSPackage() {
|
|
98
|
-
param(
|
|
99
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
100
|
-
$package,
|
|
101
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
102
|
-
$psm1_path,
|
|
103
|
-
[Parameter(Position = 2, Mandatory = $true)]
|
|
104
|
-
$url,
|
|
105
|
-
[Parameter(Position = 3, Mandatory = $true)]
|
|
106
|
-
$cmdlet
|
|
107
|
-
)
|
|
108
|
-
$module_path = "$bin_dir\$psm1_path.psm1"
|
|
109
|
-
if(-not (Test-Path $module_path -PathType Leaf)) {
|
|
110
|
-
$zip_file = "$bin_dir\$package.zip"
|
|
111
|
-
Invoke-WebRequest -Uri $url -OutFile $zip_file
|
|
112
|
-
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
|
|
113
|
-
}
|
|
114
|
-
Import-Module $module_path
|
|
115
|
-
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
116
|
-
|
|
117
|
-
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
|
118
|
-
Install-Module -Name $cmdlet -Force
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
Function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
[
|
|
127
|
-
[
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
Function
|
|
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
|
-
|
|
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
|
-
if(
|
|
282
|
-
$
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
$
|
|
365
|
-
|
|
366
|
-
$bin_dir
|
|
367
|
-
$
|
|
368
|
-
|
|
369
|
-
$
|
|
370
|
-
$
|
|
371
|
-
|
|
372
|
-
$
|
|
373
|
-
$
|
|
374
|
-
$
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
$
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
$
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
$
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
$
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
$
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
1
|
+
param (
|
|
2
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
3
|
+
[ValidateNotNull()]
|
|
4
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
5
|
+
[string]
|
|
6
|
+
$version = '8.1',
|
|
7
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
8
|
+
[ValidateNotNull()]
|
|
9
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
10
|
+
[string]
|
|
11
|
+
$dist
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# Function to log start of a operation.
|
|
15
|
+
Function Step-Log($message) {
|
|
16
|
+
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Function to log result of a operation.
|
|
20
|
+
Function Add-Log($mark, $subject, $message) {
|
|
21
|
+
if ($mark -eq $tick) {
|
|
22
|
+
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
|
|
23
|
+
} else {
|
|
24
|
+
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
|
|
25
|
+
if($env:fail_fast -eq 'true') {
|
|
26
|
+
exit 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Function to add a line to a powershell profile safely.
|
|
32
|
+
Function Add-ToProfile {
|
|
33
|
+
param(
|
|
34
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
35
|
+
[ValidateNotNull()]
|
|
36
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
37
|
+
[string]
|
|
38
|
+
$input_profile,
|
|
39
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
40
|
+
[ValidateNotNull()]
|
|
41
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
42
|
+
[string]
|
|
43
|
+
$search,
|
|
44
|
+
[Parameter(Position = 2, Mandatory = $true)]
|
|
45
|
+
[ValidateNotNull()]
|
|
46
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
47
|
+
[string]
|
|
48
|
+
$value
|
|
49
|
+
)
|
|
50
|
+
if($null -eq (Get-Content $input_profile | findstr $search)) {
|
|
51
|
+
Add-Content -Path $input_profile -Value $value
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# Function to fetch PATH from the registry.
|
|
56
|
+
Function Get-PathFromRegistry {
|
|
57
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","User") + ";" +
|
|
58
|
+
[System.Environment]::GetEnvironmentVariable("Path","Machine")
|
|
59
|
+
Add-ToProfile $current_profile 'Get-PathFromRegistry' 'Function Get-PathFromRegistry { $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine") }; Get-PathFromRegistry'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Function to add a location to PATH.
|
|
63
|
+
Function Add-Path {
|
|
64
|
+
param(
|
|
65
|
+
[string]$PathItem
|
|
66
|
+
)
|
|
67
|
+
$newPath = (Get-ItemProperty -Path 'hkcu:\Environment' -Name PATH).Path.replace("$PathItem;", '')
|
|
68
|
+
$newPath = $PathItem + ';' + $newPath
|
|
69
|
+
Set-ItemProperty -Path 'hkcu:\Environment' -Name Path -Value $newPath
|
|
70
|
+
Get-PathFromRegistry
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Function to make sure printf is in PATH.
|
|
74
|
+
Function Add-Printf {
|
|
75
|
+
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
|
|
76
|
+
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
|
|
77
|
+
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe -Force > $null 2>&1
|
|
78
|
+
} else {
|
|
79
|
+
Invoke-WebRequest -Uri "$github/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip"
|
|
80
|
+
Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe" -Force > $null 2>&1
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# Function to get a clean Powershell profile.
|
|
88
|
+
Function Get-CleanPSProfile {
|
|
89
|
+
if(-not(Test-Path -LiteralPath $profile)) {
|
|
90
|
+
New-Item -Path $profile -ItemType "file" -Force > $null 2>&1
|
|
91
|
+
}
|
|
92
|
+
Set-Content $current_profile -Value ''
|
|
93
|
+
Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Function to install a powershell package from GitHub.
|
|
97
|
+
Function Install-PSPackage() {
|
|
98
|
+
param(
|
|
99
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
100
|
+
$package,
|
|
101
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
102
|
+
$psm1_path,
|
|
103
|
+
[Parameter(Position = 2, Mandatory = $true)]
|
|
104
|
+
$url,
|
|
105
|
+
[Parameter(Position = 3, Mandatory = $true)]
|
|
106
|
+
$cmdlet
|
|
107
|
+
)
|
|
108
|
+
$module_path = "$bin_dir\$psm1_path.psm1"
|
|
109
|
+
if(-not (Test-Path $module_path -PathType Leaf)) {
|
|
110
|
+
$zip_file = "$bin_dir\$package.zip"
|
|
111
|
+
Invoke-WebRequest -Uri $url -OutFile $zip_file
|
|
112
|
+
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
|
|
113
|
+
}
|
|
114
|
+
Import-Module $module_path
|
|
115
|
+
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
116
|
+
|
|
117
|
+
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
|
118
|
+
Install-Module -Name $cmdlet -Force
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# Function to link dependencies to PHP directory.
|
|
123
|
+
Function Set-ExtensionPrerequisites
|
|
124
|
+
{
|
|
125
|
+
Param (
|
|
126
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
127
|
+
[ValidateNotNull()]
|
|
128
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
129
|
+
[string]
|
|
130
|
+
$deps_dir
|
|
131
|
+
)
|
|
132
|
+
$deps = Get-ChildItem -Recurse -Path $deps_dir
|
|
133
|
+
if ($deps.Count -ne 0) {
|
|
134
|
+
# Symlink dependencies instead of adding the directory to PATH ...
|
|
135
|
+
# as other actions change the PATH thus breaking extensions.
|
|
136
|
+
$deps | ForEach-Object {
|
|
137
|
+
New-Item -Itemtype SymbolicLink -Path $php_dir -Name $_.Name -Target $_.FullName -Force > $null 2>&1
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
Remove-Item $deps_dir -Recurse -Force
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
# Function to add CA certificates to PHP.
|
|
145
|
+
Function Add-PhpCAInfo {
|
|
146
|
+
try {
|
|
147
|
+
Update-PhpCAInfo -Path $php_dir -Source Curl
|
|
148
|
+
} catch {
|
|
149
|
+
Add-Log $cross PHP "Could not fetch CA certificate bundle from Curl"
|
|
150
|
+
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
# Function to add PHP extensions.
|
|
155
|
+
Function Add-Extension {
|
|
156
|
+
Param (
|
|
157
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
158
|
+
[ValidateNotNull()]
|
|
159
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
160
|
+
[string]
|
|
161
|
+
$extension,
|
|
162
|
+
[Parameter(Position = 1, Mandatory = $false)]
|
|
163
|
+
[ValidateNotNull()]
|
|
164
|
+
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
|
165
|
+
[string]
|
|
166
|
+
$stability = 'stable',
|
|
167
|
+
[Parameter(Position = 2, Mandatory = $false)]
|
|
168
|
+
[ValidateNotNull()]
|
|
169
|
+
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
|
170
|
+
[string]
|
|
171
|
+
$extension_version = ''
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
|
175
|
+
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
|
176
|
+
New-Item $deps_dir -Type Directory -Force > $null 2>&1
|
|
177
|
+
if ($null -ne $extension_info) {
|
|
178
|
+
switch ($extension_info.State) {
|
|
179
|
+
'Builtin' {
|
|
180
|
+
Add-Log $tick $extension "Enabled"
|
|
181
|
+
}
|
|
182
|
+
'Enabled' {
|
|
183
|
+
Add-Log $tick $extension "Enabled"
|
|
184
|
+
}
|
|
185
|
+
default {
|
|
186
|
+
Enable-ExtensionDependencies $extension
|
|
187
|
+
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
|
188
|
+
Set-ExtensionPrerequisites $deps_dir
|
|
189
|
+
Add-Log $tick $extension "Enabled"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
$params = @{ Extension = $extension; MinimumStability = $stability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
|
195
|
+
if($extension_version -ne '') {
|
|
196
|
+
$params["Version"] = $extension_version
|
|
197
|
+
}
|
|
198
|
+
Install-PhpExtension @params
|
|
199
|
+
Set-ExtensionPrerequisites $deps_dir
|
|
200
|
+
Add-Log $tick $extension "Installed and enabled"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# Function to get a map of extensions and their dependent shared extensions.
|
|
209
|
+
Function Get-ExtensionMap {
|
|
210
|
+
php -d'error_reporting=0' $dist\..\src\scripts\ext\extension_map.php
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
# Function to enable extension dependencies which are also extensions.
|
|
214
|
+
Function Enable-ExtensionDependencies {
|
|
215
|
+
Param (
|
|
216
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
217
|
+
[ValidateNotNull()]
|
|
218
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
219
|
+
[string]
|
|
220
|
+
$extension
|
|
221
|
+
)
|
|
222
|
+
if (-not(Test-Path $env:TEMP\map.orig)) {
|
|
223
|
+
Get-ExtensionMap | Set-Content -Path $env:TEMP\map.orig
|
|
224
|
+
}
|
|
225
|
+
$entry = findstr /r "$extension`:.*" $env:TEMP\map.orig
|
|
226
|
+
if($entry) {
|
|
227
|
+
$entry.split(':')[1].trim().split(' ') | ForEach-Object {
|
|
228
|
+
if (-not(php -m | findstr -i $_)) {
|
|
229
|
+
Enable-PhpExtension -Extension $_ -Path $php_dir
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
# Function to disable dependent extensions.
|
|
236
|
+
Function Disable-DependentExtensions() {
|
|
237
|
+
Param (
|
|
238
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
239
|
+
[ValidateNotNull()]
|
|
240
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
241
|
+
[string]
|
|
242
|
+
$extension
|
|
243
|
+
)
|
|
244
|
+
Get-ExtensionMap | Select-String -Pattern ".*:.*\s$extension(\s|$)" | ForEach-Object {
|
|
245
|
+
$dependent = $_.Matches[0].Value.split(':')[0];
|
|
246
|
+
Disable-ExtensionHelper -Extension $dependent -DisableDependents
|
|
247
|
+
Add-Log $tick ":$extension" "Disabled $dependent as it depends on $extension"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
# Helper function to disable an extension.
|
|
252
|
+
Function Disable-ExtensionHelper() {
|
|
253
|
+
Param (
|
|
254
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
255
|
+
[ValidateNotNull()]
|
|
256
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
257
|
+
[string]
|
|
258
|
+
$extension,
|
|
259
|
+
[switch] $DisableDependents
|
|
260
|
+
)
|
|
261
|
+
if($DisableDependents) {
|
|
262
|
+
Disable-DependentExtensions $extension
|
|
263
|
+
}
|
|
264
|
+
Disable-PhpExtension -Extension $extension -Path $php_dir
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
# Function to disable an extension.
|
|
268
|
+
Function Disable-Extension() {
|
|
269
|
+
Param (
|
|
270
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
271
|
+
[ValidateNotNull()]
|
|
272
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
273
|
+
[string]
|
|
274
|
+
$extension,
|
|
275
|
+
[Parameter(Position = 1, Mandatory = $false)]
|
|
276
|
+
[ValidateNotNull()]
|
|
277
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
278
|
+
[string]
|
|
279
|
+
$DisableDependents
|
|
280
|
+
)
|
|
281
|
+
if(php -m | findstr -i $extension) {
|
|
282
|
+
if(Test-Path $ext_dir\php_$extension.dll) {
|
|
283
|
+
try {
|
|
284
|
+
$params = @{ Extension = $extension; DisableDependents = ($DisableDependents -ne 'false') }
|
|
285
|
+
Disable-ExtensionHelper @params
|
|
286
|
+
Add-Log $tick ":$extension" "Disabled"
|
|
287
|
+
} catch {
|
|
288
|
+
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion)"
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion) as it not a shared extension"
|
|
292
|
+
}
|
|
293
|
+
} elseif(Test-Path $ext_dir\php_$extension.dll) {
|
|
294
|
+
Add-Log $tick ":$extension" "Disabled"
|
|
295
|
+
} else {
|
|
296
|
+
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
# Function to disable shared extensions.
|
|
301
|
+
Function Disable-AllShared() {
|
|
302
|
+
(Get-Content $php_dir\php.ini) | Where-Object {$_ -notmatch '^(zend_)?extension\s*='} | Set-Content $php_dir\php.ini
|
|
303
|
+
Add-Log $tick "none" "Disabled all shared extensions"
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
# Function to configure composer.
|
|
307
|
+
Function Edit-ComposerConfig() {
|
|
308
|
+
Param(
|
|
309
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
310
|
+
[ValidateNotNull()]
|
|
311
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
312
|
+
[string]
|
|
313
|
+
$tool_path
|
|
314
|
+
)
|
|
315
|
+
Copy-Item $tool_path -Destination "$tool_path.phar"
|
|
316
|
+
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
|
|
317
|
+
if ($? -eq $False) {
|
|
318
|
+
Add-Log "$cross" "composer" "Could not download composer"
|
|
319
|
+
exit 1;
|
|
320
|
+
}
|
|
321
|
+
if (-not(Test-Path $composer_json)) {
|
|
322
|
+
Set-Content -Path $composer_json -Value "{}"
|
|
323
|
+
}
|
|
324
|
+
composer -q config -g process-timeout 0
|
|
325
|
+
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
|
326
|
+
if (Test-Path env:COMPOSER_TOKEN) {
|
|
327
|
+
composer -q config -g github-oauth.github.com $env:COMPOSER_TOKEN
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
# Function to extract tool version.
|
|
332
|
+
Function Get-ToolVersion() {
|
|
333
|
+
Param (
|
|
334
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
335
|
+
$tool,
|
|
336
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
337
|
+
$param
|
|
338
|
+
)
|
|
339
|
+
$alp = "[a-zA-Z0-9]"
|
|
340
|
+
$version_regex = "[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
|
|
341
|
+
if($tool -eq 'composer') {
|
|
342
|
+
if ($param -eq 'snapshot') {
|
|
343
|
+
$composer_version = (Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }) + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value })
|
|
344
|
+
} else {
|
|
345
|
+
$composer_version = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
|
346
|
+
}
|
|
347
|
+
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
|
348
|
+
return "$composer_version"
|
|
349
|
+
}
|
|
350
|
+
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
# Function to add tools.
|
|
354
|
+
Function Add-Tool() {
|
|
355
|
+
Param (
|
|
356
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
357
|
+
[ValidateNotNull()]
|
|
358
|
+
$url,
|
|
359
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
360
|
+
[ValidateNotNull()]
|
|
361
|
+
$tool,
|
|
362
|
+
[Parameter(Position = 2, Mandatory = $true)]
|
|
363
|
+
[ValidateNotNull()]
|
|
364
|
+
$ver_param
|
|
365
|
+
)
|
|
366
|
+
if (Test-Path $bin_dir\$tool) {
|
|
367
|
+
Remove-Item $bin_dir\$tool
|
|
368
|
+
}
|
|
369
|
+
if($url.Count -gt 1) {
|
|
370
|
+
$url = $url[0]
|
|
371
|
+
}
|
|
372
|
+
$tool_path = "$bin_dir\$tool"
|
|
373
|
+
if (($url | Split-Path -Extension) -eq ".exe") {
|
|
374
|
+
$tool_path = "$tool_path.exe"
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
Invoke-WebRequest -Uri $url -OutFile $tool_path
|
|
378
|
+
} catch {
|
|
379
|
+
if($url -match '.*github.com.*releases.*latest.*') {
|
|
380
|
+
try {
|
|
381
|
+
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
|
|
382
|
+
Invoke-WebRequest -Uri $url -OutFile $tool_path
|
|
383
|
+
} catch { }
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
|
387
|
+
$bat_content = @()
|
|
388
|
+
$bat_content += "@ECHO off"
|
|
389
|
+
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
|
390
|
+
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
|
391
|
+
$bat_content += "php %BIN_TARGET% %*"
|
|
392
|
+
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content
|
|
393
|
+
Add-ToolsHelper $tool
|
|
394
|
+
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1
|
|
395
|
+
$tool_version = Get-ToolVersion $tool $ver_param
|
|
396
|
+
Add-Log $tick $tool "Added $tool $tool_version"
|
|
397
|
+
} else {
|
|
398
|
+
Add-Log $cross $tool "Could not add $tool"
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
# Function to setup a tool using composer.
|
|
403
|
+
Function Add-Composertool() {
|
|
404
|
+
Param (
|
|
405
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
406
|
+
[ValidateNotNull()]
|
|
407
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
408
|
+
[string]
|
|
409
|
+
$tool,
|
|
410
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
411
|
+
[ValidateNotNull()]
|
|
412
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
413
|
+
[string]
|
|
414
|
+
$release,
|
|
415
|
+
[Parameter(Position = 2, Mandatory = $true)]
|
|
416
|
+
[ValidateNotNull()]
|
|
417
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
418
|
+
[string]
|
|
419
|
+
$prefix
|
|
420
|
+
)
|
|
421
|
+
if($tool -match "prestissimo|composer-prefetcher" -and $composer_version.split('.')[0] -ne "1") {
|
|
422
|
+
Write-Output "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
|
|
423
|
+
Add-Log $cross $tool "Skipped"
|
|
424
|
+
Return
|
|
425
|
+
}
|
|
426
|
+
if(Test-Path $composer_lock) {
|
|
427
|
+
Remove-Item -Path $composer_lock -Force
|
|
428
|
+
}
|
|
429
|
+
(composer global require $prefix$release 2>&1 | Tee-Object -FilePath $env:APPDATA\Composer\composer.log) >$null 2>&1
|
|
430
|
+
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
|
|
431
|
+
$log = findstr $prefix$tool $env:APPDATA\Composer\composer.log
|
|
432
|
+
if(Test-Path $composer_bin\composer) {
|
|
433
|
+
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
|
|
434
|
+
}
|
|
435
|
+
Add-ToolsHelper $tool
|
|
436
|
+
if($json) {
|
|
437
|
+
$tool_version = Get-ToolVersion "Write-Output" "$log"
|
|
438
|
+
Add-Log $tick $tool "Added $tool $tool_version"
|
|
439
|
+
} else {
|
|
440
|
+
Add-Log $cross $tool "Could not setup $tool"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
# Function to handle request to add PECL.
|
|
445
|
+
Function Add-Pecl() {
|
|
446
|
+
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
# Variables
|
|
450
|
+
$tick = ([char]8730)
|
|
451
|
+
$cross = ([char]10007)
|
|
452
|
+
$php_dir = 'C:\tools\php'
|
|
453
|
+
$ext_dir = "$php_dir\ext"
|
|
454
|
+
$bin_dir = $php_dir
|
|
455
|
+
$github = 'https://github.com'
|
|
456
|
+
$php_builder = "$github/shivammathur/php-builder-windows"
|
|
457
|
+
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
|
458
|
+
$composer_json = "$env:APPDATA\Composer\composer.json"
|
|
459
|
+
$composer_lock = "$env:APPDATA\Composer\composer.lock"
|
|
460
|
+
$current_profile = "$env:TEMP\setup-php.ps1"
|
|
461
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
462
|
+
$jit_versions = '8.[0-9]'
|
|
463
|
+
$nightly_versions = '8.[1-9]'
|
|
464
|
+
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
|
465
|
+
|
|
466
|
+
$arch = 'x64'
|
|
467
|
+
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
|
468
|
+
$arch = 'x86'
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
$ts = $env:PHPTS -eq 'ts'
|
|
472
|
+
if($env:PHPTS -ne 'ts') {
|
|
473
|
+
$env:PHPTS = 'nts'
|
|
474
|
+
}
|
|
475
|
+
if($env:RUNNER -eq 'self-hosted') {
|
|
476
|
+
$bin_dir = 'C:\tools\bin'
|
|
477
|
+
$php_dir = "$php_dir$version"
|
|
478
|
+
$ext_dir = "$php_dir\ext"
|
|
479
|
+
Get-CleanPSProfile >$null 2>&1
|
|
480
|
+
New-Item $bin_dir -Type Directory -Force > $null 2>&1
|
|
481
|
+
Add-Path -PathItem $bin_dir
|
|
482
|
+
if($version -lt 5.6) {
|
|
483
|
+
Add-Log $cross "PHP" "PHP $version is not supported on self-hosted runner"
|
|
484
|
+
Start-Sleep 1
|
|
485
|
+
exit 1
|
|
486
|
+
}
|
|
487
|
+
if ((Get-InstalledModule).Name -notcontains 'VcRedist') {
|
|
488
|
+
Install-Module -Name VcRedist -Force
|
|
489
|
+
}
|
|
490
|
+
New-Item $php_dir -Type Directory -Force > $null 2>&1
|
|
491
|
+
Add-Path -PathItem $php_dir
|
|
492
|
+
setx PHPROOT $php_dir >$null 2>&1
|
|
493
|
+
} else {
|
|
494
|
+
$current_profile = "$PSHOME\Profile.ps1"
|
|
495
|
+
if(-not(Test-Path -LiteralPath $current_profile)) {
|
|
496
|
+
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
. $dist\..\src\scripts\tools\add_tools.ps1
|
|
501
|
+
|
|
502
|
+
Add-Printf >$null 2>&1
|
|
503
|
+
Step-Log "Setup PhpManager"
|
|
504
|
+
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" Get-Php >$null 2>&1
|
|
505
|
+
Add-Log $tick "PhpManager" "Installed"
|
|
506
|
+
|
|
507
|
+
Step-Log "Setup PHP"
|
|
508
|
+
$installed = $null
|
|
509
|
+
if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|
510
|
+
try {
|
|
511
|
+
if(Test-Path $php_dir\php.ini) {
|
|
512
|
+
Rename-Item -Path $php_dir\php.ini -NewName 'php.ini.bak'
|
|
513
|
+
}
|
|
514
|
+
$installed = Get-Php -Path $php_dir -ErrorAction SilentlyContinue 2>$null 3>$null
|
|
515
|
+
if(Test-Path $php_dir\php.ini.bak) {
|
|
516
|
+
Rename-Item -Path $php_dir\php.ini.bak -NewName 'php.ini'
|
|
517
|
+
}
|
|
518
|
+
} catch { }
|
|
519
|
+
}
|
|
520
|
+
$status = "Installed"
|
|
521
|
+
$extra_version = ""
|
|
522
|
+
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
|
523
|
+
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
|
|
524
|
+
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
if ($version -match $nightly_versions) {
|
|
528
|
+
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/latest/download/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
|
|
529
|
+
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
|
530
|
+
if(Test-Path $php_dir\COMMIT) {
|
|
531
|
+
$extra_version = " ($( Get-Content $php_dir\COMMIT ))"
|
|
532
|
+
}
|
|
533
|
+
} else {
|
|
534
|
+
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
|
|
535
|
+
}
|
|
536
|
+
} catch { }
|
|
537
|
+
} else {
|
|
538
|
+
Set-PhpIniKey -Key 'extension_dir' -Value $ext_dir -Path $php_dir
|
|
539
|
+
if($version -match $jit_versions) {
|
|
540
|
+
('opcache.enable=1', 'opcache.jit_buffer_size=256M', 'opcache.jit=1235') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
541
|
+
}
|
|
542
|
+
if($env:update -eq 'true') {
|
|
543
|
+
Update-Php $php_dir >$null 2>&1
|
|
544
|
+
$status = "Updated to"
|
|
545
|
+
} else {
|
|
546
|
+
$status = "Found"
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
$installed = Get-Php -Path $php_dir
|
|
551
|
+
if($installed.MajorMinorVersion -ne $version) {
|
|
552
|
+
Add-Log $cross "PHP" "Could not setup PHP $version"
|
|
553
|
+
exit 1
|
|
554
|
+
}
|
|
555
|
+
('date.timezone=UTC', 'memory_limit=-1', 'xdebug.mode=coverage') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
556
|
+
if($version -lt "5.5") {
|
|
557
|
+
('libeay32.dll', 'ssleay32.dll') | ForEach-Object { Invoke-WebRequest -Uri "$php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $php_dir\$_ >$null 2>&1 }
|
|
558
|
+
} else {
|
|
559
|
+
$enable_extensions += ('opcache')
|
|
560
|
+
}
|
|
561
|
+
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
|
562
|
+
Add-PhpCAInfo
|
|
563
|
+
Copy-Item -Path $dist\..\src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
|
564
|
+
New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1
|
|
565
|
+
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
|
|
566
|
+
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|