Skip to content

Commit

Permalink
grub2/efi: fix /boot/efi/EFI/redhat/grub.cfg
Browse files Browse the repository at this point in the history
When upgrading a UEFI system with /boot on Software Raid, the
/boot/efi/EFI/redhat/grub.cfg wrapper is created with unexpected
content, causing the system to land into 'grub>' prompt upon upgrade
completion.

jira: https://issues.redhat.com/browse/RHEL-36186

Signed-off-by: Renaud Métrich <[email protected]>
  • Loading branch information
rmetrich committed May 13, 2024
1 parent ce8dfff commit 867997c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions repos/system_upgrade/el8toel9/actors/fixgrubefiwrapper/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os

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


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:
raise StopActorExecution(
'Could not identify system firmware',
details={'details': 'Actor did not receive FirmwareFacts message.'}
)

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.')
run(['/usr/bin/sed', '-i', r's/--root-dev-only\s*//', '/boot/efi/EFI/redhat/grub.cfg'])
api.current_logger().info('Removed --root-dev-only if present.')

0 comments on commit 867997c

Please sign in to comment.