From e45c9259e5339e6291dcaddf3b0004835f0dd7dd Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Mon, 14 Dec 2020 20:01:37 +1100 Subject: [PATCH 01/11] Switch module streams named after distributions Signed-off-by: Mark Cram --- centos2ol.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index 1955828..f896e80 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -303,12 +303,24 @@ case "$os_version" in fi ;; 8*) + # There are a few dnf modules that are named after the distribution + # for each steam named 'rhel' or 'rhel8' perform a module reset and install + modules_enabled=$(dnf module list --enabled | grep rhel | cut -f1 -d\ ) # Workaround for qemu-guest-agent packages installed from virt modules - if rpm -q qemu-guest-agent; then - dnf module reset -y virt - dnf module enable -y virt - dnf install -y --allowerasing qemu-guest-agent - fi + for module in ${modules_enabled[@]}; do + dnf module reset -y ${module} + case ${module} in + container-tools|go-toolset|jmc|llvm-toolset|rust-toolset) + dnf module install -y ${module}:ol8 + ;; + virt) + dnf module install -y virt:ol + ;; + *) + echo "Unsure how to transform module ${module}" + ;; + esac + done # Two logo RPMs aren't currently covered by 'replaces' metadata, replace by hand. if rpm -q centos-logos-ipa; then From cc44b94075eca854b4316d13b9035ea87ba97e7b Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Mon, 14 Dec 2020 20:21:55 +1100 Subject: [PATCH 02/11] Quote to prevent globbing Signed-off-by: Mark Cram --- centos2ol.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index f896e80..b9bd8d0 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -305,16 +305,15 @@ case "$os_version" in 8*) # There are a few dnf modules that are named after the distribution # for each steam named 'rhel' or 'rhel8' perform a module reset and install - modules_enabled=$(dnf module list --enabled | grep rhel | cut -f1 -d\ ) - # Workaround for qemu-guest-agent packages installed from virt modules - for module in ${modules_enabled[@]}; do - dnf module reset -y ${module} + modules_enabled=($(dnf module list --enabled | grep rhel | cut -f1 -d\ )) + for module in "${modules_enabled[@]}"; do + dnf module reset -y "${module}" case ${module} in container-tools|go-toolset|jmc|llvm-toolset|rust-toolset) - dnf module install -y ${module}:ol8 + dnf module install -y "${module}":ol8 ;; virt) - dnf module install -y virt:ol + dnf module install -y "${module}":ol ;; *) echo "Unsure how to transform module ${module}" From 0e049343d51b897c6fd262da92a93b104beb46a7 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Mon, 14 Dec 2020 20:23:16 +1100 Subject: [PATCH 03/11] Patch any appsteams we've just switched Signed-off-by: Mark Cram --- centos2ol.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/centos2ol.sh b/centos2ol.sh index b9bd8d0..13f9292 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -319,6 +319,7 @@ case "$os_version" in echo "Unsure how to transform module ${module}" ;; esac + dnf update -y --disablerepo "*" --enablerepo "ol8_appstream" done # Two logo RPMs aren't currently covered by 'replaces' metadata, replace by hand. From 95ee27a919dfef2274efc9d59d1bbdacdd1114d2 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 10:00:01 +1100 Subject: [PATCH 04/11] Test there are modules to change first, only perform one update at the end Signed-off-by: Mark Cram --- centos2ol.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index 13f9292..d9e8bd2 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -306,21 +306,23 @@ case "$os_version" in # There are a few dnf modules that are named after the distribution # for each steam named 'rhel' or 'rhel8' perform a module reset and install modules_enabled=($(dnf module list --enabled | grep rhel | cut -f1 -d\ )) - for module in "${modules_enabled[@]}"; do - dnf module reset -y "${module}" - case ${module} in - container-tools|go-toolset|jmc|llvm-toolset|rust-toolset) - dnf module install -y "${module}":ol8 - ;; - virt) - dnf module install -y "${module}":ol - ;; - *) - echo "Unsure how to transform module ${module}" - ;; - esac + if [[ "${modules_enabled[@]}" ]]; then + for module in "${modules_enabled[@]}"; do + dnf module reset -y "${module}" + case ${module} in + container-tools|go-toolset|jmc|llvm-toolset|rust-toolset) + dnf module install -y "${module}":ol8 + ;; + virt) + dnf module install -y "${module}":ol + ;; + *) + echo "Unsure how to transform module ${module}" + ;; + esac + done dnf update -y --disablerepo "*" --enablerepo "ol8_appstream" - done + fi # Two logo RPMs aren't currently covered by 'replaces' metadata, replace by hand. if rpm -q centos-logos-ipa; then From 7396a615f203df51e7b5f1bc9e3bc1fe20aa4ed1 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 10:20:42 +1100 Subject: [PATCH 05/11] Make shellcheck happy Signed-off-by: Mark Cram --- centos2ol.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index d9e8bd2..ed94949 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -305,8 +305,8 @@ case "$os_version" in 8*) # There are a few dnf modules that are named after the distribution # for each steam named 'rhel' or 'rhel8' perform a module reset and install - modules_enabled=($(dnf module list --enabled | grep rhel | cut -f1 -d\ )) - if [[ "${modules_enabled[@]}" ]]; then + mapfile -t modules_enabled < <(dnf module list --enabled | grep rhel | cut -f1 -d\ ) + if [[ "${modules_enabled[*]}" ]]; then for module in "${modules_enabled[@]}"; do dnf module reset -y "${module}" case ${module} in From 16595aa2488a72e4537dc07ef05c8c25610fc0ff Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 11:55:54 +1100 Subject: [PATCH 06/11] Review feedbackup Signed-off-by: Mark Cram --- centos2ol.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index ed94949..3ed28fa 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -305,7 +305,7 @@ case "$os_version" in 8*) # There are a few dnf modules that are named after the distribution # for each steam named 'rhel' or 'rhel8' perform a module reset and install - mapfile -t modules_enabled < <(dnf module list --enabled | grep rhel | cut -f1 -d\ ) + mapfile -t modules_enabled < <(dnf module list --enabled | grep rhel | awk '{print $1}') if [[ "${modules_enabled[*]}" ]]; then for module in "${modules_enabled[@]}"; do dnf module reset -y "${module}" @@ -321,7 +321,7 @@ case "$os_version" in ;; esac done - dnf update -y --disablerepo "*" --enablerepo "ol8_appstream" + dnf --assumeyes --disablerepo "*" --enablerepo "ol8_appstream" update fi # Two logo RPMs aren't currently covered by 'replaces' metadata, replace by hand. From a01e75b1f6aafd14310e319ce590d65aa905b4f7 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 18:53:33 +1100 Subject: [PATCH 07/11] Check ability to switch modules before we start Signed-off-by: Mark Cram --- centos2ol.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index 3ed28fa..676cdb4 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -11,6 +11,7 @@ unset CDPATH yum_url=https://yum.oracle.com contact_email=oraclelinux-info_ww_grp@oracle.com +github_url=https://github.com/oracle/centos2ol/ bad_packages=(centos-backgrounds centos-logos centos-release centos-release-cr desktop-backgrounds-basic \ libreport-centos libreport-plugin-mantisbt libreport-plugin-rhtsupport python3-syspurpose \ python-oauth sl-logos yum-rhn-plugin) @@ -142,6 +143,37 @@ case "$os_version" in ;; esac +if [[ "$os_version" =~ 8.* ]]; then + echo "Identifying dnf modules that are enabled" + # There are a few dnf modules that are named after the distribution + # for each steam named 'rhel' or 'rhel8' we need to make alterations to 'ol' or 'ol8' + # Before we start the switch, identify if there are any present we don't know how to handle + mapfile -t modules_enabled < <(dnf module list --enabled | grep rhel | awk '{print $1}') + if [[ "${modules_enabled[*]}" ]]; then + for module in "${modules_enabled[@]}"; do + case ${module} in + container-tools|go-toolset|jmc|llvm-toolset|rust-toolset|virt) + ;; + *) + echo "This tool is unable to automatically switch module ${module} from a CentOS 'rhel' stream to +an Oracle Linux equivalent. Do you want to continue and resolve it manually? +You may want select No to stop and raise an issue on ${github_url} or contact <${contact_email}> for advice." + select yn in "Yes" "No"; do + case $yn in + Yes ) + break + ;; + No ) + exit_message "Unsure how to process module ${module}" + ;; + esac + done + ;; + esac + done + fi +fi + echo "Finding your repository directory..." case "$os_version" in 8*) @@ -305,7 +337,6 @@ case "$os_version" in 8*) # There are a few dnf modules that are named after the distribution # for each steam named 'rhel' or 'rhel8' perform a module reset and install - mapfile -t modules_enabled < <(dnf module list --enabled | grep rhel | awk '{print $1}') if [[ "${modules_enabled[*]}" ]]; then for module in "${modules_enabled[@]}"; do dnf module reset -y "${module}" From 360adb078c2fbdfde4646e34b8855ba4c0d54d69 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Tue, 15 Dec 2020 18:56:04 +1100 Subject: [PATCH 08/11] Formatting Signed-off-by: Mark Cram --- centos2ol.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index 676cdb4..df16c86 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -155,7 +155,7 @@ if [[ "$os_version" =~ 8.* ]]; then container-tools|go-toolset|jmc|llvm-toolset|rust-toolset|virt) ;; *) - echo "This tool is unable to automatically switch module ${module} from a CentOS 'rhel' stream to + echo "This tool is unable to automatically switch module '${module}' from a CentOS 'rhel' stream to an Oracle Linux equivalent. Do you want to continue and resolve it manually? You may want select No to stop and raise an issue on ${github_url} or contact <${contact_email}> for advice." select yn in "Yes" "No"; do @@ -164,7 +164,7 @@ You may want select No to stop and raise an issue on ${github_url} or contact <$ break ;; No ) - exit_message "Unsure how to process module ${module}" + exit_message "Unsure how to switch module '${module}'. Exiting as requested" ;; esac done From bc23d2ebf18e168cc096fe0f89b025e0a1d69cce Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Wed, 16 Dec 2020 08:53:59 +1100 Subject: [PATCH 09/11] Only provide GitHub url as location for module advice Signed-off-by: Mark Cram --- centos2ol.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index df16c86..b1e599f 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -157,7 +157,7 @@ if [[ "$os_version" =~ 8.* ]]; then *) echo "This tool is unable to automatically switch module '${module}' from a CentOS 'rhel' stream to an Oracle Linux equivalent. Do you want to continue and resolve it manually? -You may want select No to stop and raise an issue on ${github_url} or contact <${contact_email}> for advice." +You may want select No to stop and raise an issue on ${github_url} for advice." select yn in "Yes" "No"; do case $yn in Yes ) From 560d8cb77e96ecd4f60731ab865ad3d312229bc3 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Wed, 16 Dec 2020 09:23:44 +1100 Subject: [PATCH 10/11] Track multiple unknown modules for switching Signed-off-by: Mark Cram --- centos2ol.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/centos2ol.sh b/centos2ol.sh index b1e599f..f6e2e66 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -150,27 +150,34 @@ if [[ "$os_version" =~ 8.* ]]; then # Before we start the switch, identify if there are any present we don't know how to handle mapfile -t modules_enabled < <(dnf module list --enabled | grep rhel | awk '{print $1}') if [[ "${modules_enabled[*]}" ]]; then + # Create an array of modules we don't know how to manage + unknown_modules=() for module in "${modules_enabled[@]}"; do case ${module} in container-tools|go-toolset|jmc|llvm-toolset|rust-toolset|virt) ;; *) - echo "This tool is unable to automatically switch module '${module}' from a CentOS 'rhel' stream to -an Oracle Linux equivalent. Do you want to continue and resolve it manually? -You may want select No to stop and raise an issue on ${github_url} for advice." - select yn in "Yes" "No"; do - case $yn in - Yes ) - break - ;; - No ) - exit_message "Unsure how to switch module '${module}'. Exiting as requested" - ;; - esac - done + # Add this module name to our array of modules we don't know how to manage + unknown_modules+=("${module}") ;; esac done + # If we have any modules we don't know how to manage, ask the user how to proceed + if [ ${#unknown_modules[@]} -gt 0 ]; then + echo "This tool is unable to automatically switch module(s) '${unknown_modules[*]}' from a CentOS 'rhel' stream to +an Oracle Linux equivalent. Do you want to continue and resolve it manually? +You may want select No to stop and raise an issue on ${github_url} for advice." + select yn in "Yes" "No"; do + case $yn in + Yes ) + break + ;; + No ) + exit_message "Unsure how to switch module(s) '${unknown_modules[*]}'. Exiting as requested" + ;; + esac + done + fi fi fi From 2ca7444f7c864e21bc572b3fcb299c4a5ca1f979 Mon Sep 17 00:00:00 2001 From: Mark Cram Date: Wed, 16 Dec 2020 09:52:06 +1100 Subject: [PATCH 11/11] No need to use exit_message, we've informed the user about contact details Signed-off-by: Mark Cram --- centos2ol.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/centos2ol.sh b/centos2ol.sh index f6e2e66..7dcadec 100644 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -173,7 +173,8 @@ You may want select No to stop and raise an issue on ${github_url} for advice." break ;; No ) - exit_message "Unsure how to switch module(s) '${unknown_modules[*]}'. Exiting as requested" + echo "Unsure how to switch module(s) '${unknown_modules[*]}'. Exiting as requested" + exit 1 ;; esac done