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

grub2/efi: fix /boot/efi/EFI/redhat/grub.cfg #1229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions repos/system_upgrade/el8toel9/actors/fixgrubefiwrapper/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os

from leapp.actors import Actor
from leapp.libraries.stdlib import api, CalledProcessError, run
from leapp.models import FirmwareFacts, TransactionCompleted
from leapp.reporting import Report
from leapp.tags import IPUWorkflowTag, RPMUpgradePhaseTag


class FixGrubEFIWrapper(Actor):
"""
Update /boot/efi/EFI/redhat/grub.cfg on UEFI systems.

See [RHEL-36186](https://issues.redhat.com/browse/RHEL-36186).
"""

name = 'fix_grub_efi_wrapper'
consumes = (TransactionCompleted, FirmwareFacts)
produces = (Report,)
tags = (RPMUpgradePhaseTag, IPUWorkflowTag)

def process(self):
ff = next(self.consume(FirmwareFacts), None)
if not ff:
api.current_logger().warning('Could not identify system firmware')
return

if ff.firmware == 'efi' and os.path.ismount('/boot/efi') and os.path.isfile('/boot/efi/EFI/redhat/grub.cfg'):
api.current_logger().info('Removing --root-dev-only if present.')
try:
run(['/usr/bin/sed', '-i', r's/--root-dev-only\s*//', '/boot/efi/EFI/redhat/grub.cfg'])
except (OSError, CalledProcessError):
api.current_logger().warning('Cannot apply the fix of /boot/efi/EFI/redhat/grub.cfg.')
return
api.current_logger().info('Removed --root-dev-only if present.')
Loading