From d8ae70bb5dde0945d51e109594aa865f4c21e7a6 Mon Sep 17 00:00:00 2001 From: Sophie Pages Date: Sun, 19 Jan 2025 17:12:36 +0100 Subject: [PATCH 1/4] feat(Snapcraft): move parts lifecycle into a reference --- snapcraft/reference/parts-lifecycle.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 snapcraft/reference/parts-lifecycle.md diff --git a/snapcraft/reference/parts-lifecycle.md b/snapcraft/reference/parts-lifecycle.md new file mode 100644 index 0000000..e4c70b7 --- /dev/null +++ b/snapcraft/reference/parts-lifecycle.md @@ -0,0 +1,11 @@ +# Parts lifecycle + +Each part is composed of five steps, known as the "lifecycle": + +| Step | Purpose | Directory | Command | +| ----------- | ----------- | ----------- | ----------- | +| 1. **Pull** | Download or retrieve the components' sources and external dependencies needed to build the part. | Components' sources and external dependencies are put in CRAFT_PART_**SRC**. | `snapcraft pull []` | +| 2. **Build** | Build the components from the previously pulled sources. | Build the sources in CRAFT_PART_**BUILD** and places the result in CRAFT_PART_**INSTALL** | `snapcraft build []` | +| 3. **Stage** | Copy the built components into the staging area. | The built components are put in CRAFT_**STAGE**. | `snapcraft stage []` | +| 4. **Prime** | Copy the staged components into the priming area. | The staged components are put in CRAFT_**PRIME**. | `snapcraft prime []` | +| 5. **Pack** | Take the contents of the prime directory and pack it into a snap. | The snap is put in CRAFT_PROJECT_**DIR**. | `snapcraft pack or snapcraft` | From e99432f25e89a4604b88cd4ef3b7b54229566a45 Mon Sep 17 00:00:00 2001 From: Sophie Pages Date: Sun, 26 Jan 2025 17:27:07 +0100 Subject: [PATCH 2/4] feat(snapcraft): add parts paths and reorganise table --- snapcraft/reference/parts-lifecycle.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/snapcraft/reference/parts-lifecycle.md b/snapcraft/reference/parts-lifecycle.md index e4c70b7..f610103 100644 --- a/snapcraft/reference/parts-lifecycle.md +++ b/snapcraft/reference/parts-lifecycle.md @@ -1,11 +1,13 @@ # Parts lifecycle -Each part is composed of five steps, known as the "lifecycle": +Each part is composed of five steps, known as the "lifecycle". -| Step | Purpose | Directory | Command | -| ----------- | ----------- | ----------- | ----------- | -| 1. **Pull** | Download or retrieve the components' sources and external dependencies needed to build the part. | Components' sources and external dependencies are put in CRAFT_PART_**SRC**. | `snapcraft pull []` | -| 2. **Build** | Build the components from the previously pulled sources. | Build the sources in CRAFT_PART_**BUILD** and places the result in CRAFT_PART_**INSTALL** | `snapcraft build []` | -| 3. **Stage** | Copy the built components into the staging area. | The built components are put in CRAFT_**STAGE**. | `snapcraft stage []` | -| 4. **Prime** | Copy the staged components into the priming area. | The staged components are put in CRAFT_**PRIME**. | `snapcraft prime []` | -| 5. **Pack** | Take the contents of the prime directory and pack it into a snap. | The snap is put in CRAFT_PROJECT_**DIR**. | `snapcraft pack or snapcraft` | +See [Part lifecycle](/t/parts-lifecycle/12231) and [Parts environment variables](/t/parts-environment-variables/12271) to learn more about the Parts lifeycle and its environment variables. + +| Step | Command | Purpose | Directory | Path +| ----------- | ----------- | ----------- | ----------- | ----------- | +| **Pull** | `snapcraft pull []` | Downloads or retrieve the components' sources and external dependencies needed to build the part. | Components' sources and external dependencies are put in CRAFT_PART_**SRC** or CRAFT_PART_SRC_**WORK** if the source subdirectory is overridden. | **`parts//src`** or **`parts//src/`** | +| **Build** | `snapcraft build []` | Builds the components from the previously pulled sources. | Build the sources in CRAFT_PART_**BUILD** and places the result in CRAFT_PART_**INSTALL**. | **`parts//build`** and **`parts//install`** | +| **Stage** | `snapcraft stage []` | Copies the built components into the staging area. | The built components are put in CRAFT_**STAGE**. | **`stage`** | +| **Prime** | `snapcraft prime []` | Copies the staged components into the priming area. | The staged components are put in CRAFT_**PRIME**. | **`prime`** | +| **Pack** | `snapcraft pack or snapcraft` | Takes the contents of the prime directory and packs it into a snap. | The snap is put in CRAFT_PROJECT_**DIR**. | The path to the current project’s subtree in the filesystem. | From fc2c9c5dbccbe3bfceb50932f38c5b99139d179a Mon Sep 17 00:00:00 2001 From: Sophie Pages Date: Sun, 26 Jan 2025 17:35:13 +0100 Subject: [PATCH 3/4] chore(snapcraft): pull sources from discourse --- snapcraft/explanation/parts-lifecycle.md | 97 ++++++++++++++++++ .../quickstart/how-snapcraft-builds-a-snap.md | 99 +++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 snapcraft/explanation/parts-lifecycle.md create mode 100644 snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md diff --git a/snapcraft/explanation/parts-lifecycle.md b/snapcraft/explanation/parts-lifecycle.md new file mode 100644 index 0000000..9a495da --- /dev/null +++ b/snapcraft/explanation/parts-lifecycle.md @@ -0,0 +1,97 @@ +# Parts lifecycle +Parts, alongside [plugins](/t/snapcraft-plugins/4284), are a key component in any [Snapcraft](/t/snapcraft-overview/8940) project. + +See [Adding parts](/t/adding-parts/11473) for a general overview of what parts are and how to use them and [Scriptlets](https://forum.snapcraft.io/t/scriptlets/4892) for details on how they can be scripted outside of _snapcraft.yaml_. + +All parts within a project, by means of the logic encoded the plugins they're using, all go through the same series of steps. Knowing these steps, and which directories are used for each step, can help when creating more advanced snaps, and when troubleshooting build issues. + +- [Lifecycle steps](#heading--steps) +- [Step dependencies](#heading--step-dependencies) +- [Parts directories](#heading--parts-directories) + +--- + +

