Make EFI deployment more flexible

fixes
Vadim vtroshchinskiy 2024-10-29 09:57:31 +01:00
parent 38e457c35c
commit 5c253cd782
1 changed files with 23 additions and 9 deletions

View File

@ -638,7 +638,7 @@ class OpengnsysGitLibrary:
self.logger.debug("UUID is %s", uuid)
return uuid
def _efi_install(self, root_directory):
def _efi_install(self, root_directory, config_name = None):
"""
Install EFI data on the specified boot device.
@ -666,9 +666,15 @@ class OpengnsysGitLibrary:
else:
self.logger.error("No general EFI files found")
uuid = self._get_system_uuid()
self.logger.debug("Checking if we have system-specific EFI data for system id %s...", uuid)
sys_efi_files_dir = os.path.join(meta_dir, f"efi_data.{uuid}")
sys_efi_files_dir = ""
if config_name:
self.logger.debug("Custom EFI config %s specified...", config_name)
sys_efi_files_dir = os.path.join(meta_dir, f"efi_data.{config_name}")
else:
uuid = self._get_system_uuid()
self.logger.debug("Checking if we have system-specific EFI data for system id %s...", uuid)
sys_efi_files_dir = os.path.join(meta_dir, f"efi_data.{uuid}")
if os.path.exists(sys_efi_files_dir):
@ -677,10 +683,11 @@ class OpengnsysGitLibrary:
else:
self.logger.debug("No system-specific EFI data.")
def _efi_copy(self, root_directory, system_specific = False):
def _efi_copy(self, root_directory, system_specific = False, config_name = None):
meta_dir = os.path.join(root_directory, ".opengnsys-metadata")
boot_device = self._find_boot_device()
boot_mount = self._find_mountpoint(boot_device)
efi_files_dir = ""
@ -692,13 +699,18 @@ class OpengnsysGitLibrary:
shutil.copytree(boot_mount, efi_files_dir)
else:
uuid = self._get_system_uuid()
self.logger.debug("Copying EFI data for system %s", uuid)
if config_name:
self.logger.debug("Copying EFI data for preset %s", config_name)
efi_files_dir = os.path.join(meta_dir, f"efi_data.{config_name}")
else:
uuid = self._get_system_uuid()
self.logger.debug("Copying EFI data for system %s", uuid)
efi_files_dir = os.path.join(meta_dir, f"efi_data.{uuid}")
# TODO: On Windows we can probably get away with just copying:
# EFI/Microsoft/Boot/BCD*
efi_files_dir = os.path.join(meta_dir, f"efi_data.{uuid}")
if os.path.exists(efi_files_dir):
shutil.rmtree(efi_files_dir)
@ -1794,6 +1806,8 @@ if __name__ == '__main__':
parser.add_argument("--push", type=str, metavar='DEV', help="Subir cambios a ogrepository")
parser.add_argument("--pull", type=str, metavar='DEV', help="Bajar cambios de ogrepository")
parser.add_argument("--fetch", type=str, metavar='DEV', help="Fetch changes from ogrepository")
parser.add_argument("--efi-config", type=str, metavar="NAME", help="Name of the custom EFI configuration to deploy")
parser.add_argument("--ntfs-type", type=str, metavar="FS", help="Tipo de NTFS, 'kernel' o 'fuse'")
parser.add_argument("--test-create-metadata", type=str, metavar="DIR", help="Test metadata generation")
@ -1870,7 +1884,7 @@ if __name__ == '__main__':
ntfs = NTFSLibrary(ntfs_impl)
ntfs.modify_uuid(args.device, args.test_set_ntfsid)
elif args.test_efi_install:
og_git._efi_install(root_directory=args.test_efi_install) # pylint: disable=protected-access
og_git._efi_install(root_directory=args.test_efi_install, config_name = args.efi_config) # pylint: disable=protected-access
else:
print("Debe especificar una acción")
#