setup-php 2.12.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +977 -936
  3. package/package.json +66 -56
  4. package/src/config.ts +82 -82
  5. package/src/configs/brew_extensions +30 -0
  6. package/src/configs/os_releases.csv +17 -0
  7. package/src/configs/php-versions.json +6 -5
  8. package/src/configs/{php.json → pm/php.json} +29 -29
  9. package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
  10. package/src/configs/tools.json +256 -234
  11. package/src/configs/tools_schema.json +114 -103
  12. package/src/coverage.ts +169 -142
  13. package/src/extensions.ts +363 -349
  14. package/src/install.ts +79 -82
  15. package/src/scripts/common.sh +366 -314
  16. package/src/scripts/darwin.sh +257 -248
  17. package/src/scripts/ext/blackfire.ps1 +32 -32
  18. package/src/scripts/ext/blackfire.sh +22 -21
  19. package/src/scripts/ext/couchbase.sh +43 -43
  20. package/src/scripts/ext/cubrid.sh +60 -60
  21. package/src/scripts/ext/extension_map.php +109 -0
  22. package/src/scripts/ext/firebird.ps1 +19 -19
  23. package/src/scripts/ext/firebird.sh +39 -35
  24. package/src/scripts/ext/gearman.sh +22 -22
  25. package/src/scripts/ext/geos.sh +17 -17
  26. package/src/scripts/ext/http.ps1 +54 -54
  27. package/src/scripts/ext/http.sh +120 -120
  28. package/src/scripts/ext/intl.sh +23 -23
  29. package/src/scripts/ext/ioncube.ps1 +33 -32
  30. package/src/scripts/ext/ioncube.sh +21 -19
  31. package/src/scripts/ext/oci.ps1 +60 -60
  32. package/src/scripts/ext/oci.sh +65 -63
  33. package/src/scripts/ext/patches/firebird.sh +11 -11
  34. package/src/scripts/ext/patches/geos.sh +7 -7
  35. package/src/scripts/ext/patches/http.sh +11 -11
  36. package/src/scripts/ext/patches/pdo_oci.sh +6 -6
  37. package/src/scripts/ext/patches/phpize.sh +26 -26
  38. package/src/scripts/ext/patches/protobuf.sh +4 -4
  39. package/src/scripts/ext/phalcon.ps1 +54 -55
  40. package/src/scripts/ext/phalcon.sh +59 -59
  41. package/src/scripts/ext/source.sh +144 -144
  42. package/src/scripts/linux.sh +239 -280
  43. package/src/scripts/tools/add_tools.ps1 +28 -25
  44. package/src/scripts/tools/add_tools.sh +27 -19
  45. package/src/scripts/tools/blackfire.ps1 +19 -21
  46. package/src/scripts/tools/blackfire.sh +40 -35
  47. package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
  48. package/src/scripts/tools/grpc_php_plugin.sh +58 -61
  49. package/src/scripts/tools/ppa.sh +189 -0
  50. package/src/scripts/tools/protoc.ps1 +38 -38
  51. package/src/scripts/tools/protoc.sh +28 -28
  52. package/src/scripts/win32.ps1 +566 -471
  53. package/src/tools.ts +538 -509
  54. package/src/utils.ts +503 -497
  55. package/.eslintrc.json +0 -16
  56. package/.github/CODE_OF_CONDUCT.md +0 -76
  57. package/.github/CONTRIBUTING.md +0 -70
  58. package/.github/FUNDING.yml +0 -7
  59. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
  60. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  61. package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
  62. package/.github/SECURITY.md +0 -29
  63. package/.github/workflows/docs.yml +0 -77
  64. package/.github/workflows/node-workflow.yml +0 -51
  65. package/.github/workflows/workflow.yml +0 -78
  66. package/.idea/workspace.xml +0 -113
  67. package/.prettierrc.json +0 -12
  68. package/__tests__/config.test.ts +0 -52
  69. package/__tests__/coverage.test.ts +0 -110
  70. package/__tests__/extensions.test.ts +0 -261
  71. package/__tests__/install.test.ts +0 -175
  72. package/__tests__/tools.test.ts +0 -490
  73. package/__tests__/utils.test.ts +0 -303
  74. package/action.yml +0 -29
  75. package/dist/index.js +0 -3001
  76. package/examples/bedrock.yml +0 -32
  77. package/examples/blackfire-player.yml +0 -31
  78. package/examples/blackfire.yml +0 -31
  79. package/examples/cakephp-mysql.yml +0 -114
  80. package/examples/cakephp-postgres.yml +0 -112
  81. package/examples/cakephp.yml +0 -92
  82. package/examples/codeigniter.yml +0 -34
  83. package/examples/laravel-mysql.yml +0 -74
  84. package/examples/laravel-postgres.yml +0 -74
  85. package/examples/laravel.yml +0 -42
  86. package/examples/lumen-mysql.yml +0 -74
  87. package/examples/lumen-postgres.yml +0 -74
  88. package/examples/lumen.yml +0 -38
  89. package/examples/phalcon-mysql.yml +0 -74
  90. package/examples/phalcon-postgres.yml +0 -73
  91. package/examples/sage.yml +0 -57
  92. package/examples/slim-framework.yml +0 -34
  93. package/examples/symfony-mysql.yml +0 -57
  94. package/examples/symfony-postgres.yml +0 -55
  95. package/examples/symfony.yml +0 -39
  96. package/examples/yii2-mysql.yml +0 -73
  97. package/examples/yii2-postgres.yml +0 -71
  98. package/examples/zend-framework.yml +0 -36
  99. package/jest.config.js +0 -12
  100. package/lib/config.js +0 -72
  101. package/lib/config.js.map +0 -1
  102. package/lib/coverage.js +0 -88
  103. package/lib/coverage.js.map +0 -1
  104. package/lib/extensions.js +0 -201
  105. package/lib/extensions.js.map +0 -1
  106. package/lib/install.js +0 -82
  107. package/lib/install.js.map +0 -1
  108. package/lib/sapi.js +0 -64
  109. package/lib/tools.js +0 -387
  110. package/lib/tools.js.map +0 -1
  111. package/lib/utils.js +0 -292
  112. package/lib/utils.js.map +0 -1
  113. package/tsconfig.json +0 -18