Lifecycle steps

+ +The steps a part goes through are as follows: + +1. **pull**: downloads or otherwise retrieves the components needed to build the part. You can use the [`source-*` keywords](/t/snapcraft-parts-metadata/8336#heading--source) of a part to specify which components to retrieve. If `source` points to a git repository, for example, the pull step will clone that repository. +1. **build**: constructs the part from the previously pulled components. The [`plugin`](/t/snapcraft-plugins/4284) of a part specifies how it is constructed. The [`meson` plugin](/t/the-meson-plugin/8623), for example, executes `meson` and `ninja` to compile source code. Each part is built in a separate directory, but it can use the contents of the staging area if it specifies a dependency on other parts using the `after` keyword. See [Step dependencies](#heading--step-dependencies) for more information. +1. **stage**: copies the built components into the staging area. This is the first time all the different parts that make up the snap are actually placed in the same directory. If multiple parts provide the same file with differing contents, you will get a conflict. You can avoid these conflicts by using the [`stage` keyword](/t/snapcraft-parts-metadata/8336#heading--stage) to enable or block files coming from the part. You can also use this keyword to filter out files that are not required in the snap itself, for example build files specific to a single part. +1. **prime**: copies the staged components into the priming area, to their final locations for the resulting snap. This is very similar to the stage step, but files go into the priming area instead of the staging area. The `prime` step exists because the staging area might still contain files that are required for the build but not for the snap. For example, if you have a part that downloads and installs a compiler, then you stage this part so other parts can use the compiler during building. You can then use the `prime` filter keyword to make sure that it doesn't get copied to the priming area, so it's not taking up space in the snap. Some extra checks are also run during this step to ensure that all dependencies are satisfied for a proper run time. If confinement was set to `classic`, then files will be scanned and, if needed, patched to work with this confinement mode. + +Finally, **pack** takes the entire contents of the `prime` directory and packs it into [a snap](/t/the-snap-format/698). + +Each of these lifecycle steps can be run from the command line, and the command can be part specific or apply to all parts in a project. + +1. `snapcraft pull []` +1. `snapcraft build []` +1. `snapcraft stage []` +1. `snapcraft prime []` +1. `snapcraft pack` or `snapcraft` + +Note that each command also executes the previous lifecycle steps, so `snapcraft` executes all the lifecycle steps chained together. + +To access the part environment at any stage, add the `--shell` argument. For example, `snapcraft prime --shell` will run up to the *prime* step and open a shell. See [Iterating over a build](/t/iterating-over-a-build/12143) for more details. + +

Step dependencies

+ +Each lifecycle step depends on the completion of the previous step for that part, so to reach a desired step, all prior steps need to have successfully run. By default, `snapcraft` runs the same lifecycle step of all parts before moving to the next step. However, you can change this behavior using the `after` keyword in the definition of a part in `snapcraft.yaml`. This creates a dependency chain from one part to another. + +```yaml + grv: + plugin: go + go-channel: 1.11/stable + after: + - libgit2 +``` + +In the above example, the part named `grv` will be built after the part named `libgit2` has been successfully built _and_ staged. + +

Overriding a step

+ +Each plugin defines the default actions that happen during a step. This behavior can be changed in two ways. + +- By using `override-` in `snapcraft.yaml`. See [Overriding steps](/t/scriptlets/4892) for more details. +- By using a local plugin. This can inherit the parent plugin or scaffolding from the original. See [Local plugins](/t/writing-local-plugins/5125) for more details. + +See [Parts environment variables](/t/parts-environment-variables/12271) for a list of part-specific environment variables that can be accessed to help build a part. + +

Parts directories

+ +When running through its build steps, a part will use different working directories. These closely follow the step names for the lifecycle. + +The directories are specified by their environment variables: +- **Snapcraft 7+**: environment variables start with `CRAFT_` +- **Snapcraft 6, and earlier**: variables start with `SNAPCRAFT_` but are otherwise identical + +See [Parts environment variables](/t/parts-environment-variables/12271) for more details. + +| Environment variable | Directory                                     | Purpose | +|--|--|--| +| `CRAFT_PART_SRC` | **`parts//src`** | the location of the source during the *pull* step | +| `CRAFT_PART_BUILD` | **`parts//build`** | the working directory during the *build* step | +| `CRAFT_PART_INSTALL`| **`parts//install`** | contains the results of the *build* step and the stage packages. | +| `CRAFT_STAGE` | **`stage`** | shared by all parts, this directory contains the development libraries, headers, and other components (e.g.; pkgconfig files) that need to be accessible from other parts | +| `CRAFT_PRIME` | **`prime`** | shared by all parts, this directory holds the final components for the resulting snap. | + +The following table gives an overview of which directories each step uses. + + + +| Step | Explanation | +|--|--| +| **pull** | downloads and retrieves the sources specified by the [`source`](https://forum.snapcraft.io/t/snapcraft-parts-metadata/8336#heading--source) key and puts them in CRAFT_PART_**SRC** | +| **build** | builds the sources in CRAFT_PART_**BUILD** and places the result in CRAFT_PART_**INSTALL** | +| **organize** | renames built files in CRAFT_PART_**INSTALL** | +| **stage** | copies built files from CRAFT_PART_**INSTALL** to the shared CRAFT_**STAGE** | +| **prime** | copies the *staged* files from the shared CRAFT_**STAGE** to the shared CRAFT_**PRIME** | +| **pack** | packs contents of CRAFT_**PRIME** into a snap and puts the snap in CRAFT_PROJECT_DIR | diff --git a/snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md b/snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md new file mode 100644 index 0000000..b7e6318 --- /dev/null +++ b/snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md @@ -0,0 +1,99 @@ +# How Snapcraft builds snaps +The Snapcraft tool can perform a variety of operations, including: + +* Snap creation operations like build, stage, prime, pack, etc. +* Store management operations like login, register, sign-build, etc. +* Extensions-specific operations like expand-extensions and list-extensions. + +These operations translate into practical tasks like: + +* It can build snaps locally or send remote tasks to Launchpad. +* It allows the developer to register and log into the Snap Store. +* It can upload snaps to the Snap Store. +* It can promote snaps to different channels. + +The list of available global options and commands can be checked with one of: + +```bash +snapcraft help +snapcraft help --all +``` + +

snapcraft.yaml

+ +Snaps are created using a build recipe defined in a file called `snapcraft.yaml`. + +When the snapcraft tool is executed on the command line, it will look for the file in the current project work directory, either in the top-level folder or a `snap` subdirectory. If the file is found, snapcraft will then parse its contents and progress the build toward completion. + +`snapcraft.yaml` is a configuration file written in the YAML language, with stanzas defining the application structure and behavior. When snapcraft runs and parses this file, it will use the declared information to build the snap. For developers more familiar with the traditional Linux build systems, the process is somewhat similar to the use of a Makefile or an RPM spec file. + +You can create the `snapcraft.yaml` file manually, or you can run the `snapcraft init` command to create a template file in the `snap` subdirectory. + +```bash +snapcraft init +``` + +A generated template file contains just enough data to build, split across three stanzas: + +* Metadata. +* Confinement level. +* Build definition. + +

Main definitions inside snapcraft.yaml

+ +There is no one way for how a snap ought to be assembled. However, most `snapcraft.yaml` files have the same common elements, including a number of mandatory declarations. Below is a short list of these keys, which will be further explained in the Examples sections later in the tutorial. + +* **Metadata** - describes the snap functionality and provides identifiers by which the snap can be cataloged and searched in the Snap Store. +* **Security confinement** - describes the level of security of the snap. +* **Base** - describes which set of libraries the snap will use for its functionality. The base also defines the operating system version for the snap build instance in the virtual machine or container launched by Snapcraft. For instance, base: core18 means that Snapcraft will launch an Ubuntu 18.04 virtual machine or container, the set of tools and libraries used inside the snap will originate from the Ubuntu 18.04 repository archives, and the snap applications will “think” they are running on top of an Ubuntu 18.04 system, regardless of what the actual underlying Linux distribution is. +* **Parts** - describes the components that will be used to assemble the snap. +* **Apps** - describes the applications and their commands that can be run in an installed snap. + +It is important to note several additional details: + +* A snap may contain one or more parts. +* A snap may contain one or more applications +* Parts can be pre-assembled binaries or they may be compiled as part of the build process. +* The parts section of the `snapcraft.yaml` file uses Snapcraft build system or language-specific plugins to simplify the build process. +* The parts section may also include a list of [build packages](/t/build-and-staging-dependencies/11451) (build-packages) that will be used to create the snap applications but will not be included in the final snap. For instance, gcc or make. + +The parts section may also include a list of [stage packages](/t/build-and-staging-dependencies/11451) (stage-packages) that will be used by the snap’s applications at runtime, e.g.: python-bcrypt. These will be obtained from the repository archives in the build instance. + +

Snapcraft build lifecycle

+ +Snaps are [built](/t/parts-lifecycle/12231) in several steps, collectively known as the “lifecycle”: + +* **Pull** - At this step of the snap build process, Snapcraft downloads or retrieves the components needed to build the relevant part. For instance, if source points to a Git repository, the pull step will clone that repository. +* **Build** - Snapcraft constructs the part from the previously pulled components. Since the snap ecosystem supports multiple types of applications (C, Java, Go, Rust, Python, etc.), the build definition also needs to include a specification on how to construct the part. This is done by declaring a [Snapcraft plugin](/t/snapcraft-plugins/4284). Parts are processed linearly, unless there is a dependency order declared. +* **Stage** - Snapcraft copies the built parts into the staging area. Parts are not ordered at this point, and there might be an additional level of processing to ensure the snap contains the required files, and that there are no conflicts between parts. This is an advanced topic beyond the scope of this tutorial. +* **Prime** - Snapcraft copies the staged components into the priming area, where the files will be placed in their final locations (folder and files path hierarchy) for the resulting snap. The prime step is similar to the stage step, but it may exclude certain components from the stage step. +* **Pack** - Snapcraft packs the assembled components in the prime directory into a single archive. + + +

Snapcraft build output

+ +The artifact of a successful Snapcraft build run is a snap file, which is itself a compressed Squashfs archive distinguished by the .snap suffix. + +A snap may contain one or more files that allow the applications to run without reliance on the underlying host system’s libraries. A snap will contain one or more applications, daemons, configuration files, assets like icons, and other objects. + +Typically, the content of a snap will resemble a Linux filesystem layout: + +```no-highlight +drwxr-xr-x 10 igor igor 4096 Jun 10 2020 ./ +drwxrwxrwx 14 igor igor 16384 Oct 17 16:40 ../ +drwxr-xr-x 2 igor igor 4096 Jun 10 2020 bin/ +drwxr-xr-x 10 igor igor 4096 Jun 10 2020 etc/ +-rw-r--r-- 1 igor igor 14 Jun 10 2020 flavor-select +drwxr-xr-x 3 igor igor 4096 Jun 10 2020 lib/ +drwxr-xr-x 2 igor igor 4096 Jun 10 2020 lib64/ +drwxr-xr-x 3 igor igor 4096 Jun 10 2020 meta/ +drwxr-xr-x 3 igor igor 4096 Jun 10 2020 snap/ +drwxr-xr-x 7 igor igor 4096 Jun 10 2020 usr/ +drwxr-xr-x 3 igor igor 4096 Feb 26 2018 var/ +``` + +The end user can examine the contents of a snap by either looking through the 'prime' directory of the build environment, or by extracting the snap archive: + +```bash +unsquashfs .snap +``` From 9fc34e580a3a11a3d318416e8b60934c075c8934 Mon Sep 17 00:00:00 2001 From: Sophie Pages Date: Sun, 26 Jan 2025 17:45:41 +0100 Subject: [PATCH 4/4] feat(snapcraft): remove duplicate information Streamline documentation and add links to the reference. --- snapcraft/explanation/parts-lifecycle.md | 29 +++++++------------ .../quickstart/how-snapcraft-builds-a-snap.md | 13 ++------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/snapcraft/explanation/parts-lifecycle.md b/snapcraft/explanation/parts-lifecycle.md index 9a495da..60f1b3d 100644 --- a/snapcraft/explanation/parts-lifecycle.md +++ b/snapcraft/explanation/parts-lifecycle.md @@ -1,26 +1,30 @@ # Parts lifecycle + Parts, alongside [plugins](/t/snapcraft-plugins/4284), are a key component in any [Snapcraft](/t/snapcraft-overview/8940) project. -See [Adding parts](/t/adding-parts/11473) for a general overview of what parts are and how to use them and [Scriptlets](https://forum.snapcraft.io/t/scriptlets/4892) for details on how they can be scripted outside of _snapcraft.yaml_. +See [Adding parts](/t/adding-parts/11473) for a general overview of what parts are and how to use them, [Scriptlets](https://forum.snapcraft.io/t/scriptlets/4892) for details on how they can be scripted outside of _snapcraft.yaml_, and [Parts lifecycle]() reference for the summarised information of this page. All parts within a project, by means of the logic encoded the plugins they're using, all go through the same series of steps. Knowing these steps, and which directories are used for each step, can help when creating more advanced snaps, and when troubleshooting build issues. - [Lifecycle steps](#heading--steps) -- [Step dependencies](#heading--step-dependencies) +- [Steps commands](#heading--steps-commands) +- [Steps dependencies](#heading--steps-dependencies) +- [Overriding a step](#heading--overriding-steps) - [Parts directories](#heading--parts-directories) ---

Lifecycle steps

-The steps a part goes through are as follows: +The steps of a part goes through are as follows: 1. **pull**: downloads or otherwise retrieves the components needed to build the part. You can use the [`source-*` keywords](/t/snapcraft-parts-metadata/8336#heading--source) of a part to specify which components to retrieve. If `source` points to a git repository, for example, the pull step will clone that repository. 1. **build**: constructs the part from the previously pulled components. The [`plugin`](/t/snapcraft-plugins/4284) of a part specifies how it is constructed. The [`meson` plugin](/t/the-meson-plugin/8623), for example, executes `meson` and `ninja` to compile source code. Each part is built in a separate directory, but it can use the contents of the staging area if it specifies a dependency on other parts using the `after` keyword. See [Step dependencies](#heading--step-dependencies) for more information. 1. **stage**: copies the built components into the staging area. This is the first time all the different parts that make up the snap are actually placed in the same directory. If multiple parts provide the same file with differing contents, you will get a conflict. You can avoid these conflicts by using the [`stage` keyword](/t/snapcraft-parts-metadata/8336#heading--stage) to enable or block files coming from the part. You can also use this keyword to filter out files that are not required in the snap itself, for example build files specific to a single part. 1. **prime**: copies the staged components into the priming area, to their final locations for the resulting snap. This is very similar to the stage step, but files go into the priming area instead of the staging area. The `prime` step exists because the staging area might still contain files that are required for the build but not for the snap. For example, if you have a part that downloads and installs a compiler, then you stage this part so other parts can use the compiler during building. You can then use the `prime` filter keyword to make sure that it doesn't get copied to the priming area, so it's not taking up space in the snap. Some extra checks are also run during this step to ensure that all dependencies are satisfied for a proper run time. If confinement was set to `classic`, then files will be scanned and, if needed, patched to work with this confinement mode. +1. **pack**: takes the entire contents of the `prime` directory and packs it into [a snap](/t/the-snap-format/698). -Finally, **pack** takes the entire contents of the `prime` directory and packs it into [a snap](/t/the-snap-format/698). +

Steps commands

Each of these lifecycle steps can be run from the command line, and the command can be part specific or apply to all parts in a project. @@ -34,7 +38,7 @@ Note that each command also executes the previous lifecycle steps, so `snapcraft To access the part environment at any stage, add the `--shell` argument. For example, `snapcraft prime --shell` will run up to the *prime* step and open a shell. See [Iterating over a build](/t/iterating-over-a-build/12143) for more details. -

Step dependencies

+

Steps dependencies

Each lifecycle step depends on the completion of the previous step for that part, so to reach a desired step, all prior steps need to have successfully run. By default, `snapcraft` runs the same lifecycle step of all parts before moving to the next step. However, you can change this behavior using the `after` keyword in the definition of a part in `snapcraft.yaml`. This creates a dependency chain from one part to another. @@ -67,7 +71,7 @@ The directories are specified by their environment variables: See [Parts environment variables](/t/parts-environment-variables/12271) for more details. -| Environment variable | Directory                                     | Purpose | +| Environment variable | Directory | Purpose | |--|--|--| | `CRAFT_PART_SRC` | **`parts//src`** | the location of the source during the *pull* step | | `CRAFT_PART_BUILD` | **`parts//build`** | the working directory during the *build* step | @@ -75,10 +79,8 @@ See [Parts environment variables](/t/parts-environment-variables/12271) for more | `CRAFT_STAGE` | **`stage`** | shared by all parts, this directory contains the development libraries, headers, and other components (e.g.; pkgconfig files) that need to be accessible from other parts | | `CRAFT_PRIME` | **`prime`** | shared by all parts, this directory holds the final components for the resulting snap. | -The following table gives an overview of which directories each step uses. - - -| Step | Explanation | -|--|--| -| **pull** | downloads and retrieves the sources specified by the [`source`](https://forum.snapcraft.io/t/snapcraft-parts-metadata/8336#heading--source) key and puts them in CRAFT_PART_**SRC** | -| **build** | builds the sources in CRAFT_PART_**BUILD** and places the result in CRAFT_PART_**INSTALL** | -| **organize** | renames built files in CRAFT_PART_**INSTALL** | -| **stage** | copies built files from CRAFT_PART_**INSTALL** to the shared CRAFT_**STAGE** | -| **prime** | copies the *staged* files from the shared CRAFT_**STAGE** to the shared CRAFT_**PRIME** | -| **pack** | packs contents of CRAFT_**PRIME** into a snap and puts the snap in CRAFT_PROJECT_DIR | diff --git a/snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md b/snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md index b7e6318..5356c7d 100644 --- a/snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md +++ b/snapcraft/how-to/quickstart/how-snapcraft-builds-a-snap.md @@ -59,19 +59,10 @@ It is important to note several additional details: The parts section may also include a list of [stage packages](/t/build-and-staging-dependencies/11451) (stage-packages) that will be used by the snap’s applications at runtime, e.g.: python-bcrypt. These will be obtained from the repository archives in the build instance. -

Snapcraft build lifecycle

- -Snaps are [built](/t/parts-lifecycle/12231) in several steps, collectively known as the “lifecycle”: - -* **Pull** - At this step of the snap build process, Snapcraft downloads or retrieves the components needed to build the relevant part. For instance, if source points to a Git repository, the pull step will clone that repository. -* **Build** - Snapcraft constructs the part from the previously pulled components. Since the snap ecosystem supports multiple types of applications (C, Java, Go, Rust, Python, etc.), the build definition also needs to include a specification on how to construct the part. This is done by declaring a [Snapcraft plugin](/t/snapcraft-plugins/4284). Parts are processed linearly, unless there is a dependency order declared. -* **Stage** - Snapcraft copies the built parts into the staging area. Parts are not ordered at this point, and there might be an additional level of processing to ensure the snap contains the required files, and that there are no conflicts between parts. This is an advanced topic beyond the scope of this tutorial. -* **Prime** - Snapcraft copies the staged components into the priming area, where the files will be placed in their final locations (folder and files path hierarchy) for the resulting snap. The prime step is similar to the stage step, but it may exclude certain components from the stage step. -* **Pack** - Snapcraft packs the assembled components in the prime directory into a single archive. - -

Snapcraft build output

+See [Parts lifecycle]() to consult the Parts lifecycle steps. + The artifact of a successful Snapcraft build run is a snap file, which is itself a compressed Squashfs archive distinguished by the .snap suffix. A snap may contain one or more files that allow the applications to run without reliance on the underlying host system’s libraries. A snap will contain one or more applications, daemons, configuration files, assets like icons, and other objects.