Skip to content

Commit b982474

Browse files
committed
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 This patch: - adds a check for dnf5 - removes some indirection through env-vars, and instead inlines the code Note that with CentOS 7 being EOL, we can probably remove the `yum` variant from the script, but I left those in place for now. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 4e65530 commit b982474

1 file changed

Lines changed: 38 additions & 27 deletions

File tree

install.sh

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -552,46 +552,57 @@ do_install() {
552552
exit 0
553553
;;
554554
centos|fedora|rhel)
555-
if command_exists dnf; then
556-
pkg_manager="dnf"
557-
pkg_manager_flags="-y -q --best"
558-
config_manager="dnf config-manager"
559-
enable_channel_flag="--set-enabled"
560-
disable_channel_flag="--set-disabled"
561-
pre_reqs="dnf-plugins-core"
562-
else
563-
pkg_manager="yum"
564-
pkg_manager_flags="-y -q"
565-
config_manager="yum-config-manager"
566-
enable_channel_flag="--enable"
567-
disable_channel_flag="--disable"
568-
pre_reqs="yum-utils"
569-
fi
570-
571-
if [ "$lsb_dist" = "fedora" ]; then
572-
pkg_suffix="fc$dist_version"
573-
else
574-
pkg_suffix="el"
575-
fi
576555
repo_file_url="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE"
577556
(
578557
if ! is_dry_run; then
579558
set -x
580559
fi
581-
$sh_c "$pkg_manager $pkg_manager_flags install $pre_reqs"
582-
$sh_c "$config_manager --add-repo $repo_file_url"
560+
if command_exists dnf5; then
561+
$sh_c "dnf -y -q install dnf-plugins-core"
562+
$sh_c "dnf5 config-manager addrepo --save-filename=docker-ce.repo --from-repofile='$repo_file_url'"
563+
564+
if [ "$CHANNEL" != "stable" ]; then
565+
$sh_c "dnf5 config-manager setopt 'docker-ce-*.enabled=0'"
566+
$sh_c "dnf5 config-manager setopt 'docker-ce-$CHANNEL.enabled=1'"
567+
fi
568+
$sh_c "dnf makecache"
569+
elif command_exists dnf; then
570+
$sh_c "dnf -y -q install dnf-plugins-core"
571+
$sh_c "dnf config-manager --add-repo $repo_file_url"
572+
573+
if [ "$CHANNEL" != "stable" ]; then
574+
$sh_c "dnf config-manager --set-disabled 'docker-ce-*'"
575+
$sh_c "dnf config-manager --set-enabled 'docker-ce-$CHANNEL'"
576+
fi
577+
$sh_c "dnf makecache"
578+
else
579+
$sh_c "yum -y -q install yum-utils"
580+
$sh_c "yum config-manager --add-repo $repo_file_url"
583581

584-
if [ "$CHANNEL" != "stable" ]; then
585-
$sh_c "$config_manager $disable_channel_flag 'docker-ce-*'"
586-
$sh_c "$config_manager $enable_channel_flag 'docker-ce-$CHANNEL'"
582+
if [ "$CHANNEL" != "stable" ]; then
583+
$sh_c "yum config-manager --disable 'docker-ce-*'"
584+
$sh_c "yum config-manager --enable 'docker-ce-$CHANNEL'"
585+
fi
586+
$sh_c "yum makecache"
587587
fi
588-
$sh_c "$pkg_manager makecache"
589588
)
590589
pkg_version=""
590+
if command_exists dnf; then
591+
pkg_manager="dnf"
592+
pkg_manager_flags="-y -q --best"
593+
else
594+
pkg_manager="yum"
595+
pkg_manager_flags="-y -q"
596+
fi
591597
if [ -n "$VERSION" ]; then
592598
if is_dry_run; then
593599
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
594600
else
601+
if [ "$lsb_dist" = "fedora" ]; then
602+
pkg_suffix="fc$dist_version"
603+
else
604+
pkg_suffix="el"
605+
fi
595606
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/\\\\.ce.*/g' | sed 's/-/.*/g').*$pkg_suffix"
596607
search_command="$pkg_manager list --showduplicates docker-ce | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
597608
pkg_version="$($sh_c "$search_command")"

0 commit comments

Comments
 (0)