setup-php 2.23.0 → 2.25.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.
Files changed (42) hide show
  1. package/README.md +22 -16
  2. package/lib/coverage.js +11 -7
  3. package/lib/coverage.js.map +1 -1
  4. package/lib/extensions.js +6 -1
  5. package/lib/extensions.js.map +1 -1
  6. package/lib/install.js +1 -1
  7. package/lib/install.js.map +1 -1
  8. package/lib/tools.js +8 -4
  9. package/lib/tools.js.map +1 -1
  10. package/lib/utils.d.ts +1 -0
  11. package/lib/utils.js +27 -4
  12. package/lib/utils.js.map +1 -1
  13. package/package.json +17 -17
  14. package/src/configs/brew_extensions +2 -0
  15. package/src/configs/mod_priority +27 -0
  16. package/src/coverage.ts +12 -16
  17. package/src/extensions.ts +17 -1
  18. package/src/install.ts +1 -1
  19. package/src/scripts/extensions/add_extensions.ps1 +18 -1
  20. package/src/scripts/extensions/add_extensions.sh +13 -2
  21. package/src/scripts/extensions/blackfire.ps1 +1 -1
  22. package/src/scripts/extensions/couchbase.sh +0 -6
  23. package/src/scripts/extensions/firebird.ps1 +1 -1
  24. package/src/scripts/extensions/http.ps1 +3 -8
  25. package/src/scripts/extensions/ioncube.ps1 +1 -1
  26. package/src/scripts/extensions/oci.ps1 +2 -2
  27. package/src/scripts/extensions/phalcon.ps1 +3 -3
  28. package/src/scripts/extensions/relay.sh +146 -0
  29. package/src/scripts/extensions/source.sh +1 -1
  30. package/src/scripts/extensions/zephir_parser.ps1 +80 -0
  31. package/src/scripts/extensions/zephir_parser.sh +38 -0
  32. package/src/scripts/linux.sh +8 -3
  33. package/src/scripts/tools/add_tools.ps1 +5 -5
  34. package/src/scripts/tools/add_tools.sh +3 -3
  35. package/src/scripts/tools/blackfire.ps1 +1 -1
  36. package/src/scripts/tools/grpc_php_plugin.ps1 +1 -1
  37. package/src/scripts/tools/protoc.ps1 +3 -3
  38. package/src/scripts/tools/symfony.ps1 +1 -1
  39. package/src/scripts/unix.sh +2 -1
  40. package/src/scripts/win32.ps1 +52 -14
  41. package/src/tools.ts +7 -6
  42. package/src/utils.ts +32 -5
package/src/coverage.ts CHANGED
@@ -16,7 +16,7 @@ export async function checkXdebugError(
16
16
  }
17
17
 
