Skip to content

Commit

Permalink
one ExitStack is enough
Browse files Browse the repository at this point in the history
  • Loading branch information
schaefi committed Feb 20, 2024
1 parent e20f216 commit 1de9cba
Showing 1 changed file with 17 additions and 46 deletions.
63 changes: 17 additions & 46 deletions kiwi/builder/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,24 @@ def create_disk(self) -> Result:
device_map, luks_root
)

# create system layout for root system
device_map = self._create_system_instance(
device_map, stack
)
# build bootable disk
self._process_build(device_map, disk)
self._build_main_system(
stack,
device_map,
disk,
self.storage_map['system'],
self.storage_map['system_boot'],
self.storage_map['system_efi'],
self.storage_map['system_spare'],
self.storage_map['system_custom_parts'] or {},
self.storage_map['luks_root'],
self.storage_map['raid_root'],
self.storage_map['integrity_root']
)

# store image bundle_format in result
if self.bundle_format:
Expand Down Expand Up @@ -715,51 +731,6 @@ def _map_root_filesystem(
)
self.storage_map['system'] = filesystem

def _process_build(self, device_map: Dict, disk: Disk) -> None:
with ExitStack() as stack:
# create system layout for root system
device_map = self._create_system_instance(device_map, stack)

# representing the entire image system except for the boot/ area
# which could live on another part of the disk
system: Optional[Union[FileSystemBase, VolumeManagerBase]] = \
self.storage_map['system']

# an instance of a class with the sync_data capability
# representing the boot/ area of the disk if not part of
# system
system_boot: Optional[FileSystemBase] = \
self.storage_map['system_boot']

# an instance of a class with the sync_data capability
# representing the boot/efi area of the disk
system_efi: Optional[FileSystemBase] = \
self.storage_map['system_efi']

# an instance of a class with the sync_data capability
# representing the spare_part_mountpoint area of the disk
system_spare: Optional[FileSystemBase] = \
self.storage_map['system_spare']

# a dict of instances with the sync_data capability
# representing the custom partitions area of the disk
system_custom_parts: Dict[str, FileSystemBase] = \
self.storage_map['system_custom_parts'] or {}

self._build_main_system(
stack,
device_map,
disk,
system,
system_boot,
system_efi,
system_spare,
system_custom_parts,
self.storage_map['luks_root'],
self.storage_map['raid_root'],
self.storage_map['integrity_root']
)

def _build_main_system(
self,
stack: ExitStack,
Expand Down

0 comments on commit 1de9cba

Please sign in to comment.