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.
This commit is contained in:
Peter Ajamian 2021-07-09 16:28:03 +12:00
parent 64fd6b5f08
commit 23bc5d57c8

View File

@ -222,9 +222,20 @@ bin_check() {
fi fi
done done
if ! pkg_ver dnf 4.2; then local -A pkgs
exit_message 'dnf >= 4.2 is required for this script. Please run "dnf update" first.' pkgs=(
fi [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 if (( ${#missing[@]} )); then
exit_message "Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt installation." exit_message "Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt installation."
@ -717,9 +728,10 @@ EOF
infomsg $'\nRemoving dnf cache\n' infomsg $'\nRemoving dnf cache\n'
rm -rf /var/cache/{yum,dnf} rm -rf /var/cache/{yum,dnf}
infomsg $'Ensuring repos are enabled before the package swap\n' infomsg $'Ensuring repos are enabled before the package swap\n'
safednf -y config-manager --set-enabled "${!repo_map[@]}" || { safednf -y --enableplugin=config-manager config-manager \
printf '%s\n' 'Repo name missing?' --set-enabled "${!repo_map[@]}" || {
exit 25 printf '%s\n' 'Repo name missing?'
exit 25
} }
if (( ${#managed_repos[@]} )); then if (( ${#managed_repos[@]} )); then
@ -730,7 +742,8 @@ EOF
if (( ${#managed_repos[@]} )); then if (( ${#managed_repos[@]} )); then
infomsg $'\nDisabling subscription managed repos\n' 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
fi fi