craft_parts.packages.apt_cache module

Manages the state of packages obtained using apt.

class craft_parts.packages.apt_cache.AptCache(*, stage_cache=None, stage_cache_arch=None)[source]

Bases: ContextDecorator

Transient cache for stage packages, or read-only for build packages.

Parameters:
  • stage_cache (Optional[Path])

  • stage_cache_arch (Optional[str])

classmethod configure_apt(application_package_name)[source]

Set up apt options and directories.

Parameters:

application_package_name (str)

Return type:

None

fetch_archives(download_path)[source]

Retrieve packages marked to be fetched.

Parameters:

download_path (Path) – The directory to download files to.

Return type:

list[tuple[str, str, Path]]

Returns:

A list of (<package-name>, <package-version>, <dl-path>) tuples.

get_installed_packages()[source]

Obtain a list of all packages and versions installed on the system.

Return type:

dict[str, str]

Returns:

A dictionary of files and installed versions.

get_installed_version(package_name, *, resolve_virtual_packages=False)[source]

Obtain the version of the package currently installed on the system.

Parameters:
  • package_name (str) – The package installed on the system.

  • resolve_virtual_packages (bool) – If the package is virtual, pick a non-virtual package that satisfies this virtual package name.

Return type:

str | None

Returns:

The installed package version.

get_packages_marked_for_installation()[source]

Obtain a list of packages and versions to be installed on the system.

Return type:

list[tuple[str, str]]

Returns:

A list of (<package-name>, <package-version>) tuples.

is_package_valid(package_name)[source]

Verify whether there is a valid package with the given name.

Parameters:

package_name (str) – The name of the package to verify.

Return type:

bool

Returns:

Whether a package with the given name is valid.

mark_packages(package_names)[source]

Mark the given package names to be fetched from the repository.

Parameters:

package_names (set[str]) – The set of package names to be marked.

Return type:

None

unmark_packages(unmark_names)[source]

Unmark packages and dependencies that are no longer required.

Parameters:

unmark_names (set[str]) – The names of the packages to unmark.

Return type:

None

class craft_parts.packages.apt_cache.LogProgress[source]

Bases: AcquireProgress

Internal Base class for text progress classes.

fail(item)[source]

Handle failed item.

Parameters:

item (AcquireItemDesc)

Return type:

None

fetch(item)[source]

Handle item’s data is fetch.

Parameters:

item (AcquireItemDesc)

Return type:

None