setup-php 2.15.0 → 2.17.1
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 +157 -143
- package/lib/config.d.ts +3 -3
- package/lib/config.js +71 -71
- package/lib/config.js.map +1 -1
- package/lib/coverage.d.ts +5 -4
- package/lib/coverage.js +97 -87
- package/lib/coverage.js.map +1 -1
- package/lib/extensions.d.ts +4 -4
- package/lib/extensions.js +214 -210
- 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 -2
- package/lib/install.js +75 -80
- package/lib/install.js.map +1 -1
- package/lib/tools.d.ts +23 -24
- package/lib/tools.js +373 -386
- package/lib/tools.js.map +1 -1
- package/lib/utils.d.ts +21 -23
- package/lib/utils.js +261 -293
- package/lib/utils.js.map +1 -1
- package/package.json +21 -20
- package/src/config.ts +8 -8
- package/src/configs/brew_extensions +2 -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-versions.json +2 -2
- package/src/configs/php_packages +12 -0
- package/src/configs/{php.json → pm/php.json} +0 -0
- package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
- package/src/configs/tools.json +48 -26
- package/src/configs/tools_schema.json +11 -0
- package/src/coverage.ts +47 -55
- package/src/extensions.ts +23 -19
- package/src/fetch.ts +54 -0
- package/src/install.ts +27 -40
- package/src/scripts/darwin.sh +72 -39
- 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 +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 +0 -0
- package/src/scripts/{ext → extensions}/http.sh +4 -15
- 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 +23 -22
- package/src/scripts/extensions/sqlsrv.sh +15 -0
- package/src/scripts/linux.sh +71 -40
- package/src/scripts/tools/add_tools.ps1 +220 -10
- package/src/scripts/tools/add_tools.sh +166 -15
- package/src/scripts/tools/blackfire.sh +2 -1
- 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 +145 -356
- package/src/tools.ts +62 -82
- package/src/utils.ts +57 -145
- package/lib/sapi.js +0 -64
- package/src/scripts/common.sh +0 -366
package/src/scripts/win32.ps1
CHANGED
|
@@ -3,12 +3,12 @@ param (
|
|
|
3
3
|
[ValidateNotNull()]
|
|
4
4
|
[ValidateLength(1, [int]::MaxValue)]
|
|
5
5
|
[string]
|
|
6
|
-
$version = '8.
|
|
6
|
+
$version = '8.1',
|
|
7
7
|
[Parameter(Position = 1, Mandatory = $true)]
|
|
8
8
|
[ValidateNotNull()]
|
|
9
9
|
[ValidateLength(1, [int]::MaxValue)]
|
|
10
10
|
[string]
|
|
11
|
-
$
|
|
11
|
+
$ini = 'production'
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
# Function to log start of a operation.
|
|
@@ -28,6 +28,25 @@ Function Add-Log($mark, $subject, $message) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
# Function to set output on GitHub Actions.
|
|
32
|
+
Function Set-Output() {
|
|
33
|
+
param(
|
|
34
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
35
|
+
[ValidateNotNull()]
|
|
36
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
37
|
+
[string]
|
|
38
|
+
$output,
|
|
39
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
40
|
+
[ValidateNotNull()]
|
|
41
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
42
|
+
[string]
|
|
43
|
+
$value
|
|
44
|
+
)
|
|
45
|
+
if ($env:GITHUB_ACTIONS -eq 'true') {
|
|
46
|
+
Write-Output "::set-output name=$output::$value"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
31
50
|
# Function to add a line to a powershell profile safely.
|
|
32
51
|
Function Add-ToProfile {
|
|
33
52
|
param(
|
|
@@ -64,10 +83,48 @@ Function Add-Path {
|
|
|
64
83
|
param(
|
|
65
84
|
[string]$PathItem
|
|
66
85
|
)
|
|
67
|
-
$
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
86
|
+
if("$env:PATH;".contains("$PathItem;")) {
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
if ($env:GITHUB_PATH) {
|
|
90
|
+
Add-Content $PathItem -Path $env:GITHUB_PATH -Encoding utf8
|
|
91
|
+
} else {
|
|
92
|
+
$newPath = (Get-ItemProperty -Path 'hkcu:\Environment' -Name PATH).Path.replace("$PathItem;", '')
|
|
93
|
+
$newPath = $PathItem + ';' + $newPath
|
|
94
|
+
Set-ItemProperty -Path 'hkcu:\Environment' -Name Path -Value $newPath
|
|
95
|
+
Get-PathFromRegistry
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Function to add an environment variable.
|
|
100
|
+
Function Add-Env {
|
|
101
|
+
param(
|
|
102
|
+
[string]$EnvName,
|
|
103
|
+
[string]$EnvValue
|
|
104
|
+
)
|
|
105
|
+
if ($env:GITHUB_ENV) {
|
|
106
|
+
Add-Content "$EnvName=$EnvValue" -Path $env:GITHUB_ENV -Encoding utf8
|
|
107
|
+
} else {
|
|
108
|
+
Set-ItemProperty -Path 'hkcu:\Environment' -Name $EnvName -Value $EnvValue
|
|
109
|
+
Add-ToProfile $current_profile $EnvName "`$env:$EnvName=`"$EnvValue`""
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# Function to add environment variables using a PATH.
|
|
114
|
+
Function Add-EnvPATH {
|
|
115
|
+
param(
|
|
116
|
+
[string]$EnvPATH
|
|
117
|
+
)
|
|
118
|
+
if(-not(Test-Path $EnvPATH)) {
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
$env_file = $env:GITHUB_ENV
|
|
122
|
+
$env_data = Get-Content -Path $EnvPATH
|
|
123
|
+
if (-not($env:GITHUB_ENV)) {
|
|
124
|
+
$env_file = $current_profile
|
|
125
|
+
$env_data = $env_data | ForEach-Object { '$env:' + $_ }
|
|
126
|
+
}
|
|
127
|
+
$env_data | Add-Content -Path $env_file -Encoding utf8
|
|
71
128
|
}
|
|
72
129
|
|
|
73
130
|
# Function to make sure printf is in PATH.
|
|
@@ -112,55 +169,13 @@ Function Install-PSPackage() {
|
|
|
112
169
|
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
|
|
113
170
|
}
|
|
114
171
|
Import-Module $module_path
|
|
115
|
-
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
116
|
-
|
|
117
172
|
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
|
118
|
-
Install-Module -Name $
|
|
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
|
-
}
|
|
173
|
+
Install-Module -Name $package -Force
|
|
139
174
|
} else {
|
|
140
|
-
|
|
175
|
+
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
141
176
|
}
|
|
142
177
|
}
|
|
143
178
|
|
|
144
|
-
# Function to get extension pre-requisites.
|
|
145
|
-
# https://windows.php.net/downloads/pecl/deps
|
|
146
|
-
# Currently only imagick is supported using this Cmdlet.
|
|
147
|
-
Function Get-ExtensionPrerequisites{
|
|
148
|
-
Param (
|
|
149
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
150
|
-
[ValidateNotNull()]
|
|
151
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
152
|
-
[string]
|
|
153
|
-
$extension
|
|
154
|
-
)
|
|
155
|
-
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
|
156
|
-
$extensions_with_dependencies = ('imagick')
|
|
157
|
-
New-Item $deps_dir -Type Directory -Force > $null 2>&1
|
|
158
|
-
if($extensions_with_dependencies.Contains($extension)) {
|
|
159
|
-
Install-PhpExtensionPrerequisite -Extension $extension -InstallPath $deps_dir -PhpPath $php_dir
|
|
160
|
-
}
|
|
161
|
-
return $deps_dir
|
|
162
|
-
}
|
|
163
|
-
|
|
164
179
|
# Function to add CA certificates to PHP.
|
|
165
180
|
Function Add-PhpCAInfo {
|
|
166
181
|
try {
|
|
@@ -171,299 +186,56 @@ Function Add-PhpCAInfo {
|
|
|
171
186
|
}
|
|
172
187
|
}
|
|
173
188
|
|
|
174
|
-
# Function to
|
|
175
|
-
Function Add-
|
|
176
|
-
Param (
|
|
177
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
178
|
-
[ValidateNotNull()]
|
|
179
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
180
|
-
[string]
|
|
181
|
-
$extension,
|
|
182
|
-
[Parameter(Position = 1, Mandatory = $false)]
|
|
183
|
-
[ValidateNotNull()]
|
|
184
|
-
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
|
185
|
-
[string]
|
|
186
|
-
$stability = 'stable',
|
|
187
|
-
[Parameter(Position = 2, Mandatory = $false)]
|
|
188
|
-
[ValidateNotNull()]
|
|
189
|
-
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
|
190
|
-
[string]
|
|
191
|
-
$extension_version = ''
|
|
192
|
-
)
|
|
189
|
+
# Function to set OpenSSL config.
|
|
190
|
+
Function Add-OpenSSLConf {
|
|
193
191
|
try {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
Add-Log $tick $extension "Enabled"
|
|
199
|
-
}
|
|
200
|
-
'Enabled' {
|
|
201
|
-
Add-Log $tick $extension "Enabled"
|
|
202
|
-
}
|
|
203
|
-
default {
|
|
204
|
-
$deps_dir = Get-ExtensionPrerequisites $extension
|
|
205
|
-
Enable-ExtensionDependencies $extension
|
|
206
|
-
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
|
207
|
-
Set-ExtensionPrerequisites $deps_dir
|
|
208
|
-
Add-Log $tick $extension "Enabled"
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
$deps_dir = Get-ExtensionPrerequisites $extension
|
|
214
|
-
$params = @{ Extension = $extension; MinimumStability = $stability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
|
215
|
-
if($extension_version -ne '') {
|
|
216
|
-
$params["Version"] = $extension_version
|
|
217
|
-
}
|
|
218
|
-
Install-PhpExtension @params
|
|
219
|
-
Set-ExtensionPrerequisites $deps_dir
|
|
220
|
-
Add-Log $tick $extension "Installed and enabled"
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
catch {
|
|
224
|
-
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
# Function to get a map of extensions and their dependent shared extensions.
|
|
229
|
-
Function Get-ExtensionMap {
|
|
230
|
-
php -d'error_reporting=0' $dist\..\src\scripts\ext\extension_map.php
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
# Function to enable extension dependencies which are also extensions.
|
|
234
|
-
Function Enable-ExtensionDependencies {
|
|
235
|
-
Param (
|
|
236
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
237
|
-
[ValidateNotNull()]
|
|
238
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
239
|
-
[string]
|
|
240
|
-
$extension
|
|
241
|
-
)
|
|
242
|
-
if (-not(Test-Path $env:TEMP\map.orig)) {
|
|
243
|
-
Get-ExtensionMap | Set-Content -Path $env:TEMP\map.orig
|
|
244
|
-
}
|
|
245
|
-
$entry = findstr /r "$extension`:.*" $env:TEMP\map.orig
|
|
246
|
-
if($entry) {
|
|
247
|
-
$entry.split(':')[1].trim().split(' ') | ForEach-Object {
|
|
248
|
-
if (-not(php -m | findstr -i $_)) {
|
|
249
|
-
Enable-PhpExtension -Extension $_ -Path $php_dir
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
# Function to disable dependent extensions.
|
|
256
|
-
Function Disable-DependentExtensions() {
|
|
257
|
-
Param (
|
|
258
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
259
|
-
[ValidateNotNull()]
|
|
260
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
261
|
-
[string]
|
|
262
|
-
$extension
|
|
263
|
-
)
|
|
264
|
-
Get-ExtensionMap | Select-String -Pattern ".*:.*\s$extension(\s|$)" | ForEach-Object {
|
|
265
|
-
$dependent = $_.Matches[0].Value.split(':')[0];
|
|
266
|
-
Disable-ExtensionHelper -Extension $dependent -DisableDependents
|
|
267
|
-
Add-Log $tick ":$extension" "Disabled $dependent as it depends on $extension"
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
# Helper function to disable an extension.
|
|
272
|
-
Function Disable-ExtensionHelper() {
|
|
273
|
-
Param (
|
|
274
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
275
|
-
[ValidateNotNull()]
|
|
276
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
277
|
-
[string]
|
|
278
|
-
$extension,
|
|
279
|
-
[switch] $DisableDependents
|
|
280
|
-
)
|
|
281
|
-
if($DisableDependents) {
|
|
282
|
-
Disable-DependentExtensions $extension
|
|
283
|
-
}
|
|
284
|
-
Disable-PhpExtension -Extension $extension -Path $php_dir
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
# Function to disable an extension.
|
|
288
|
-
Function Disable-Extension() {
|
|
289
|
-
Param (
|
|
290
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
291
|
-
[ValidateNotNull()]
|
|
292
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
293
|
-
[string]
|
|
294
|
-
$extension,
|
|
295
|
-
[Parameter(Position = 1, Mandatory = $false)]
|
|
296
|
-
[ValidateNotNull()]
|
|
297
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
298
|
-
[string]
|
|
299
|
-
$DisableDependents
|
|
300
|
-
)
|
|
301
|
-
if(php -m | findstr -i $extension) {
|
|
302
|
-
if(Test-Path $ext_dir\php_$extension.dll) {
|
|
303
|
-
try {
|
|
304
|
-
$params = @{ Extension = $extension; DisableDependents = ($DisableDependents -ne 'false') }
|
|
305
|
-
Disable-ExtensionHelper @params
|
|
306
|
-
Add-Log $tick ":$extension" "Disabled"
|
|
307
|
-
} catch {
|
|
308
|
-
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion)"
|
|
309
|
-
}
|
|
310
|
-
} else {
|
|
311
|
-
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion) as it not a shared extension"
|
|
312
|
-
}
|
|
313
|
-
} elseif(Test-Path $ext_dir\php_$extension.dll) {
|
|
314
|
-
Add-Log $tick ":$extension" "Disabled"
|
|
315
|
-
} else {
|
|
316
|
-
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
# Function to disable shared extensions.
|
|
321
|
-
Function Disable-AllShared() {
|
|
322
|
-
(Get-Content $php_dir\php.ini) | Where-Object {$_ -notmatch '^(zend_)?extension\s*='} | Set-Content $php_dir\php.ini
|
|
323
|
-
Add-Log $tick "none" "Disabled all shared extensions"
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
# Function to configure composer.
|
|
327
|
-
Function Edit-ComposerConfig() {
|
|
328
|
-
Param(
|
|
329
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
330
|
-
[ValidateNotNull()]
|
|
331
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
332
|
-
[string]
|
|
333
|
-
$tool_path
|
|
334
|
-
)
|
|
335
|
-
Copy-Item $tool_path -Destination "$tool_path.phar"
|
|
336
|
-
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
|
|
337
|
-
if ($? -eq $False) {
|
|
338
|
-
Add-Log "$cross" "composer" "Could not download composer"
|
|
339
|
-
exit 1;
|
|
340
|
-
}
|
|
341
|
-
if (-not(Test-Path $composer_json)) {
|
|
342
|
-
Set-Content -Path $composer_json -Value "{}"
|
|
343
|
-
}
|
|
344
|
-
composer -q config -g process-timeout 0
|
|
345
|
-
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
|
346
|
-
if (Test-Path env:COMPOSER_TOKEN) {
|
|
347
|
-
composer -q config -g github-oauth.github.com $env:COMPOSER_TOKEN
|
|
192
|
+
Set-OpenSSLConf -Target User
|
|
193
|
+
} catch {
|
|
194
|
+
New-Item $php_dir\extras\openssl.cnf -Type File -Force > $null 2>&1
|
|
195
|
+
Set-OpenSSLConf -Path $php_dir\extras\openssl.cnf -Target User
|
|
348
196
|
}
|
|
197
|
+
Add-Env -EnvName OPENSSL_CONF -EnvValue $env:OPENSSL_CONF
|
|
349
198
|
}
|
|
350
199
|
|
|
351
|
-
# Function to
|
|
352
|
-
Function
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
$
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
|
368
|
-
return "$composer_version"
|
|
369
|
-
}
|
|
370
|
-
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
|
200
|
+
# Function to set PHP config.
|
|
201
|
+
Function Add-PhpConfig {
|
|
202
|
+
$current = Get-Content -Path $php_dir\php.ini-current -ErrorAction SilentlyContinue
|
|
203
|
+
if($ini -eq 'development' -or ($ini -eq 'production' -and $current -and $current -ne 'production')) {
|
|
204
|
+
Copy-Item -Path $php_dir\php.ini-$ini -Destination $php_dir\php.ini -Force
|
|
205
|
+
} elseif ($ini -eq 'none') {
|
|
206
|
+
Set-Content -Path $php_dir\php.ini -Value ''
|
|
207
|
+
}
|
|
208
|
+
Set-Content -Path $php_dir\php.ini-current -Value $ini
|
|
209
|
+
$ini_config_dir = "$src\configs\ini"
|
|
210
|
+
$ini_files = @("$ini_config_dir\php.ini")
|
|
211
|
+
$version -match $jit_versions -and ($ini_files += ("$ini_config_dir\jit.ini")) > $null 2>&1
|
|
212
|
+
$version -match $xdebug3_versions -and ($ini_files += ("$ini_config_dir\xdebug.ini")) > $null 2>&1
|
|
213
|
+
Add-Content -Path $ini_config_dir\php.ini -Value extension_dir=$ext_dir
|
|
214
|
+
Get-Content -Path $ini_files | Add-Content -Path $php_dir\php.ini
|
|
371
215
|
}
|
|
372
216
|
|
|
373
|
-
# Function to
|
|
374
|
-
Function
|
|
375
|
-
Param (
|
|
376
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
377
|
-
[ValidateNotNull()]
|
|
378
|
-
$url,
|
|
379
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
380
|
-
[ValidateNotNull()]
|
|
381
|
-
$tool,
|
|
382
|
-
[Parameter(Position = 2, Mandatory = $true)]
|
|
383
|
-
[ValidateNotNull()]
|
|
384
|
-
$ver_param
|
|
385
|
-
)
|
|
386
|
-
if (Test-Path $bin_dir\$tool) {
|
|
387
|
-
Remove-Item $bin_dir\$tool
|
|
388
|
-
}
|
|
389
|
-
if($url.Count -gt 1) {
|
|
390
|
-
$url = $url[0]
|
|
391
|
-
}
|
|
392
|
-
$tool_path = "$bin_dir\$tool"
|
|
393
|
-
if (($url | Split-Path -Extension) -eq ".exe") {
|
|
394
|
-
$tool_path = "$tool_path.exe"
|
|
395
|
-
}
|
|
217
|
+
# Function to get PHP from GitHub releases cache
|
|
218
|
+
Function Set-PhpCache {
|
|
396
219
|
try {
|
|
397
|
-
Invoke-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
Invoke-WebRequest -Uri $url -OutFile $tool_path
|
|
403
|
-
} catch { }
|
|
220
|
+
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
|
|
221
|
+
$asset = $release.assets | ForEach-Object {
|
|
222
|
+
if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
|
|
223
|
+
return $_.name
|
|
224
|
+
}
|
|
404
225
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
$bat_content += "@ECHO off"
|
|
409
|
-
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
|
410
|
-
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
|
411
|
-
$bat_content += "php %BIN_TARGET% %*"
|
|
412
|
-
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content
|
|
413
|
-
Add-ToolsHelper $tool
|
|
414
|
-
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1
|
|
415
|
-
$tool_version = Get-ToolVersion $tool $ver_param
|
|
416
|
-
Add-Log $tick $tool "Added $tool $tool_version"
|
|
417
|
-
} else {
|
|
418
|
-
Add-Log $cross $tool "Could not add $tool"
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
# Function to setup a tool using composer.
|
|
423
|
-
Function Add-Composertool() {
|
|
424
|
-
Param (
|
|
425
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
426
|
-
[ValidateNotNull()]
|
|
427
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
428
|
-
[string]
|
|
429
|
-
$tool,
|
|
430
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
431
|
-
[ValidateNotNull()]
|
|
432
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
433
|
-
[string]
|
|
434
|
-
$release,
|
|
435
|
-
[Parameter(Position = 2, Mandatory = $true)]
|
|
436
|
-
[ValidateNotNull()]
|
|
437
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
438
|
-
[string]
|
|
439
|
-
$prefix
|
|
440
|
-
)
|
|
441
|
-
if($tool -match "prestissimo|composer-prefetcher" -and $composer_version.split('.')[0] -ne "1") {
|
|
442
|
-
Write-Output "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
|
|
443
|
-
Add-Log $cross $tool "Skipped"
|
|
444
|
-
Return
|
|
445
|
-
}
|
|
446
|
-
if(Test-Path $composer_lock) {
|
|
447
|
-
Remove-Item -Path $composer_lock -Force
|
|
448
|
-
}
|
|
449
|
-
(composer global require $prefix$release 2>&1 | Tee-Object -FilePath $env:APPDATA\Composer\composer.log) >$null 2>&1
|
|
450
|
-
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
|
|
451
|
-
$log = findstr $prefix$tool $env:APPDATA\Composer\composer.log
|
|
452
|
-
if(Test-Path $composer_bin\composer) {
|
|
453
|
-
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
|
|
454
|
-
}
|
|
455
|
-
Add-ToolsHelper $tool
|
|
456
|
-
if($json) {
|
|
457
|
-
$tool_version = Get-ToolVersion "Write-Output" "$log"
|
|
458
|
-
Add-Log $tick $tool "Added $tool $tool_version"
|
|
459
|
-
} else {
|
|
460
|
-
Add-Log $cross $tool "Could not setup $tool"
|
|
461
|
-
}
|
|
226
|
+
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
|
|
227
|
+
Set-PhpDownloadCache -Path $php_dir CurrentUser
|
|
228
|
+
} catch { }
|
|
462
229
|
}
|
|
463
230
|
|
|
464
|
-
# Function to
|
|
465
|
-
Function
|
|
466
|
-
|
|
231
|
+
# Function to install nightly version of PHP
|
|
232
|
+
Function Install-PhpNightly {
|
|
233
|
+
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/latest/download/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
|
|
234
|
+
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
|
235
|
+
if(Test-Path $php_dir\COMMIT) {
|
|
236
|
+
return " ($( Get-Content $php_dir\COMMIT ))"
|
|
237
|
+
}
|
|
238
|
+
return;
|
|
467
239
|
}
|
|
468
240
|
|
|
469
241
|
# Variables
|
|
@@ -474,13 +246,11 @@ $ext_dir = "$php_dir\ext"
|
|
|
474
246
|
$bin_dir = $php_dir
|
|
475
247
|
$github = 'https://github.com'
|
|
476
248
|
$php_builder = "$github/shivammathur/php-builder-windows"
|
|
477
|
-
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
|
478
|
-
$composer_json = "$env:APPDATA\Composer\composer.json"
|
|
479
|
-
$composer_lock = "$env:APPDATA\Composer\composer.lock"
|
|
480
249
|
$current_profile = "$env:TEMP\setup-php.ps1"
|
|
481
250
|
$ProgressPreference = 'SilentlyContinue'
|
|
482
251
|
$jit_versions = '8.[0-9]'
|
|
483
|
-
$nightly_versions = '8.[
|
|
252
|
+
$nightly_versions = '8.[2-9]'
|
|
253
|
+
$xdebug3_versions = "7.[2-4]|8.[0-9]"
|
|
484
254
|
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
|
485
255
|
|
|
486
256
|
$arch = 'x64'
|
|
@@ -490,9 +260,24 @@ if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
|
|
490
260
|
|
|
491
261
|
$ts = $env:PHPTS -eq 'ts'
|
|
492
262
|
if($env:PHPTS -ne 'ts') {
|
|
493
|
-
$env:PHPTS = 'nts'
|
|
263
|
+
$env:PHPTS = '-nts'
|
|
264
|
+
} else {
|
|
265
|
+
$env:PHPTS = ''
|
|
494
266
|
}
|
|
495
|
-
|
|
267
|
+
|
|
268
|
+
if ( $env:GITHUB_ACTIONS -eq 'true') {
|
|
269
|
+
$env:GROUP = '::group::'
|
|
270
|
+
$env:END_GROUP = '::endgroup::'
|
|
271
|
+
} else {
|
|
272
|
+
$env:GROUP = ''
|
|
273
|
+
$env:END_GROUP = ''
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
|
|
277
|
+
if($env:RUNNER -eq 'github') {
|
|
278
|
+
Add-Log $cross "Runner" "Runner set as github in self-hosted environment"
|
|
279
|
+
exit 1
|
|
280
|
+
}
|
|
496
281
|
$bin_dir = 'C:\tools\bin'
|
|
497
282
|
$php_dir = "$php_dir$version"
|
|
498
283
|
$ext_dir = "$php_dir\ext"
|
|
@@ -504,7 +289,7 @@ if($env:RUNNER -eq 'self-hosted') {
|
|
|
504
289
|
Start-Sleep 1
|
|
505
290
|
exit 1
|
|
506
291
|
}
|
|
507
|
-
if ((Get-
|
|
292
|
+
if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) {
|
|
508
293
|
Install-Module -Name VcRedist -Force
|
|
509
294
|
}
|
|
510
295
|
New-Item $php_dir -Type Directory -Force > $null 2>&1
|
|
@@ -517,7 +302,9 @@ if($env:RUNNER -eq 'self-hosted') {
|
|
|
517
302
|
}
|
|
518
303
|
}
|
|
519
304
|
|
|
520
|
-
|
|
305
|
+
$src = Join-Path -Path $PSScriptRoot -ChildPath \..
|
|
306
|
+
. $src\scripts\tools\add_tools.ps1
|
|
307
|
+
. $src\scripts\extensions\add_extensions.ps1
|
|
521
308
|
|
|
522
309
|
Add-Printf >$null 2>&1
|
|
523
310
|
Step-Log "Setup PhpManager"
|
|
@@ -528,35 +315,38 @@ Step-Log "Setup PHP"
|
|
|
528
315
|
$installed = $null
|
|
529
316
|
if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|
530
317
|
try {
|
|
531
|
-
|
|
318
|
+
if(Test-Path $php_dir\php.ini) {
|
|
319
|
+
Rename-Item -Path $php_dir\php.ini -NewName 'php.ini.bak'
|
|
320
|
+
}
|
|
321
|
+
$installed = Get-Php -Path $php_dir -ErrorAction SilentlyContinue 2>$null 3>$null
|
|
322
|
+
if(Test-Path $php_dir\php.ini.bak) {
|
|
323
|
+
Rename-Item -Path $php_dir\php.ini.bak -NewName 'php.ini'
|
|
324
|
+
}
|
|
532
325
|
} catch { }
|
|
533
326
|
}
|
|
534
327
|
$status = "Installed"
|
|
535
328
|
$extra_version = ""
|
|
536
329
|
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
|
537
|
-
if ($version -lt '7.0' -and (Get-
|
|
330
|
+
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
|
|
538
331
|
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
|
539
332
|
}
|
|
540
333
|
try {
|
|
541
334
|
if ($version -match $nightly_versions) {
|
|
542
|
-
|
|
543
|
-
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
|
544
|
-
$extra_version = " ($(Get-Content $php_dir\COMMIT))"
|
|
335
|
+
$extra_version = Install-PhpNightly
|
|
545
336
|
} else {
|
|
546
|
-
|
|
337
|
+
Set-PhpCache
|
|
338
|
+
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni production -Force > $null 2>&1
|
|
547
339
|
}
|
|
340
|
+
Add-PhpConfig
|
|
548
341
|
} catch { }
|
|
549
342
|
} else {
|
|
550
|
-
Set-PhpIniKey -Key 'extension_dir' -Value $ext_dir -Path $php_dir
|
|
551
|
-
if($version -match $jit_versions) {
|
|
552
|
-
('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 }
|
|
553
|
-
}
|
|
554
343
|
if($env:update -eq 'true') {
|
|
555
344
|
Update-Php $php_dir >$null 2>&1
|
|
556
345
|
$status = "Updated to"
|
|
557
346
|
} else {
|
|
558
347
|
$status = "Found"
|
|
559
348
|
}
|
|
349
|
+
Add-PhpConfig
|
|
560
350
|
}
|
|
561
351
|
|
|
562
352
|
$installed = Get-Php -Path $php_dir
|
|
@@ -564,15 +354,14 @@ if($installed.MajorMinorVersion -ne $version) {
|
|
|
564
354
|
Add-Log $cross "PHP" "Could not setup PHP $version"
|
|
565
355
|
exit 1
|
|
566
356
|
}
|
|
567
|
-
('date.timezone=UTC', 'memory_limit=-1', 'xdebug.mode=coverage') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
568
357
|
if($version -lt "5.5") {
|
|
569
|
-
('libeay32.dll', 'ssleay32.dll') | ForEach-Object { Invoke-WebRequest -Uri "$php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $php_dir\$_ >$null 2>&1 }
|
|
358
|
+
('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Invoke-WebRequest -Uri "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ >$null 2>&1 }
|
|
570
359
|
} else {
|
|
571
360
|
$enable_extensions += ('opcache')
|
|
572
361
|
}
|
|
573
362
|
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
|
574
363
|
Add-PhpCAInfo
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
364
|
+
Add-OpenSSLConf
|
|
365
|
+
Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
|
366
|
+
Set-Output php-version $($installed.FullVersion)
|
|
578
367
|
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|