18
18
  /**
19
- * Function to setup Xdebug
19
+ * Function to set up Xdebug
20
20
  *
21
21
  * @param extension
22
22
  * @param version
@@ -30,9 +30,8 @@ export async function addCoverageXdebug(
30
30
  pipe: string
31
31
  ): Promise<string> {
32
32
  let script = '\n';
33
- let message: string = await checkXdebugError(extension, version);
34
- let status = '$cross';
35
- if (!message) {
33
+ const error: string = await checkXdebugError(extension, version);
34
+ if (!error) {
36
35
  script +=
37
36
  (await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
38
37
  extension = extension == 'xdebug3' ? 'xdebug' : extension;
@@ -43,15 +42,17 @@ export async function addCoverageXdebug(
43
42
  'php -r "echo phpversion(\'xdebug\');"',
44
43
  os
45
44
  );
46
- message = 'Xdebug $xdebug_version enabled as coverage driver';
47
- status = '$tick';
45
+ script +=
46
+ (await utils.getCommand(os, 'extension_log')) +
47
+ 'xdebug "Xdebug $xdebug_version enabled as coverage driver"';
48
+ } else {
49
+ script += await utils.addLog('$cross', extension, error, os);
48
50
  }
49
- script += await utils.addLog(status, extension, message, os);
50
51
  return script;
51
52
  }
52
53
 
53
54
  /**
54
- * Function to setup PCOV
55
+ * Function to set up PCOV
55
56
  *
56
57
  * @param version
57
58
  * @param os
@@ -76,14 +77,9 @@ export async function addCoveragePCOV(
76
77
  'php -r "echo phpversion(\'pcov\');"',
77
78
  os
78
79
  );
79
- // success
80
- script += await utils.addLog(
81
- '$tick',
82
- 'coverage: pcov',
83
- 'PCOV $pcov_version enabled as coverage driver',
84
- os
85
- );
86
- // version is not supported
80
+ script +=
81
+ (await utils.getCommand(os, 'extension_log')) +
82
+ 'pcov "PCOV $pcov_version enabled as coverage driver"';
87
83
  break;
88
84
 
89
85
  case /5\.[3-6]|7\.0/.test(version):
package/src/extensions.ts CHANGED
@@ -31,11 +31,14 @@ export async function addExtensionDarwin(
31
31
  case /.+-.+\/.+@.+/.test(extension):
32
32
  add_script += await utils.parseExtensionSource(extension, ext_prefix);
33
33
  return;
34
+ // match 7.4relay...8.3relay
34
35
  // match 5.3blackfire...8.2blackfire
35
36
  // match 5.3blackfire-(semver)...8.1blackfire-(semver)
36
37
  // match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
37
38
  // match 5.3ioncube...7.4ioncube
38
39
  // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
40
+ // match 7.0zephir_parser...8.2zephir_parser
41
+ case /^(7\.4|8\.[0-3])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
39
42
  case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
40
43
  version_extension
41
44
  ):
@@ -47,6 +50,9 @@ export async function addExtensionDarwin(
47
50
  version_extension
48
51
  ):
49
52
  case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
53
+ case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
54
+ version_extension
55
+ ):
50
56
  add_script += await utils.customPackage(
51
57
  ext_name,
52
58
  'extensions',
@@ -77,7 +83,7 @@ export async function addExtensionDarwin(
77
83
  add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
78
84
  return;
79
85
  // match brew extensions
80
- case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test(
86
+ case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|snmp|ssh2|swoole|uuid|xdebug|xdebug2|yaml|zmq)/.test(
81
87
  version_extension
82
88
  ):
83
89
  case /(?<!5\.[3-6])(ds|v8js)/.test(version_extension):
@@ -134,6 +140,7 @@ export async function addExtensionWindows(
134
140
  // match 5.3ioncube...7.4ioncube
135
141
  // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
136
142
  // match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
143
+ // match 7.0zephir_parser...8.2zephir_parser
137
144
  case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
138
145
  version_extension
139
146
  ):
@@ -143,6 +150,9 @@ export async function addExtensionWindows(
143
150
  version_extension
144
151
  ):
145
152
  case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
153
+ case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
154
+ version_extension
155
+ ):
146
156
  add_script += await utils.customPackage(
147
157
  ext_name,
148
158
  'extensions',
@@ -252,12 +262,15 @@ export async function addExtensionLinux(
252
262
  case /.+-.+\/.+@.+/.test(extension):
253
263
  add_script += await utils.parseExtensionSource(extension, ext_prefix);
254
264
  return;
265
+ // match 7.4relay...8.3relay
255
266
  // match 5.3blackfire...8.2blackfire
256
267
  // match 5.3blackfire-(semver)...8.1blackfire-(semver)
257
268
  // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
258
269
  // match couchbase, geos, pdo_oci, oci8, http, pecl_http
259
270
  // match 5.3ioncube...7.4ioncube
260
271
  // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.2phalcon5
272
+ // match 7.0zephir_parser...8.2zephir_parser
273
+ case /^(7\.4|8\.[0-3])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
261
274
  case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
262
275
  version_extension
263
276
  ):
@@ -273,6 +286,9 @@ export async function addExtensionLinux(
273
286
  version_extension
274
287
  ):
275
288
  case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
289
+ case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
290
+ version_extension
291
+ ):
276
292
  add_script += await utils.customPackage(
277
293
  ext_name,
278
294
  'extensions',
package/src/install.ts CHANGED
@@ -24,7 +24,7 @@ export async function getScript(os: string): Promise<string> {
24
24
  const coverage_driver: string = await utils.getInput('coverage', false);
25
25
  const tools_csv: string = await utils.getInput('tools', false);
26
26
  const version: string = await utils.parseVersion(
27
- await utils.getInput('php-version', true)
27
+ await utils.readPHPVersion()
28
28
  );
29
29
  const ini_file: string = await utils.parseIniFile(
30
30
  await utils.getInput('ini-file', false)
@@ -1,3 +1,20 @@
1
+ Function Add-ExtensionLog() {
2
+ Param (
3
+ [Parameter(Position = 0, Mandatory = $true)]
4
+ [ValidateNotNull()]
5
+ $extension,
6
+ [Parameter(Position = 1, Mandatory = $true)]
7
+ [ValidateNotNull()]
8
+ $message
9
+ )
10
+ $extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
11
+ if ($null -ne $extension_info -and ($extension_info.State -eq 'Enabled' -or $extension_info.State -eq 'Builtin')) {
12
+ Add-Log $tick $extension $message
13
+ } else {
14
+ Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
15
+ }
16
+ }
17
+
1
18
  # Function to link dependencies to PHP directory.
2
19
  Function Set-ExtensionPrerequisites
3
20
  {
@@ -48,7 +65,7 @@ Function Add-NightlyExtension {
48
65
  if($ts) { $ts_part = 'ts' } else { $ts_part = 'nts' }
49
66
  $repo = "$github/shivammathur/php-extensions-windows"
50
67
  $url = "$repo/releases/download/builds/php$version`_$ts_part`_$arch`_$extension.dll"
51
- Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile "$ext_dir\php_$extension.dll"
68
+ Get-File -Url $url -OutFile "$ext_dir\php_$extension.dll"
52
69
  if(Test-Path "$ext_dir\php_$extension.dll") {
53
70
  Enable-Extension $extension > $null
54
71
  } else {
@@ -48,7 +48,18 @@ enable_extension() {
48
48
  [ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
49
49
  enable_extension_dependencies "$1" "$2"
50
50
  enable_cache_extension_dependencies "$1" "$2"
51
- echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
51
+ if ! [[ "${version:?}" =~ ${old_versions:?} ]] && command -v phpenmod >/dev/null 2>&1; then
52
+ mod="${ini_dir:?}"/../mods-available/"$1".ini
53
+ if ! [ -e "$mod" ]; then
54
+ priority="${3:-20}";
55
+ mod_priority_line="$(grep -E "^$1=" "${src:?}/configs/mod_priority")";
56
+ [ -n "$mod_priority_line" ] && priority=$(echo "$mod_priority_line" | cut -d'=' -f 2)
57
+ (echo "; priority=$priority"; echo "$2=${ext_dir:?}/$1.so") | sudo tee "$mod" >/dev/null
58
+ fi
59
+ sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
60
+ else
61
+ echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
62
+ fi
52
63
  fi
53
64
  }
54
65
 
@@ -114,7 +125,7 @@ disable_all_shared() {
114
125
  sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
115
126
  mkdir -p /tmp/extdisabled/"$version"
116
127
  sudo rm -f /tmp/php"$version"_extensions
117
- sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -n 1 -I{} touch /tmp/extdisabled/"$version"/{}
128
+ sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -I{} touch /tmp/extdisabled/"$version"/{}
118
129
  add_log "${tick:?}" "none" "Disabled all shared extensions"
119
130
  }
120
131
 
@@ -21,7 +21,7 @@ Function Add-Blackfire() {
21
21
  $status="Enabled"
22
22
  } else {
23
23
  $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
24
- Invoke-WebRequest -Uri "https://packages.blackfire.io/binaries/blackfire-php/${extension_version}/blackfire-php-windows_${arch}-php-${no_dot_version}${nts}.dll" -OutFile $ext_dir\blackfire.dll > $null 2>&1
24
+ Get-File -Url "https://packages.blackfire.io/binaries/blackfire-php/${extension_version}/blackfire-php-windows_${arch}-php-${no_dot_version}${nts}.dll" -OutFile $ext_dir\blackfire.dll > $null 2>&1
25
25
  Enable-PhpExtension -Extension blackfire -Path $php_dir
26
26
  $status="Installed and enabled"
27
27
  }
@@ -17,12 +17,6 @@ add_couchbase_clibs() {
17
17
  }
18
18
 
19
19
  add_couchbase_cxxlibs() {
20
- if [ "$VERSION_ID" = "18.04" ]; then
21
- if ! command -v gcc-8 >/dev/null || ! command -v g++-8 >/dev/null; then
22
- install_packages gcc-8 g++-8 -y
23
- fi
24
- printf "gcc g++" | xargs -d ' ' -I {} sudo update-alternatives --install /usr/bin/{} {} /usr/bin/{}-8 8
25
- fi
26
20
  if [ "${runner:?}" = "self-hosted" ]; then
27
21
  add_list cmake https://apt.kitware.com/ubuntu/ https://apt.kitware.com/keys/kitware-archive-latest.asc "$VERSION_CODENAME" main
28
22
  fi
@@ -4,7 +4,7 @@ Function Add-Choco() {
4
4
  # Source: https://docs.chocolatey.org/en-us/choco/setup
5
5
  Set-ExecutionPolicy Bypass -Scope Process -Force
6
6
  [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
7
- Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
7
+ Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
8
8
  }
9
9
  } catch { }
10
10
  }
@@ -13,7 +13,7 @@ Function Get-ICUUrl() {
13
13
  $trunk = "https://windows.php.net"
14
14
  $urls=@("${trunk}/downloads/php-sdk/deps/${vs_version}/${arch}", "${trunk}/downloads/php-sdk/deps/archives/${vs_version}/${arch}")
15
15
  foreach ($url in $urls) {
16
- $web_content = Invoke-WebRequest -Uri $url
16
+ $web_content = Get-File -Url $url
17
17
  foreach ($link in $web_content.Links) {
18
18
  if ($link -match "/.*ICU-${icu_version}.*/") {
