Skip to content

fix matching of package versions on debian, ubuntu, and raspbian#330

Merged
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:fix_version_matching
Jan 11, 2023
Merged

fix matching of package versions on debian, ubuntu, and raspbian#330
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:fix_version_matching

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Jan 11, 2023

The version-format of the packages changed in the docker-ce-packaging repo; docker/docker-ce-packaging@39772a7

Which caused the script to fail when specifying a version:

INFO: Searching repository for VERSION '23.0.0-rc.2'
INFO: apt-cache madison 'docker-ce' | grep '23.0.0.*rc.2.*-0~debian' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3

ERROR: '23.0.0-rc.2' not found amongst apt-cache madison results

Looking at that search, it seemed like it was overly strict;

  • matching the distro (debian, ubuntu, or raspbian), which should not be needed, assuming the package repository has been set up correctly (which the script does in earlier steps).
  • matching the "0" prefix, which was intended to be used a package-revision (so to allow for packaging-only releases). That part definitely shouldn't be done, as it would not match later revisions (1, 2, 3)

This patch simplifies the matching, and only searches for the package name, and the version specified, which should satisfy the requirement;

apt-cache madison 'docker-ce' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
5:23.0.0~rc.2-1~ubuntu.22.04~jammy

apt-cache madison 'docker-ce-cli' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
5:23.0.0~rc.2-1~ubuntu.22.04~jammy

With this patch applied, the installation succeeds:

cat install.sh | DOWNLOAD_URL=https://download-stage.docker.com CHANNEL=test VERSION=23.0.0-rc.2 REPO_FILE=docker-ce-staging.repo sh
...
INFO: Searching repository for VERSION '23.0.0-rc.2'
INFO: apt-cache madison 'docker-ce' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
INFO: apt-cache madison 'docker-ce-cli' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce=5:23.0.0~rc.2-1~ubuntu.22.04~jammy docker-ce-cli=5:23.0.0~rc.2-1~ubuntu.22.04~jammy containerd.io docker-compose-plugin docker-scan-plugin docker-buildx-plugin >/dev/null

The version-format of the packages changed in the docker-ce-packaging repo;
docker/docker-ce-packaging@39772a7

Which caused the script to fail when specifying a version:

    INFO: Searching repository for VERSION '23.0.0-rc.2'
    INFO: apt-cache madison 'docker-ce' | grep '23.0.0.*rc.2.*-0~debian' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3

    ERROR: '23.0.0-rc.2' not found amongst apt-cache madison results

Looking at that search, it seemed like it was overly strict;

- matching the distro (debian, ubuntu, or raspbian), which should not be needed,
  assuming the package repository has been set up correctly (which the script
  does in earlier steps).
- matching the "0" prefix, which was intended to be used a package-revision (so
  to allow for packaging-only releases). That part definitely shouldn't be done,
  as it would not match later revisions (1, 2, 3)

This patch simplifies the matching, and only searches for the package name, and
the version specified, which should satisfy the requirement;

    apt-cache madison 'docker-ce' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
    5:23.0.0~rc.2-1~ubuntu.22.04~jammy

    apt-cache madison 'docker-ce-cli' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
    5:23.0.0~rc.2-1~ubuntu.22.04~jammy

With this patch applied, the installation succeeds:

    cat install.sh | DOWNLOAD_URL=https://download-stage.docker.com CHANNEL=test VERSION=23.0.0-rc.2 REPO_FILE=docker-ce-staging.repo sh
    ...
    INFO: Searching repository for VERSION '23.0.0-rc.2'
    INFO: apt-cache madison 'docker-ce' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
    INFO: apt-cache madison 'docker-ce-cli' | grep '23.0.0.*rc.2' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
    + sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce=5:23.0.0~rc.2-1~ubuntu.22.04~jammy docker-ce-cli=5:23.0.0~rc.2-1~ubuntu.22.04~jammy containerd.io docker-compose-plugin docker-scan-plugin docker-buildx-plugin >/dev/null

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Copy link
Copy Markdown
Contributor

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

@thaJeztah
Copy link
Copy Markdown
Member Author

thx! bringing this one in, and I'll trigger a deploy of the script

@thaJeztah thaJeztah merged commit 1d97565 into docker:master Jan 11, 2023
@thaJeztah thaJeztah deleted the fix_version_matching branch January 11, 2023 23:21
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.

2 participants