Skip to content
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

Add el9toel10 actor to handle symlink -> directory with ruby IRB. #1304

Merged
merged 2 commits into from
Nov 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@

class RegisterRubyIRBAdjustment(Actor):
"""
Registers a workaround which will adjust the Ruby IRB directories during the upgrade.
Register a workaround to allow rubygem-irb's directory -> symlink conversion.

The /usr/share/ruby/irb has been moved from a directory to a symlink
in RHEL 9 and this conversion was not handled on RPM level.
This leads to DNF reporting package file conflicts when a major upgrade
is attempted and rubygem-irb (or ruby-irb) is installed.

Register "handlerubyirbsymlink" script that removes the directory prior
to DNF upgrade and allows it to create the expected symlink in place of
the removed directory.
"""

name = 'register_ruby_irb_adjustment'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from leapp.actors import Actor
from leapp.models import DNFWorkaround
from leapp.tags import FactsPhaseTag, IPUWorkflowTag


class RegisterRubyIRBAdjustment(Actor):
"""
Register a workaround to allow rubygem-irb's symlink -> directory conversion.

The /usr/share/ruby/irb has been moved from a symlink to a directory
in RHEL 10 and this conversion was not handled on the RPM level.
This leads to DNF reporting package file conflicts when a major upgrade
is attempted and rubygem-irb is installed.

Register "handlerubyirbsymlink" script that removes the symlink prior
to DNF upgrade and allows it to create the expected directory in place of
the removed symlink.
"""

name = 'register_ruby_irb_adjustment'
consumes = ()
produces = (DNFWorkaround,)
tags = (IPUWorkflowTag, FactsPhaseTag)

def process(self):
self.produce(
DNFWorkaround(
display_name='IRB directory fix',
script_path=self.get_tool_path('handlerubyirbsymlink'),
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os.path

from leapp.models import DNFWorkaround


def test_register_ruby_irb_adjustments(current_actor_context):
current_actor_context.run()
assert len(current_actor_context.consume(DNFWorkaround)) == 1
assert current_actor_context.consume(DNFWorkaround)[0].display_name == 'IRB directory fix'
assert os.path.basename(current_actor_context.consume(DNFWorkaround)[0].script_path) == 'handlerubyirbsymlink'
assert os.path.exists(current_actor_context.consume(DNFWorkaround)[0].script_path)
22 changes: 22 additions & 0 deletions repos/system_upgrade/el9toel10/tools/handlerubyirbsymlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/bash -e

# just in case of hidden files.. not sure why would someone do that, it's more
# like forgotten cache file possibility, but rather do that..
shopt -s dotglob

handle_dir() {
# Check that $1 is a symlink then unlink it so that RPM
# can freely create the directory.
if [ ! -L "$1" ]; then
return
fi

# There is no configuration or anything that the user should ever customize
# and expect to retain.
unlink "$1"

return 0
}


handle_dir /usr/share/ruby/irb