craft_parts.packages.snaps module¶
Helpers to install snap packages.
- class craft_parts.packages.snaps.SnapPackage(snap)¶
Bases:
objectSnapPackage acts as a mediator to install or refresh a snap.
It uses information provided by snapd implicitly referring to the local and remote stores to obtain information about the snap, such as its confinement value and channel availability.
This information can also be used to determine if a snap should be installed or refreshed.
There are risks of the data falling out of date between the query and the requested action given that it is not possible to hold a global lock on snapd and the store data can change in between validation and execution.
- Parameters:
snap (
str)
- download(*, directory=None)¶
Download a given snap.
- Parameters:
directory (
str|Path|None)- Return type:
None
- get_current_channel()¶
Obtain the current channel for this snap.
- Return type:
str
- get_local_snap_info()¶
Return a local payload for the snap.
Validity of the results are determined by checking self.installed.
- Return type:
dict[str,Any] |None
- get_store_snap_info()¶
Return a store payload for the snap.
- Return type:
dict[str,Any] |None
- has_assertions()¶
Verify whether this snap has assertions.
- Return type:
bool
- property in_store: bool¶
Whether this snap is available in the store.
- install()¶
Installs the snap onto the system.
- Return type:
None
- property installed: bool¶
Whether this snap is currently installed on the system.
- is_classic()¶
Verify whether this snap is a classic snap.
- Return type:
bool
- classmethod is_snap_installed(snap)¶
Verify whether the given snap is installed.
- Parameters:
snap (
str)- Return type:
bool
- is_valid()¶
Check if the snap is valid.
- Return type:
bool
- classmethod is_valid_snap(snap)¶
Verify whether the given snap is valid.
- Parameters:
snap (
str)- Return type:
bool
- refresh()¶
Refresh a snap onto a channel on the system.
- Return type:
None
- craft_parts.packages.snaps.download_snaps(*, snaps_list, directory)¶
Download snaps of the format <snap-name>/<channel> into directory.
The target directory is created if it does not exist.
- Parameters:
snaps_list (
Sequence[str])directory (
str|Path)
- Return type:
None
- craft_parts.packages.snaps.get_assertion(assertion_params)¶
Get assertion information.
- Parameters:
assertion_params (
Sequence[str]) – a sequence of strings to pass to ‘snap known’.- Returns:
a stream of bytes from the assertion.
- Return type:
bytes
- craft_parts.packages.snaps.get_installed_snaps()¶
Return all the snaps installed in the system.
- Return type:
list[str]- Returns:
a list of “name=revision” for the snaps installed.
- craft_parts.packages.snaps.get_snapd_socket_path_template()¶
Return the template for the snapd socket URI.
- Return type:
str
- craft_parts.packages.snaps.install_snaps(snaps_list)¶
Install snaps of the format <snap-name>/<channel>.
- Return type:
list[str]- Returns:
a list of “name=revision” for the snaps installed.
- Parameters:
snaps_list (
Sequence[str] |set[str])