Merge ~ltrager/curtin:lp1895067 into curtin:master

Proposed by Lee Trager
Status: Merged
Approved by: Chad Smith
Approved revision: 840b8ae4e3743c8b0f652f5bb207d9e9082d43e8
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~ltrager/curtin:lp1895067
Merge into: curtin:master
Diff against target: 81 lines (+54/-6)
2 files modified
curtin/commands/install_grub.py (+13/-6)
tests/unittests/test_commands_install_grub.py (+41/-0)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Ryan Harper (community) Approve
Review via email: mp+390517@code.launchpad.net

Commit message

Don't install grub if it is already found on CentOS/RHEL

LP: #1895067

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) :
review: Needs Fixing
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

ltrager any further updates on this? or should someone else pick this up?

Revision history for this message
Lee Trager (ltrager) wrote :

Sorry for taking so long I was investing another issue I thought was related and got caught up with other things. Updated as suggested and verified.

Revision history for this message
Ryan Harper (raharper) wrote :

Thanks, LGTM

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

LGTM. Review comments addressed, logic addresses the bug.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/curtin/commands/install_grub.py b/curtin/commands/install_grub.py
index 5f8311f..030087c 100644
--- a/curtin/commands/install_grub.py
+++ b/curtin/commands/install_grub.py
@@ -254,12 +254,19 @@ def gen_uefi_install_commands(grub_name, grub_target, grub_cmd, update_nvram,
254 install_cmds.append(['update-grub'])254 install_cmds.append(['update-grub'])
255 elif distroinfo.family == distro.DISTROS.redhat:255 elif distroinfo.family == distro.DISTROS.redhat:
256 loader = find_efi_loader(target, bootid)256 loader = find_efi_loader(target, bootid)
257 if loader and update_nvram:257 if loader:
258 grub_cmd = None # don't install just add entry258 # Disable running grub's install command. CentOS/RHEL ships
259 efi_disk, efi_part_num = get_efi_disk_part(devices)259 # a pre-built signed grub which installs into /boot. grub2-install
260 install_cmds.append(['efibootmgr', '--create', '--write-signature',260 # will generated a new unsigned grub which breaks UEFI secure boot.
261 '--label', bootid, '--disk', efi_disk,261 grub_cmd = None
262 '--part', efi_part_num, '--loader', loader])262 if update_nvram:
263 efi_disk, efi_part_num = get_efi_disk_part(devices)
264 # Add entry to the EFI boot menu
265 install_cmds.append(['efibootmgr', '--create',
266 '--write-signature', '--label', bootid,
267 '--disk', efi_disk,
268 '--part', efi_part_num,
269 '--loader', loader])
263 post_cmds.append(['grub2-mkconfig', '-o',270 post_cmds.append(['grub2-mkconfig', '-o',
264 '/boot/efi/EFI/%s/grub.cfg' % bootid])271 '/boot/efi/EFI/%s/grub.cfg' % bootid])
265 else:272 else:
diff --git a/tests/unittests/test_commands_install_grub.py b/tests/unittests/test_commands_install_grub.py
index 8808159..b1d132e 100644
--- a/tests/unittests/test_commands_install_grub.py
+++ b/tests/unittests/test_commands_install_grub.py
@@ -774,6 +774,47 @@ class TestGenUefiInstallCommands(CiTestCase):
774 grub_name, grub_target, grub_cmd, update_nvram, distroinfo,774 grub_name, grub_target, grub_cmd, update_nvram, distroinfo,
775 devices, self.target))775 devices, self.target))
776776
777 def test_redhat_install_existing_no_nvram(self):
778 # verify grub install command is not executed if update_nvram is False
779 # on redhat.
780 def _enable_loaders(bootid):
781 efi_path = 'boot/efi/EFI'
782 target_efi_path = os.path.join(self.target, efi_path)
783 loaders = [
784 os.path.join(target_efi_path, bootid, 'shimx64.efi'),
785 os.path.join(target_efi_path, 'BOOT', 'BOOTX64.EFI'),
786 os.path.join(target_efi_path, bootid, 'grubx64.efi'),
787 ]
788 for loader in loaders:
789 util.write_file(loader, content="")
790
791 self.m_os_release.return_value = {'ID': 'redhat'}
792 distroinfo = install_grub.distro.get_distroinfo()
793 bootid = distroinfo.variant
794 _enable_loaders(bootid)
795 grub_name = 'grub2-efi-x64'
796 grub_target = 'x86_64-efi'
797 grub_cmd = 'grub2-install'
798 update_nvram = False
799 devices = ['/dev/disk-a-part1']
800 disk = '/dev/disk-a'
801 part = '1'
802 self.m_get_disk_part.return_value = (disk, part)
803
804 expected_install = [
805 ['efibootmgr', '-v'],
806 ]
807 expected_post = [
808 ['grub2-mkconfig', '-o', '/boot/efi/EFI/%s/grub.cfg' % bootid],
809 ['efibootmgr', '-v']
810 ]
811
812 self.assertEqual(
813 (expected_install, expected_post),
814 install_grub.gen_uefi_install_commands(
815 grub_name, grub_target, grub_cmd, update_nvram, distroinfo,
816 devices, self.target))
817
777818
778class TestGenInstallCommands(CiTestCase):819class TestGenInstallCommands(CiTestCase):
779820

Subscribers

People subscribed via source and target branches