Skip to content

Commit 152a737

Browse files
chapterjasonclaude
andcommitted
Skip Sury extensions not packaged separately per PHP minor
PHP 8.5 made opcache a core, always-available extension; Sury ships it inside php8.5-common rather than as php8.5-opcache. The previous flat package list aborted the build (`Unable to locate package php8.5-opcache`). Filter the extension set through `apt-cache show` before apt-get, log what got skipped, install the rest. Same pattern in pvm's `install` subcommand so adding versions later doesn't regress. Also add apcu to the default extension set (Symfony cache adapters). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 07f2a6d commit 152a737

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

scripts/php/install.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set -e
1010
PHP_DEFAULT_VERSION="${VERSION:-8.5}"
1111
# Extensions installed for every version (Sury naming, prefixed at use-site).
1212
# `common` pulls pdo/phar; `mysql`/`pgsql`/`sqlite3` include their pdo drivers.
13-
PHP_EXT_SET="cli common curl mbstring xml intl zip gd bcmath opcache mysql pgsql sqlite3 redis xdebug"
13+
PHP_EXT_SET="cli common curl mbstring xml intl zip gd bcmath opcache apcu mysql pgsql sqlite3 redis xdebug"
1414

1515
install -m 0755 -d /etc/apt/keyrings
1616
curl -fsSL https://packages.sury.org/php/apt.gpg \
@@ -19,12 +19,26 @@ chmod a+r /etc/apt/keyrings/sury-php.gpg
1919
echo "deb [signed-by=/etc/apt/keyrings/sury-php.gpg] https://packages.sury.org/php/ $(. /etc/os-release && echo $VERSION_CODENAME) main" \
2020
> /etc/apt/sources.list.d/sury-php.list
2121

22+
apt-get update
23+
24+
# Filter to extensions Sury actually packages separately for this minor.
25+
# Some extensions move into -common over time (notably opcache became core
26+
# and is bundled in php8.5-common — no separate php8.5-opcache package).
27+
# Install what exists; skip the rest rather than fail the whole install.
2228
pkgs=""
29+
skipped=""
2330
for ext in $PHP_EXT_SET; do
24-
pkgs="$pkgs php${PHP_DEFAULT_VERSION}-${ext}"
31+
p="php${PHP_DEFAULT_VERSION}-${ext}"
32+
if apt-cache show "$p" >/dev/null 2>&1; then
33+
pkgs="$pkgs $p"
34+
else
35+
skipped="$skipped $ext"
36+
fi
2537
done
38+
if [ -n "$skipped" ]; then
39+
echo "php: skipped (bundled into -common or not packaged separately by Sury for ${PHP_DEFAULT_VERSION}):${skipped}" >&2
40+
fi
2641

27-
apt-get update
2842
# shellcheck disable=SC2086
2943
apt-get install -y --no-install-recommends --no-install-suggests $pkgs
3044
rm -rf /var/lib/apt/lists/*

scripts/php/pvm

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# "oldest branch still in security support" (longest-lived pin).
1111
set -e
1212

13-
EXT_SET="cli common curl mbstring xml intl zip gd bcmath opcache mysql pgsql sqlite3 redis xdebug"
13+
EXT_SET="cli common curl mbstring xml intl zip gd bcmath opcache apcu mysql pgsql sqlite3 redis xdebug"
1414
USER_BIN="$HOME/.local/bin"
1515
TOOLS=(php phpize php-config)
1616

@@ -111,9 +111,22 @@ cmd_install() {
111111
local raw="${1:-}" ver
112112
[ -n "$raw" ] || { usage; exit 1; }
113113
ver=$(resolve_alias "$raw")
114-
local pkgs=""
115-
for ext in $EXT_SET; do pkgs="$pkgs php${ver}-${ext}"; done
116114
sudo apt-get update
115+
# Filter to what Sury packages separately for this minor. Opcache, for
116+
# example, is bundled into php8.5-common (core as of 8.5) so there's no
117+
# php8.5-opcache. Skip-with-warning beats hard-failing on packaging drift.
118+
local pkgs="" skipped=""
119+
for ext in $EXT_SET; do
120+
local p="php${ver}-${ext}"
121+
if apt-cache show "$p" >/dev/null 2>&1; then
122+
pkgs="$pkgs $p"
123+
else
124+
skipped="$skipped $ext"
125+
fi
126+
done
127+
if [ -n "$skipped" ]; then
128+
echo "pvm: skipped (bundled into -common or not packaged separately for $ver):$skipped" >&2
129+
fi
117130
# shellcheck disable=SC2086
118131
sudo apt-get install -y --no-install-recommends --no-install-suggests $pkgs
119132
echo "PHP $ver installed. Activate with: pvm use $ver"

0 commit comments

Comments
 (0)