From 23bc5d57c8bf6f4b7e803aef616a3337ec531c67 Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Fri, 9 Jul 2021 16:28:03 +1200 Subject: [PATCH] Check for dnf-plugins-core and enable config-manager Check to make sure that dnf-plugins-core is present, and force-enable the config-manager plugin for those dnf commands that need it in case it has been disabled. --- migrate2rocky/migrate2rocky.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/migrate2rocky/migrate2rocky.sh b/migrate2rocky/migrate2rocky.sh index b41559a..3f267c2 100644 --- a/migrate2rocky/migrate2rocky.sh +++ b/migrate2rocky/migrate2rocky.sh @@ -222,9 +222,20 @@ bin_check() { fi done - if ! pkg_ver dnf 4.2; then - exit_message 'dnf >= 4.2 is required for this script. Please run "dnf update" first.' - fi + local -A pkgs + pkgs=( + [dnf]=4.2 + [dnf-plugins-core]=0 + ) + + for pkg in "${!pkgs[@]}"; do + ver=${pkgs[$pkg]} + if ! pkg_ver "$pkg" "$ver"; then + exit_message \ +"$pkg >= $ver is required for this script. Please run "\ +"\"dnf install $pkg; dnf update\" first." + fi + done; if (( ${#missing[@]} )); then exit_message "Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt installation." @@ -717,9 +728,10 @@ EOF infomsg $'\nRemoving dnf cache\n' rm -rf /var/cache/{yum,dnf} infomsg $'Ensuring repos are enabled before the package swap\n' - safednf -y config-manager --set-enabled "${!repo_map[@]}" || { - printf '%s\n' 'Repo name missing?' - exit 25 + safednf -y --enableplugin=config-manager config-manager \ + --set-enabled "${!repo_map[@]}" || { + printf '%s\n' 'Repo name missing?' + exit 25 } if (( ${#managed_repos[@]} )); then @@ -730,7 +742,8 @@ EOF if (( ${#managed_repos[@]} )); then infomsg $'\nDisabling subscription managed repos\n' - safednf -y config-manager --disable "${managed_repos[@]}" + safednf -y --enableplugin=config-manager config-manager \ + --disable "${managed_repos[@]}" fi fi