-
Notifications
You must be signed in to change notification settings - Fork 88
Switch distro-specific module streams #15
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e45c925
Switch module streams named after distributions
mark-au cc44b94
Quote to prevent globbing
mark-au 0e04934
Patch any appsteams we've just switched
mark-au 95ee27a
Test there are modules to change first, only perform one update at th…
mark-au 7396a61
Make shellcheck happy
mark-au 16595aa
Review feedbackup
mark-au a01e75b
Check ability to switch modules before we start
mark-au 360adb0
Formatting
mark-au bc23d2e
Only provide GitHub url as location for module advice
mark-au 560d8cb
Track multiple unknown modules for switching
mark-au 2ca7444
No need to use exit_message, we've informed the user about contact de…
mark-au File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ unset CDPATH | |
|
||
yum_url=https://yum.oracle.com | ||
[email protected] | ||
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,45 @@ 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 | ||
# 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) | ||
;; | ||
*) | ||
# 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 ) | ||
echo "Unsure how to switch module(s) '${unknown_modules[*]}'. Exiting as requested" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
fi | ||
fi | ||
fi | ||
|
||
echo "Finding your repository directory..." | ||
case "$os_version" in | ||
8*) | ||
|
@@ -303,11 +343,24 @@ case "$os_version" in | |
fi | ||
;; | ||
8*) | ||
# 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 | ||
# 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 | ||
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 --assumeyes --disablerepo "*" --enablerepo "ol8_appstream" update | ||
fi | ||
|
||
# Two logo RPMs aren't currently covered by 'replaces' metadata, replace by hand. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either break here or get user confirmation to continue, instead of just logging the exception.
I would then rewrite this as
"Cannot switch enabled module \"${module}\" to Oracle Linux. Continue switching (y/N):
with "no" as the default option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point in the code the core OS has been switched and we're tidying up the edge cases. We can't easily revert the changes already made so I don't think halting would help. I appreciate it's something that should be strongly highlighted to the user to replace a line that may scroll by.
What do you think of a summary at the end indicating that a module $x couldn't be automatically switched and requires manual intervention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move this test to before we do anything that changes the system so that users have the option to abort the switch before any damage is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll leave this modify code at the end but I'll add a check at the start to see if there are rhel* streams enabled that we aren't familiar with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thant seems like a perfectly cromulent solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented change. I temporarily disabled knowledge of the virt:rhel stream and this is the output:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there are multiple unknown modules? This format seems very single-module specific.
Also, only provide the GitHub URL, not the email address.