Skip to content

Commit 992da63

Browse files
authored
Merge pull request #441 from thaJeztah/add_dnf5_support
add support for dnf5 (in preparation of fedora 41)
2 parents 4ebfeb7 + 27f47c5 commit 992da63

2 files changed

Lines changed: 55 additions & 37 deletions

File tree

install.sh

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,13 @@ do_install() {
498498
if ! is_dry_run; then
499499
set -x
500500
fi
501-
$sh_c 'apt-get update -qq >/dev/null'
502-
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pre_reqs >/dev/null"
501+
$sh_c 'apt-get -qq update >/dev/null'
502+
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $pre_reqs >/dev/null"
503503
$sh_c 'install -m 0755 -d /etc/apt/keyrings'
504504
$sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" -o /etc/apt/keyrings/docker.asc"
505505
$sh_c "chmod a+r /etc/apt/keyrings/docker.asc"
506506
$sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list"
507-
$sh_c 'apt-get update -qq >/dev/null'
507+
$sh_c 'apt-get -qq update >/dev/null'
508508
)
509509
pkg_version=""
510510
if [ -n "$VERSION" ]; then
@@ -546,52 +546,70 @@ do_install() {
546546
if ! is_dry_run; then
547547
set -x
548548
fi
549-
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pkgs >/dev/null"
549+
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $pkgs >/dev/null"
550550
)
551551
echo_docker_as_nonroot
552552
exit 0
553553
;;
554554
centos|fedora|rhel)
555-
if command_exists dnf; then
556-
pkg_manager="dnf"
557-
pkg_manager_flags="--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=""
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 -y -q $pre_reqs"
582-
$sh_c "$config_manager --add-repo $repo_file_url"
560+
if command_exists dnf5; then
561+
# $sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core"
562+
# $sh_c "dnf5 config-manager addrepo --save-filename=docker-ce.repo --from-repofile='$repo_file_url'"
563+
564+
$sh_c "dnf -y -q --setopt=install_weak_deps=False install curl dnf-plugins-core"
565+
# FIXME(thaJeztah); strip empty lines as workaround for https://github.com/rpm-software-management/dnf5/issues/1603
566+
TMP_REPO_FILE="$(mktemp --dry-run)"
567+
$sh_c "curl -fsSL '$repo_file_url' | tr -s '\n' > '${TMP_REPO_FILE}'"
568+
$sh_c "dnf5 config-manager addrepo --save-filename=docker-ce.repo --overwrite --from-repofile='${TMP_REPO_FILE}'"
569+
$sh_c "rm -f '${TMP_REPO_FILE}'"
570+
571+
if [ "$CHANNEL" != "stable" ]; then
572+
$sh_c "dnf5 config-manager setopt 'docker-ce-*.enabled=0'"
573+
$sh_c "dnf5 config-manager setopt 'docker-ce-$CHANNEL.enabled=1'"
574+
fi
575+
$sh_c "dnf makecache"
576+
elif command_exists dnf; then
577+
$sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core"
578+
$sh_c "dnf config-manager --add-repo $repo_file_url"
579+
580+
if [ "$CHANNEL" != "stable" ]; then
581+
$sh_c "dnf config-manager --set-disabled 'docker-ce-*'"
582+
$sh_c "dnf config-manager --set-enabled 'docker-ce-$CHANNEL'"
583+
fi
584+
$sh_c "dnf makecache"
585+
else
586+
$sh_c "yum -y -q install yum-utils"
587+
$sh_c "yum config-manager --add-repo $repo_file_url"
583588

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'"
589+
if [ "$CHANNEL" != "stable" ]; then
590+
$sh_c "yum config-manager --disable 'docker-ce-*'"
591+
$sh_c "yum config-manager --enable 'docker-ce-$CHANNEL'"
592+
fi
593+
$sh_c "yum makecache"
587594
fi
588-
$sh_c "$pkg_manager makecache"
589595
)
590596
pkg_version=""
597+
if command_exists dnf; then
598+
pkg_manager="dnf"
599+
pkg_manager_flags="-y -q --best"
600+
else
601+
pkg_manager="yum"
602+
pkg_manager_flags="-y -q"
603+
fi
591604
if [ -n "$VERSION" ]; then
592605
if is_dry_run; then
593606
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
594607
else
608+
if [ "$lsb_dist" = "fedora" ]; then
609+
pkg_suffix="fc$dist_version"
610+
else
611+
pkg_suffix="el"
612+
fi
595613
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/\\\\.ce.*/g' | sed 's/-/.*/g').*$pkg_suffix"
596614
search_command="$pkg_manager list --showduplicates docker-ce | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
597615
pkg_version="$($sh_c "$search_command")"
@@ -631,7 +649,7 @@ do_install() {
631649
if ! is_dry_run; then
632650
set -x
633651
fi
634-
$sh_c "$pkg_manager $pkg_manager_flags install -y -q $pkgs"
652+
$sh_c "$pkg_manager $pkg_manager_flags install $pkgs"
635653
)
636654
echo_docker_as_nonroot
637655
exit 0

rootless-install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ checks() {
128128
# uidmap dependency check
129129
if ! command -v newuidmap >/dev/null 2>&1; then
130130
if command -v apt-get >/dev/null 2>&1; then
131-
INSTRUCTIONS="apt-get install -y uidmap"
131+
INSTRUCTIONS="apt-get -y install uidmap"
132132
elif command -v dnf >/dev/null 2>&1; then
133-
INSTRUCTIONS="dnf install -y shadow-utils"
133+
INSTRUCTIONS="dnf -y install shadow-utils"
134134
elif command -v yum >/dev/null 2>&1; then
135135
INSTRUCTIONS="curl -o /etc/yum.repos.d/vbatts-shadow-utils-newxidmap-epel-7.repo https://copr.fedorainfracloud.org/coprs/vbatts/shadow-utils-newxidmap/repo/epel-7/vbatts-shadow-utils-newxidmap-epel-7.repo
136-
yum install -y shadow-utils46-newxidmap"
136+
yum -y install shadow-utils46-newxidmap"
137137
else
138138
echo "newuidmap binary not found. Please install with a package manager."
139139
exit 1
@@ -144,10 +144,10 @@ yum install -y shadow-utils46-newxidmap"
144144
if [ -z "$SKIP_IPTABLES" ] && ! command -v iptables >/dev/null 2>&1 && [ ! -f /sbin/iptables ] && [ ! -f /usr/sbin/iptables ]; then
145145
if command -v apt-get >/dev/null 2>&1; then
146146
INSTRUCTIONS="${INSTRUCTIONS}
147-
apt-get install -y iptables"
147+
apt-get -y install iptables"
148148
elif command -v dnf >/dev/null 2>&1; then
149149
INSTRUCTIONS="${INSTRUCTIONS}
150-
dnf install -y iptables"
150+
dnf -y install iptables"
151151
else
152152
echo "iptables binary not found. Please install with a package manager."
153153
exit 1

0 commit comments

Comments
 (0)