setup-php 2.35.5 → 2.37.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 (58) hide show
  1. package/README.md +103 -90
  2. package/lib/core.d.ts +8 -0
  3. package/lib/core.js +55 -0
  4. package/lib/core.js.map +1 -0
  5. package/lib/extensions.js +17 -16
  6. package/lib/extensions.js.map +1 -1
  7. package/lib/fetch.js +25 -70
  8. package/lib/fetch.js.map +1 -1
  9. package/lib/install.js +1 -1
  10. package/lib/install.js.map +1 -1
  11. package/lib/tools.d.ts +48 -21
  12. package/lib/tools.js +175 -154
  13. package/lib/tools.js.map +1 -1
  14. package/lib/utils.js +5 -5
  15. package/lib/utils.js.map +1 -1
  16. package/package.json +23 -22
  17. package/src/configs/brew_extensions +20 -0
  18. package/src/configs/darwin_libs +22 -0
  19. package/src/configs/linux_libs +22 -0
  20. package/src/configs/php-versions.json +5 -4
  21. package/src/configs/tools.json +2 -1
  22. package/src/core.ts +112 -0
  23. package/src/extensions.ts +39 -32
  24. package/src/fetch.ts +28 -42
  25. package/src/install.ts +1 -1
  26. package/src/scripts/darwin.sh +45 -19
  27. package/src/scripts/extensions/add_extensions.sh +5 -3
  28. package/src/scripts/extensions/couchbase.sh +13 -2
  29. package/src/scripts/extensions/firebird.sh +6 -23
  30. package/src/scripts/extensions/gearman.sh +3 -1
  31. package/src/scripts/extensions/http.ps1 +7 -5
  32. package/src/scripts/extensions/ibm.ps1 +56 -0
  33. package/src/scripts/extensions/ibm.sh +106 -0
  34. package/src/scripts/extensions/oci.sh +2 -1
  35. package/src/scripts/extensions/patches/amqp.sh +5 -0
  36. package/src/scripts/extensions/patches/common.sh +31 -8
  37. package/src/scripts/extensions/patches/geos.sh +1 -5
  38. package/src/scripts/extensions/patches/pdo_oci.sh +3 -0
  39. package/src/scripts/extensions/patches/pdo_sqlsrv.sh +5 -0
  40. package/src/scripts/extensions/patches/phpize.sh +2 -1
  41. package/src/scripts/extensions/relay.sh +25 -35
  42. package/src/scripts/extensions/source.sh +26 -6
  43. package/src/scripts/extensions/sqlsrv.ps1 +2 -0
  44. package/src/scripts/extensions/sqlsrv.sh +2 -0
  45. package/src/scripts/linux.sh +50 -10
  46. package/src/scripts/tools/add_tools.ps1 +52 -26
  47. package/src/scripts/tools/add_tools.sh +41 -19
  48. package/src/scripts/tools/blackfire.sh +1 -1
  49. package/src/scripts/tools/brew.sh +130 -0
  50. package/src/scripts/tools/grpc_php_plugin.sh +2 -2
  51. package/src/scripts/tools/ppa.sh +201 -28
  52. package/src/scripts/tools/symfony.ps1 +28 -14
  53. package/src/scripts/tools/symfony.sh +34 -31
  54. package/src/scripts/unix.sh +8 -4
  55. package/src/scripts/win32.ps1 +9 -4
  56. package/src/tools.ts +312 -203
  57. package/src/utils.ts +6 -7
  58. package/src/scripts/extensions/patches/gearman.sh +0 -5
