File tree Expand file tree Collapse file tree
scripts/install/repositories Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,8 +78,38 @@ retry_add_ppa ppa:lepapareil/hurl
7878# add-apt-repository -yn ppa:tuxinvader/lts-mainline-longterm
7979
8080# PHP
81- # add-apt-repository handles keyring automatically on Ubuntu 24.04+
82- retry_add_ppa ppa:ondrej/php
81+ install_php_repository () {
82+ local ubuntu_codename
83+ local sury_keyring_deb=" /tmp/debsuryorg-archive-keyring.deb"
84+
85+ ubuntu_codename=" $( lsb_release -cs) "
86+
87+ # Disable legacy or stale PHP sources when migrating an existing install.
88+ find /etc/apt/sources.list.d/ -type f \( -name ' *.list' -o -name ' *.sources' \) \
89+ -exec grep -lE ' ondrej/php|ppa\.launchpad(content)?\.net/ondrej/php|packages\.sury\.org/php' {} \; \
90+ | while IFS= read -r apt_source; do
91+ mv " ${apt_source} " " ${apt_source} .save"
92+ done
93+
94+ curl -fsSL -o " ${sury_keyring_deb} " " https://packages.sury.org/debsuryorg-archive-keyring.deb" || {
95+ echo " Error: Failed to download the DEB.SURY.ORG archive keyring."
96+ exit 1
97+ }
98+
99+ dpkg -i " ${sury_keyring_deb} " || {
100+ echo " Error: Failed to install the DEB.SURY.ORG archive keyring."
101+ exit 1
102+ }
103+ rm -f " ${sury_keyring_deb} "
104+
105+ if [[ ! -s /usr/share/keyrings/debsuryorg-archive-keyring.gpg ]]; then
106+ echo " Error: DEB.SURY.ORG archive keyring was not installed."
107+ exit 1
108+ fi
109+
110+ echo " deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ ${ubuntu_codename} main" | sudo tee /etc/apt/sources.list.d/php.list
111+ }
112+ install_php_repository
83113
84114# Python
85115retry_add_ppa ppa:deadsnakes/ppa
You can’t perform that action at this time.
0 commit comments