stages/grub: extract module copying code

Part of refactoring the grub2 module so it can also handle UEFI.
No semantic change.
This commit is contained in:
Christian Kellner 2019-12-08 13:04:52 +01:00 committed by Tom Gundersen
parent d1d27567e8
commit 1c0f00e37c

View file

@ -48,6 +48,19 @@ STAGE_OPTS = """
}
"""
def copy_modules(tree):
"""Copy all modules from the build image to /boot"""
os.makedirs(f"{tree}/boot/grub2/i386-pc", exist_ok=True)
for dirent in os.scandir("/usr/lib/grub/i386-pc"):
(_, ext) = os.path.splitext(dirent.name)
if ext not in ('.mod', '.lst'):
continue
if dirent.name == "fdt.lst":
continue
shutil.copy2(f"/usr/lib/grub/i386-pc/{dirent.name}", f"{tree}/boot/grub2/i386-pc/")
def main(tree, options):
root_fs_uuid = options["root_fs_uuid"]
kernel_opts = options.get("kernel_opts", "")
@ -74,15 +87,7 @@ def main(tree, options):
"}\n"
"blscfg\n")
# Copy all modules from the build image to /boot
os.makedirs(f"{tree}/boot/grub2/i386-pc", exist_ok=True)
for dirent in os.scandir("/usr/lib/grub/i386-pc"):
(_, ext) = os.path.splitext(dirent.name)
if ext not in ('.mod', '.lst'):
continue
if dirent.name == "fdt.lst":
continue
shutil.copy2(f"/usr/lib/grub/i386-pc/{dirent.name}", f"{tree}/boot/grub2/i386-pc/")
copy_modules(tree)
# Copy a unicode font into /boot
os.makedirs(f"{tree}/boot/grub2/fonts", exist_ok=True)