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
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index 4cf7301..eaeb9c4 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -1266,15 +1266,22 @@ def install_missing_packages(cfg, target, osfamily=DISTROS.debian):
1266 if util.is_uefi_bootable():1266 if util.is_uefi_bootable():
1267 uefi_pkgs = ['efibootmgr']1267 uefi_pkgs = ['efibootmgr']
1268 if osfamily == DISTROS.redhat:1268 if osfamily == DISTROS.redhat:
1269 # centos/redhat doesn't support 32-bit?1269 arch = distro.get_architecture()
1270 if 'grub2-efi-x64-modules' not in installed_packages:1270 if arch == 'amd64':
1271 # Previously Curtin only supported unsigned GRUB due to an1271 # centos/redhat doesn't support 32-bit?
1272 # upstream bug. By default lp:maas-image-builder and1272 if 'grub2-efi-x64-modules' not in installed_packages:
1273 # packer-maas have grub preinstalled. If grub2-efi-x64-modules1273 # Previously Curtin only supported unsigned GRUB due to an
1274 # is already in the image use unsigned grub so the install1274 # upstream bug. By default lp:maas-image-builder and
1275 # doesn't require Internet access. If grub is missing use the1275 # packer-maas have grub preinstalled. If
1276 # signed version.1276 # grub2-efi-x64-modules is already in the image use
1277 uefi_pkgs.extend(['grub2-efi-x64', 'shim-x64'])1277 # unsigned grub so the install doesn't require Internet
1278 # access. If grub is missing use to signed version.
1279 uefi_pkgs.extend(['grub2-efi-x64', 'shim-x64'])
1280 if arch == 'arm64':
1281 if 'grub2-efi-aa64-modules' not in installed_packages:
1282 # Packages required for arm64 grub installer
1283 uefi_pkgs.extend(['grub2-efi-aa64-modules',
1284 'grub2-efi-aa64', 'shim-aa64'])
1278 elif osfamily == DISTROS.debian:1285 elif osfamily == DISTROS.debian:
1279 arch = distro.get_architecture()1286 arch = distro.get_architecture()
1280 if arch == 'i386':1287 if arch == 'i386':
diff --git a/curtin/commands/install_grub.py b/curtin/commands/install_grub.py
index 5f8311f..89810c7 100644
--- a/curtin/commands/install_grub.py
+++ b/curtin/commands/install_grub.py
@@ -51,6 +51,11 @@ def get_grub_package_name(target_arch, uefi, rhel_ver=None):
51 # grub2-efi-x64 installs a signed grub bootloader51 # grub2-efi-x64 installs a signed grub bootloader
52 grub_name = "grub2-efi-x64"52 grub_name = "grub2-efi-x64"
53 grub_target = "x86_64-efi"53 grub_target = "x86_64-efi"
54 elif target_arch == 'aarch64':
55 # centos 7+, no centos6 support
56 # grub2-efi-aa64 installs a signed grub bootloader
57 grub_name = "grub2-efi-aa64"
58 grub_target = "arm64-efi"
54 elif target_arch == 'arm64':59 elif target_arch == 'arm64':
55 grub_name = 'grub-efi-%s' % target_arch60 grub_name = 'grub-efi-%s' % target_arch
56 grub_target = "arm64-efi"61 grub_target = "arm64-efi"
diff --git a/tests/unittests/test_commands_install_grub.py b/tests/unittests/test_commands_install_grub.py
index 8808159..a53f35d 100644
--- a/tests/unittests/test_commands_install_grub.py
+++ b/tests/unittests/test_commands_install_grub.py
@@ -44,6 +44,22 @@ class TestGetGrubPackageName(CiTestCase):
44 ('grub2-efi-x64', 'x86_64-efi'),44 ('grub2-efi-x64', 'x86_64-efi'),
45 install_grub.get_grub_package_name(target_arch, uefi, rhel_ver))45 install_grub.get_grub_package_name(target_arch, uefi, rhel_ver))
4646
47 def test_uefi_rhel7_arm64(self):
48 target_arch = 'aarch64'
49 uefi = True
50 rhel_ver = '7'
51 self.assertEqual(
52 ('grub2-efi-aa64', 'arm64-efi'),
53 install_grub.get_grub_package_name(target_arch, uefi, rhel_ver))
54
55 def test_uefi_rhel8_arm64(self):
56 target_arch = 'aarch64'
57 uefi = True
58 rhel_ver = '8'
59 self.assertEqual(
60 ('grub2-efi-aa64', 'arm64-efi'),
61 install_grub.get_grub_package_name(target_arch, uefi, rhel_ver))
62
47 def test_uefi_debian_arm64(self):63 def test_uefi_debian_arm64(self):
48 target_arch = 'arm64'64 target_arch = 'arm64'
49 uefi = True65 uefi = True
diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
index e5fead3..41670f7 100644
--- a/tests/unittests/test_curthooks.py
+++ b/tests/unittests/test_curthooks.py
@@ -504,6 +504,22 @@ class TestInstallMissingPkgs(CiTestCase):
504 self.mock_install_packages.assert_called_with(504 self.mock_install_packages.assert_called_with(
505 expected_pkgs, target=target, osfamily=distro.DISTROS.redhat)505 expected_pkgs, target=target, osfamily=distro.DISTROS.redhat)
506506
507 @patch.object(events, 'ReportEventStack')
508 def test_install_packages_on_uefi_arm64_centos(self, mock_events):
509 arch = 'arm64'
510 self.mock_arch.return_value = arch
511 self.mock_machine.return_value = 'arm64'
512 expected_pkgs = ['efibootmgr', 'grub2-efi-aa64',
513 'grub2-efi-aa64-modules', 'shim-aa64']
514 self.mock_uefi.return_value = True
515 self.mock_haspkg.return_value = True
516 target = "not-a-real-target"
517 cfg = {}
518 curthooks.install_missing_packages(
519 cfg, target=target, osfamily=distro.DISTROS.redhat)
520 self.mock_install_packages.assert_called_with(
521 expected_pkgs, target=target, osfamily=distro.DISTROS.redhat)
522
507523
508class TestSetupZipl(CiTestCase):524class TestSetupZipl(CiTestCase):
509525

Subscribers

People subscribed via source and target branches