Implement system-specific EFI data support
parent
a6242b4b39
commit
2ffdd51110
|
@ -633,6 +633,13 @@ class OpengnsysGitLibrary:
|
|||
else:
|
||||
raise RequirementException("Couldn't find /usr/sbin/grub2-install or /usr/sbin/grub-install")
|
||||
|
||||
def _get_system_uuid(self):
|
||||
self.logger.debug("Obtaining system UUID...")
|
||||
result = subprocess.run(["/usr/sbin/dmidecode", "-s", "system-uuid"], check=True, capture_output=True)
|
||||
uuid = result.stdout.strip()
|
||||
self.logger.debug("UUID is %s", uuid)
|
||||
return uuid
|
||||
|
||||
def _efi_install(self, boot_device, root_directory):
|
||||
"""
|
||||
Install EFI data on the specified boot device.
|
||||
|
@ -648,12 +655,48 @@ class OpengnsysGitLibrary:
|
|||
shutil.Error: If an error occurs during the copying of the EFI data.
|
||||
"""
|
||||
|
||||
self.logger.info(f"Instalando datos EFI en {boot_device}")
|
||||
self.logger.info(f"Installing EFI files in {boot_device}")
|
||||
meta_dir = os.path.join(root_directory, ".opengnsys-metadata")
|
||||
efi_files_dir = os.path.join(meta_dir, "efi_data")
|
||||
|
||||
shutil.copytree(efi_files_dir, boot_device)
|
||||
|
||||
uuid = self._get_system_uuid()
|
||||
self.logger.debug("Checking if we have system-specific EFI data...")
|
||||
sys_efi_files_dir = os.path.join(meta_dir, f"efi_data.{uuid}")
|
||||
|
||||
|
||||
if os.path.exists(sys_efi_files_dir):
|
||||
self.logger.info("This system has specific EFI data, overriding default...")
|
||||
shutil.copytree(sys_efi_files_dir, boot_device)
|
||||
else:
|
||||
self.logger.debug("No system-specific EFI data.")
|
||||
|
||||
def _efi_copy(self, root_directory, system_specific = False):
|
||||
meta_dir = os.path.join(root_directory, ".opengnsys-metadata")
|
||||
|
||||
if not system_specific:
|
||||
self.logger.debug("Copying default EFI data")
|
||||
efi_files_dir = os.path.join(meta_dir, "efi_data")
|
||||
if os.path.exists(efi_files_dir):
|
||||
shutil.rmtree(efi_files_dir)
|
||||
|
||||
boot_device = self._find_boot_device
|
||||
shutil.copytree(boot_device, efi_files_dir)
|
||||
else:
|
||||
uuid = self._get_system_uuid()
|
||||
self.logger.debug("Copying EFI data for system %s", 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)
|
||||
|
||||
boot_device = self._find_boot_device
|
||||
shutil.copytree(boot_device, efi_files_dir)
|
||||
|
||||
|
||||
|
||||
def _find_boot_device(self):
|
||||
"""
|
||||
|
@ -873,13 +916,13 @@ class OpengnsysGitLibrary:
|
|||
metadata["efi_boot"] = self._is_efi()
|
||||
|
||||
if self._is_efi():
|
||||
self.logger.debug("Copying EFI data")
|
||||
efi_files_dir = os.path.join(meta_dir, "efi_data")
|
||||
if os.path.exists(efi_files_dir):
|
||||
shutil.rmtree(efi_files_dir)
|
||||
|
||||
boot_device = self._find_boot_device
|
||||
shutil.copytree(boot_device, efi_files_dir)
|
||||
self._efi_copy(path)
|
||||
#self.logger.debug("Copying EFI data")
|
||||
#efi_files_dir = os.path.join(meta_dir, "efi_data")
|
||||
#if os.path.exists(efi_files_dir):
|
||||
# shutil.rmtree(efi_files_dir)
|
||||
# boot_device = self._find_boot_device
|
||||
# shutil.copytree(boot_device, efi_files_dir)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue