craft_parts.overlays.overlay_manager module

Overlay mount operations and package installation helpers.

class craft_parts.overlays.overlay_manager.ChrootMount(overlay_manager, top_part, pkg_cache=True)

Bases: LayerMount

Context manager that mounts an overlay for step processing and runs code inside a chroot environment.

Parameters:
class craft_parts.overlays.overlay_manager.LayerMount(overlay_manager, top_part, pkg_cache=True)

Bases: object

Mount 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.

install_packages(package_names)

Install the specified packages on the local system.

Parameters:

package_names (list[str]) – The list of packages to install.

Return type:

None

class craft_parts.overlays.overlay_manager.OverlayManager(*, project_info, part_list, base_layer_dir, cache_level, use_host_sources=False)

Bases: object

Execution 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.

property base_layer_dir: Path | None

Return the path to the base layer, if any.

property cache_level: int

The cache layer index above the base layer.

download_packages(package_names)

Download packages and populate the overlay package cache.

Parameters:

package_names (list[str]) – The list of packages to download.

Return type:

None

install_packages(package_names)

Install packages on the overlay area using chroot.

Parameters:

package_names (list[str]) – The list of packages to install.

Return type:

None

mkdirs()

Create overlay directories and mountpoints.

Return type:

None

mount_layer(part, *, pkg_cache=False)

Mount the overlay step layer stack up to the given part.

Parameters:
  • part (Part) – The part corresponding to the topmost layer to mount.

  • cache (pkg) – Whether the package cache layer is enabled.

  • pkg_cache (bool)

Return type:

None

mount_pkg_cache()

Mount the overlay step package cache layer.

Return type:

None

refresh_packages_list()

Update the list of available packages in the overlay system.

Return type:

None

run(target, *args, **kwargs)

Run the given callable inside the chroot environment.

Parameters:
  • target (Callable[..., TypeVar(_T)])

  • args (Any)

  • kwargs (Any)

Return type:

TypeVar(_T)

unmount()

Unmount the overlay step layer stack.

Return type:

None

class craft_parts.overlays.overlay_manager.PackageCacheMount(overlay_manager)

Bases: object

Mount and umount the overlay package cache.

Parameters:

overlay_manager (OverlayManager) – The overlay manager.

download_packages(package_names)

Download the specified packages to the local system.

Parameters:

package_names (list[str]) – The list of packages to download.

Return type:

None

refresh_packages_list()

Update the list of available packages in the overlay system.

Return type:

None