@@ -50,12 +50,23 @@ update_lists_helper() {
50
50
  update_lists() {
51
51
  local ppa=${1:-}
52
52
  local ppa_search=${2:-}
53
+ local status_token=${3:-$ppa_search}
53
54
  local list=
54
- status_file=/tmp/os_lists
55
+ local status_file=/tmp/os_lists
56
+ local hash_cmd
55
57
  if [[ -n "$ppa" && -n "$ppa_search" ]]; then
56
- list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
57
- status_file=/tmp/"$(echo -n "$ppa_search" | shasum -a 256 | cut -d ' ' -f 1)"
58
- elif [ -e "$list_file" ] && grep -Eq '^deb |^Types deb' "$list_file"; then
58
+ if [ -f "$ppa_search" ]; then
59
+ list="$ppa_search"
60
+ else
61
+ list="$(grep -Elr "$ppa_search" "$list_dir" 2>/dev/null | head -n 1)"
62
+ fi
63
+ hash_cmd="$(command -v sha256sum || command -v shasum)"
64
+ if [ -n "$status_token" ] && [ -n "$hash_cmd" ]; then
65
+ status_file=/tmp/os_lists_"$(echo -n "$status_token" | $hash_cmd | awk '{print $1}')"
66
+ elif [ -n "$status_token" ]; then
67
+ status_file=/tmp/os_lists_$(date +%s)
68
+ fi
69
+ elif [ -e "$list_file" ] && grep -Eq '^deb |^Types: *deb' "$list_file"; then
59
70
  list="$list_file"
60
71
  fi
61
72
  if [ ! -e "$status_file" ]; then
@@ -64,6 +75,81 @@ update_lists() {
64
75
  fi
65
76
  }
66
77
 
78
+ # Determine whether deb822 sources are the default on this system.
79
+ get_sources_format() {
80
+ if [ -n "$sources_format" ]; then
81
+ echo "$sources_format"
82
+ return
83
+ fi
84
+ sources_format=deb
85
+ if [ -e "$list_dir"/ubuntu.sources ] || [ -e "$list_dir"/debian.sources ]; then
86
+ sources_format="deb822"
87
+ elif ! [[ "$ID" =~ ubuntu|debian ]]; then
88
+ find "$list_dir" -type f -name '*.sources' | grep -q . && sources_format="deb822"
89
+ fi
90
+ echo "$sources_format"
91
+ }
92
+
93
+ # Function to get sources file extension.
94
+ get_sources_extension() {
95
+ [ "$1" = "deb822" ] && echo "sources" || echo "list"
96
+ }
97
+
98
+ # Function to escape regex special characters.
99
+ escape_regex() {
100
+ printf '%s' "$1" | sed -e 's/[][\.^$*+?{}()|\/]/\\&/g'
101
+ }
102
+
103
+ # Function to merge two components strings.
104
+ merge_components() {
105
+ local out=() t
106
+ for t in $1 $2; do [[ $t && " ${out[*]} " != *" $t "* ]] && out+=("$t"); done
107
+ printf '%s\n' "${out[*]}"
108
+ }
109
+
110
+ # Function to merge components from a file.
111
+ merge_components_from_file() {
112
+ local path=$1
113
+ local incoming=$2
114
+ local current=
115
+ if [ -n "$path" ] && [ -e "$path" ]; then
116
+ if grep -Eq '^Components:' "$path"; then
117
+ current="$(grep -E '^Components:' "$path" | head -n 1 | cut -d ':' -f 2 | xargs)"
118
+ else
119
+ current="$(sed -E -n 's/^deb[[:space:]]+(\[[^]]*\][[:space:]]+)?[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]+//p' "$path" | head -n 1 | xargs)"
120
+ fi
121
+ fi
122
+ local merged
123
+ merged="$(merge_components "$current" "$incoming")"
124
+ if [ -z "$merged" ] || [ "$merged" = "$current" ]; then
125
+ return 1
126
+ fi
127
+ printf '%s\n' "$merged"
128
+ }
129
+
130
+ # Function to get repo patterns based on format.
131
+ get_repo_patterns() {
132
+ local list_format=$1
133
+ local ppa_url=$2
134
+ local package_dist=$3
135
+ local branches=$4
136
+ local escaped_url
137
+ local escaped_dist
138
+ local escaped_branches
139
+ escaped_url="$(escape_regex "$ppa_url")"
140
+ escaped_dist="$(escape_regex "$package_dist")"
141
+ escaped_branches="$(escape_regex "$branches")"
142
+ local deb_primary="^deb[[:space:]]+(\\[[^]]*\\][[:space:]]+)?${escaped_url}[[:space:]]+${escaped_dist}[[:space:]]"
143
+ local deb_secondary="^deb[[:space:]]+(\\[[^]]*\\][[:space:]]+)?${escaped_url}[[:space:]]+${escaped_dist}[[:space:]]+.*${escaped_branches}([[:space:]]|$)"
144
+ local deb822_primary="^URIs: ${escaped_url}$"
145
+ local deb822_secondary="^Suites: ${escaped_dist}$"
146
+ if [ "$list_format" = "deb822" ]; then
147
+ printf '%s|%s\n' "$deb822_primary" "$deb822_secondary"
148
+ else
149
+ printf '%s|%s\n' "$deb_primary" "$deb_secondary"
150
+ fi
151
+ }
152
+
67
153
  # Function to get fingerprint from an Ubuntu PPA.
68
154
  ubuntu_fingerprint() {
69
155
  ppa="$1"
@@ -104,19 +190,78 @@ add_key() {
104
190
  fi
105
191
  }
106
192
 
193
+ # Function to handle existing list files.
194
+ handle_existing_list() {
195
+ local ppa=$1
196
+ local list_format=$2
197
+ local branches=$3
198
+ local merged_components
199
+ if [ -z "$check_lists_file" ]; then
200
+ echo "Repository $ppa ($branches) already exists" && return 1
201
+ fi
202
+ if merged_components="$(merge_components_from_file "$check_lists_file" "$branches")"; then
203
+ sudo rm -f "$check_lists_file" && printf '%s\n' "$merged_components" && return 0
204
+ fi
205
+ if [[ "$list_format" = "deb822" && "$check_lists_file" = *.list ]]; then
206
+ sudo rm -f "$check_lists_file" && printf '%s\n' "$branches" && return 0
207
+ fi
208
+ echo "Repository $ppa ($branches) already exists" && return 1
209
+ }
210
+
211
+ # Function to write a list file.
212
+ write_list() {
213
+ local type=$1
214
+ local ppa=$2
215
+ local url=$3
216
+ local suite=$4
217
+ local components=$5
218
+ local key_file=$6
219
+ local list_basename="${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$suite"
220
+ local arch
221
+ arch="$(dpkg --print-architecture)"
222
+ sudo rm -f "$list_dir"/"${ppa/\//-}".list "$list_dir"/"${ppa/\//-}".sources "$list_dir"/"$list_basename".list "$list_dir"/"$list_basename".sources || true
223
+ if [ "$type" = "deb822" ]; then
224
+ cat <<EOF | sudo tee "$list_dir"/"$list_basename".sources >/dev/null
225
+ Types: deb
226
+ URIs: $url
227
+ Suites: $suite
228
+ Components: $components
229
+ Architectures: $arch
230
+ Signed-By: $key_file
231
+ EOF
232
+ else
233
+ echo "deb [arch=$arch signed-by=$key_file] $url $suite $components" | sudo tee "$list_dir"/"$list_basename".list >/dev/null 2>&1
234
+ fi
235
+ }
236
+
107
237
  # Function to check if a PPA and its lists exist
108
238
  check_lists() {
109
- ppa=$1
110
- ppa_search=$2
111
- if grep -Eqr "$ppa_search" "$list_dir"; then
239
+ local ppa=$1
240
+ local primary=${2:-}
241
+ local secondary=${3:-}
242
+ local status_token=${4:-$primary}
243
+ local match_file=
244
+ check_lists_file=
245
+ if [ -n "$primary" ]; then
246
+ match_file=$(grep -Elr "$primary" "$list_dir" 2>/dev/null | head -n 1)
247
+ fi
248
+ if [ -z "$match_file" ] && [ -n "$secondary" ]; then
249
+ local candidate
250
+ candidate=$(grep -Elr "$secondary" "$list_dir" 2>/dev/null | head -n 1)
251
+ if [ -n "$candidate" ] && { [ -z "$primary" ] || grep -Eq "$primary" "$candidate"; }; then
252
+ match_file="$candidate"
253
+ fi
254
+ fi
255
+ if [ -n "$match_file" ]; then
256
+ local list_count
112
257
  list_count="$(sudo find /var/lib/apt/lists -type f -name "*${ppa/\//_}*" | wc -l)"
113
258
  if [ "$list_count" = "0" ]; then
114
- update_lists "$ppa" "$ppa_search"
259
+ update_lists "$ppa" "$match_file" "$status_token"
115
260
  fi
116
- return 0;
117
- else
118
- return 1;
261
+ check_lists_file="$match_file"
262
+ return 0
119
263
  fi
264
+ return 1
120
265
  }
121
266
 
122
267
  # Function to add a sources list.
@@ -126,19 +271,32 @@ add_list() {
126
271
  key_source=${3:-"$ppa_url"}
127
272
  package_dist=${4:-"$VERSION_CODENAME"}
128
273
  branches=${5:-main}
129
- ppa_search="deb .*$ppa_url $package_dist .*$branches$"
130
- if check_lists "$ppa" "$ppa_search"; then
131
- echo "Repository $ppa already exists";
132
- return 1;
133
- else
134
- arch=$(dpkg --print-architecture)
135
- [ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
136
- add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
137
- sudo rm -rf "$list_dir"/"${ppa/\//-}".list || true
138
- echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$package_dist".list >/dev/null 2>&1
139
- update_lists "$ppa" "$ppa_search"
140
- . /etc/os-release
274
+ local list_format
275
+ local list_extension
276
+ local status_token
277
+ local resolved_branches
278
+ local list_path=
279
+ list_format="$(get_sources_format)"
280
+ list_extension="$(get_sources_extension "$list_format")"
281
+ status_token="${ppa_url}|${package_dist}|${branches}"
282
+ IFS='|' read -r primary_pattern secondary_pattern <<< "$(get_repo_patterns "$list_format" "$ppa_url" "$package_dist" "$branches")"
283
+ if check_lists "$ppa" "$primary_pattern" "$secondary_pattern" "$status_token"; then
284
+ list_path="$check_lists_file"
285
+ if resolved_branches="$(handle_existing_list "$ppa" "$list_format" "$branches")"; then
286
+ branches="$resolved_branches"
287
+ else
288
+ [ -n "$resolved_branches" ] && echo "$resolved_branches" && return 1
289
+ fi
290
+ check_lists_file=
291
+ IFS='|' read -r primary_pattern secondary_pattern <<< "$(get_repo_patterns "$list_format" "$ppa_url" "$package_dist" "$branches")"
292
+ status_token="${ppa_url}|${package_dist}|${branches}"
141
293
  fi
294
+ [ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
295
+ add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
296
+ write_list "$list_format" "$ppa" "$ppa_url" "$package_dist" "$branches" "$key_file"
297
+ list_path="$list_dir"/"${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$package_dist"."$list_extension"
298
+ update_lists "$ppa" "$list_path" "$status_token"
299
+ . /etc/os-release
142
300
  return 0;
143
301
  }
144
302
 
@@ -148,8 +306,12 @@ check_ppa() {
148
306
  ppa_url=${2:-"$lpc_ppa/$ppa/ubuntu"}
149
307
  package_dist=${3:-"$VERSION_CODENAME"}
150
308
  branches=${4:-main}
151
- ppa_search="deb .*$ppa_url $package_dist .*$branches$"
152
- if check_lists "$ppa" "$ppa_search"; then
309
+ local list_format
310
+ list_format="$(get_sources_format)"
311
+ IFS='|' read -r primary_pattern secondary_pattern <<< "$(get_repo_patterns "$list_format" "$ppa_url" "$package_dist" "$branches")"
312
+ local status_token
313
+ status_token="${ppa_url}|${package_dist}|${branches}"
314
+ if check_lists "$ppa" "$primary_pattern" "$secondary_pattern" "$status_token"; then
153
315
  return 0;
154
316
  else
155
317
  return 1;
@@ -163,7 +325,7 @@ remove_list() {
163
325
  for ppa_url in "${ppa_urls[@]}"; do
164
326
  grep -lr "$ppa_url" "$list_dir" | xargs -n1 sudo rm -f
165
327
  done
166
- sudo rm -f "$key_dir"/"${ppa/\//-}"-keyring || true
328
+ sudo rm -f "$key_dir"/"${ppa/\//-}"-keyring /tmp/os_lists* || true
167
329
  }
168
330
 
169
331
  # Function to check if ubuntu ppa is up
@@ -213,12 +375,23 @@ update_ppa() {
213
375
  ppa_url=${2:-"$lpc_ppa/$ppa/ubuntu"}
214
376
  package_dist=${4:-"$VERSION_CODENAME"}
215
377
  branches=${5:-main}
216
- ppa_search="deb .*$ppa_url $package_dist .*$branches"
217
- update_lists "$ppa" "$ppa_search"
378
+ local list_format
379
+ list_format="$(get_sources_format)"
380
+ IFS='|' read -r primary_pattern secondary_pattern <<< "$(get_repo_patterns "$list_format" "$ppa_url" "$package_dist" "$branches")"
381
+ local list_path
382
+ list_path="$(grep -Elr "$primary_pattern" "$list_dir" 2>/dev/null | head -n 1)"
383
+ if [ -z "$list_path" ] && [ -n "$secondary_pattern" ]; then
384
+ list_path="$(grep -Elr "$secondary_pattern" "$list_dir" 2>/dev/null | head -n 1)"
385
+ fi
386
+ local status_token
387
+ status_token="${ppa_url}|${package_dist}|${branches}"
388
+ update_lists "$ppa" "${list_path:-$primary_pattern}" "$status_token"
218
389
  . /etc/os-release
219
390
  }
220
391
 
221
392
  # Variables
393
+ sources_format=
394
+ check_lists_file=
222
395
  list_dir='/etc/apt/sources.list.d'
223
396
  list_file="/etc/apt/sources.list.d/$ID.sources"
224
397
  [ -e "$list_file" ] || list_file='/etc/apt/sources.list'
@@ -1,18 +1,32 @@
1
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
- Get-File -Url $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
- if(Test-Path $bin_dir\symfony.exe) {
10
- Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1
11
- Add-ToProfile $current_profile 'symfony' "New-Alias symfony $bin_dir\symfony.exe"
12
- Add-ToProfile $current_profile 'symfony_cli' "New-Alias symfony-cli $bin_dir\symfony-cli.exe"
13
- $tool_version = Get-ToolVersion symfony "-V"
14
- Add-Log $tick "symfony-cli" "Added symfony-cli $tool_version"
2
+ param(
3
+ [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Symfony version to be installed')]
4
+ [string] $protobuf_tag
5
+ )
6
+ $protobuf_tag = $protobuf_tag.replace('v', '')
7
+ if($protobuf_tag -ne 'latest' -and $protobuf_tag -notmatch '^\d+(\.\d+)*$') {
8
+ Add-Log $cross "symfony-cli" "Invalid symfony version: $protobuf_tag"
15
9
  } else {
16
- Add-Log $cross "symfony-cli" "Could not setup symfony-cli"
10
+ $arch_name = 'amd64'
11
+ if (-not ([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
12
+ $arch_name = '386'
13
+ }
14
+ $symfony_releases = "https://github.com/symfony-cli/symfony-cli/releases"
15
+ if ($protobuf_tag -eq 'latest') {
16
+ $url = "$symfony_releases/latest/download/symfony-cli_windows_${arch_name}.zip"
17
+ } else {
18
+ $url = "$symfony_releases/download/v$protobuf_tag/symfony-cli_windows_${arch_name}.zip"
19
+ }
20
+ Get-File -Url $url -OutFile $bin_dir\symfony.zip > $null 2>&1
21
+ Expand-Archive -Path $bin_dir\symfony.zip -DestinationPath $bin_dir -Force > $null 2>&1
22
+ if (Test-Path $bin_dir\symfony.exe) {
23
+ Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1
24
+ Add-ToProfile $current_profile 'symfony' "New-Alias symfony $bin_dir\symfony.exe"
25
+ Add-ToProfile $current_profile 'symfony_cli' "New-Alias symfony-cli $bin_dir\symfony-cli.exe"
26
+ $tool_version = Get-ToolVersion symfony "-V"
27
+ Add-Log $tick "symfony-cli" "Added symfony-cli $tool_version"
28
+ } else {
29
+ Add-Log $cross "symfony-cli" "Could not setup symfony-cli"
30
+ }
17
31
  }
18
32
  }
@@ -1,41 +1,44 @@
1
- add_symfony_with_brew() {
2
- add_brew_tap symfony-cli/homebrew-tap
3
- brew install symfony-cli/tap/symfony-cli
4
- }
5
-
6
1
  get_symfony_artifact_url() {
7
- arch=$(dpkg --print-architecture)
8
- url=$(get -s -n "" https://raw.githubusercontent.com/symfony-cli/homebrew-tap/main/Formula/symfony-cli.rb 2<&1 | grep -m 1 "url.*linux.*${arch}" | cut -d\" -f 2)
9
- if [ -z "$url" ]; then
10
- url=$(get -s -n "" https://api.github.com/repos/symfony-cli/symfony-cli/releases 2<&1 | grep -m 1 "url.*linux.*${arch}.*gz\"" | cut -d\" -f 4)
11
- fi
12
- echo "$url"
2
+ local symfony_tag=$1
3
+ local os
4
+ local arch
5
+ os="$(uname -s | tr '[:upper:]' '[:lower:]')"
6
+ arch="$(uname -m)"
7
+ case "$arch" in
8
+ arm|armv6*|armv7*) arch="armv6" ;;
9
+ aarch64*|armv8*|arm64) arch="arm64" ;;
10
+ i[36]86) arch="386" ;;
11
+ x86_64|amd64) arch="amd64" ;;
12
+ esac
13
+ [ "$os" = "darwin" ] && arch="all"
14
+ symfony_releases="https://github.com/symfony-cli/symfony-cli/releases"
15
+ if [ "$symfony_tag" = "latest" ]; then
16
+ echo "$symfony_releases/latest/download/symfony-cli_${os}_${arch}.tar.gz"
17
+ else
18
+ echo "$symfony_releases/download/v$symfony_tag/symfony-cli_${os}_${arch}.tar.gz"
19
+ fi
13
20
  }
14
21
 
15
22
  add_symfony_helper() {
16
- if [ "$(uname -s)" = "Linux" ]; then
17
- url="$(get_symfony_artifact_url)"
18
- if [ -z "$url" ]; then
19
- . "${0%/*}"/tools/brew.sh
20
- configure_brew
21
- add_symfony_with_brew
22
- else
23
- get -s -n "" "$url" | sudo tar -xz -C "${tool_path_dir:?}" 2>/dev/null
24
- sudo chmod a+x /usr/local/bin/symfony
25
- fi
26
- elif [ "$(uname -s)" = "Darwin" ]; then
27
- add_symfony_with_brew
28
- fi
23
+ local install_dir=/usr/local/bin
24
+ [ "$(uname -s)" = "Darwin" ] && install_dir=${brew_prefix:?}/bin
25
+ get -s -n "" "$(get_symfony_artifact_url "$symfony_tag")" | sudo tar -xz -C "$install_dir" 2>/dev/null
26
+ sudo chmod a+x "$install_dir"/symfony
29
27
  }
30
28
 
31
29
  add_symfony() {
32
- add_symfony_helper >/dev/null 2>&1
33
- symfony_path="$(command -v symfony)"
34
- if [[ -n "$symfony_path" ]]; then
35
- sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli
36
- tool_version=$(get_tool_version "symfony" "-V")
37
- add_log "${tick:?}" "symfony-cli" "Added symfony-cli $tool_version"
30
+ local symfony_tag="${1/v/}"
31
+ if ! [[ "$symfony_tag" =~ ^[0-9]+(\.[0-9]+)*$ || "$symfony_tag" == 'latest' ]]; then
32
+ add_log "${cross:?}" "symfony-cli" "Version '$symfony_tag' is not valid for symfony-cli"
38
33
  else
39
- add_log "${cross:?}" "symfony-cli" "Could not setup symfony-cli"
34
+ add_symfony_helper "$symfony_tag" >/dev/null 2>&1
35
+ symfony_path="$(command -v symfony)"
36
+ if [[ -n "$symfony_path" ]]; then
37
+ sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli
38
+ tool_version=$(get_tool_version "symfony" "-V")
39
+ add_log "${tick:?}" "symfony-cli" "Added symfony-cli $tool_version"
40
+ else
41
+ add_log "${cross:?}" "symfony-cli" "Could not setup symfony-cli"
42
+ fi
40
43
  fi
41
44
  }
@@ -4,7 +4,8 @@ export cross="✗"
4
4
  export curl_opts=(-sL)
5
5
  export old_versions="5.[3-5]"
6
6
  export jit_versions="8.[0-9]"
7
- export nightly_versions="8.[3-9]"
7
+ export php_builder_versions="8.[3-9]"
8
+ export nightly_versions="8.[6-9]"
8
9
  export xdebug3_versions="7.[2-4]|8.[0-9]"
9
10
  export latest="releases/latest/download"
10
11
  export github="https://github.com/shivammathur"
@@ -58,6 +59,7 @@ read_env() {
58
59
  -n "$ACT" || -n "$CONTAINER" ]] && _runner=self-hosted || _runner=github
59
60
  runner="${runner:-${RUNNER:-$_runner}}"
60
61
  tool_path_dir="${setup_php_tools_dir:-${SETUP_PHP_TOOLS_DIR:-/usr/local/bin}}"
62
+ tool_cache_path_dir="${setup_php_tool_cache_dir:-${SETUP_PHP_TOOL_CACHE_DIR:-${RUNNER_TOOL_CACHE:-/opt/hostedtoolcache}/setup-php/tools}}"
61
63
 
62
64
  if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
63
65
  fail_fast=true
@@ -79,6 +81,7 @@ read_env() {
79
81
  export update
80
82
  export ts
81
83
  export tool_path_dir
84
+ export tool_cache_path_dir
82
85
  }
83
86
 
84
87
  # Function to create a lock.
@@ -169,14 +172,15 @@ get_shell_profile() {
169
172
  # Function to add a path to the PATH variable.
170
173
  add_path() {
171
174
  path_to_add=$1
172
- [[ ":$PATH:" == *":$path_to_add:"* ]] && return
175
+ action=$2
176
+ [[ "$action" == "verify" && ":$PATH:" == *":$path_to_add:"* ]] && return
173
177
  if [[ -n "$GITHUB_PATH" ]]; then
174
- echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1
178
+ printf '%s\n%s' "$path_to_add" "$(grep -v "^${path_to_add}$" "$GITHUB_PATH" 2>/dev/null)" > "$GITHUB_PATH"
175
179
  else
176
180
  profile=$(get_shell_profile)
177
181
  ([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1
178
182
  fi
179
- export PATH="${PATH:+${PATH}:}$path_to_add"
183
+ [[ ":$PATH:" == *":$path_to_add:"* ]] || export PATH="${PATH:+${PATH}:}$path_to_add"
180
184
  }
181
185
 
182
186
  # Function to add environment variables using a PATH.
@@ -81,9 +81,10 @@ Function Get-PathFromRegistry {
81
81
  # Function to add a location to PATH.
82
82
  Function Add-Path {
83
83
  param(
84
- [string]$PathItem
84
+ [string]$PathItem,
85
+ [switch]$Force
85
86
  )
86
- if("$env:PATH;".contains("$PathItem;")) {
87
+ if(-not($Force) -and "$env:PATH;".contains("$PathItem;")) {
87
88
  return
88
89
  }
89
90
  if ($env:GITHUB_PATH) {
@@ -323,7 +324,7 @@ $php_builder = "$github/shivammathur/php-builder-windows"
323
324
  $current_profile = "$env:TEMP\setup-php.ps1"
324
325
  $ProgressPreference = 'SilentlyContinue'
325
326
  $jit_versions = '8.[0-9]'
326
- $nightly_versions = '8.[2-9]'
327
+ $nightly_versions = '8.[6-9]'
327
328
  $xdebug3_versions = "7.[2-4]|8.[0-9]"
328
329
  $enable_extensions = ('openssl', 'curl', 'mbstring')
329
330
 
@@ -375,6 +376,7 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
375
376
  if(-not(Test-Path -LiteralPath $current_profile)) {
376
377
  New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
377
378
  }
379
+ Add-Path -PathItem $bin_dir -Force
378
380
  }
379
381
 
380
382
  $src = Join-Path -Path $PSScriptRoot -ChildPath \..
@@ -444,9 +446,12 @@ if($installed.MajorMinorVersion -ne $version) {
444
446
  }
445
447
  if($version -lt "5.5") {
446
448
  ('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Invoke-WebRequest -Uri "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ >$null 2>&1 }
447
- } else {
449
+ } elseif($version -lt "8.5") {
448
450
  $enable_extensions += ('opcache')
449
451
  }
452
+ if($version -ge "8.5" -and (Test-Path $ext_dir\php_opcache.dll)) {
453
+ Remove-Item $ext_dir\php_opcache.dll -Force
454
+ }
450
455
  Enable-PhpExtension -Extension ($enable_extensions | Where-Object { Test-Path $ext_dir\php_$_.dll }) -Path $php_dir
451
456
  Add-PhpCAInfo
452
457
  Add-OpenSSLConf