setup-php 2.30.4 → 2.31.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.
@@ -55,7 +55,7 @@ update_lists() {
55
55
  if [[ -n "$ppa" && -n "$ppa_search" ]]; then
56
56
  list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
57
57
  status_file=/tmp/"${ppa/\//_}"
58
- elif [ -e "$list_file" ] && grep -Eq '^deb ' "$list_file"; then
58
+ elif [ -e "$list_file" ] && grep -Eq '^deb |^Types deb' "$list_file"; then
59
59
  list="$list_file"
60
60
  fi
61
61
  if [ ! -e "$status_file" ]; then
@@ -88,7 +88,7 @@ add_key() {
88
88
  key_source=$4
89
89
  key_file=$5
90
90
  key_urls=("$key_source")
91
- if [[ "$key_source" =~ launchpad.net|debian.org|setup-php.com ]]; then
91
+ if [[ "$key_source" =~ launchpad.net|debian.org ]]; then
92
92
  fingerprint="$("${ID}"_fingerprint "$ppa" "$ppa_url" "$package_dist")"
93
93
  sks_params="op=get&options=mr&exact=on&search=0x$fingerprint"
94
94
  key_urls=("${sks[@]/%/\/pks\/lookup\?"$sks_params"}")
@@ -153,18 +153,39 @@ check_ppa() {
153
153
  # Function to remove a PPA.
154
154
  remove_list() {
155
155
  ppa=${1-ondrej/php}
156
- ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
157
- grep -lr "$ppa_url" "$list_dir" | xargs -n1 sudo rm -f
156
+ [ -n "$2" ] && ppa_urls=("$2") || ppa_urls=("$lp_ppa/$ppa/ubuntu" "$lpc_ppa/$ppa/ubuntu")
157
+ for ppa_url in "${ppa_urls[@]}"; do
158
+ grep -lr "$ppa_url" "$list_dir" | xargs -n1 sudo rm -f
159
+ done
158
160
  sudo rm -f "$key_dir"/"${ppa/\//-}"-keyring || true
159
161
  }
160
162
 
163
+ # Function to check if ubuntu ppa is up
164
+ is_ubuntu_ppa_up() {
165
+ ppa=${1:-ondrej/php}
166
+ curl -s --connect-timeout 5 --max-time 5 --head --fail "$lp_ppa/$ppa/ubuntu/dists/$VERSION_CODENAME/Release" > /dev/null
167
+ }
168
+
169
+ # Function to add the PPA mirror.
170
+ add_ppa_sp_mirror() {
171
+ ppa=$1
172
+ ppa_name="$(basename "$ppa")"
173
+ remove_list "$ppa" || true
174
+ [ "${debug:?}" = "debug" ] && add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg" "$VERSION_CODENAME" "main/debug"
175
+ add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg"
176
+ }
177
+
161
178
  # Function to add a PPA.
162
179
  add_ppa() {
163
180
  set_base_version
164
181
  ppa=${1:-ondrej/php}
165
182
  if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
166
- [ "${debug:?}" = "debug" ] && add_list "$ppa" "$lp_ppa/$ppa/ubuntu" "$lp_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug"
167
- add_list "$ppa"
183
+ if is_ubuntu_ppa_up "$ppa" ; then
184
+ [ "${debug:?}" = "debug" ] && add_list "$ppa" "$lp_ppa/$ppa/ubuntu" "$lp_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug"
185
+ add_list "$ppa"
186
+ else
187
+ add_ppa_sp_mirror "$ppa"
188
+ fi
168
189
  elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then
169
190
  [ "${debug:?}" = "debug" ] && add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg "$VERSION_CODENAME" "main/debug"
170
191
  add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg
@@ -189,14 +210,17 @@ update_ppa() {
189
210
  }
190
211
 
191
212
  # Variables
192
- list_file='/etc/apt/sources.list'
193
- list_dir="$list_file.d"
213
+ list_dir='/etc/apt/sources.list.d'
214
+ list_file="/etc/apt/sources.list.d/$ID.sources"
215
+ [ -e "$list_file" ] || list_file='/etc/apt/sources.list'
194
216
  upstream_lsb='/etc/upstream-release/lsb-release'
195
217
  lp_api='https://api.launchpad.net/1.0'
196
218
  lp_ppa='http://ppa.launchpad.net'
219
+ lpc_ppa='https://ppa.launchpadcontent.net'
197
220
  key_dir='/usr/share/keyrings'
198
221
  dist_info_dir='/usr/share/distro-info'
199
222
  sury='https://packages.sury.org'
223
+ sp='https://setup-php.com'
200
224
  sks=(
201
225
  'https://keyserver.ubuntu.com'
202
226
  'https://pgp.mit.edu'