19
19
  return $trunk + $link.HREF
@@ -32,7 +32,7 @@ Function Repair-ICU() {
32
32
  $zip_url = Get-ICUUrl $icu.Groups[1].Value $installed.Architecture $vs
33
33
  if ($zip_url -ne '') {
34
34
  New-Item -Path "$php_dir" -Name "icu" -ItemType "directory" -Force > $null 2>&1
35
- Invoke-WebRequest -Uri $zip_url -OutFile "$php_dir\icu\icu.zip"
35
+ Get-File -Url $zip_url -OutFile "$php_dir\icu\icu.zip"
36
36
  Expand-Archive -Path $php_dir\icu\icu.zip -DestinationPath $php_dir\icu -Force
37
37
  Get-ChildItem $php_dir\icu\bin -Filter *.dll | Copy-Item -Destination $php_dir -Force
38
38
  }
@@ -47,10 +47,5 @@ Function Add-Http() {
47
47
  }
48
48
  Add-Extension pecl_http >$null 2>&1
49
49
  Repair-ICU
50
- try {
51
- php --ri "http" 2> $null | Out-Null
52
- Add-Log $tick "http" "Installed and enabled"
53
- } catch {
54
- Add-Log $cross "http" "Could not install http on PHP $( $installed.FullVersion )"
55
- }
50
+ Add-ExtensionLog http "Installed and enabled"
56
51
  }
