setup-php 2.13.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.
Files changed (134) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +990 -922
  3. package/lib/config.d.ts +3 -0
  4. package/lib/config.js +71 -71
  5. package/lib/config.js.map +1 -1
  6. package/lib/coverage.d.ts +5 -0
  7. package/lib/coverage.js +97 -87
  8. package/lib/coverage.js.map +1 -1
  9. package/lib/extensions.d.ts +4 -0
  10. package/lib/extensions.js +214 -200
  11. package/lib/extensions.js.map +1 -1
  12. package/lib/fetch.d.ts +1 -0
  13. package/lib/fetch.js +63 -0
  14. package/lib/fetch.js.map +1 -0
  15. package/lib/install.d.ts +2 -0
  16. package/lib/install.js +75 -81
  17. package/lib/install.js.map +1 -1
  18. package/lib/tools.d.ts +23 -0
  19. package/lib/tools.js +367 -386
  20. package/lib/tools.js.map +1 -1
  21. package/lib/utils.d.ts +21 -0
  22. package/lib/utils.js +261 -291
  23. package/lib/utils.js.map +1 -1
  24. package/package.json +67 -56
  25. package/src/config.ts +82 -82
  26. package/src/configs/brew_extensions +31 -0
  27. package/src/configs/composer.env +2 -0
  28. package/src/configs/ini/jit.ini +3 -0
  29. package/src/configs/ini/php.ini +2 -0
  30. package/src/configs/ini/xdebug.ini +1 -0
  31. package/src/configs/os_releases.csv +19 -17
  32. package/src/configs/php-versions.json +6 -5
  33. package/src/configs/php_packages +12 -0
  34. package/src/configs/{php.json → pm/php.json} +29 -29
  35. package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
  36. package/src/configs/tools.json +278 -235
  37. package/src/configs/tools_schema.json +125 -114
  38. package/src/coverage.ts +144 -142
  39. package/src/extensions.ts +367 -349
  40. package/src/fetch.ts +54 -0
  41. package/src/install.ts +66 -82
  42. package/src/scripts/darwin.sh +285 -249
  43. package/src/scripts/extensions/add_extensions.ps1 +194 -0
  44. package/src/scripts/extensions/add_extensions.sh +184 -0
  45. package/src/scripts/{ext → extensions}/blackfire.ps1 +32 -32
  46. package/src/scripts/{ext → extensions}/blackfire.sh +22 -21
  47. package/src/scripts/{ext → extensions}/couchbase.sh +43 -43
  48. package/src/scripts/{ext → extensions}/cubrid.sh +60 -60
  49. package/src/scripts/extensions/extension_map.php +132 -0
  50. package/src/scripts/{ext → extensions}/firebird.ps1 +19 -19
  51. package/src/scripts/{ext → extensions}/firebird.sh +39 -35
  52. package/src/scripts/{ext → extensions}/gearman.sh +22 -22
  53. package/src/scripts/{ext → extensions}/geos.sh +17 -17
  54. package/src/scripts/{ext → extensions}/http.ps1 +54 -54
  55. package/src/scripts/{ext → extensions}/http.sh +109 -120
  56. package/src/scripts/{ext → extensions}/intl.sh +23 -23
  57. package/src/scripts/{ext → extensions}/ioncube.ps1 +33 -32
  58. package/src/scripts/{ext → extensions}/ioncube.sh +21 -19
  59. package/src/scripts/{ext → extensions}/oci.ps1 +85 -60
  60. package/src/scripts/{ext → extensions}/oci.sh +65 -63
  61. package/src/scripts/{ext → extensions}/patches/firebird.sh +11 -11
  62. package/src/scripts/{ext → extensions}/patches/geos.sh +7 -7
  63. package/src/scripts/{ext → extensions}/patches/http.sh +11 -11
  64. package/src/scripts/{ext → extensions}/patches/pdo_oci.sh +6 -6
  65. package/src/scripts/{ext → extensions}/patches/phpize.sh +26 -26
  66. package/src/scripts/{ext → extensions}/patches/protobuf.sh +4 -4
  67. package/src/scripts/{ext → extensions}/phalcon.ps1 +54 -54
  68. package/src/scripts/{ext → extensions}/phalcon.sh +58 -58
  69. package/src/scripts/{ext → extensions}/source.sh +145 -144
  70. package/src/scripts/extensions/sqlsrv.sh +15 -0
  71. package/src/scripts/linux.sh +269 -256
  72. package/src/scripts/tools/add_tools.ps1 +239 -26
  73. package/src/scripts/tools/add_tools.sh +175 -20
  74. package/src/scripts/tools/blackfire.ps1 +19 -19
  75. package/src/scripts/tools/blackfire.sh +40 -39
  76. package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
  77. package/src/scripts/tools/grpc_php_plugin.sh +58 -58
  78. package/src/scripts/tools/ppa.sh +192 -151
  79. package/src/scripts/tools/protoc.ps1 +38 -38
  80. package/src/scripts/tools/protoc.sh +28 -28
  81. package/src/scripts/tools/symfony.ps1 +14 -0
  82. package/src/scripts/tools/symfony.sh +13 -0
  83. package/src/scripts/unix.sh +186 -0
  84. package/src/scripts/win32.ps1 +352 -494
  85. package/src/tools.ts +512 -538
  86. package/src/utils.ts +415 -500
  87. package/.eslintrc.json +0 -16
  88. package/.github/CODE_OF_CONDUCT.md +0 -76
  89. package/.github/CONTRIBUTING.md +0 -70
  90. package/.github/FUNDING.yml +0 -7
  91. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
  92. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  93. package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
  94. package/.github/SECURITY.md +0 -29
  95. package/.github/workflows/docs.yml +0 -77
  96. package/.github/workflows/node-workflow.yml +0 -51
  97. package/.github/workflows/workflow.yml +0 -78
  98. package/.idea/workspace.xml +0 -113
  99. package/.prettierrc.json +0 -12
  100. package/__tests__/config.test.ts +0 -52
  101. package/__tests__/coverage.test.ts +0 -110
  102. package/__tests__/extensions.test.ts +0 -263
  103. package/__tests__/install.test.ts +0 -175
  104. package/__tests__/tools.test.ts +0 -524
  105. package/__tests__/utils.test.ts +0 -307
  106. package/action.yml +0 -29
  107. package/dist/index.js +0 -3051
  108. package/examples/bedrock.yml +0 -32
  109. package/examples/blackfire-player.yml +0 -31
  110. package/examples/blackfire.yml +0 -31
  111. package/examples/cakephp-mysql.yml +0 -114
  112. package/examples/cakephp-postgres.yml +0 -112
  113. package/examples/cakephp.yml +0 -92
  114. package/examples/codeigniter.yml +0 -34
  115. package/examples/laravel-mysql.yml +0 -74
  116. package/examples/laravel-postgres.yml +0 -74
  117. package/examples/laravel.yml +0 -42
  118. package/examples/lumen-mysql.yml +0 -74
  119. package/examples/lumen-postgres.yml +0 -74
  120. package/examples/lumen.yml +0 -38
  121. package/examples/phalcon-mysql.yml +0 -74
  122. package/examples/phalcon-postgres.yml +0 -73
  123. package/examples/sage.yml +0 -57
  124. package/examples/slim-framework.yml +0 -34
  125. package/examples/symfony-mysql.yml +0 -57
  126. package/examples/symfony-postgres.yml +0 -55
  127. package/examples/symfony.yml +0 -39
  128. package/examples/yii2-mysql.yml +0 -73
  129. package/examples/yii2-postgres.yml +0 -71
  130. package/examples/zend-framework.yml +0 -36
  131. package/jest.config.js +0 -12
  132. package/lib/sapi.js +0 -64
  133. package/src/scripts/common.sh +0 -314
  134. package/tsconfig.json +0 -18
