From 47885b1f995f1e0ffa86e6e3e8d5a701fec12904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=85=B8?= Date: Sun, 9 Aug 2026 09:00:58 +0800 Subject: [PATCH] fix: anchor VERSION match on the madison version field to avoid distro-version hits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Anchor the apt-cache madison grep on the version field separator with an optional Docker epoch (5:), so VERSION matches the start of the package version instead of the distro version inside the release suffix. Packages published before 18.03 carry no epoch and keep matching. Closes https://github.com/docker/docker-install/issues/526 Signed-off-by: 付典 --- install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 4b9ae4ad..8c7a862c 100755 --- a/install.sh +++ b/install.sh @@ -594,7 +594,10 @@ do_install() { else # Will work for incomplete versions IE (17.12), but may not actually grab the "latest" if in the test channel pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/~ce~.*/g' | sed 's/-/.*/g')" - search_command="apt-cache madison docker-ce | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3" + # Anchor on the madison version field (optional "5:" epoch) so the pattern + # matches the package version, not the distro version in the release suffix + # (VERSION=24.0 must match 5:24.0.x, not 28.4.0-1~ubuntu.24.04~noble). See #526. + search_command="apt-cache madison docker-ce | grep -E ' \\| (5:)?$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3" echo "INFO: Searching repository for VERSION '$VERSION'" echo "INFO: $search_command" pkg_version="$($sh_c "$search_command")" @@ -607,7 +610,7 @@ do_install() { pkg_version="=$pkg_version" if version_gte "18.09"; then - search_command="apt-cache madison docker-ce-cli | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3" + search_command="apt-cache madison docker-ce-cli | grep -E ' \\| (5:)?$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3" echo "INFO: $search_command" cli_pkg_version="$($sh_c "$search_command")" if [ -n "$cli_pkg_version" ]; then