setup-php 2.16.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -141
- package/lib/config.d.ts +3 -0
- package/lib/config.js +76 -0
- package/lib/config.js.map +1 -0
- package/lib/coverage.d.ts +5 -0
- package/lib/coverage.js +102 -0
- package/lib/coverage.js.map +1 -0
- package/lib/extensions.d.ts +4 -0
- package/lib/extensions.js +219 -0
- package/lib/extensions.js.map +1 -0
- package/lib/fetch.d.ts +1 -0
- package/lib/fetch.js +67 -0
- package/lib/fetch.js.map +1 -0
- package/lib/install.d.ts +2 -0
- package/lib/install.js +80 -0
- package/lib/install.js.map +1 -0
- package/lib/tools.d.ts +23 -0
- package/lib/tools.js +378 -0
- package/lib/tools.js.map +1 -0
- package/lib/utils.d.ts +21 -0
- package/lib/utils.js +266 -0
- package/lib/utils.js.map +1 -0
- package/package.json +21 -20
- package/src/config.ts +8 -8
- package/src/configs/brew_extensions +1 -0
- package/src/configs/composer.env +2 -0
- package/src/configs/ini/jit.ini +3 -0
- package/src/configs/ini/php.ini +2 -0
- package/src/configs/ini/xdebug.ini +1 -0
- package/src/configs/os_releases.csv +2 -0
- package/src/configs/php_packages +12 -0
- package/src/configs/tools.json +48 -26
- package/src/configs/tools_schema.json +11 -0
- package/src/coverage.ts +24 -49
- package/src/extensions.ts +28 -24
- package/src/fetch.ts +54 -0
- package/src/install.ts +28 -41
- package/src/scripts/darwin.sh +81 -33
- package/src/scripts/extensions/add_extensions.ps1 +194 -0
- package/src/scripts/extensions/add_extensions.sh +198 -0
- package/src/scripts/{ext → extensions}/blackfire.ps1 +0 -0
- package/src/scripts/{ext → extensions}/blackfire.sh +0 -0
- package/src/scripts/{ext → extensions}/couchbase.sh +0 -0
- package/src/scripts/{ext → extensions}/cubrid.sh +3 -3
- package/src/scripts/{ext → extensions}/extension_map.php +36 -13
- package/src/scripts/{ext → extensions}/firebird.ps1 +0 -0
- package/src/scripts/{ext → extensions}/firebird.sh +0 -0
- package/src/scripts/{ext → extensions}/gearman.sh +0 -0
- package/src/scripts/{ext → extensions}/geos.sh +0 -0
- package/src/scripts/{ext → extensions}/http.ps1 +1 -0
- package/src/scripts/{ext → extensions}/http.sh +13 -20
- package/src/scripts/{ext → extensions}/intl.sh +0 -0
- package/src/scripts/{ext → extensions}/ioncube.ps1 +2 -2
- package/src/scripts/{ext → extensions}/ioncube.sh +2 -2
- package/src/scripts/{ext → extensions}/oci.ps1 +39 -14
- package/src/scripts/{ext → extensions}/oci.sh +3 -3
- package/src/scripts/{ext → extensions}/patches/firebird.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/geos.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/http.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/pdo_oci.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/phpize.sh +0 -0
- package/src/scripts/{ext → extensions}/patches/protobuf.sh +0 -0
- package/src/scripts/{ext → extensions}/phalcon.ps1 +0 -0
- package/src/scripts/{ext → extensions}/phalcon.sh +4 -5
- package/src/scripts/{ext → extensions}/source.sh +36 -22
- package/src/scripts/extensions/sqlsrv.sh +15 -0
- package/src/scripts/linux.sh +76 -36
- package/src/scripts/tools/add_tools.ps1 +220 -10
- package/src/scripts/tools/add_tools.sh +164 -17
- package/src/scripts/tools/grpc_php_plugin.ps1 +4 -4
- package/src/scripts/tools/grpc_php_plugin.sh +3 -3
- package/src/scripts/tools/ppa.sh +12 -9
- package/src/scripts/tools/protoc.ps1 +2 -2
- package/src/scripts/tools/protoc.sh +2 -2
- package/src/scripts/tools/symfony.ps1 +18 -0
- package/src/scripts/tools/symfony.sh +18 -0
- package/src/scripts/unix.sh +186 -0
- package/src/scripts/win32.ps1 +137 -336
- package/src/tools.ts +62 -82
- package/src/utils.ts +57 -145
- package/src/scripts/common.sh +0 -366
package/src/scripts/win32.ps1
CHANGED
|
@@ -8,7 +8,7 @@ param (
|
|
|
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,32 +169,10 @@ 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
|
|
|
@@ -151,299 +186,56 @@ Function Add-PhpCAInfo {
|
|
|
151
186
|
}
|
|
152
187
|
}
|
|
153
188
|
|
|
154
|
-
# Function to
|
|
155
|
-
Function Add-
|
|
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
|
-
)
|
|
189
|
+
# Function to set OpenSSL config.
|
|
190
|
+
Function Add-OpenSSLConf {
|
|
173
191
|
try {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
New-Item $
|
|
177
|
-
|
|
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
|
|
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
|
|
328
196
|
}
|
|
197
|
+
Add-Env -EnvName OPENSSL_CONF -EnvValue $env:OPENSSL_CONF
|
|
329
198
|
}
|
|
330
199
|
|
|
331
|
-
# Function to
|
|
332
|
-
Function
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
$
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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 }
|
|
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
|
|
351
215
|
}
|
|
352
216
|
|
|
353
|
-
# Function to
|
|
354
|
-
Function
|
|
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
|
-
}
|
|
217
|
+
# Function to get PHP from GitHub releases cache
|
|
218
|
+
Function Set-PhpCache {
|
|
376
219
|
try {
|
|
377
|
-
Invoke-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
Invoke-WebRequest -Uri $url -OutFile $tool_path
|
|
383
|
-
} 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
|
+
}
|
|
384
225
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
}
|
|
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 { }
|
|
442
229
|
}
|
|
443
230
|
|
|
444
|
-
# Function to
|
|
445
|
-
Function
|
|
446
|
-
|
|
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;
|
|
447
239
|
}
|
|
448
240
|
|
|
449
241
|
# Variables
|
|
@@ -454,13 +246,11 @@ $ext_dir = "$php_dir\ext"
|
|
|
454
246
|
$bin_dir = $php_dir
|
|
455
247
|
$github = 'https://github.com'
|
|
456
248
|
$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
249
|
$current_profile = "$env:TEMP\setup-php.ps1"
|
|
461
250
|
$ProgressPreference = 'SilentlyContinue'
|
|
462
251
|
$jit_versions = '8.[0-9]'
|
|
463
|
-
$nightly_versions = '8.[
|
|
252
|
+
$nightly_versions = '8.[2-9]'
|
|
253
|
+
$xdebug3_versions = "7.[2-4]|8.[0-9]"
|
|
464
254
|
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
|
465
255
|
|
|
466
256
|
$arch = 'x64'
|
|
@@ -470,9 +260,24 @@ if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
|
|
470
260
|
|
|
471
261
|
$ts = $env:PHPTS -eq 'ts'
|
|
472
262
|
if($env:PHPTS -ne 'ts') {
|
|
473
|
-
$env:PHPTS = 'nts'
|
|
263
|
+
$env:PHPTS = '-nts'
|
|
264
|
+
} else {
|
|
265
|
+
$env:PHPTS = ''
|
|
266
|
+
}
|
|
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 = ''
|
|
474
274
|
}
|
|
475
|
-
|
|
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
|
+
}
|
|
476
281
|
$bin_dir = 'C:\tools\bin'
|
|
477
282
|
$php_dir = "$php_dir$version"
|
|
478
283
|
$ext_dir = "$php_dir\ext"
|
|
@@ -484,7 +289,7 @@ if($env:RUNNER -eq 'self-hosted') {
|
|
|
484
289
|
Start-Sleep 1
|
|
485
290
|
exit 1
|
|
486
291
|
}
|
|
487
|
-
if ((Get-
|
|
292
|
+
if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) {
|
|
488
293
|
Install-Module -Name VcRedist -Force
|
|
489
294
|
}
|
|
490
295
|
New-Item $php_dir -Type Directory -Force > $null 2>&1
|
|
@@ -497,7 +302,9 @@ if($env:RUNNER -eq 'self-hosted') {
|
|
|
497
302
|
}
|
|
498
303
|
}
|
|
499
304
|
|
|
500
|
-
|
|
305
|
+
$src = Join-Path -Path $PSScriptRoot -ChildPath \..
|
|
306
|
+
. $src\scripts\tools\add_tools.ps1
|
|
307
|
+
. $src\scripts\extensions\add_extensions.ps1
|
|
501
308
|
|
|
502
309
|
Add-Printf >$null 2>&1
|
|
503
310
|
Step-Log "Setup PhpManager"
|
|
@@ -520,31 +327,26 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|
|
520
327
|
$status = "Installed"
|
|
521
328
|
$extra_version = ""
|
|
522
329
|
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-
|
|
330
|
+
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
|
|
524
331
|
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
|
525
332
|
}
|
|
526
333
|
try {
|
|
527
334
|
if ($version -match $nightly_versions) {
|
|
528
|
-
|
|
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
|
-
}
|
|
335
|
+
$extra_version = Install-PhpNightly
|
|
533
336
|
} else {
|
|
534
|
-
|
|
337
|
+
Set-PhpCache
|
|
338
|
+
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni production -Force > $null 2>&1
|
|
535
339
|
}
|
|
340
|
+
Add-PhpConfig
|
|
536
341
|
} catch { }
|
|
537
342
|
} 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
343
|
if($env:update -eq 'true') {
|
|
543
344
|
Update-Php $php_dir >$null 2>&1
|
|
544
345
|
$status = "Updated to"
|
|
545
346
|
} else {
|
|
546
347
|
$status = "Found"
|
|
547
348
|
}
|
|
349
|
+
Add-PhpConfig
|
|
548
350
|
}
|
|
549
351
|
|
|
550
352
|
$installed = Get-Php -Path $php_dir
|
|
@@ -552,15 +354,14 @@ if($installed.MajorMinorVersion -ne $version) {
|
|
|
552
354
|
Add-Log $cross "PHP" "Could not setup PHP $version"
|
|
553
355
|
exit 1
|
|
554
356
|
}
|
|
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
357
|
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 }
|
|
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 }
|
|
558
359
|
} else {
|
|
559
360
|
$enable_extensions += ('opcache')
|
|
560
361
|
}
|
|
561
362
|
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
|
562
363
|
Add-PhpCAInfo
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
364
|
+
Add-OpenSSLConf
|
|
365
|
+
Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
|
366
|
+
Set-Output php-version $($installed.FullVersion)
|
|
566
367
|
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|