@@ -1,58 +1,58 @@
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
- }
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
+ set_output 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 "$END_GROUP"
58
+ }
@@ -1,151 +1,192 @@
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
- printf "ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n" "$ID" "$VERSION_ID" "$VERSION_CODENAME" | tee /tmp/os-release >/dev/null 2>&1
35
- fi
36
- }
37
-
38
- # Helper function to update package lists.
39
- update_lists_helper() {
40
- list=$1
41
- command -v sudo >/dev/null && SUDO=sudo
42
- if [[ -n "$list" ]]; then
43
- ${SUDO} apt-get update -o Dir::Etc::sourcelist="$list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
44
- else
45
- ${SUDO} apt-get update
46
- fi
47
- }
48
-
49
- # Function to update the package lists.
50
- update_lists() {
51
- local ppa=${1:-}
52
- local ppa_search=${2:-}
53
- if [ ! -e /tmp/setup_php ] || [[ -n $ppa && -n $ppa_search ]]; then
54
- if [[ -n "$ppa" && -n "$ppa_search" ]]; then
55
- list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
56
- elif grep -Eq '^deb ' "$list_file"; then
57
- list="$list_file"
58
- fi
59
- update_lists_helper "$list" >/dev/null 2>&1
60
- echo '' | tee /tmp/setup_php >/dev/null 2>&1
61
- fi
62
- }
63
-
64
- # Function to get fingerprint from an Ubuntu PPA.
65
- ubuntu_fingerprint() {
66
- ppa=$1
67
- get -s -n "" "$lp_api"/~"${ppa%/*}"/+archive/"${ppa##*/}" | jq -r '.signing_key_fingerprint'
68
- }
69
-
70
- # Function to get fingerprint from a Debian PPA.
71
- debian_fingerprint() {
72
- ppa=$1
73
- ppa_url=$2
74
- package_dist=$3
75
- release_pub=/tmp/"${ppa/\//-}".gpg
76
- get -q -n "$release_pub" "$ppa_url"/dists/"$package_dist"/Release.gpg
77
- gpg --list-packets "$release_pub" | grep -Eo 'fpr\sv4\s.*[a-zA-Z0-9]+' | head -n 1 | cut -d ' ' -f 3
78
- }
79
-
80
- # Function to add a GPG key.
81
- add_key() {
82
- ppa=${1:-ondrej/php}
83
- ppa_url=$2
84
- package_dist=$3
85
- key_source=$4
86
- key_file=$5
87
- key_urls=("$key_source")
88
- if [[ "$key_source" =~ launchpad.net|debian.org|setup-php.com ]]; then
89
- fingerprint="$("${ID}"_fingerprint "$ppa" "$ppa_url" "$package_dist")"
90
- sks_params="op=get&options=mr&exact=on&search=0x$fingerprint"
91
- key_urls=("${sks[@]/%/\/pks\/lookup\?"$sks_params"}")
92
- fi
93
- [ ! -e "$key_source" ] && get -q -n "$key_file" "${key_urls[@]}"
94
- if [[ "$(file "$key_file")" =~ .*('Public-Key (old)'|'Secret-Key') ]]; then
95
- sudo gpg --batch --yes --dearmor "$key_file" >/dev/null 2>&1 && sudo mv "$key_file".gpg "$key_file"
96
- fi
97
- }
98
-
99
- # Function to add a sources list.
100
- add_list() {
101
- ppa=${1-ondrej/php}
102
- ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
103
- key_source=${3:-"$ppa_url"}
104
- package_dist=${4:-"$VERSION_CODENAME"}
105
- branches=${5:-main}
106
- ppa_search="deb .*$ppa_url $package_dist .*$branches"
107
- grep -Eqr "$ppa_search" "$list_dir" && echo "Repository $ppa already exists" && return;
108
- arch=$(dpkg --print-architecture)
109
- [ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
110
- add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
111
- echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa/\//-}".list >/dev/null 2>&1
112
- update_lists "$ppa" "$ppa_search"
113
- . /etc/os-release
114
- }
115
-
116
- # Function to remove a PPA.
117
- remove_list() {
118
- ppa=${1-ondrej/php}
119
- ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
120
- grep -lr "$ppa_url" "$list_dir" | xargs -n1 sudo rm -f
121
- sudo rm -f "$key_dir"/"${ppa/\//-}"-keyring || true
122
- }
123
-
124
- # Function to add a PPA.
125
- add_ppa() {
126
- set_base_version
127
- ppa=${1:-ondrej/php}
128
- if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
129
- add_list "$ppa"
130
- elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then
131
- add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg
132
- else
133
- add_list "$ppa"
134
- fi
135
- . /etc/os-release
136
- }
137
-
138
- # Variables
139
- list_file='/etc/apt/sources.list'
140
- list_dir="$list_file.d"
141
- upstream_lsb='/etc/upstream-release/lsb-release'
142
- lp_api='https://api.launchpad.net/1.0'
143
- lp_ppa='http://ppa.launchpad.net'
144
- key_dir='/usr/share/keyrings'
145
- dist_info_dir='/usr/share/distro-info'
146
- sury='https://packages.sury.org'
147
- sks=(
148
- 'https://keyserver.ubuntu.com'
149
- 'https://pgp.mit.edu'
150
- 'https://keys.openpgp.org'
151
- )
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
+ local list=
58
+ status_file=/tmp/os_lists
59
+ if [[ -n "$ppa" && -n "$ppa_search" ]]; then
60
+ list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
61
+ status_file=/tmp/"${ppa/\//_}"
62
+ elif grep -Eq '^deb ' "$list_file"; then
63
+ list="$list_file"
64
+ fi
65
+ if [ ! -e "$status_file" ]; then
66
+ update_lists_helper "$list" >/dev/null 2>&1
67
+ echo '' | tee "$status_file" >/dev/null 2>&1
68
+ fi
69
+ }
70
+
71
+ # Function to get fingerprint from an Ubuntu PPA.
72
+ ubuntu_fingerprint() {
73
+ ppa=$1
74
+ get -s -n "" "$lp_api"/~"${ppa%/*}"/+archive/"${ppa##*/}" | jq -r '.signing_key_fingerprint'
75
+ }
76
+
77
+ # Function to get fingerprint from a Debian PPA.
78
+ debian_fingerprint() {
79
+ ppa=$1
80
+ ppa_url=$2
81
+ package_dist=$3
82
+ release_pub=/tmp/"${ppa/\//-}".gpg
83
+ get -q -n "$release_pub" "$ppa_url"/dists/"$package_dist"/Release.gpg
84
+ gpg --list-packets "$release_pub" | grep -Eo 'fpr\sv4\s.*[a-zA-Z0-9]+' | head -n 1 | cut -d ' ' -f 3
85
+ }
86
+
87
+ # Function to add a GPG key.
88
+ add_key() {
89
+ ppa=${1:-ondrej/php}
90
+ ppa_url=$2
91
+ package_dist=$3
92
+ key_source=$4
93
+ key_file=$5
94
+ key_urls=("$key_source")
95
+ if [[ "$key_source" =~ launchpad.net|debian.org|setup-php.com ]]; then
96
+ fingerprint="$("${ID}"_fingerprint "$ppa" "$ppa_url" "$package_dist")"
97
+ sks_params="op=get&options=mr&exact=on&search=0x$fingerprint"
98
+ key_urls=("${sks[@]/%/\/pks\/lookup\?"$sks_params"}")
99
+ fi
100
+ [ ! -e "$key_source" ] && get -q -n "$key_file" "${key_urls[@]}"
101
+ if [[ "$(file "$key_file")" =~ .*('Public-Key (old)'|'Secret-Key') ]]; then
102
+ sudo gpg --batch --yes --dearmor "$key_file" >/dev/null 2>&1 && sudo mv "$key_file".gpg "$key_file"
103
+ fi
104
+ }
105
+
106
+ # Function to check if a PPA and its lists exist
107
+ check_lists() {
108
+ ppa=$1
109
+ ppa_search=$2
110
+ if grep -Eqr "$ppa_search" "$list_dir"; then
111
+ list_count="$(sudo find /var/lib/apt/lists -type f -name "*${ppa/\//_}*" | wc -l)"
112
+ if [ "$list_count" = "0" ]; then
113
+ update_lists "$ppa" "$ppa_search"
114
+ fi
115
+ return 0;
116
+ else
117
+ return 1;
118
+ fi
119
+ }
120
+
121
+ # Function to add a sources list.
122
+ add_list() {
123
+ ppa=${1-ondrej/php}
124
+ ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
125
+ key_source=${3:-"$ppa_url"}
126
+ package_dist=${4:-"$VERSION_CODENAME"}
127
+ branches=${5:-main}
128
+ ppa_search="deb .*$ppa_url $package_dist .*$branches"
129
+ if check_lists "$ppa" "$ppa_search"; then
130
+ echo "Repository $ppa already exists";
131
+ return 1;
132
+ else
133
+ arch=$(dpkg --print-architecture)
134
+ [ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
135
+ add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
136
+ echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa/\//-}".list >/dev/null 2>&1
137
+ update_lists "$ppa" "$ppa_search"
138
+ . /etc/os-release
139
+ fi
140
+ return 0;
141
+ }
142
+
143
+ # Function to remove a PPA.
144
+ remove_list() {
145
+ ppa=${1-ondrej/php}
146
+ ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
147
+ grep -lr "$ppa_url" "$list_dir" | xargs -n1 sudo rm -f
148
+ sudo rm -f "$key_dir"/"${ppa/\//-}"-keyring || true
149
+ }
150
+
151
+ # Function to add a PPA.
152
+ add_ppa() {
153
+ set_base_version
154
+ ppa=${1:-ondrej/php}
155
+ if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
156
+ add_list "$ppa"
157
+ elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then
158
+ add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg
159
+ else
160
+ add_list "$ppa"
161
+ fi
162
+ exit_code="$?"
163
+ . /etc/os-release
164
+ return $exit_code
165
+ }
166
+
167
+ # Function to update a PPA.
168
+ update_ppa() {
169
+ set_base_version
170
+ ppa=${1:-ondrej/php}
171
+ ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
172
+ package_dist=${4:-"$VERSION_CODENAME"}
173
+ branches=${5:-main}
174
+ ppa_search="deb .*$ppa_url $package_dist .*$branches"
175
+ update_lists "$ppa" "$ppa_search"
176
+ . /etc/os-release
177
+ }
178
+
179
+ # Variables
180
+ list_file='/etc/apt/sources.list'
181
+ list_dir="$list_file.d"
182
+ upstream_lsb='/etc/upstream-release/lsb-release'
183
+ lp_api='https://api.launchpad.net/1.0'
184
+ lp_ppa='http://ppa.launchpad.net'
185
+ key_dir='/usr/share/keyrings'
186
+ dist_info_dir='/usr/share/distro-info'
187
+ sury='https://packages.sury.org'
188
+ sks=(
189
+ 'https://keyserver.ubuntu.com'
190
+ 'https://pgp.mit.edu'
191
+ 'https://keys.openpgp.org'
192
+ )
@@ -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 "$env: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 "$env:END_GROUP"
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 "$END_GROUP"
28
+ }
@@ -0,0 +1,14 @@
1
+ Function Add-Symfony() {
2
+ $arch_name ='amd64'
3
+ if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
4
+ $arch_name = '386'
5
+ }
6
+ $url = "https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_windows_${arch_name}.zip"
7
+ Invoke-WebRequest -Uri $url -OutFile $bin_dir\symfony.zip >$null 2>&1
8
+ Expand-Archive -Path $bin_dir\symfony.zip -DestinationPath $bin_dir -Force >$null 2>&1
9
+ Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe >$null 2>&1
10
+ Add-ToProfile $current_profile 'symfony' "New-Alias symfony $bin_dir\symfony.exe"
11
+ Add-ToProfile $current_profile 'symfony_cli' "New-Alias symfony-cli $bin_dir\symfony-cli.exe"
12
+ $tool_version = Get-ToolVersion symfony "-V"
13
+ Add-Log $tick "symfony-cli" "Added symfony-cli $tool_version"
14
+ }
@@ -0,0 +1,13 @@
1
+ add_symfony() {
2
+ if [ "$(uname -s)" = "Linux" ]; then
3
+ echo 'deb [trusted=yes] https://repo.symfony.com/apt/ /' | sudo tee /etc/apt/sources.list.d/symfony-cli.list >/dev/null 2>&1
4
+ update_lists symfony repo.symfony.com
5
+ install_packages symfony-cli
6
+ elif [ "$(uname -s)" = "Darwin" ]; then
7
+ add_brew_tap symfony-cli/homebrew-tap
8
+ brew install symfony-cli/tap/symfony-cli >/dev/null 2>&1
9
+ fi
10
+ sudo ln -s "$(command -v symfony)" "${tool_path_dir:?}"/symfony-cli
11
+ tool_version=$(get_tool_version "symfony" "-V")
12
+ add_log "${tick:?}" "symfony-cli" "Added symfony-cli $tool_version"
13
+ }