Skip to content

Anchor VERSION match on the Docker epoch to avoid distro-version hits - #571

Open
fudianchn wants to merge 1 commit into
docker:masterfrom
fudianchn:fix-version-selection-distro-match
Open

Anchor VERSION match on the Docker epoch to avoid distro-version hits#571
fudianchn wants to merge 1 commit into
docker:masterfrom
fudianchn:fix-version-selection-distro-match

Conversation

@fudianchn

Copy link
Copy Markdown

Problem

On Ubuntu noble, VERSION=24.0 installs the latest Docker (28.4.0) instead of the requested 24.0 (#526):

INFO: apt-cache madison docker-ce | grep '24.0' | head -1 | ...

The grep matches VERSION anywhere in the madison line, so 24.0 matches the 24.04 in 5:28.4.0-1~ubuntu.24.04~noble, and head -1 then resolves to 28.4.0.

Fix

Anchor the grep on the Docker epoch (5:) so it matches the package version field (5:<version>-...) rather than the distro version embedded in the release suffix:

- search_command="apt-cache madison docker-ce     | grep '$pkg_pattern' | head -1 | ..."
+ search_command="apt-cache madison docker-ce     | grep '5:$pkg_pattern' | head -1 | ..."

Applied to both the docker-ce and docker-ce-cli lookups. Docker packages consistently use the 5: epoch, so this reliably binds the match to the version.

Verification

Simulated apt-cache madison docker-ce output (noble) with both 28.4.0 and 24.0.2 present, VERSION=24.0:

grep selected (cut -f3)
grep '24.0' (before) 5:28.4.0-1~ubuntu.24.04~noble ← wrong (matched 24.04)
grep '5:24.0' (after) 5:24.0.2-1~ubuntu.24.04~noble ← correct

And when 24.0 is genuinely unavailable, grep '5:24.0' matches nothing → the script hits its existing ERROR: '$VERSION' not found amongst apt-cache madison results path and exits 1, instead of silently installing the latest.

bash -n install.sh passes.

Closes #526

@742764146

742764146 commented Aug 9, 2026 via email

Copy link
Copy Markdown

… hits

The apt madison grep matched VERSION anywhere in the package line, so on
Ubuntu noble `VERSION=24.0` matched the `24.04` in
`5:28.4.0-1~ubuntu.24.04~noble` and installed the latest (28.4.0) instead
of the requested 24.0 (or a clean "not found"). (docker#526)

Anchor the grep on the Docker epoch ("5:") so it matches the package
version field (`5:<version>-...`), not the distro version embedded in the
release suffix. Applied to both docker-ce and docker-ce-cli lookups.

Closes docker#526

Signed-off-by: 付典 <fudianchn@gmail.com>
@fudianchn
fudianchn force-pushed the fix-version-selection-distro-match branch from 037c57c to 5a33dc2 Compare August 9, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

version-selection fails if the version matches the distro version

2 participants