diff options
| author | Christian Breunig <christian@breunig.cc> | 2024-03-28 20:02:12 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-28 20:02:12 +0100 | 
| commit | 18a39bb1cb0044f4b272d66bd0defb5d5dbc7e77 (patch) | |
| tree | 499a6d05983955cc98101b4b09b3c3858461eb8c /python | |
| parent | 7c650ae9a41d90d863906fec388de427dfdb7195 (diff) | |
| parent | 90507681cfb39c5570f0afbf1542bd49feb5c0ab (diff) | |
| download | vyos-1x-18a39bb1cb0044f4b272d66bd0defb5d5dbc7e77.tar.gz vyos-1x-18a39bb1cb0044f4b272d66bd0defb5d5dbc7e77.zip | |
Merge pull request #3207 from dmbaturin/T3664-grub-chroot
vyos.system.grub: T3664: add chroot argument to the GRUB install function
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/system/grub.py | 12 | 
1 files changed, 9 insertions, 3 deletions
| diff --git a/python/vyos/system/grub.py b/python/vyos/system/grub.py index e56f0bec8..5ab9d76f0 100644 --- a/python/vyos/system/grub.py +++ b/python/vyos/system/grub.py @@ -56,7 +56,7 @@ REGEX_KERNEL_CMDLINE: str = r'^BOOT_IMAGE=/(?P<boot_type>boot|live)/((?P<image_v  REGEX_GRUB_BOOT_OPTS: str = r'^\s*set boot_opts="(?P<boot_opts>[^$]+)"$' -def install(drive_path: str, boot_dir: str, efi_dir: str, id: str = 'VyOS') -> None: +def install(drive_path: str, boot_dir: str, efi_dir: str, id: str = 'VyOS', chroot : str = "") -> None:      """Install GRUB for both BIOS and EFI modes (hybrid boot)      Args: @@ -65,17 +65,22 @@ def install(drive_path: str, boot_dir: str, efi_dir: str, id: str = 'VyOS') -> N          efi_dir (str): a path to '/boot/efi' directory      """ +    if chroot: +        chroot_cmd = f"chroot {chroot}" +    else: +        chroot_cmd = "" +      efi_installation_arch = "x86_64"      if platform.machine() == "aarch64":          efi_installation_arch = "arm64"      elif platform.machine() == "x86_64":          cmd( -            f'grub-install --no-floppy --target=i386-pc \ +            f'{chroot_cmd} grub-install --no-floppy --target=i386-pc \              --boot-directory={boot_dir}  {drive_path} --force'          )      cmd( -        f'grub-install --no-floppy --recheck --target={efi_installation_arch}-efi \ +        f'{chroot_cmd} grub-install --no-floppy --recheck --target={efi_installation_arch}-efi \              --force-extra-removable --boot-directory={boot_dir} \              --efi-directory={efi_dir} --bootloader-id="{id}" \              --no-uefi-secure-boot' @@ -458,3 +463,4 @@ def sort_inodes(dir_path: str) -> None:      for item in temp_list_new:          new_name = Path(f'{item.as_posix()[0:-4]}')          item.rename(new_name) + | 
