Skip to content

Replace CentOS content with Oracle Linux content when versions are identical #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ CentOS Linux 8. It does not support CentOS Stream.
1. Either clone this repository or download the [`centos2ol.sh`](./centos2ol.sh) script.
1. Run `sudo bash centos2ol.sh` to switch your CentOS instance to Oracle Linux.

### Usage options
* `-r` Reinstalls all CentOS RPMs with Oracle Linux RPMs

If a system is swiched to Oracle Linux and there is no newer Oracle Linux version
of a package already installed then the CentOS version remains.
This option proceeds to reinstall any CentOS RPM with an identical version from
Oracle Linunx. This is not necessary for support and has no impact to a systems functionality
but is offered so a user can remove CentOS GPG keys from the truststore.
A list of all non-Oracle RPMs will be displayed after the reinstall process.

## Limitations

1. The script currently needs to be able communicate with the CentOS and Oracle
Expand Down
28 changes: 27 additions & 1 deletion centos2ol.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ usage() {
echo "OPTIONS"
echo "-h"
echo " Display this help and exit"
echo "-r"
echo " Reinstall all CentOS RPMs with Oracle Linux RPMs"
echo " Note: This is not necessary for support"
exit 1
} >&2

Expand Down Expand Up @@ -72,9 +75,12 @@ Your repositories have been restored to your previous configuration."

## Start of script

while getopts "h" option; do
reinstall_all_rpms=false

while getopts "h:r" option; do
case "$option" in
h) usage ;;
r) reinstall_all_rpms=true ;;
*) usage ;;
esac
done
Expand Down Expand Up @@ -486,6 +492,26 @@ case "$os_version" in
;;
esac

if "${reinstall_all_rpms}"; then
echo "Testing for remaining CentOS RPMs"
# If CentOS and Oracle Linux have identically versioned RPMs then those RPMs are left unchanged.
# This should have no technical impact but for completeness, reinstall these RPMs
# so there is no accidental cross pollination.
mapfile -t list_of_centos_rpms < <(rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE} %{VENDOR}\n" | grep CentOS | awk '{print $1}')
if [[ -n "${list_of_centos_rpms[*]}" ]]; then
echo "Reinstalling RPMs: ${list_of_centos_rpms[*]}"
yum --assumeyes --disablerepo "*" --enablerepo "ol*" reinstall "${list_of_centos_rpms[@]}"
fi
# See if non-Oracle RPMs are present and print them
mapfile -t non_oracle_rpms < <(rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}|%{VENDOR}|%{PACKAGER}\n" |grep -v Oracle)
if [[ -n "${non_oracle_rpms[*]}" ]]; then
echo "The following non-Oracle RPMs are installed on the system:"
printf '\t%s\n' "${non_oracle_rpms[@]}"
echo "This may be expected of your environment and does not necessarily indicate a problem."
echo "If a large number of CentOS RPMs are included and you're unsure why please open an issue on ${github_url}"
fi
fi

echo "Sync successful. Switching default kernel to the UEK."

arch=$(uname -m)
Expand Down