craft_parts.packages.snaps module¶
Helpers to install snap packages.
- class craft_parts.packages.snaps.SnapPackage(snap)[source]¶
Bases:
object
SnapPackage 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)[source]¶
Download a given snap.
- Parameters:
directory (
Union
[str
,Path
,None
])- Return type:
None
- get_local_snap_info()[source]¶
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()[source]¶
Return a store payload for the snap.
- Return type:
dict
[str
,Any
] |None
- property in_store: bool¶
Whether this snap is available in the store.
- property installed: bool¶
Whether this snap is currently installed on the system.
- classmethod is_snap_installed(snap)[source]¶
Verify whether the given snap is installed.
- Parameters:
snap (
str
)- Return type:
bool
- craft_parts.packages.snaps.download_snaps(*, snaps_list, directory)[source]¶
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)[source]¶
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()[source]¶
Return all the snaps installed in the system.
- Return type:
list
[str
]- Returns:
a list of “name=revision” for the snaps installed.