From 3f21b5a631b2c36e2d0c44845f0cd29bfdc335d2 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Fri, 11 Dec 2020 15:31:36 +1100 Subject: [PATCH 01/12] Learn which repos are enabled prior to switch Signed-off-by: Mark Cram --- centos2ol.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/centos2ol.sh b/centos2ol.sh index 88a4f9c..00cf542 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -167,6 +167,31 @@ for dir in yum.YumBase().doConfigSetup(init_plugins=False).reposdir: ;; esac +echo "Learning which repositories are enabled..." +case "$os_version" in + 8*) + enabled_repos=$(/usr/libexec/platform-python -c " +import dnf + +base = dnf.Base() +base.read_all_repos() +for repo in base.repos.iter_enabled(): + print(repo.id) +") + ;; + *) + enabled_repos=$(python2 -c " +import yum + +base = yum.YumBase() +base.doConfigSetup(init_plugins=False) +for repo in base.repos.listEnabled(): + print repo +") + ;; +esac +echo -e "Repositories enabled before update include:\n${enabled_repos}" + if [ -z "${reposdir}" ]; then exit_message "Could not locate your repository directory." fi From 687025ff107e5cba72a49fd14823d7366a40bd66 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Mon, 14 Dec 2020 17:03:46 +1100 Subject: [PATCH 02/12] Start working out a replacement system Signed-off-by: Mark Cram --- centos2ol.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/centos2ol.sh b/centos2ol.sh index 00cf542..8ac2fe9 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -297,6 +297,75 @@ rm -f "${reposdir}/switch-to-oraclelinux.repo" # At this point, the switch is completed. trap - ERR +# When an additional enabled CentOS repository has a match with Oracle Linux +# then automatically enable the OL repository to ensure the RPM is maintained +# +# Create an associate array where the key is the CentOS reponame and the value +# contains the method of getting the content (Enable a repo or install an RPM) +# and the details of the repo or RPM +case "$os_version" in + 6*) + declare -A repositories=( + [base]="REPO ol6_u10_base" + [base-debuginfo]="REPO https://oss.oracle.com/ol6/debuginfo/" + [updates]="REPO ol6_latest" + ) + ;; + 7*) + declare -A repositories=( + [base]="REPO ol7_u9_base" + [base-debuginfo]="REPO https://oss.oracle.com/ol7/debuginfo/" + [updates]="REPO ol7_latest" + [centos-ceph-jewel]="RPM oracle-ceph-release-el7" + [centos-gluster41]="RPM oracle-gluster-release-el7" + [centos-gluster5]="RPM oracle-gluster-release-el7" + [centos-gluster46]="RPM oracle-gluster-release-el7" + [centos-nfs-ganesha30]="RPM oracle-gluster-release-el7" + [centos-ovirt42]="RPM oracle-ovirt-release-el7" + [centos-ovirt43]="RPM oracle-ovirt-release-el7" + [centos-sclo-sclo]="RPM oracle-softwarecollection-release-el7" + [centos-sclo-rh]="RPM oracle-softwarecollection-release-el7" + ) + ;; + 8*) + declare -A repositories=( + [AppStream]="REPO ol8_appstream" + [BaseOS]="REPO ol8_baseos_latest" + [HighAvailability]="REPO ol8_addons" + [PowerTools]="REPO ol8_codeready_builder" + [centos-release-nfs-ganesha28]="RPM oracle-gluster-release-el8" + [centos-gluster6-test]="RPM oracle-gluster-release-el8" + [centos-gluster7]="RPM oracle-gluster-release-el8" + [centos-gluster8]="RPM oracle-gluster-release-el8" + ) + ;; +esac + +# For each entry in the list, enable it +for reponame in ${enabled_repos}; do + # action[0] will be REPO or RPM + # action[1] will be the repos details or the RPMs name + action=(${repositories[${reponame}]}) + if [[ -n ${action[0]} ]]; then + if [ ${action[0]} == "REPO" ] ; then + matching_repo=${action[1]} + echo "Enabling ${matching_repo} which replaces ${reponame}" + # An RPM that describes debuginfo repository does not exist + # check to see if the repo id starts with https, if it does then + # create a new repo pointing to the repository + if [[ ${matching_repo} =~ https.* ]]; then + yum-config-manager --add-repo ${matching_repo} + else + yum-config-manager --enable ${matching_repo} + fi + elif [ ${action[0]} == "RPM" ] ; then + matching_rpm=${action[1]} + echo "Installing ${matching_rpm} to get content that replaces ${reponame}" + yum install -y ${matching_rpm} + fi + fi +done + echo "Installing base packages for Oracle Linux..." if ! yum shell -y < Date: Mon, 14 Dec 2020 17:23:06 +1100 Subject: [PATCH 03/12] Remove all the 'extras' RPMs Signed-off-by: Mark Cram --- centos2ol.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/centos2ol.sh b/centos2ol.sh index 8ac2fe9..b21bc8c 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -12,6 +12,22 @@ unset CDPATH yum_url=https://yum.oracle.com contact_email=oraclelinux-info_ww_grp@oracle.com bad_packages=(centos-backgrounds centos-logos centos-release centos-release-cr desktop-backgrounds-basic \ + centos-release-advanced-virtualization centos-release-ansible26 centos-release-ansible-27 \ + centos-release-ansible-28 centos-release-ansible-29 centos-release-ansible-29 centos-release-azure \ + centos-release-ceph-jewel centos-release-ceph-luminous centos-release-ceph-nautilus centos-release-ceph-nautilus \ + centos-release-ceph-octopus centos-release-configmanagement centos-release-dotnet centos-release-fdio \ + centos-release-gluster40 centos-release-gluster41 centos-release-gluster5 centos-release-gluster6 \ + centos-release-gluster6 centos-release-gluster7 centos-release-gluster7 centos-release-gluster8 \ + centos-release-gluster-legacy centos-release-messaging centos-release-nfs-ganesha28 centos-release-nfs-ganesha28 \ + centos-release-nfs-ganesha30 centos-release-nfs-ganesha30 centos-release-nfv-common centos-release-nfv-common \ + centos-release-nfv-openvswitch centos-release-openshift-origin centos-release-openstack-queens \ + centos-release-openstack-rocky centos-release-openstack-stein centos-release-openstack-train centos-release-openstack-train \ + centos-release-openstack-ussuri centos-release-opstools centos-release-ovirt42 centos-release-ovirt43 \ + centos-release-ovirt44 centos-release-paas-common centos-release-qemu-ev centos-release-qpid-proton \ + centos-release-rabbitmq-38 centos-release-samba411 centos-release-samba411 centos-release-samba412 \ + centos-release-scl centos-release-scl-rh centos-release-storage-common centos-release-storage-common \ + centos-release-virt-common centos-release-virt-common centos-release-xen centos-release-xen-410 \ + centos-release-xen-412 centos-release-xen-46 centos-release-xen-48 centos-release-xen-common \ libreport-centos libreport-plugin-mantisbt libreport-plugin-rhtsupport python3-syspurpose \ python-oauth sl-logos yum-rhn-plugin) From 12dd8229ea9584f5a796d26a2516bc3dd57d705a Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Mon, 14 Dec 2020 18:02:00 +1100 Subject: [PATCH 04/12] Remove duplicates Signed-off-by: Mark Cram --- centos2ol.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index b21bc8c..76265c8 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -13,20 +13,20 @@ yum_url=https://yum.oracle.com contact_email=oraclelinux-info_ww_grp@oracle.com bad_packages=(centos-backgrounds centos-logos centos-release centos-release-cr desktop-backgrounds-basic \ centos-release-advanced-virtualization centos-release-ansible26 centos-release-ansible-27 \ - centos-release-ansible-28 centos-release-ansible-29 centos-release-ansible-29 centos-release-azure \ - centos-release-ceph-jewel centos-release-ceph-luminous centos-release-ceph-nautilus centos-release-ceph-nautilus \ + centos-release-ansible-28 centos-release-ansible-29 centos-release-azure \ + centos-release-ceph-jewel centos-release-ceph-luminous centos-release-ceph-nautilus \ centos-release-ceph-octopus centos-release-configmanagement centos-release-dotnet centos-release-fdio \ - centos-release-gluster40 centos-release-gluster41 centos-release-gluster5 centos-release-gluster6 \ - centos-release-gluster6 centos-release-gluster7 centos-release-gluster7 centos-release-gluster8 \ - centos-release-gluster-legacy centos-release-messaging centos-release-nfs-ganesha28 centos-release-nfs-ganesha28 \ - centos-release-nfs-ganesha30 centos-release-nfs-ganesha30 centos-release-nfv-common centos-release-nfv-common \ + centos-release-gluster40 centos-release-gluster41 centos-release-gluster5 \ + centos-release-gluster6 centos-release-gluster7 centos-release-gluster8 \ + centos-release-gluster-legacy centos-release-messaging centos-release-nfs-ganesha28 \ + centos-release-nfs-ganesha30 centos-release-nfv-common \ centos-release-nfv-openvswitch centos-release-openshift-origin centos-release-openstack-queens \ - centos-release-openstack-rocky centos-release-openstack-stein centos-release-openstack-train centos-release-openstack-train \ + centos-release-openstack-rocky centos-release-openstack-stein centos-release-openstack-train \ centos-release-openstack-ussuri centos-release-opstools centos-release-ovirt42 centos-release-ovirt43 \ centos-release-ovirt44 centos-release-paas-common centos-release-qemu-ev centos-release-qpid-proton \ - centos-release-rabbitmq-38 centos-release-samba411 centos-release-samba411 centos-release-samba412 \ - centos-release-scl centos-release-scl-rh centos-release-storage-common centos-release-storage-common \ - centos-release-virt-common centos-release-virt-common centos-release-xen centos-release-xen-410 \ + centos-release-rabbitmq-38 centos-release-samba411 centos-release-samba412 \ + centos-release-scl centos-release-scl-rh centos-release-storage-common \ + centos-release-virt-common centos-release-xen centos-release-xen-410 \ centos-release-xen-412 centos-release-xen-46 centos-release-xen-48 centos-release-xen-common \ libreport-centos libreport-plugin-mantisbt libreport-plugin-rhtsupport python3-syspurpose \ python-oauth sl-logos yum-rhn-plugin) From bc877053db0dd21e090303c984e37eb36ff80e57 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Mon, 14 Dec 2020 18:38:24 +1100 Subject: [PATCH 05/12] We only need the ol repos enabled for this Signed-off-by: Mark Cram --- centos2ol.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index 76265c8..583dda4 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -377,7 +377,7 @@ for reponame in ${enabled_repos}; do elif [ ${action[0]} == "RPM" ] ; then matching_rpm=${action[1]} echo "Installing ${matching_rpm} to get content that replaces ${reponame}" - yum install -y ${matching_rpm} + yum install -y ${matching_rpm} --disablerepo "*" --enablerepo "ol*_latest" fi fi done From 9d13629394c1995515292aa35a25396780d4a321 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Mon, 14 Dec 2020 18:52:39 +1100 Subject: [PATCH 06/12] Disable the centos-release-* repos that come from 'Extras' but leave them in place Signed-off-by: Mark Cram --- centos2ol.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/centos2ol.sh b/centos2ol.sh index 583dda4..72993d5 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -279,6 +279,7 @@ fi echo "Backing up and removing old repository files..." rpm -ql "$old_release" | grep '\.repo$' > repo_files +rpm -qla "centos-release-*" | grep '\.repo$' >> repo_files while read -r repo; do if [ -f "$repo" ]; then cat - "$repo" > "$repo".disabled < Date: Mon, 14 Dec 2020 20:29:21 +1100 Subject: [PATCH 07/12] No need to enable a media repo Signed-off-by: Mark Cram --- centos2ol.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index 72993d5..a15dd6d 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -323,14 +323,12 @@ trap - ERR case "$os_version" in 6*) declare -A repositories=( - [base]="REPO ol6_u10_base" [base-debuginfo]="REPO https://oss.oracle.com/ol6/debuginfo/" [updates]="REPO ol6_latest" ) ;; 7*) declare -A repositories=( - [base]="REPO ol7_u9_base" [base-debuginfo]="REPO https://oss.oracle.com/ol7/debuginfo/" [updates]="REPO ol7_latest" [centos-ceph-jewel]="RPM oracle-ceph-release-el7" From e7996f796aac33009321bdf60adcf57d180a7513 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 16:09:16 +1100 Subject: [PATCH 08/12] Avoid grepping until we know we have RPMs Signed-off-by: Mark Cram --- centos2ol.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index a15dd6d..6230346 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -278,8 +278,12 @@ if [[ $old_release =~ ^centos-release-8.* ]] || [[ $old_release =~ ^centos-linux fi echo "Backing up and removing old repository files..." +# Identify repo files from the base OS rpm -ql "$old_release" | grep '\.repo$' > repo_files -rpm -qla "centos-release-*" | grep '\.repo$' >> repo_files +# Identify repo files from 'CentOS extras' +if [ $(rpm -qa "centos-release-*" | wc -l) -gt 0 ] ; then + rpm -qla "centos-release-*" | grep '\.repo$' >> repo_files +fi while read -r repo; do if [ -f "$repo" ]; then cat - "$repo" > "$repo".disabled < Date: Tue, 15 Dec 2020 16:44:46 +1100 Subject: [PATCH 09/12] Shellcheck Signed-off-by: Mark Cram --- centos2ol.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index 6230346..de1f994 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -281,7 +281,7 @@ echo "Backing up and removing old repository files..." # Identify repo files from the base OS rpm -ql "$old_release" | grep '\.repo$' > repo_files # Identify repo files from 'CentOS extras' -if [ $(rpm -qa "centos-release-*" | wc -l) -gt 0 ] ; then +if [ "$(rpm -qa "centos-release-*" | wc -l)" -gt 0 ] ; then rpm -qla "centos-release-*" | grep '\.repo$' >> repo_files fi while read -r repo; do @@ -364,23 +364,24 @@ esac for reponame in ${enabled_repos}; do # action[0] will be REPO or RPM # action[1] will be the repos details or the RPMs name - action=(${repositories[${reponame}]}) + IFS=" " read -r -a action <<< "${repositories[${reponame}]}" + # action=(${repositories[${reponame}]}) if [[ -n ${action[0]} ]]; then - if [ ${action[0]} == "REPO" ] ; then + if [ "${action[0]}" == "REPO" ] ; then matching_repo=${action[1]} echo "Enabling ${matching_repo} which replaces ${reponame}" # An RPM that describes debuginfo repository does not exist # check to see if the repo id starts with https, if it does then # create a new repo pointing to the repository if [[ ${matching_repo} =~ https.* ]]; then - yum-config-manager --add-repo ${matching_repo} + yum-config-manager --add-repo "${matching_repo}" else - yum-config-manager --enable ${matching_repo} + yum-config-manager --enable "${matching_repo}" fi - elif [ ${action[0]} == "RPM" ] ; then + elif [ "${action[0]}" == "RPM" ] ; then matching_rpm=${action[1]} echo "Installing ${matching_rpm} to get content that replaces ${reponame}" - yum install -y ${matching_rpm} --disablerepo "*" --enablerepo "ol*_latest" + yum install -y "${matching_rpm}" --disablerepo "*" --enablerepo "ol*_latest" fi fi done From 98433afe330735b5fe8bcbd09ffef48e90947eee Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 17:12:17 +1100 Subject: [PATCH 10/12] use full name based on feedback Signed-off-by: Mark Cram --- centos2ol.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index de1f994..596d5df 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -381,7 +381,7 @@ for reponame in ${enabled_repos}; do elif [ "${action[0]}" == "RPM" ] ; then matching_rpm=${action[1]} echo "Installing ${matching_rpm} to get content that replaces ${reponame}" - yum install -y "${matching_rpm}" --disablerepo "*" --enablerepo "ol*_latest" + yum install --assumeyes "${matching_rpm}" --disablerepo "*" --enablerepo "ol*_latest" fi fi done From 1f7f05a8df5c098cac39fbd143738a97eab51fdd Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 17:58:20 +1100 Subject: [PATCH 11/12] Formatting Signed-off-by: Mark Cram --- centos2ol.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index 596d5df..af046e5 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -365,7 +365,6 @@ for reponame in ${enabled_repos}; do # action[0] will be REPO or RPM # action[1] will be the repos details or the RPMs name IFS=" " read -r -a action <<< "${repositories[${reponame}]}" - # action=(${repositories[${reponame}]}) if [[ -n ${action[0]} ]]; then if [ "${action[0]}" == "REPO" ] ; then matching_repo=${action[1]} From a63f806935f6cf58c93f30128f3eb93936e5cf4f Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 18:36:15 +1100 Subject: [PATCH 12/12] Formatting Signed-off-by: Mark Cram --- centos2ol.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index af046e5..ff2004c 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -380,7 +380,7 @@ for reponame in ${enabled_repos}; do elif [ "${action[0]}" == "RPM" ] ; then matching_rpm=${action[1]} echo "Installing ${matching_rpm} to get content that replaces ${reponame}" - yum install --assumeyes "${matching_rpm}" --disablerepo "*" --enablerepo "ol*_latest" + yum --assumeyes --disablerepo "*" --enablerepo "ol*_latest" install "${matching_rpm}" fi fi done