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.