mirror of https://git.48k.eu/ogclient
uefi: remove dependency with probe.py
Reduce interdependency between imports by checking the correct OS for copy_windows_efi_bootloader() from the code invoking the operation. Break circular dependency where: probe.py imports from winreg.py winreg.py imports from uefi.py uefi.py imports from probe.pymaster
parent
476d82e6a9
commit
d29b601f17
|
@ -655,6 +655,7 @@ class OgLiveOperations:
|
|||
raise OgError(f'Cannot mount {ro_mountpoint} as readonly')
|
||||
|
||||
try:
|
||||
is_windows = get_os_family(ro_mountpoint) == OSFamily.WINDOWS
|
||||
if is_hibernation_enabled(ro_mountpoint):
|
||||
raise OgError(f'Target system in {padev} has hibernation enabled')
|
||||
finally:
|
||||
|
@ -669,7 +670,9 @@ class OgLiveOperations:
|
|||
if os.access(f'{image_path}', os.R_OK) == True:
|
||||
logging.info(f'image file {image_path} already exists, updating.')
|
||||
|
||||
copy_windows_efi_bootloader(disk, partition)
|
||||
if is_windows and is_uefi_supported():
|
||||
copy_windows_efi_bootloader(disk, partition)
|
||||
|
||||
if ogReduceFs(disk, partition) == -1:
|
||||
raise OgError(f'Failed to shrink {fstype} filesystem in {padev}')
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import subprocess
|
|||
import shutil
|
||||
from src.utils.disk import *
|
||||
from src.utils.fs import *
|
||||
from src.utils.probe import *
|
||||
from src.log import OgError
|
||||
|
||||
import fdisk
|
||||
|
@ -170,13 +169,7 @@ def copy_windows_efi_bootloader(disk, partition):
|
|||
device = get_partition_device(disk, partition)
|
||||
mountpoint = device.replace('dev', 'mnt')
|
||||
if not mount_mkdir(device, mountpoint):
|
||||
raise OgError(f'Cannot probe OS family. Unable to mount {device} into {mountpoint}')
|
||||
|
||||
os_family = get_os_family(mountpoint)
|
||||
is_uefi = is_uefi_supported()
|
||||
|
||||
if not is_uefi or os_family != OSFamily.WINDOWS:
|
||||
return
|
||||
raise OgError(f'Unable to mount {device} into {mountpoint}')
|
||||
|
||||
bootlabel = f'Part-{disk:02d}-{partition:02d}'
|
||||
esp, esp_disk, esp_part_number = get_efi_partition(disk, enforce_gpt=True)
|
||||
|
@ -209,7 +202,7 @@ def restore_windows_efi_bootloader(disk, partition):
|
|||
device = get_partition_device(disk, partition)
|
||||
mountpoint = device.replace('dev', 'mnt')
|
||||
if not mount_mkdir(device, mountpoint):
|
||||
raise OgError(f'Cannot probe OS family. Unable to mount {device} into {mountpoint}')
|
||||
raise OgError(f'Unable to mount {device} into {mountpoint}')
|
||||
|
||||
bootlabel = f'Part-{disk:02d}-{partition:02d}'
|
||||
esp, esp_disk, esp_part_number = get_efi_partition(disk, enforce_gpt=True)
|
||||
|
|
Loading…
Reference in New Issue