Components¶
Components are parts of a snap that can be built and uploaded in conjunction
with a snap and later optionally installed beside it. Components are defined
with a top-level components
keyword in a snapcraft.yaml.
Like snaps, components are packaged a squashfs file. When installed, the
component is mounted at the path $SNAP/../components/$SNAP_REVISION/
so
the host snap can access it.
Types¶
A component must declare a type
in the project’s snapcraft.yaml
file.
For some types, Snapcraft may place requirements on the files of a component
and snapd may have special handling for the component.
Standard¶
The standard
type is the general use type for components. It should be used
when no specific type applies. Snapcraft has no requirements or special
handling for this type.
Kernel-modules¶
The kernel-modules
type should only be used for
kernel snaps. These components are for kernel
modules and firmware that are made available to the system after installation.
This type allows the kernel to find firmware and for users to load kernel
modules with modprobe
.
Static modules should be organized under modules/<kernel-version>/
in the
component, where <kernel-version>
is the version reported by uname -r
.
Firmware should be organized under firmware/
in the component.
Modules and firmware may be dynamically generated by the component’s
install
or refresh
hooks:
Modules generated by a hook should be placed in
$SNAP_DATA/modules/<kernel-version>/
.Firmware generated by a hook should be placed in
$SNAP_DATA/firmware/
.
To allow loading of dynamically generated modules and firmware, the snap’s
meta/kernel.yaml
file must declare dynamic-modules: $SNAP_DATA
.
Partition-specific output directory environment variables¶
If partitions are enabled, partition-specific environment variables will be created for use during step processing and execution of user-defined scriptlets.
These variable names will contain the (optional) namespace, partition name, and lifecycle step, formatted as CRAFT_[<namespace>_]<partition>_{STAGE|PRIME}
. The values of these variables will be the directory that corresponds to that partition and step. For instance, if the defined partitions are default
, kernel
, and component/bar-baz
, the following environment variables will be created:
$CRAFT_STAGE -> stage
$CRAFT_DEFAULT_STAGE -> stage
$CRAFT_KERNEL_STAGE -> partitions/kernel/stage
$CRAFT_COMPONENT_BAR_BAZ_STAGE -> partitions/component/bar-baz/stage
$CRAFT_PRIME -> prime
$CRAFT_DEFAULT_PRIME -> prime
$CRAFT_KERNEL_PRIME -> partitions/kernel/prime
$CRAFT_COMPONENT_BAR_BAZ_PRIME -> partitions/component/bar-baz/prime
(Note that the hyphen in the partition component/bar-baz
is converted to an underscore in the corresponding variable names.)