/usr/lib/python3/dist-packages/provisioningserver/boot/uefi_arm64.py is in python3-maas-provisioningserver 2.0.0~beta3+bzr4941-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | # Copyright 2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""UEFI ARM64 Boot Method"""
__all__ = [
'UEFIARM64BootMethod',
]
import glob
import os.path
from textwrap import dedent
from urllib.parse import urlparse
from provisioningserver.boot import (
BootMethodInstallError,
get_ports_archive_url,
utils,
)
from provisioningserver.boot.install_bootloader import install_bootloader
from provisioningserver.boot.uefi import UEFIBootMethod
from provisioningserver.utils import typed
from provisioningserver.utils.fs import tempdir
from provisioningserver.utils.shell import call_and_check
CONFIG_FILE_ARM64 = dedent("""
# MAAS GRUB2 pre-loader configuration file
# Load based on MAC address first.
configfile (pxe)/grub/grub.cfg-${net_default_mac}
# Failed to load based on MAC address.
# Load arm64 by default, UEFI only supported by 64-bit
configfile (pxe)/grub/grub.cfg-default-arm64
""")
class UEFIARM64BootMethod(UEFIBootMethod):
name = "uefi_arm64"
bios_boot_method = "uefi"
template_subdir = "uefi"
bootloader_arches = ['arm64']
bootloader_path = "grubaa64.efi"
arch_octet = "00:0B" # ARM64 EFI
def match_path(self, backend, path):
"""Doesn't need to do anything, as the UEFIBootMethod provides
the grub implementation needed.
"""
return None
def get_reader(self, backend, kernel_params, **extra):
"""Doesn't need to do anything, as the UEFIBootMethod provides
the grub implementation needed.
"""
return None
@typed
def install_bootloader(self, destination: str):
"""Installs the required files for UEFI ARM64 booting into the
tftproot.
"""
ports_archive_url = get_ports_archive_url()
archive_url = ports_archive_url.strip(urlparse(ports_archive_url).path)
with tempdir() as tmp:
# Download the grub-efi-arm64-bin package
data, filename = utils.get_updates_package(
'grub-efi-arm64-bin', archive_url,
'main', 'arm64')
if data is None:
raise BootMethodInstallError(
'Failed to download grub-efi-arm64-bin package from '
'the archive.')
grub_output = os.path.join(tmp, filename)
with open(grub_output, 'wb') as stream:
stream.write(data)
# Extract the package with dpkg
call_and_check(["dpkg", "-x", grub_output, tmp])
# Output the embedded config, so grub-mkimage can use it
config_output = os.path.join(tmp, 'grub.cfg')
with open(config_output, 'wb') as stream:
stream.write(CONFIG_FILE_ARM64.encode('utf-8'))
# Get list of grub modules
module_dir = os.path.join(
tmp, 'usr', 'lib', 'grub', 'arm64-efi')
modules = []
for module_path in glob.glob(os.path.join(module_dir, '*.mod')):
module_filename = os.path.basename(module_path)
module_name, _ = os.path.splitext(module_filename)
# XXX newell 2015-04-28 bug=1459871,1459872: The module
# skipping logic below can be removed once the listed bugs have
# been fixed and released. See listed bugs for details.
if module_name in ('setjmp', 'setjmp_test', 'progress'):
continue
modules.append(module_name)
# Generate the grub bootloader
mkimage_output = os.path.join(tmp, self.bootloader_path)
args = [
'grub-mkimage',
'-o', mkimage_output,
'-O', 'arm64-efi',
'-d', module_dir,
'-c', config_output,
]
call_and_check(args + modules)
install_bootloader(
mkimage_output,
os.path.join(destination, self.bootloader_path))
|