craft_parts.overlays package¶
Submodules¶
Module contents¶
Overlay filesystem management and helpers.
- class craft_parts.overlays.ChrootMount(overlay_manager, top_part, pkg_cache=True)¶
Bases:
LayerMountContext manager that mounts an overlay for step processing and runs code inside a chroot environment.
- Parameters:
overlay_manager (
OverlayManager)top_part (
Part)pkg_cache (
bool)
- class craft_parts.overlays.LayerHash(layer_hash)¶
Bases:
objectThe layer validation hash for a part.
- Parameters:
layer_hash (
bytes)
- classmethod for_part(part, *, previous_layer_hash)¶
Obtain the validation hash for a part.
- classmethod load(part)¶
Read the part layer validation hash from persistent state.
- class craft_parts.overlays.LayerMount(overlay_manager, top_part, pkg_cache=True)¶
Bases:
objectMount the overlay layer stack for step processing.
- Parameters:
overlay_manager (
OverlayManager) – The overlay manager.top_part (
Part) – The topmost part to mount.pkg_cache (
bool) – Whether to mount the overlay package cache.
- class craft_parts.overlays.LayerStateManager(part_list, base_layer_hash)¶
Bases:
objectAn in-memory layer state management helper for action planning.
- Parameters:
- compute_layer_hash(part)¶
Calculate the layer validation hash for the given part.
- get_layer_hash(part)¶
Obtain the layer hash for the given part.
- class craft_parts.overlays.OverlayManager(*, project_info, part_list, base_layer_dir, cache_level, use_host_sources=False)¶
Bases:
objectExecution time overlay mounting and package installation.
- Parameters:
project_info (
ProjectInfo) – The project information.part_list (
list[Part]) – A list of all parts in the project.base_layer_dir (
Path|None) – The directory containing the overlay base, or None if the project doesn’t use overlay parameters.cache_level (
int) – The number of part layers to be mounted before the package cache.use_host_sources (
bool) – Configure chroot to use package sources from the host environment.
- download_packages(package_names, *, include_recommends=False)¶
Download packages and populate the overlay package cache.
- install_packages(package_names, *, include_recommends=False)¶
Install packages on the overlay area using chroot.
- mount_layer(part, *, pkg_cache=False)¶
Mount the overlay step layer stack up to the given part.
- refresh_packages_list()¶
Update the list of available packages in the overlay system.
- Return type:
- run(target, *args, **kwargs)¶
Run the given callable inside the chroot environment.
- class craft_parts.overlays.PackageCacheMount(overlay_manager)¶
Bases:
objectMount and umount the overlay package cache.
- Parameters:
overlay_manager (
OverlayManager) – The overlay manager.
- download_packages(package_names, *, include_recommends=False)¶
Download the specified packages to the local system.
- craft_parts.overlays.is_oci_opaque_dir(path)¶
Verify if the given path corresponds to an opaque directory.
- craft_parts.overlays.is_oci_whiteout(path)¶
Verify if the given path corresponds to an OCI whiteout file.
- craft_parts.overlays.is_oci_whiteout_file(path)¶
Verify if the given path corresponds to an OCI whiteout file hiding a file.
- craft_parts.overlays.is_opaque_dir(path)¶
Verify if the given path corresponds to an opaque directory.
Overlayfs opaque directories are represented by directories with the extended attribute trusted.overlay.opaque set to y.
- craft_parts.overlays.is_whiteout_file(path)¶
Verify if the given path corresponds to a whiteout file.
Overlayfs whiteout files are represented as character devices with major and minor numbers set to 0.
- craft_parts.overlays.oci_opaque_dir(path)¶
Return the OCI opaque directory marker.
- craft_parts.overlays.oci_whited_out_file(whiteout_file)¶
Find the whited out file corresponding to a whiteout file.
- craft_parts.overlays.oci_whiteout(path)¶
Convert the given path to an OCI whiteout file name.
- craft_parts.overlays.visible_in_layer(lower_dir, upper_dir)¶
Determine the files and directories that are visible in a layer.
Given a pair of directories containing lower and upper layer entries, list the files and subdirectories in the lower layer that would be directly visible when the layers are stacked (i.e. the visibility is not “blocked” by an entry with the same name that exists in the upper directory). The upper directory may contain OCI whiteout files and opaque dirs.