From 0b51c4711c7e6211ca0ba8ed15ae76373d0bc172 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 4 Sep 2024 10:38:07 +0200 Subject: [PATCH 1/3] install_rpm_containerd: minor cleanup - use command -v for detecting dnf instead of the --version - quote repo-IDs to prevent globbing by the shell Signed-off-by: Sebastiaan van Stijn (cherry picked from commit c47674df7ed69d0bc4fa021c9efc7b4c9eb4b429) Signed-off-by: Sebastiaan van Stijn --- install-containerd-helpers | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/install-containerd-helpers b/install-containerd-helpers index 631ad57938..5d80c5ed05 100644 --- a/install-containerd-helpers +++ b/install-containerd-helpers @@ -24,15 +24,17 @@ function install_rpm_containerd() { # so this logic works for both cases. # (See also same logic in install_debian_containerd) - if dnf --version; then + if command -v dnf; then + dnf --version + dnf config-manager --add-repo "${REPO_URL}" - dnf config-manager --set-disabled docker-ce-* - dnf config-manager --set-enabled docker-ce-test + dnf config-manager --set-disabled 'docker-ce-*' + dnf config-manager --set-enabled 'docker-ce-test' dnf makecache else yum-config-manager --add-repo "${REPO_URL}" - yum-config-manager --disable docker-ce-* - yum-config-manager --enable docker-ce-test + yum-config-manager --disable 'docker-ce-*' + yum-config-manager --enable 'docker-ce-test' yum makecache fi } From 371577bbc7a78da171fb530e002a727140b92a60 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 4 Sep 2024 10:43:17 +0200 Subject: [PATCH 2/3] install_rpm_containerd: add support for dnf5 Fedora 41 and up use the new dnf5 as default, which is a rewrite of the dnf commands with different options; + dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo Unknown argument "--add-repo" for command "config-manager". Add "--help" for more information about the arguments. make: *** [Makefile:95: verify] Error 2 script returned exit code 2 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 3fdf2619609881cda7e736ed70c72d14eff711b5) Signed-off-by: Sebastiaan van Stijn --- install-containerd-helpers | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install-containerd-helpers b/install-containerd-helpers index 5d80c5ed05..131b7e298b 100644 --- a/install-containerd-helpers +++ b/install-containerd-helpers @@ -24,7 +24,14 @@ function install_rpm_containerd() { # so this logic works for both cases. # (See also same logic in install_debian_containerd) - if command -v dnf; then + if command -v dnf5; then + dnf --version + + dnf config-manager addrepo --save-filename=docker-ce.repo --from-repofile="${REPO_URL}" + dnf config-manager setopt 'docker-ce-*.enabled=0' + dnf config-manager setopt 'docker-ce-test.enabled=1' + dnf makecache + elif command -v dnf; then dnf --version dnf config-manager --add-repo "${REPO_URL}" From f3e01cb61b1ddb8ca7a4b89f40ac1287cb1de6b6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 4 Sep 2024 10:46:31 +0200 Subject: [PATCH 3/3] install_rpm_containerd: add workaround for dnf5 addrepo bug The addrepo command has a bug that causes it to fail if the `.repo` file contains empty lines, causing it to fail; dnf config-manager addrepo --from-repofile="https://download.docker.com/linux/fedora/docker-ce.repo" Error in added repository configuration file. Cannot set repository option "#1= ": Option "#1" not found Use a temporary file and strip empty lines as a workaround until the bug is fixed. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit f43b3cf1dddb5da9172ddad7c0f9c6231b3fb354) Signed-off-by: Sebastiaan van Stijn --- install-containerd-helpers | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install-containerd-helpers b/install-containerd-helpers index 131b7e298b..e38c613990 100644 --- a/install-containerd-helpers +++ b/install-containerd-helpers @@ -27,7 +27,12 @@ function install_rpm_containerd() { if command -v dnf5; then dnf --version - dnf config-manager addrepo --save-filename=docker-ce.repo --from-repofile="${REPO_URL}" + # FIXME(thaJeztah); strip empty lines as workaround for https://github.com/rpm-software-management/dnf5/issues/1603 + TMP_REPO_FILE="$(mktemp --dry-run)" + curl -fsSL "${REPO_URL}" | tr -s '\n' > "${TMP_REPO_FILE}" + dnf config-manager addrepo --save-filename=docker-ce.repo --overwrite --from-repofile="${TMP_REPO_FILE}" + rm -f "${TMP_REPO_FILE}" + # dnf config-manager addrepo --save-filename=docker-ce.repo --from-repofile="${REPO_URL}" dnf config-manager setopt 'docker-ce-*.enabled=0' dnf config-manager setopt 'docker-ce-test.enabled=1' dnf makecache