Merge ~kleinm/curtin:centos-arm64-fixes into curtin:master

Proposed by Mark Klein
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 5acb6de9f235975a4c4ab3fb49146e5e348497a0
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~kleinm/curtin:centos-arm64-fixes
Merge into: curtin:master
Diff against target: 105 lines (+53/-9)
4 files modified
curtin/commands/curthooks.py (+16/-9)
curtin/commands/install_grub.py (+5/-0)
tests/unittests/test_commands_install_grub.py (+16/-0)
tests/unittests/test_curthooks.py (+16/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Michael Hudson-Doyle Approve
Review via email: mp+394831@code.launchpad.net

Commit message

This adds arm64 compatibility for RH installations

The current behaviour for Redhat based installs assumes x86_64
arch for grub. This change queries the target arch and makes
decisions on packages based on that.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks plausible but I have no way to test this.

Are there tests that need updating?

Revision history for this message
Mark Klein (kleinm) wrote :

I added some unit tests for the new combinations. Also restructured some longer lines due to tox complaints

I also fixed an issue with original commit after doing some tests on real hardware. x86_64 should have been amd64 at this check so nothing breaks on that side.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Sorry for dropping this. I can't test this but also I can't see a way this could possibly make things worse so let's get it landed and out there.

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

Commit message lints:
- Line #2 has 86 too many characters. Line starts with: "The current behaviour"...

review: Needs Fixing
Revision history for this message
Server Team CI bot (server-team-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
2index 4cf7301..eaeb9c4 100644
3--- a/curtin/commands/curthooks.py
4+++ b/curtin/commands/curthooks.py
5@@ -1266,15 +1266,22 @@ def install_missing_packages(cfg, target, osfamily=DISTROS.debian):
6 if util.is_uefi_bootable():
7 uefi_pkgs = ['efibootmgr']
8 if osfamily == DISTROS.redhat:
9- # centos/redhat doesn't support 32-bit?
10- if 'grub2-efi-x64-modules' not in installed_packages:
11- # Previously Curtin only supported unsigned GRUB due to an
12- # upstream bug. By default lp:maas-image-builder and
13- # packer-maas have grub preinstalled. If grub2-efi-x64-modules
14- # is already in the image use unsigned grub so the install
15- # doesn't require Internet access. If grub is missing use the
16- # signed version.
17- uefi_pkgs.extend(['grub2-efi-x64', 'shim-x64'])
18+ arch = distro.get_architecture()
19+ if arch == 'amd64':
20+ # centos/redhat doesn't support 32-bit?
21+ if 'grub2-efi-x64-modules' not in installed_packages:
22+ # Previously Curtin only supported unsigned GRUB due to an
23+ # upstream bug. By default lp:maas-image-builder and
24+ # packer-maas have grub preinstalled. If
25+ # grub2-efi-x64-modules is already in the image use
26+ # unsigned grub so the install doesn't require Internet
27+ # access. If grub is missing use to signed version.
28+ uefi_pkgs.extend(['grub2-efi-x64', 'shim-x64'])
29+ if arch == 'arm64':
30+ if 'grub2-efi-aa64-modules' not in installed_packages:
31+ # Packages required for arm64 grub installer
32+ uefi_pkgs.extend(['grub2-efi-aa64-modules',
33+ 'grub2-efi-aa64', 'shim-aa64'])
34 elif osfamily == DISTROS.debian:
35 arch = distro.get_architecture()
36 if arch == 'i386':
37diff --git a/curtin/commands/install_grub.py b/curtin/commands/install_grub.py
38index 5f8311f..89810c7 100644
39--- a/curtin/commands/install_grub.py
40+++ b/curtin/commands/install_grub.py
41@@ -51,6 +51,11 @@ def get_grub_package_name(target_arch, uefi, rhel_ver=None):
42 # grub2-efi-x64 installs a signed grub bootloader
43 grub_name = "grub2-efi-x64"
44 grub_target = "x86_64-efi"
45+ elif target_arch == 'aarch64':
46+ # centos 7+, no centos6 support
47+ # grub2-efi-aa64 installs a signed grub bootloader
48+ grub_name = "grub2-efi-aa64"
49+ grub_target = "arm64-efi"
50 elif target_arch == 'arm64':
51 grub_name = 'grub-efi-%s' % target_arch
52 grub_target = "arm64-efi"
53diff --git a/tests/unittests/test_commands_install_grub.py b/tests/unittests/test_commands_install_grub.py
54index 8808159..a53f35d 100644
55--- a/tests/unittests/test_commands_install_grub.py
56+++ b/tests/unittests/test_commands_install_grub.py
57@@ -44,6 +44,22 @@ class TestGetGrubPackageName(CiTestCase):
58 ('grub2-efi-x64', 'x86_64-efi'),
59 install_grub.get_grub_package_name(target_arch, uefi, rhel_ver))
60
61+ def test_uefi_rhel7_arm64(self):
62+ target_arch = 'aarch64'
63+ uefi = True
64+ rhel_ver = '7'
65+ self.assertEqual(
66+ ('grub2-efi-aa64', 'arm64-efi'),
67+ install_grub.get_grub_package_name(target_arch, uefi, rhel_ver))
68+
69+ def test_uefi_rhel8_arm64(self):
70+ target_arch = 'aarch64'
71+ uefi = True
72+ rhel_ver = '8'
73+ self.assertEqual(
74+ ('grub2-efi-aa64', 'arm64-efi'),
75+ install_grub.get_grub_package_name(target_arch, uefi, rhel_ver))
76+
77 def test_uefi_debian_arm64(self):
78 target_arch = 'arm64'
79 uefi = True
80diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
81index e5fead3..41670f7 100644
82--- a/tests/unittests/test_curthooks.py
83+++ b/tests/unittests/test_curthooks.py
84@@ -504,6 +504,22 @@ class TestInstallMissingPkgs(CiTestCase):
85 self.mock_install_packages.assert_called_with(
86 expected_pkgs, target=target, osfamily=distro.DISTROS.redhat)
87
88+ @patch.object(events, 'ReportEventStack')
89+ def test_install_packages_on_uefi_arm64_centos(self, mock_events):
90+ arch = 'arm64'
91+ self.mock_arch.return_value = arch
92+ self.mock_machine.return_value = 'arm64'
93+ expected_pkgs = ['efibootmgr', 'grub2-efi-aa64',
94+ 'grub2-efi-aa64-modules', 'shim-aa64']
95+ self.mock_uefi.return_value = True
96+ self.mock_haspkg.return_value = True
97+ target = "not-a-real-target"
98+ cfg = {}
99+ curthooks.install_missing_packages(
100+ cfg, target=target, osfamily=distro.DISTROS.redhat)
101+ self.mock_install_packages.assert_called_with(
102+ expected_pkgs, target=target, osfamily=distro.DISTROS.redhat)
103+
104
105 class TestSetupZipl(CiTestCase):
106

Subscribers

People subscribed via source and target branches