setup-php 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -141
- package/lib/config.d.ts +3 -0
- package/lib/config.js +72 -0
- package/lib/config.js.map +1 -0
- package/lib/coverage.d.ts +5 -0
- package/lib/coverage.js +98 -0
- package/lib/coverage.js.map +1 -0
- package/lib/extensions.d.ts +4 -0
- package/lib/extensions.js +215 -0
- package/lib/extensions.js.map +1 -0
- package/lib/fetch.d.ts +1 -0
- package/lib/fetch.js +63 -0
- package/lib/fetch.js.map +1 -0
- package/lib/install.d.ts +2 -0
- package/lib/install.js +76 -0
- package/lib/install.js.map +1 -0
- package/lib/tools.d.ts +23 -0
- package/lib/tools.js +368 -0
- package/lib/tools.js.map +1 -0
- package/lib/utils.d.ts +21 -0
- package/lib/utils.js +262 -0
- package/lib/utils.js.map +1 -0
- package/package.json +18 -17
- 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 +23 -19
- package/src/fetch.ts +54 -0
- package/src/install.ts +27 -40
- package/src/scripts/darwin.sh +58 -30
- 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 +63 -33
- 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 +14 -0
- package/src/scripts/tools/symfony.sh +13 -0
- package/src/scripts/unix.sh +186 -0
- package/src/scripts/win32.ps1 +126 -340
- package/src/tools.ts +56 -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,45 @@ Function Add-Path {
|
|
|
64
83
|
param(
|
|
65
84
|
[string]$PathItem
|
|
66
85
|
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
86
|
+
if(-not(Test-Path $PathItem) -or "$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
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Function to add environment variables using a PATH.
|
|
113
|
+
Function Add-EnvPATH {
|
|
114
|
+
param(
|
|
115
|
+
[string]$EnvPATH
|
|
116
|
+
)
|
|
117
|
+
if(-not(Test-Path $EnvPATH)) {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
$env_file = $current_profile
|
|
121
|
+
if ($env:GITHUB_ENV) {
|
|
122
|
+
$env_file = $env:GITHUB_ENV
|
|
123
|
+
}
|
|
124
|
+
Get-Content -Path $EnvPATH | Add-Content -Path $env_file -Encoding utf8
|
|
71
125
|
}
|
|
72
126
|
|
|
73
127
|
# Function to make sure printf is in PATH.
|
|
@@ -112,32 +166,10 @@ Function Install-PSPackage() {
|
|
|
112
166
|
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
|
|
113
167
|
}
|
|
114
168
|
Import-Module $module_path
|
|
115
|
-
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
116
|
-
|
|
117
169
|
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
|
-
}
|
|
170
|
+
Install-Module -Name $package -Force
|
|
139
171
|
} else {
|
|
140
|
-
|
|
172
|
+
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
141
173
|
}
|
|
142
174
|
}
|
|
143
175
|
|
|
@@ -151,299 +183,45 @@ Function Add-PhpCAInfo {
|
|
|
151
183
|
}
|
|
152
184
|
}
|
|
153
185
|
|
|
154
|
-
# Function to
|
|
155
|
-
Function Add-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
|
186
|
+
# Function to set PHP config.
|
|
187
|
+
Function Add-PhpConfig {
|
|
188
|
+
$current = Get-Content -Path $php_dir\php.ini-current -ErrorAction SilentlyContinue
|
|
189
|
+
if($ini -eq 'development' -or ($ini -eq 'production' -and $current -and $current -ne 'production')) {
|
|
190
|
+
Copy-Item -Path $php_dir\php.ini-$ini -Destination $php_dir\php.ini -Force
|
|
191
|
+
} elseif ($ini -eq 'none') {
|
|
192
|
+
Set-Content -Path $php_dir\php.ini -Value ''
|
|
193
|
+
}
|
|
194
|
+
Set-Content -Path $php_dir\php.ini-current -Value $ini
|
|
195
|
+
$ini_config_dir = "$src\configs\ini"
|
|
196
|
+
$ini_files = @("$ini_config_dir\php.ini")
|
|
197
|
+
$version -match $jit_versions -and ($ini_files += ("$ini_config_dir\jit.ini")) > $null 2>&1
|
|
198
|
+
$version -match $xdebug3_versions -and ($ini_files += ("$ini_config_dir\xdebug.ini")) > $null 2>&1
|
|
199
|
+
Add-Content -Path $ini_config_dir\php.ini -Value extension_dir=$ext_dir
|
|
200
|
+
Get-Content -Path $ini_files | Add-Content -Path $php_dir\php.ini
|
|
211
201
|
}
|
|
212
202
|
|
|
213
|
-
# Function to
|
|
214
|
-
Function
|
|
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
|
-
}
|
|
203
|
+
# Function to get PHP from GitHub releases cache
|
|
204
|
+
Function Set-PhpCache {
|
|
376
205
|
try {
|
|
377
|
-
Invoke-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
Invoke-WebRequest -Uri $url -OutFile $tool_path
|
|
383
|
-
} catch { }
|
|
206
|
+
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
|
|
207
|
+
$asset = $release.assets | ForEach-Object {
|
|
208
|
+
if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
|
|
209
|
+
return $_.name
|
|
210
|
+
}
|
|
384
211
|
}
|
|
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
|
-
}
|
|
212
|
+
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
|
|
213
|
+
Set-PhpDownloadCache -Path $php_dir CurrentUser
|
|
214
|
+
} catch { }
|
|
442
215
|
}
|
|
443
216
|
|
|
444
|
-
# Function to
|
|
445
|
-
Function
|
|
446
|
-
|
|
217
|
+
# Function to install nightly version of PHP
|
|
218
|
+
Function Install-PhpNightly {
|
|
219
|
+
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/latest/download/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
|
|
220
|
+
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
|
221
|
+
if(Test-Path $php_dir\COMMIT) {
|
|
222
|
+
return " ($( Get-Content $php_dir\COMMIT ))"
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
447
225
|
}
|
|
448
226
|
|
|
449
227
|
# Variables
|
|
@@ -454,13 +232,11 @@ $ext_dir = "$php_dir\ext"
|
|
|
454
232
|
$bin_dir = $php_dir
|
|
455
233
|
$github = 'https://github.com'
|
|
456
234
|
$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
235
|
$current_profile = "$env:TEMP\setup-php.ps1"
|
|
461
236
|
$ProgressPreference = 'SilentlyContinue'
|
|
462
237
|
$jit_versions = '8.[0-9]'
|
|
463
|
-
$nightly_versions = '8.[
|
|
238
|
+
$nightly_versions = '8.[2-9]'
|
|
239
|
+
$xdebug3_versions = "7.[2-4]|8.[0-9]"
|
|
464
240
|
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
|
465
241
|
|
|
466
242
|
$arch = 'x64'
|
|
@@ -470,9 +246,24 @@ if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
|
|
470
246
|
|
|
471
247
|
$ts = $env:PHPTS -eq 'ts'
|
|
472
248
|
if($env:PHPTS -ne 'ts') {
|
|
473
|
-
$env:PHPTS = 'nts'
|
|
249
|
+
$env:PHPTS = '-nts'
|
|
250
|
+
} else {
|
|
251
|
+
$env:PHPTS = ''
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if ( $env:GITHUB_ACTIONS -eq 'true') {
|
|
255
|
+
$env:GROUP = '::group::'
|
|
256
|
+
$env:END_GROUP = '::endgroup::'
|
|
257
|
+
} else {
|
|
258
|
+
$env:GROUP = ''
|
|
259
|
+
$env:END_GROUP = ''
|
|
474
260
|
}
|
|
475
|
-
|
|
261
|
+
|
|
262
|
+
if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
|
|
263
|
+
if($env:RUNNER -eq 'github') {
|
|
264
|
+
Add-Log $cross "Runner" "Runner set as github in self-hosted environment"
|
|
265
|
+
exit 1
|
|
266
|
+
}
|
|
476
267
|
$bin_dir = 'C:\tools\bin'
|
|
477
268
|
$php_dir = "$php_dir$version"
|
|
478
269
|
$ext_dir = "$php_dir\ext"
|
|
@@ -484,7 +275,7 @@ if($env:RUNNER -eq 'self-hosted') {
|
|
|
484
275
|
Start-Sleep 1
|
|
485
276
|
exit 1
|
|
486
277
|
}
|
|
487
|
-
if ((Get-
|
|
278
|
+
if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) {
|
|
488
279
|
Install-Module -Name VcRedist -Force
|
|
489
280
|
}
|
|
490
281
|
New-Item $php_dir -Type Directory -Force > $null 2>&1
|
|
@@ -497,7 +288,9 @@ if($env:RUNNER -eq 'self-hosted') {
|
|
|
497
288
|
}
|
|
498
289
|
}
|
|
499
290
|
|
|
500
|
-
|
|
291
|
+
$src = Join-Path -Path $PSScriptRoot -ChildPath \..
|
|
292
|
+
. $src\scripts\tools\add_tools.ps1
|
|
293
|
+
. $src\scripts\extensions\add_extensions.ps1
|
|
501
294
|
|
|
502
295
|
Add-Printf >$null 2>&1
|
|
503
296
|
Step-Log "Setup PhpManager"
|
|
@@ -520,31 +313,26 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|
|
520
313
|
$status = "Installed"
|
|
521
314
|
$extra_version = ""
|
|
522
315
|
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-
|
|
316
|
+
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
|
|
524
317
|
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
|
525
318
|
}
|
|
526
319
|
try {
|
|
527
320
|
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
|
-
}
|
|
321
|
+
$extra_version = Install-PhpNightly
|
|
533
322
|
} else {
|
|
534
|
-
|
|
323
|
+
Set-PhpCache
|
|
324
|
+
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni production -Force > $null 2>&1
|
|
535
325
|
}
|
|
326
|
+
Add-PhpConfig
|
|
536
327
|
} catch { }
|
|
537
328
|
} 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
329
|
if($env:update -eq 'true') {
|
|
543
330
|
Update-Php $php_dir >$null 2>&1
|
|
544
331
|
$status = "Updated to"
|
|
545
332
|
} else {
|
|
546
333
|
$status = "Found"
|
|
547
334
|
}
|
|
335
|
+
Add-PhpConfig
|
|
548
336
|
}
|
|
549
337
|
|
|
550
338
|
$installed = Get-Php -Path $php_dir
|
|
@@ -552,15 +340,13 @@ if($installed.MajorMinorVersion -ne $version) {
|
|
|
552
340
|
Add-Log $cross "PHP" "Could not setup PHP $version"
|
|
553
341
|
exit 1
|
|
554
342
|
}
|
|
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
343
|
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 }
|
|
344
|
+
('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
345
|
} else {
|
|
559
346
|
$enable_extensions += ('opcache')
|
|
560
347
|
}
|
|
561
348
|
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
|
562
349
|
Add-PhpCAInfo
|
|
563
|
-
Copy-Item -Path $
|
|
564
|
-
|
|
565
|
-
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
|
|
350
|
+
Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
|
351
|
+
Set-Output php-version $($installed.FullVersion)
|
|
566
352
|
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|