@@ -1,21 +1,19 @@
1
- # Function to add blackfire and blackfire-agent.
2
- Function Add-Blackfire() {
3
- $arch_name ='amd64'
4
- if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
5
- $arch_name = '386'
6
- }
7
- $agent_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).agent
8
- $url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip"
9
- Invoke-WebRequest -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1
10
- Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1
11
- Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe"
12
- Add-ToProfile $current_profile 'blackfire-agent' "New-Alias blackfire-agent $bin_dir\blackfire-agent.exe"
13
- if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) {
14
- blackfire-agent --register --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN >$null 2>&1
15
- }
16
- if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
17
- blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
18
- }
19
- Add-Log $tick "blackfire" "Added blackfire $agent_version"
20
- Add-Log $tick "blackfire-agent" "Added blackfire-agent $agent_version"
21
- }
1
+ # Function to add blackfire cli.
2
+ Function Add-Blackfire() {
3
+ $arch_name ='amd64'
4
+ if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
5
+ $arch_name = '386'
6
+ }
7
+ $cli_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).cli
8
+ $url = "https://packages.blackfire.io/binaries/blackfire/${cli_version}/blackfire-windows_${arch_name}.zip"
9
+ Invoke-WebRequest -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1
10
+ Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1
11
+ Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe"
12
+ if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) {
13
+ blackfire agent:config --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN >$null 2>&1
14
+ }
15
+ if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
16
+ blackfire client:config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
17
+ }
18
+ Add-Log $tick "blackfire" "Added blackfire $cli_version"
19
+ }
@@ -1,35 +1,40 @@
1
- add_blackfire_linux() {
2
- sudo mkdir -p /var/run/blackfire
3
- get -s -n "" https://packages.blackfire.io/gpg.key | sudo apt-key add -
4
- echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list
5
- sudo "${debconf_fix:?}" apt-get update
6
- ${apt_install:?} blackfire-agent
7
- }
8
-
9
- add_blackfire_darwin() {
10
- sudo mkdir -p /usr/local/var/run
11
- brew tap --shallow blackfireio/homebrew-blackfire
12
- brew install blackfire-agent
13
- }
14
-
15
- blackfire_config() {
16
- if [[ -n $BLACKFIRE_SERVER_ID ]] && [[ -n $BLACKFIRE_SERVER_TOKEN ]]; then
17
- sudo blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN"
18
- [ "$os" = "Linux" ] && sudo /etc/init.d/blackfire-agent restart
19
- [ "$os" = "Darwin" ] && brew services start blackfire-agent
20
- fi
21
- if [[ -n $BLACKFIRE_CLIENT_ID ]] && [[ -n $BLACKFIRE_CLIENT_TOKEN ]]; then
22
- blackfire config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN"
23
- fi
24
- }
25
-
26
- # Function to add blackfire and blackfire-agent.
27
- add_blackfire() {
28
- os="$(uname -s)"
29
- [ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1
30
- [ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1
31
- blackfire_config >/dev/null 2>&1
32
- tool_version=$(get_tool_version "blackfire" "version")
33
- add_log "${tick:?}" "blackfire" "Added blackfire $tool_version"
34
- add_log "${tick:?}" "blackfire-agent" "Added blackfire-agent $tool_version"
35
- }
1
+ add_blackfire_linux() {
2
+ sudo mkdir -p /var/run/blackfire /etc/blackfire
3
+ add_list debian/blackfire http://packages.blackfire.io/debian https://packages.blackfire.io/gpg.key any main
4
+ install_packages blackfire
5
+ sudo chmod 777 /etc/blackfire/agent
6
+ }
7
+
8
+ add_blackfire_darwin() {
9
+ sudo mkdir -p /usr/local/var/run
10
+ add_brew_tap blackfireio/homebrew-blackfire
11
+ brew install blackfire
12
+ }
13
+
14
+ blackfire_config() {
15
+ if [[ -n $BLACKFIRE_SERVER_ID ]] && [[ -n $BLACKFIRE_SERVER_TOKEN ]]; then
16
+ blackfire agent:config --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN"
17
+ if [ "$os" = "Linux" ]; then
18
+ if [ -d /run/systemd/system ]; then
19
+ sudo systemctl start blackfire-agent
20
+ else
21
+ sudo service blackfire-agent start
22
+ fi
23
+ elif [ "$os" = "Darwin" ]; then
24
+ brew services start blackfire
25
+ fi
26
+ fi
27
+ if [[ -n $BLACKFIRE_CLIENT_ID ]] && [[ -n $BLACKFIRE_CLIENT_TOKEN ]]; then
28
+ blackfire client:config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN"
29
+ fi
30
+ }
31
+
32
+ # Function to add blackfire cli.
33
+ add_blackfire() {
34
+ os="$(uname -s)"
35
+ [ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1
36
+ [ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1
37
+ blackfire_config >/dev/null 2>&1
38
+ tool_version=$(get_tool_version "blackfire" "version")
39
+ add_log "${tick:?}" "blackfire" "Added blackfire $tool_version"
40
+ }
@@ -1,21 +1,21 @@
1
- Function Add-Msys2() {
2
- $msys_location = 'C:\msys64'
3
- if (-not(Test-Path $msys_location)) {
4
- choco install msys2 -y >$null 2>&1
5
- $msys_location = 'C:\tools\msys64'
6
- }
7
- return $msys_location
8
- }
9
-
10
- Function Add-Grpc_php_plugin() {
11
- $msys_location = Add-Msys2
12
- $logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
13
- $grpc_version = Get-ToolVersion 'Write-Output' "$logs"
14
- Write-Output "$msys_location\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
15
- Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
16
- Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe"
17
- Add-Log $tick "grpc_php_plugin" "Added grpc_php_plugin $grpc_version"
18
- printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
19
- Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
20
- Write-Output "::endgroup::"
21
- }
1
+ Function Add-Msys2() {
2
+ $msys_location = 'C:\msys64'
3
+ if (-not(Test-Path $msys_location)) {
4
+ choco install msys2 -y >$null 2>&1
5
+ $msys_location = 'C:\tools\msys64'
6
+ }
7
+ return $msys_location
8
+ }
9
+
10
+ Function Add-Grpc_php_plugin() {
11
+ $msys_location = Add-Msys2
12
+ $logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
13
+ $grpc_version = Get-ToolVersion 'Write-Output' "$logs"
14
+ Write-Output "$msys_location\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
15
+ Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
16
+ Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe"
17
+ Add-Log $tick "grpc_php_plugin" "Added grpc_php_plugin $grpc_version"
18
+ printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
19
+ Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
20
+ Write-Output "::endgroup::"
21
+ }
@@ -1,61 +1,58 @@
1
- add_bazel() {
2
- if ! command -v bazel; then
3
- if [ "$(uname -s)" = "Linux" ]; then
4
- ${apt_install:?} curl gnupg
5
- get -s -n "" https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
6
- echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
7
- sudo "${debconf_fix:?}" apt-get update -y
8
- ${apt_install:?} bazel
9
- else
10
- brew install bazel
11
- fi
12
- fi
13
- }
14
-
15
- get_grpc_tag() {
16
- if [ "$grpc_tag" = "latest" ]; then
17
- grpc_tag=$(get -s -n "" https://github.com/grpc/grpc/releases/latest | grep -Eo -m 1 "v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
18
- else
19
- if [[ ${grpc_tag:0:1} != "v" ]] ; then grpc_tag="v$grpc_tag"; fi
20
- status_code=$(get -v -n /tmp/grpc.tmp "https://github.com/grpc/grpc/releases/tag/$grpc_tag")
21
- if [ "$status_code" != "200" ]; then
22
- grpc_tag=$(get -s -n "" https://github.com/grpc/grpc/releases/latest | grep -Eo -m 1 "v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
23
- fi
24
- fi
25
- }
26
-
27
- add_grpc_php_plugin_brew() {
28
- brew install grpc
29
- brew link --force --overwrite grpc >/dev/null 2>&1
30
- grpc_tag="v$(brew info grpc | grep "grpc:" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
31
- license_path="$(brew --prefix grpc)/LICENSE"
32
- }
33
-
34
- add_grpc_php_plugin_compile() {
35
- get_grpc_tag
36
- get -s -n "" "https://github.com/grpc/grpc/archive/$grpc_tag.tar.gz" | tar -xz -C /tmp
37
- export DISABLE_BAZEL_WRAPPER=1
38
- (
39
- cd "/tmp/grpc-${grpc_tag:1}" || exit
40
- add_bazel
41
- ./tools/bazel build src/compiler:grpc_php_plugin
42
- sudo mv ./bazel-bin/src/compiler/grpc_php_plugin /usr/local/bin/grpc_php_plugin
43
- sudo chmod a+x /usr/local/bin/grpc_php_plugin
44
- license_path="/tmp/grpc-${grpc_tag:1}/LICENSE"
45
- )
46
- }
47
-
48
- add_grpc_php_plugin() {
49
- grpc_tag=$1
50
- license_path=""
51
- if [ "$grpc_tag" = "latest" ]; then
52
- add_grpc_php_plugin_brew >/dev/null 2>&1
53
- else
54
- add_grpc_php_plugin_compile >/dev/null 2>&1
55
- fi
56
- echo "::set-output name=grpc_php_plugin_path::$(command -v grpc_php_plugin)"
57
- add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
58
- printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
59
- cat "$license_path"
60
- echo "::endgroup::"
61
- }
1
+ add_bazel() {
2
+ if ! command -v bazel; then
3
+ if [ "$(uname -s)" = "Linux" ]; then
4
+ add_list bazel/apt https://storage.googleapis.com/bazel-apt https://bazel.build/bazel-release.pub.gpg stable jdk1.8
5
+ install_packages bazel
6
+ else
7
+ brew install bazel
8
+ fi
9
+ fi
10
+ }
11
+
12
+ get_grpc_tag() {
13
+ if [ "$grpc_tag" = "latest" ]; then
14
+ grpc_tag=$(get -s -n "" https://github.com/grpc/grpc/releases/latest | grep -Eo -m 1 "v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
15
+ else
16
+ if [[ ${grpc_tag:0:1} != "v" ]] ; then grpc_tag="v$grpc_tag"; fi
17
+ status_code=$(get -v -n /tmp/grpc.tmp "https://github.com/grpc/grpc/releases/tag/$grpc_tag")
18
+ if [ "$status_code" != "200" ]; then
19
+ grpc_tag=$(get -s -n "" https://github.com/grpc/grpc/releases/latest | grep -Eo -m 1 "v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
20
+ fi
21
+ fi
22
+ }
23
+
24
+ add_grpc_php_plugin_brew() {
25
+ brew install grpc
26
+ brew link --force --overwrite grpc >/dev/null 2>&1
27
+ grpc_tag="v$(brew info grpc | grep "grpc:" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
28
+ license_path="$(brew --prefix grpc)/LICENSE"
29
+ }
30
+
31
+ add_grpc_php_plugin_compile() {
32
+ get_grpc_tag
33
+ get -s -n "" "https://github.com/grpc/grpc/archive/$grpc_tag.tar.gz" | tar -xz -C /tmp
34
+ export DISABLE_BAZEL_WRAPPER=1
35
+ (
36
+ cd "/tmp/grpc-${grpc_tag:1}" || exit
37
+ add_bazel
38
+ ./tools/bazel build src/compiler:grpc_php_plugin
39
+ sudo mv ./bazel-bin/src/compiler/grpc_php_plugin /usr/local/bin/grpc_php_plugin
40
+ sudo chmod a+x /usr/local/bin/grpc_php_plugin
41
+ license_path="/tmp/grpc-${grpc_tag:1}/LICENSE"
42
+ )
43
+ }
44
+
45
+ add_grpc_php_plugin() {
46
+ grpc_tag=$1
47
+ license_path=""
48
+ if [ "$grpc_tag" = "latest" ]; then
49
+ add_grpc_php_plugin_brew >/dev/null 2>&1
50
+ else
51
+ add_grpc_php_plugin_compile >/dev/null 2>&1
52
+ fi
53
+ echo "::set-output name=grpc_php_plugin_path::$(command -v grpc_php_plugin)"
54
+ add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
55
+ printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
56
+ cat "$license_path"
57
+ echo "::endgroup::"
58
+ }
@@ -0,0 +1,189 @@
1
+ # Function to try to set ubuntu or debian version.
2
+ set_base_version_id() {
3
+ [[ "$ID" =~ ubuntu|debian ]] && return;
4
+ if ! [ -d "$dist_info_dir" ]; then
5
+ sudo mkdir -p "$dist_info_dir"
6
+ get -q -n "$dist_info_dir"/os_releases.csv https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/os_releases.csv
7
+ fi
8
+ for base in ubuntu debian; do
9
+ [[ "$ID_LIKE" =~ $base ]] && ID="$base" && VERSION_ID="$(grep -hr -m 1 "$VERSION_CODENAME" /usr/share/distro-info | cut -d ',' -f 1 | cut -d ' ' -f 1)" && break
10
+ done
11
+ }
12
+
13
+ # Function to try to set ubuntu or debian codename.
14
+ set_base_version_codename() {
15
+ [[ "$ID" =~ ubuntu|debian ]] && return;
16
+ if [[ "$ID_LIKE" =~ ubuntu ]]; then
17
+ [[ -n "$UBUNTU_CODENAME" ]] && VERSION_CODENAME="$UBUNTU_CODENAME" && return;
18
+ [ -e "$upstream_lsb" ] && VERSION_CODENAME=$(grep 'CODENAME' "$upstream_lsb" | cut -d '=' -f 2) && return;
19
+ VERSION_CODENAME=$(grep -E -m1 'deb .*ubuntu.com' "$list_file" | cut -d ' ' -f 3) && VERSION_CODENAME=${VERSION_CODENAME%-*}
20
+ elif [[ "$ID_LIKE" =~ debian ]] || command -v dpkg >/dev/null; then
21
+ ID_LIKE=debian
22
+ [[ -n "$DEBIAN_CODENAME" ]] && VERSION_CODENAME="$DEBIAN_CODENAME" && return;
23
+ update_lists && VERSION_CODENAME=$(apt-cache show tzdata | grep -m 1 Provides | cut -d '-' -f 2)
24
+ fi
25
+ }
26
+
27
+ # Function to set base os details
28
+ set_base_version() {
29
+ if [ -e /tmp/os-release ]; then
30
+ . /tmp/os-release
31
+ else
32
+ set_base_version_codename
33
+ set_base_version_id
34
+
35
+ # Remove once PPAs start having bookworm releases
36
+ [ "$VERSION_CODENAME" = 'bookworm' ] && VERSION_CODENAME="bullseye"
37
+
38
+ printf "ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n" "$ID" "$VERSION_ID" "$VERSION_CODENAME" | tee /tmp/os-release >/dev/null 2>&1
39
+ fi
40
+ }
41
+
42
+ # Helper function to update package lists.
43
+ update_lists_helper() {
44
+ list=$1
45
+ command -v sudo >/dev/null && SUDO=sudo
46
+ if [[ -n "$list" ]]; then
47
+ ${SUDO} apt-get update -o Dir::Etc::sourcelist="$list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
48
+ else
49
+ ${SUDO} apt-get update
50
+ fi
51
+ }
52
+
53
+ # Function to update the package lists.
54
+ update_lists() {
55
+ local ppa=${1:-}
56
+ local ppa_search=${2:-}
57
+ if [ ! -e /tmp/setup_php ] || [[ -n $ppa && -n $ppa_search ]]; then
58
+ if [[ -n "$ppa" && -n "$ppa_search" ]]; then
59
+ list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
60
+ elif grep -Eq '^deb ' "$list_file"; then
61
+ list="$list_file"
62
+ fi
63
+ update_lists_helper "$list" >/dev/null 2>&1
64
+ echo '' | tee /tmp/setup_php >/dev/null 2>&1
65
+ fi
66
+ }
67
+
68
+ # Function to get fingerprint from an Ubuntu PPA.
69
+ ubuntu_fingerprint() {
70
+ ppa=$1
71
+ get -s -n "" "$lp_api"/~"${ppa%/*}"/+archive/"${ppa##*/}" | jq -r '.signing_key_fingerprint'
72
+ }
73
+
74
+ # Function to get fingerprint from a Debian PPA.
75
+ debian_fingerprint() {
76
+ ppa=$1
77
+ ppa_url=$2
78
+ package_dist=$3
79
+ release_pub=/tmp/"${ppa/\//-}".gpg
80
+ get -q -n "$release_pub" "$ppa_url"/dists/"$package_dist"/Release.gpg
81
+ gpg --list-packets "$release_pub" | grep -Eo 'fpr\sv4\s.*[a-zA-Z0-9]+' | head -n 1 | cut -d ' ' -f 3
82
+ }
83
+
84
+ # Function to add a GPG key.
85
+ add_key() {
86
+ ppa=${1:-ondrej/php}
87
+ ppa_url=$2
88
+ package_dist=$3
89
+ key_source=$4
90
+ key_file=$5
91
+ key_urls=("$key_source")
92
+ if [[ "$key_source" =~ launchpad.net|debian.org|setup-php.com ]]; then
93
+ fingerprint="$("${ID}"_fingerprint "$ppa" "$ppa_url" "$package_dist")"
94
+ sks_params="op=get&options=mr&exact=on&search=0x$fingerprint"
95
+ key_urls=("${sks[@]/%/\/pks\/lookup\?"$sks_params"}")
96
+ fi
97
+ [ ! -e "$key_source" ] && get -q -n "$key_file" "${key_urls[@]}"
98
+ if [[ "$(file "$key_file")" =~ .*('Public-Key (old)'|'Secret-Key') ]]; then
99
+ sudo gpg --batch --yes --dearmor "$key_file" >/dev/null 2>&1 && sudo mv "$key_file".gpg "$key_file"
100
+ fi
101
+ }
102
+
103
+ # Function to check if a PPA and its lists exist
104
+ check_lists() {
105
+ ppa=$1
106
+ ppa_search=$2
107
+ if grep -Eqr "$ppa_search" "$list_dir"; then
108
+ list_count="$(sudo find /var/lib/apt/lists -type f -name "*${ppa/\//_}*" | wc -l)"
109
+ if [ "$list_count" = "0" ]; then
110
+ update_lists "$ppa" "$ppa_search"
111
+ fi
112
+ return 0;
113
+ else
114
+ return 1;
115
+ fi
116
+ }
117
+
118
+ # Function to add a sources list.
119
+ add_list() {
120
+ ppa=${1-ondrej/php}
121
+ ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
122
+ key_source=${3:-"$ppa_url"}
123
+ package_dist=${4:-"$VERSION_CODENAME"}
124
+ branches=${5:-main}
125
+ ppa_search="deb .*$ppa_url $package_dist .*$branches"
126
+ if check_lists "$ppa" "$ppa_search"; then
127
+ echo "Repository $ppa already exists";
128
+ return 1;
129
+ else
130
+ arch=$(dpkg --print-architecture)
131
+ [ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
132
+ add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
133
+ echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa/\//-}".list >/dev/null 2>&1
134
+ update_lists "$ppa" "$ppa_search"
135
+ . /etc/os-release
136
+ fi
137
+ return 0;
138
+ }
139
+
140
+ # Function to remove a PPA.
141
+ remove_list() {
142
+ ppa=${1-ondrej/php}
143
+ ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
144
+ grep -lr "$ppa_url" "$list_dir" | xargs -n1 sudo rm -f
145
+ sudo rm -f "$key_dir"/"${ppa/\//-}"-keyring || true
146
+ }
147
+
148
+ # Function to add a PPA.
149
+ add_ppa() {
150
+ set_base_version
151
+ ppa=${1:-ondrej/php}
152
+ if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
153
+ add_list "$ppa"
154
+ elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then
155
+ add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg
156
+ else
157
+ add_list "$ppa"
158
+ fi
159
+ status="$?"
160
+ . /etc/os-release
161
+ return $status
162
+ }
163
+
164
+ # Function to update a PPA.
165
+ update_ppa() {
166
+ set_base_version
167
+ ppa=${1:-ondrej/php}
168
+ ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
169
+ package_dist=${4:-"$VERSION_CODENAME"}
170
+ branches=${5:-main}
171
+ ppa_search="deb .*$ppa_url $package_dist .*$branches"
172
+ update_lists "$ppa" "$ppa_search"
173
+ . /etc/os-release
174
+ }
175
+
176
+ # Variables
177
+ list_file='/etc/apt/sources.list'
178
+ list_dir="$list_file.d"
179
+ upstream_lsb='/etc/upstream-release/lsb-release'
180
+ lp_api='https://api.launchpad.net/1.0'
181
+ lp_ppa='http://ppa.launchpad.net'
182
+ key_dir='/usr/share/keyrings'
183
+ dist_info_dir='/usr/share/distro-info'
184
+ sury='https://packages.sury.org'
185
+ sks=(
186
+ 'https://keyserver.ubuntu.com'
187
+ 'https://pgp.mit.edu'
188
+ 'https://keys.openpgp.org'
189
+ )
@@ -1,38 +1,38 @@
1
- Function Get-ProtobufTag() {
2
- if("$protobuf_tag" -eq "latest") {
3
- $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/tags).Name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
4
- } else {
5
- try {
6
- [net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
7
- $req.Method = "HEAD"
8
- [net.httpWebResponse] $response = $request.getResponse()
9
- $response.Close()
10
- $protobuf_tag = "v$protobuf_tag"
11
- } catch {
12
- $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/tags).Name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
13
- }
14
- }
15
- return $protobuf_tag
16
- }
17
-
18
- Function Add-Protoc() {
19
- param(
20
- [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The PHP version to be installed')]
21
- [ValidatePattern('^latest$|^(v?)\d+\.\d+\.\d+$')]
22
- [string] $protobuf_tag
23
- )
24
- $protobuf_tag = Get-ProtobufTag
25
- $arch_num = '64'
26
- if(-not([Environment]::Is64BitOperatingSystem)) {
27
- $arch_num = '32'
28
- }
29
- $url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip"
30
- Invoke-WebRequest -Uri $url -OutFile $bin_dir\protoc.zip >$null 2>&1
31
- Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1
32
- Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
33
- Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
34
- Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
35
- printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
36
- Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
37
- Write-Output "::endgroup::"
38
- }
1
+ Function Get-ProtobufTag() {
2
+ if("$protobuf_tag" -eq "latest") {
3
+ $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/tags).Name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
4
+ } else {
5
+ try {
6
+ [net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
7
+ $req.Method = "HEAD"
8
+ [net.httpWebResponse] $response = $request.getResponse()
9
+ $response.Close()
10
+ $protobuf_tag = "v$protobuf_tag"
11
+ } catch {
12
+ $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/tags).Name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
13
+ }
14
+ }
15
+ return $protobuf_tag
16
+ }
17
+
18
+ Function Add-Protoc() {
19
+ param(
20
+ [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The PHP version to be installed')]
21
+ [ValidatePattern('^latest$|^(v?)\d+\.\d+\.\d+$')]
22
+ [string] $protobuf_tag
23
+ )
24
+ $protobuf_tag = Get-ProtobufTag
25
+ $arch_num = '64'
26
+ if(-not([Environment]::Is64BitOperatingSystem)) {
27
+ $arch_num = '32'
28
+ }
29
+ $url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip"
30
+ Invoke-WebRequest -Uri $url -OutFile $bin_dir\protoc.zip >$null 2>&1
31
+ Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1
32
+ Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
33
+ Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
34
+ Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
35
+ printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
36
+ Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
37
+ Write-Output "::endgroup::"
38
+ }
@@ -1,28 +1,28 @@
1
- get_protobuf_tag() {
2
- if [ "$protobuf_tag" = "latest" ]; then
3
- protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
4
- else
5
- status_code=$(get -v -n /tmp/protobuf.tmp "https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
6
- if [ "$status_code" = "200" ]; then
7
- protobuf_tag="v$protobuf_tag"
8
- else
9
- protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
10
- fi
11
- fi
12
- }
13
-
14
- add_protoc() {
15
- protobuf_tag=$1
16
- get_protobuf_tag
17
- (
18
- platform='linux'
19
- [ "$(uname -s)" = "Darwin" ] && platform='osx'
20
- get -q -n /tmp/protobuf.zip "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-x86_64.zip"
21
- sudo unzip /tmp/protobuf.zip -d /usr/local/
22
- sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google
23
- ) >/dev/null 2>&1
24
- add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
25
- printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
26
- curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
27
- echo "::endgroup::"
28
- }
1
+ get_protobuf_tag() {
2
+ if [ "$protobuf_tag" = "latest" ]; then
3
+ protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
4
+ else
5
+ status_code=$(get -v -n /tmp/protobuf.tmp "https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
6
+ if [ "$status_code" = "200" ]; then
7
+ protobuf_tag="v$protobuf_tag"
8
+ else
9
+ protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
10
+ fi
11
+ fi
12
+ }
13
+
14
+ add_protoc() {
15
+ protobuf_tag=$1
16
+ get_protobuf_tag
17
+ (
18
+ platform='linux'
19
+ [ "$(uname -s)" = "Darwin" ] && platform='osx'
20
+ get -q -n /tmp/protobuf.zip "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-x86_64.zip"
21
+ sudo unzip /tmp/protobuf.zip -d /usr/local/
22
+ sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google
23
+ ) >/dev/null 2>&1
24
+ add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
25
+ printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
26
+ curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
27
+ echo "::endgroup::"
28
+ }