Keep new packages when migrating from Stream until RockyLinux catches up (#96)

* CentOS Stream changes

* Retain CentOS Stream repositories and packages to avoid version downgrade
  issues.
* Only remove centos-stream-repos from the rpm db, do not actually uninstall the
  files.
* Rename system repositories from CentOS Stream with a "stream-" prefix to avoid
  clashing with Rockylinux system repository names.
* Disable CentOS Stream repositories after the distro-sync.

Note that these changes will leave CentOS Stream packages on the system, likely
until the next RockyLinux point release.  This is intentional to avoid issues
with downgrading package versions.

* Apply stream logic to epel-next-release.

epel-next-release is installed for CentOS stream machines with
EPEL.  Apply similar logic for epel-next as for CentOS stream.
This commit is contained in:
Peter Ajamian 2021-08-14 01:35:50 +12:00 committed by GitHub
parent d7f52751d0
commit 7eb310f907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,6 +125,15 @@ repo_urls=(
[rockyappstream]="https://dl.rockylinux.org/pub/rocky/${SUPPORTED_MAJOR}/AppStream/$ARCH/os/"
)
# The repos package for CentOS stream requires special handling.
declare -g -A stream_repos_pkgs
stream_repos_pkgs=(
[rocky-repos]=centos-stream-repos
[epel-release]=epel-next-release
)
# Prefix to add to CentOS stream repo names when renaming them.
stream_prefix=stream-
unset CDPATH
exit_message() {
@ -212,8 +221,8 @@ bin_check() {
local -a missing bins
bins=(
rpm dnf awk column tee tput mkdir cat arch sort uniq
rmdir rm head curl sha512sum mktemp systemd-detect-virt
rpm dnf awk column tee tput mkdir cat arch sort uniq rmdir
rm head curl sha512sum mktemp systemd-detect-virt sed
)
if [[ $update_efi ]]; then
bins+=(findmnt grub2-mkconfig efibootmgr grep mokutil lsblk)
@ -539,6 +548,22 @@ $'because continuing with the migration could cause further damage to system.'
fi
done;
# Special Handling for CentOS Stream Repos
installed_sys_stream_repos_pkgs=()
installed_stream_repos_pkgs=()
for p in "${!stream_repos_pkgs[@]}"; do
if [[ ${installed_pkg_map[$p]} &&
${installed_pkg_map[$p]} == "${stream_repos_pkgs[$p]}" ]]
then
# System package that needs to be swapped / disabled
installed_pkg_map[$p]=
installed_sys_stream_repos_pkgs+=( ${stream_repos_pkgs[$p]} )
elif rpm --quiet -q "${stream_repos_pkgs[$p]}"; then
# Non-system package, repos just need to be disabled.
installed_stream_repos_pkgs+=( ${stream_repos_pkgs[$p]} )
fi
done
printf '%s\n' '' "We will replace the following $PRETTY_NAME packages with their Rocky Linux 8 equivalents"
column -t -s $'\t' -N "Packages to be Removed,Packages to be Installed" < <(
for p in "${!installed_pkg_map[@]}"; do
@ -546,8 +571,24 @@ $'because continuing with the migration could cause further damage to system.'
done
)
if (( ${#installed_sys_stream_repos_pkgs[@]} )); then
printf '%s\n' '' \
'Also to aid the transition from CentOS Stream the following packages will be '\
'removed from the rpm database but the included repos will be renamed and '\
'retained but disabled:' \
"${installed_sys_stream_repos_pkgs[@]}"
fi
if (( ${#installed_stream_repos_pkgs[@]} )); then
printf '%s\n' '' \
'Also to aid the transition from CentOS Stream the repos included in the '\
'following packages will be renamed and retained but disabled:' \
"${installed_stream_repos_pkgs[@]}"
fi
if (( ${#addl_pkg_removes[@]} )); then
printf '%s\n' '' "In addition to the above the following system packages will be removed:" \
printf '%s\n' '' \
"In addition to the above the following system packages will be removed:" \
"${addl_pkg_removes[@]}"
fi
@ -661,6 +702,25 @@ package_swaps() {
dnfparameters+=( "--setopt=${repo}.gpgkey=file://${gpg_key_file}" )
done
# CentOS Stream specific processing
if (( ${#installed_stream_repos_pkgs[@]} )); then
# Get a list of the repo files.
local -a repos_files
readarray -t repos_files < <(
saferpm -ql "${installed_sys_stream_repos_pkgs[@]}" \
"${installed_stream_repos_pkgs[@]}" |
grep '^/etc/yum\.repos\.d/.\+\.repo$'
)
# Remove the package from the rpm db.
saferpm -e --justdb --nodeps -a "${installed_sys_stream_repos_pkgs[@]}" ||
exit_message \
"Could not remove packages from the rpm db: ${installed_sys_stream_repos_pkgs[@]}"
# Rename the stream repos with a prefix.
sed -i 's/^\[/['"$stream_prefix"'/' "${repos_files[@]}"
fi
# Use dnf shell to swap the system packages out.
safednf -y shell --disablerepo=\* --noautoremove \
--setopt=protected_packages= --setopt=keepcache=True \
@ -757,7 +817,7 @@ EOF
# Distrosync
infomsg $'Ensuring repos are enabled before the package swap\n'
safednf -y --enableplugin=config-manager config-manager \
safednf -y --enableplugin=config_manager config-manager \
--set-enabled "${!repo_map[@]}" || {
printf '%s\n' 'Repo name missing?'
exit 25
@ -788,7 +848,7 @@ EOF
exit_message "Can't enable modules ${enabled_modules[*]}"
fi
# Make sure that excluded repos are disabled.
# Make sure that excluded modules are disabled.
infomsg $'Disabling excluded modules\n\n'
safednf -y module disable "${module_excludes[@]}" ||
exit_message "Can't disable modules ${module_excludes[*]}"
@ -796,8 +856,39 @@ EOF
infomsg $'\nSyncing packages\n\n'
dnf -y distro-sync || exit_message "Error during distro-sync."
# Disable Stream repos.
if (( ${#installed_sys_stream_repos_pkgs[@]} ||
${#installed_stream_repos_pkgs[@]} )); then
dnf -y --enableplugin=config_manager config-manager --set-disabled \
"$stream_prefix*" ||
errmsg \
$'Failed to disable CentOS Stream repos, please check and disable manually.\n'
infomsg $'\nCentOS Stream Migration Notes:\n\n'
cat <<EOF
Because CentOS Stream leads RockyLinux by the next point release many packages
in Stream will have higher version numbers than those in RockyLinux, some will
even be rebased to a new upstream version. Downgrading these packages to the
versions in RockyLinux carries the risk that the older version may not
recognize config files, data or other files generated by the newer version in
Stream.
To avoid issues with this the newer package versions from CentOS Stream have
been retained. Also the CentOS Stream repositories have been retained but
renamed with a prefix of "stream-" to avoid clashing with RockyLinux
repositories, but these same repos have also been disabled so that future
package installs will come from the stock RockyLinux repositories.
If you do nothing except update to the next point release of RockyLinux when it
becomes available then the packages retained from Stream should be replaced at
that time. If you need to update a package from Stream (eg: to fix a bug or
security issue) then you will need to enable the appropriate repository to do
so.
EOF
fi
if rpm --quiet -q subscription-manager; then
infomsg $'Subscription Manager found on system.\n'
infomsg $'\nSubscription Manager found on system.\n\n'
cat <<EOF
If you're converting from a subscription-managed distribution such as RHEL then
you may no longer need subscription-manager or dnf-plugin-subscription-manager.
@ -812,7 +903,6 @@ The subscription-manager dnf plugin may be enabled for the benefit of
Subscription Management. If no longer desired, you can use
"subscription-manager config --rhsm.auto_enable_yum_plugins=0" to block this
behavior.
EOF
fi
if [[ $tmp_sm_ca_dir ]]; then