sdkcraft (CLI)

The sdkcraft utility exposes the following commands, each with its own set of options, and also has a number of global flags:

-h, --help

Print the help message for the command.

sdkcraft clean

Remove a part’s assets

Usage

$ sdkcraft clean [--destructive-mode] [--platform name] [part-name ...]

Description

Clean up artifacts belonging to parts. If no parts are specified, remove the packing environment.

Flags

--destructive-mode

Build in the current host Default: False

--platform

Platform to clean

Examples

Clean build artifacts:

$ sdkcraft clean

Clean specific parts:

$ sdkcraft clean my-part

Clean in destructive mode:

$ sdkcraft clean --destructive-mode

sdkcraft pull

Download or retrieve artifacts defined for a part

Usage

$ sdkcraft pull [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                  [--platform name | --build-for arch]
                  [part-name ...]

Description

Download or retrieve artifacts defined for a part. If part names are specified only those parts will be pulled, otherwise all parts will be pulled.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft build

Build artifacts defined for a part

Usage

$ sdkcraft build [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                   [--platform name | --build-for arch]
                   [part-name ...]

Description

Build artifacts defined for a part. If part names are specified only those parts will be built, otherwise all parts will be built.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft stage

Stage built artifacts into a common staging area

Usage

$ sdkcraft stage [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                   [--platform name | --build-for arch]
                   [part-name ...]

Description

Stage built artifacts into a common staging area. If part names are specified only those parts will be staged. The default is to stage all parts.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft prime

Prime artifacts defined for a part

Usage

$ sdkcraft prime [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                   [--platform name | --build-for arch]
                   [part-name ...]

Description

Prepare the final payload to be packed, performing additional processing and adding metadata files. If part names are specified only those parts will be primed. The default is to prime all parts.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft pack

Create the final artifact

Usage

$ sdkcraft pack [--destructive-mode] [--shell | --shell-after] [--debug]
                  [--platform name | --build-for arch] [--output OUTPUT]

Description

Process parts and create the final artifact.

Flags

--destructive-mode

Build in the current host Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

--output

Output directory for created packages. Default: .

Examples

Pack the project:

$ sdkcraft pack

Pack to a specific output directory:

$ sdkcraft pack --output dist/

sdkcraft test

Run SDK tests

Usage

$ sdkcraft test [--destructive-mode] [--shell | --shell-after] [--debug] [--platform name]
                  [--list]
                  [test_expressions ...]

Description

Tests are defined and run using spread (https://github.com/canonical/spread).

Compared to running spread manually, sdkcraft test also: - Packs SDKs for all platforms matching the current architecture. - Copies the packed SDKs into the test environment using sdkcraft try. - Installs Workshop in the test environment. - Skips spread variants for bases that weren’t packed.

Flags

--destructive-mode

Build in the current host Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--list

Just show list of jobs that would run. Default: False

Examples

Test the project:

$ sdkcraft test

List the jobs that would run:

$ sdkcraft test --list

Run a specific test suite:

$ sdkcraft test my-suite/

sdkcraft try

Try SDKs before publishing

Usage

$ sdkcraft try [--destructive-mode] [--shell | --shell-after] [--debug]
                 [--platform name | --build-for arch] [--output OUTPUT]
                 [SDKs ...]

Description

Pack the SDK and copy it to the Workshop try area.

Flags

--destructive-mode

Build in the current host Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

--output

Output directory for created packages. Default: .

Examples

Try the built artifact:

$ sdkcraft try

sdkcraft init

Initialize an SDKcraft project

Usage

$ sdkcraft init [--name NAME] [--profile {simple}] [project_dir]

Description

Initialize an SDKcraft project by creating an ‘sdkcraft.yaml’ file together with hooks and tests.

Flags

--name

The name of project; defaults to the name of <project_dir>

--profile

Use the specified project profile (default is simple, c