@@ -20,7 +20,7 @@ Function Add-Ioncube() {
20
20
  if (-not($installed.ThreadSafe)) {
21
21
  $ts_part = "_nonts"
22
22
  }
23
- Invoke-WebRequest -Uri "https://downloads.ioncube.com/loader_downloads/ioncube_loaders_win$ts_part`_vc$vc`_$arch_part.zip" -OutFile $ext_dir\ioncube.zip
23
+ Get-File -Url "https://downloads.ioncube.com/loader_downloads/ioncube_loaders_win$ts_part`_vc$vc`_$arch_part.zip" -OutFile $ext_dir\ioncube.zip
24
24
  Expand-Archive -Path $ext_dir\ioncube.zip -DestinationPath $ext_dir -Force
25
25
  Copy-Item $ext_dir\ioncube\ioncube_loader_win_$version.dll $ext_dir\php_ioncube.dll
26
26
  }
@@ -14,7 +14,7 @@ Function Add-InstantClient() {
14
14
  if ($arch -eq 'x86') {
15
15
  $suffix = 'nt'
16
16
  }
17
- Invoke-WebRequest -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip
17
+ Get-File -Url https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip
18
18
  Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force
19
19
  Copy-Item $php_dir\instantclient*\* $php_dir
20
20
  }
