diff --git a/src/scripts/tools/ppa.sh b/src/scripts/tools/ppa.sh index d9c28fb69..17f5fbb7a 100644 --- a/src/scripts/tools/ppa.sh +++ b/src/scripts/tools/ppa.sh @@ -88,7 +88,7 @@ add_key() { key_source=$4 key_file=$5 key_urls=("$key_source") - if [[ "$key_source" =~ launchpad.net|debian.org|setup-php.com ]]; then + if [[ "$key_source" =~ launchpad.net|debian.org ]]; then fingerprint="$("${ID}"_fingerprint "$ppa" "$ppa_url" "$package_dist")" sks_params="op=get&options=mr&exact=on&search=0x$fingerprint" key_urls=("${sks[@]/%/\/pks\/lookup\?"$sks_params"}") @@ -158,13 +158,24 @@ remove_list() { sudo rm -f "$key_dir"/"${ppa/\//-}"-keyring || true } +# Function to check if launchpad is up +is_launchpad_up() { + curl -s --head --fail "$lp_ppa/ondrej/php/ubuntu/dists/$VERSION_CODENAME/Release" > /dev/null +} + # Function to add a PPA. add_ppa() { set_base_version ppa=${1:-ondrej/php} if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then - [ "${debug:?}" = "debug" ] && add_list "$ppa" "$lp_ppa/$ppa/ubuntu" "$lp_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug" - add_list "$ppa" + if is_launchpad_up; then + [ "${debug:?}" = "debug" ] && add_list "$ppa" "$lp_ppa/$ppa/ubuntu" "$lp_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug" + add_list "$ppa" + else + ppa_name="$(basename "$ppa")" + [ "${debug:?}" = "debug" ] && add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg" "$VERSION_CODENAME" "main/debug" + add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg" + fi elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then [ "${debug:?}" = "debug" ] && add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg "$VERSION_CODENAME" "main/debug" add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg @@ -198,6 +209,7 @@ lp_ppa='http://ppa.launchpad.net' key_dir='/usr/share/keyrings' dist_info_dir='/usr/share/distro-info' sury='https://packages.sury.org' +sp='https://setup-php.com' sks=( 'https://keyserver.ubuntu.com' 'https://pgp.mit.edu'