@@ -71,7 +71,7 @@ Function Add-Oci() {
71
71
  Copy-Item -Path $oci8DLL -Destination $ext_dir\php_oci8.dll
72
72
  } else {
73
73
  $status = 'Installed and enabled'
74
- Invoke-WebRequest -Uri (Get-Oci8Url) -OutFile $php_dir\oci8.zip
74
+ Get-File -Url (Get-Oci8Url) -OutFile $php_dir\oci8.zip
75
75
  Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
76
76
  }
77
77
  }
@@ -13,14 +13,14 @@ Function Get-PhalconReleaseAssetUrl() {
13
13
  try {
14
14
  $match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
15
15
  } catch {
16
- $match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
16
+ $match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
17
17
  }
18
18
  } else {
19
19
  $nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
20
20
  try {
21
21
  $match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
22
22
  } catch {
23
- $match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
23
+ $match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
24
24
  }
25
25
  }
26
26
  if($NULL -ne $match) {
@@ -39,7 +39,7 @@ Function Add-PhalconFromGitHub() {
39
39
  )
40
40
  $zip_url = Get-PhalconReleaseAssetUrl $Semver
41
41
  if($zip_url) {
42
- Invoke-WebRequest -Uri $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
42
+ Get-File -Url $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
43
43
  Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
44
44
  Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
45
45
  Enable-PhpExtension -Extension phalcon -Path $php_dir
@@ -0,0 +1,146 @@
1
+ # Get relay version
2
+ get_relay_version() {
3
+ local ext=$1
4
+ if [[ "$ext" =~ ^relay$ ]]; then
5
+ get -s -n "" "${relay_releases:?}"/latest 2<&1 | grep -m 1 -Eo "tag/(v[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2
6
+ else
7
+ relay_version="${ext##*-}"
8
+ echo "v${relay_version/v//}"
9
+ fi
10
+ }
11
+
12
+ # Get OS suffix in relay artifact URL.
13
+ get_os_suffix() {
14
+ if [ "$os" = "Linux" ]; then
15
+ if [[ "$ID" =~ ubuntu|debian ]]; then
16
+ echo debian
17
+ elif [ "$ID" = "centos" ]; then
18
+ echo centos"$VERSION_ID"
19
+ else
20
+ echo "$ID"
21
+ fi
22
+ else
23
+ echo darwin
24
+ fi
25
+ }
26
+
27
+ # Get openssl suffix in relay artifact URL.
28
+ get_openssl_suffix() {
29
+ openssl_3=$(php -r "echo strpos(OPENSSL_VERSION_TEXT, 'SSL 3') !== false;")
30
+ [ "$openssl_3" = "1" ] && echo '+libssl3' || echo ''
31
+ }
32
+
33
+ # Change library paths in relay binary.
34
+ change_library_paths() {
35
+ if [ "$os" = "Darwin" ]; then
36
+ otool -L "${ext_dir:?}"/relay.so | grep -q 'ssl.1' && openssl_version='1.1' || openssl_version='3'
37
+ [ -e "${brew_prefix:?}"/opt/openssl@"$openssl_version" ] || brew install openssl@"$openssl_version"
38
+ dylibs="$(otool -L "${ext_dir:?}"/relay.so | grep -Eo '.*\.dylib' | cut -f1 -d ' ')"
39
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "libzstd.*dylib" | xargs)" "$brew_prefix"/opt/zstd/lib/libzstd.dylib "$ext_dir"/relay.so
40
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "liblz4.*dylib" | xargs)" "$brew_prefix"/opt/lz4/lib/liblz4.dylib "$ext_dir"/relay.so
41
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "libssl.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libssl.dylib "$ext_dir"/relay.so
42
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "libcrypto.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libcrypto.dylib "$ext_dir"/relay.so
43
+ fi
44
+ }
45
+
46
+ # Add relay dependencies
47
+ add_relay_dependencies() {
48
+ add_extension json
49
+ add_extension msgpack
50
+ add_extension igbinary
51
+ if [ "$os" = "Darwin" ]; then
52
+ . "${0%/*}"/tools/brew.sh
53
+ configure_brew
54
+ brew install hiredis lz4 zstd
55
+ fi
56
+ }
57
+
58
+ # Initialize relay extension ini configuration
59
+ init_relay_ini() {
60
+ relay_ini=$1
61
+ if [ -e "$relay_ini" ]; then
62
+ if [[ -n "$RELAY_KEY" ]]; then
63
+ sudo sed -i.bak "s/^; relay.key =.*/relay.key = $RELAY_KEY/" "$relay_ini"
64
+ fi
65
+ if [[ -n "$RELAY_ENVIRONMENT" ]]; then
66
+ sudo sed -i.bak "s/^; relay.environment =.*/relay.environment = $RELAY_ENVIRONMENT/" "$relay_ini"
67
+ fi
68
+ if [[ -n "$RELAY_EVICTION_POLICY" ]]; then
69
+ sudo sed -i.bak "s/^; relay.eviction_policy =.*/relay.eviction_policy = $RELAY_EVICTION_POLICY/" "$relay_ini"
70
+ fi
71
+ if [[ -n "$RELAY_MAX_MEMORY" ]]; then
72
+ sudo sed -i.bak "s/^; relay.maxmemory =.*/relay.maxmemory = $RELAY_MAX_MEMORY/" "$relay_ini"
73
+ fi
74
+ sudo rm -rf "$relay_ini".bak
75
+ fi
76
+ }
77
+
78
+ # Enable relay extension
79
+ enable_relay() {
80
+ relay_ini=$1
81
+ if [ -e "$relay_ini" ]; then
82
+ init_relay_ini "$relay_ini"
83
+ if [ "$os" = "Linux" ]; then
84
+ sudo cp "$relay_ini" "${ini_dir:?}"/../mods-available/relay.ini
85
+ sudo phpenmod -v "${version:?}" relay
86
+ else
87
+ sudo cp "${relay_ini}" "${scan_dir:?}"/60-relay.ini
88
+ fi
89
+ fi
90
+ }
91
+
92
+ # Patch binary id in relay extension
93
+ init_relay_binary_id() {
94
+ if [ -e "${ext_dir:?}"/relay.so ]; then
95
+ grep -aq 00000000 "${ext_dir:?}"/relay.so && \
96
+ sudo LC_ALL=C sed -i.bak "s/00000000-0000-0000-0000-000000000000/$(uuidgen)/" "$ext_dir"/relay.so
97
+ fi
98
+ }
99
+
100
+ # Configure relay extension
101
+ configure_relay() {
102
+ change_library_paths
103
+ init_relay_binary_id
104
+ enable_relay "${ext_dir}"/relay.ini
105
+ }
106
+
107
+ # Helper function to add relay extension
108
+ add_relay_helper() {
109
+ arch="$(uname -m | sed 's/_/-/')"
110
+ os_suffix="$(get_os_suffix)"
111
+ openssl_suffix="$(get_openssl_suffix)"
112
+ artifact_file_name="relay-$relay_version-php${version:?}-$os_suffix-$arch$openssl_suffix.tar.gz"
113
+ url="$relay_trunk"/"$relay_version"/"$artifact_file_name"
114
+ get -q -n /tmp/relay.tar.gz "$url"
115
+ if (! [ -e /tmp/relay.tar.gz ] || ! file /tmp/relay.tar.gz | grep -q 'gzip'); then
116
+ if [ "$openssl_suffix" = '+libssl3' ]; then
117
+ get -q -n /tmp/relay.tar.gz "${url/+libssl3/}"
118
+ else
119
+ get -q -n /tmp/relay.tar.gz "${url/.tar/+libssl3.tar}"
120
+ fi
121
+ fi
122
+ if [ -e /tmp/relay.tar.gz ] && file /tmp/relay.tar.gz | grep -q 'gzip'; then
123
+ sudo tar --strip-components=1 -xzf /tmp/relay.tar.gz -C "${ext_dir:?}"
124
+ sudo mv "${ext_dir:?}"/relay-pkg.so "${ext_dir:?}"/relay.so
125
+ fi
126
+ }
127
+
128
+ # Add relay extension
129
+ add_relay() {
130
+ local ext=$1
131
+ local arch
132
+ local url
133
+ os=$(uname -s)
134
+ relay_releases=https://github.com/cachewerk/relay/releases
135
+ relay_trunk=https://builds.r2.relay.so
136
+ relay_version=$(get_relay_version "$ext")
137
+ add_relay_dependencies >/dev/null 2>&1
138
+ if shared_extension relay; then
139
+ message="Enabled"
140
+ else
141
+ add_relay_helper >/dev/null 2>&1
142
+ message="Installed and enabled"
143
+ fi
144
+ configure_relay >/dev/null 2>&1
145
+ add_extension_log relay "$message"
146
+ }
@@ -13,7 +13,7 @@ parse_args() {
13
13
  # Function to parse configure options for pecl
14
14
  # Make sure we have all options in name="value" form i.e XML properties.
15
15
  parse_pecl_configure_options() {
16
- configure_opts=$(echo "$1" | sed -r -e "s#['\"]|--##g")
16
+ configure_opts=$(echo "$1" | sed -E -e "s#['\"]|--##g")
17
17
  IFS=' ' read -r -a opts_array <<< "$configure_opts"
18
18
  output_opts=()
19
19
  for opt in "${opts_array[@]}"; do
@@ -0,0 +1,80 @@
1
+ # Function to get the url of the phalcon release asset.
2
+ Function Get-ZephirParserReleaseAssetUrl() {
3
+ Param (
4
+ [Parameter(Position = 0, Mandatory = $true)]
5
+ [ValidateNotNull()]
6
+ [string]
7
+ $extension_version
8
+ )
9
+ $repo = 'zephir-lang/php-zephir-parser'
10
+ $zp_releases = "$github/$repo/releases"
11
+ $nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" }
12
+ try {
13
+ $match = (Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/tags/$extension_version").assets | Select-String -Pattern "browser_download_url=.*(zephir_parser-php-${version}-$nts-windows.*.zip)"
14
+ } catch {
15
+ $match = (Get-File -Url "$zp_releases/expanded_assets/$extension_version").Links.href | Select-String -Pattern "(zephir_parser-php-${version}-$nts-windows.*.zip)"
16
+ }
17
+ if($NULL -ne $match) {
18
+ return "$zp_releases/download/$extension_version/$($match.Matches[0].Groups[1].Value)"
19
+ }
20
+ return false;
21
+ }
22
+
23
+ # Function to get zephir parser version using GitHub releases.
24
+ Function Get-ZephirParserVersion() {
25
+ Param (
26
+ [Parameter(Position = 0, Mandatory = $true)]
27
+ [ValidateNotNull()]
28
+ [string]
29
+ $extension
30
+ )
31
+ $repo = 'zephir-lang/php-zephir-parser'
32
+ $zp_releases = "$github/$repo/releases"
33
+ if($extension -eq 'zephir_parser') {
34
+ return (Get-File -Url $zp_releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
35
+ } else {
36
+ return 'v' + ($extension.split('-')[1] -replace 'v')
37
+ }
38
+ }
39
+
40
+ # Function to add zephir parser using GitHub releases.
41
+ Function Add-ZephirParserFromGitHub() {
42
+ Param (
43
+ [Parameter(Position = 0, Mandatory = $true)]
44
+ [ValidateNotNull()]
45
+ [string]
46
+ $extension
47
+ )
48
+ $extension_version = Get-ZephirParserVersion $extension
49
+ $zip_url = Get-ZephirParserReleaseAssetUrl $extension_version
50
+ if($zip_url) {
51
+ Get-File -Url $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\zp.zip > $null 2>&1
52
+ Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\zp.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\zp -Force > $null 2>&1
53
+ Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\zp\php_zephir_parser.dll" -Destination "$ext_dir\php_zephir_parser.dll"
54
+ Enable-PhpExtension -Extension zephir_parser -Path $php_dir
55
+ } else {
56
+ throw "Unable to get zephir_parser release from the GitHub repo"
57
+ }
58
+ }
59
+
60
+ # Function to add zephir parser.
61
+ Function Add-ZephirParser() {
62
+ Param (
63
+ [Parameter(Position = 0, Mandatory = $true)]
64
+ [ValidateNotNull()]
65
+ [string]
66
+ $extension
67
+ )
68
+ try {
69
+ $status = 'Enabled'
70
+ if (Test-Path $ext_dir\php_zephir_parser.dll) {
71
+ Enable-PhpExtension -Extension zephir_parser -Path $php_dir
72
+ } else {
73
+ $status = 'Installed and enabled'
74
+ Add-ZephirParserFromGitHub $extension
75
+ }
76
+ Add-ExtensionLog zephir_parser $status
77
+ } catch {
78
+ Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
79
+ }
80
+ }
@@ -0,0 +1,38 @@
1
+ # Get zephir_parser version
2
+ get_zephir_parser_version() {
3
+ local ext=$1
4
+ if [[ "$ext" =~ ^zephir_parser$ ]]; then
5
+ get -s -n "" "${zp_releases:?}"/latest 2<&1 | grep -m 1 -Eo "tag/(v?[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2
6
+ else
7
+ zp_version="${ext##*-}"
8
+ echo "v${zp_version/v//}"
9
+ fi
10
+ }
11
+
12
+ # Add zephir_parser helper
13
+ add_zephir_parser_helper() {
14
+ local ext=$1
15
+ nts="${ts:?}" && nts="${nts/z/}"
16
+ ext_version=$(get_zephir_parser_version "$ext")
17
+ [ "$(uname -s)" = "Linux" ] && os_suffix=ubuntu || os_suffix=macos
18
+ build_name=$(get -s -n "" https://api.github.com/repos/"$repo"/releases/tags/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}-$nts-$os_suffix-.*.zip" | head -n 1)
19
+ [ -z "$build_name" ] && build_name=$(get -s -n "" "$zp_releases"/expanded_assets/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}-$nts-$os_suffix-.*.zip" | head -n 1)
20
+ get -q -e "/tmp/zp.zip" "$zp_releases"/download/"$ext_version"/"$build_name"
21
+ sudo unzip -o "/tmp/zp.zip" -d "${ext_dir:?}"
22
+ enable_extension zephir_parser extension
23
+ }
24
+
25
+ # Add zephir_parser
26
+ add_zephir_parser() {
27
+ ext=$1
28
+ repo=zephir-lang/php-zephir-parser
29
+ zp_releases=https://github.com/"$repo"/releases
30
+ if ! shared_extension zephir_parser; then
31
+ message='Installed and enabled'
32
+ add_zephir_parser_helper "$ext" >/dev/null 2>&1
33
+ else
34
+ message='Enabled'
35
+ enable_extension zephir_parser extension
36
+ fi
37
+ add_extension_log zephir_parser "$message"
38
+ }
@@ -2,7 +2,7 @@
2
2
  add_sudo() {
3
3
  if ! command -v sudo >/dev/null; then
4
4
  check_package sudo || apt-get update
5
- apt-get install -y sudo
5
+ apt-get install -y sudo || (apt-get update && apt-get install -y sudo)
6
6
  fi
7
7
  }
8
8
 
@@ -15,10 +15,15 @@ self_hosted_helper() {
15
15
  install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
16
16
  }
17
17
 
18
+ # Function to fix broken packages.
19
+ fix_broken_packages() {
20
+ sudo apt --fix-broken install >/dev/null 2>&1
21
+ }
22
+
18
23
  # Function to install a package
19
24
  install_packages() {
20
25
  packages=("$@")
21
- $apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && $apt_install "${packages[@]}" >/dev/null 2>&1)
26
+ $apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" >/dev/null 2>&1)
22
27
  }
23
28
 
24
29
  # Function to disable an extension.
@@ -96,7 +101,7 @@ add_devtools() {
96
101
 
97
102
  # Function to setup the nightly build from shivammathur/php-builder
98
103
  setup_nightly() {
99
- run_script "php-builder" "${runner:?}" "$version" "${debug:?}" ${ts:?}
104
+ run_script "php-builder" "${runner:?}" "$version" "${debug:?}" "${ts:?}"
100
105
  }
101
106
 
102
107
  # Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.