Module 14 · Lesson 48 of 92

CI and the release gate

Build a production image in clean CI and use its release identity, package manifest, SPDX SBOM, license evidence, and CVE findings to decide whether to publish it.

  • Beginner to advanced
  • 9 min read
  • 50 min lab
What you will need

Ubuntu 24.04 in WSL2 or a VM, a pinned Yocto Project Scarthgap checkout with Poky, and the custom layer from the preceding lessons. Use an x86-64 host for the qemux86-64 example. No physical board is required.

Your place in the module
By the end you can 4 objectives
  • Distinguish a fresh CI workspace from a build that executes tasks without shared state.
  • Build a production image with a custom distro name, version, and feature policy.
  • Inspect the built image's os-release file, package manifest, and SPDX SBOM.
  • Apply a release policy to a CVE finding and document a go or no-go decision.
Video coming soonCI and the release gate
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from Pinning versions and image variants
  • SRCREV = "${AUTOREV}" and moving tags make a release unrepeatable; pin full commit hashes and lock every layer commit
  • debug-tweaks allows an empty root password and root SSH login, and local.conf.sample enables it by default through EXTRA_IMAGE_FEATURES
  • The PR server hands out increasing PR values so package feeds upgrade correctly when PV stays the same
01

What CI must prove before publication

4 min read

A release is a promise, and CI is how you keep it. This lesson answers how the autobuilder and sstate mirrors gate a clean build, and how CVE and SPDX checks become the release's go/no-go.

A kernel CVE can apply to one device and be irrelevant to another because their kernels enable different features. The Linux kernel's CVE documentation places that applicability decision with the user of the kernel. A release job therefore needs to preserve the evidence that lets you identify the kernel and configuration you actually shipped. CVE handling in the Linux kernel

Continuous integration, or CI, runs the build from a recorded set of inputs. An autobuilder schedules jobs and assigns them to workers. Give each release job the pinned layer revisions, machine, distro, production image target, and configuration it must use. Run the selected image target and collect the required artifacts and logs. A production image and a debug image can come from the same revision and still contain different packages. A successful debug job provides evidence about the debug image. For a product with several supported machines, require a successful production job for every machine in the release list.

BitBake's lets a worker restore eligible outputs when BitBake finds a matching cache entry. SSTATE_DIR controls the local cache location. SSTATE_MIRRORS tells BitBake where else to look for shared state. A worker can start with an empty local cache and still restore outputs from a mirror. DL_DIR holds downloaded source inputs. A shared download directory can save fetch time while the build still executes tasks to produce their outputs. Use mirrors controlled by the build team for release jobs that allow shared state.

Define what your team means by a clean build before you make it a release requirement. A fresh workspace job starts with a new build directory and no previous work directory or deploy output. It can reuse approved shared state. That job checks whether the declared configuration and approved infrastructure can produce the candidate on a fresh worker. A build without sstate reuse starts with a new build directory, uses an empty job-specific SSTATE_DIR, and sets SSTATE_MIRRORS = "". It also needs fresh task state in TMPDIR. The fresh configuration may still point DL_DIR at approved downloads. For this lesson's release policy, use cached jobs for early feedback and build the release candidate itself without sstate reuse.

Production build in CIPin buildinputsRunfeedbackjobsapprovedsstatemirrorBuildproductioncandidatefreshworkspace,no sstatereuseCollectbuildevidencePin buildinputsRunfeedbackjobsapprovedsstatemirrorBuildproductioncandidatefreshworkspace,no sstatereuseCollectbuildevidence
Cached feedback jobs and the clean production job serve different purposes

A clean build can expose an undeclared dependency or a file that was present only on someone's workstation. It establishes that this job produced an image from the configured inputs. Proving that two builds yield identical bytes requires a second build and a comparison. Before queuing either kind of job, save the configuration and the selected revisions so a reviewer can reproduce the conditions under which the job ran. Keep the build log even on failure. If BitBake fails, the publication stage should stop and show which job failed.

Use a separate publication step that takes the specific artifact approved by the gate. Save its SHA-256 digest with the release record and verify the digest before publishing. For example, run sha256sum on the candidate file after the build and retain the result with the job artifacts. If a package changes after review, build again and review the new candidate. M20 takes this workflow further with CI pipeline design and automation. sha256sum(1): compute and check SHA-256 digests

02

Inspect the image CI built

3 min read

Use the custom layer from the preceding lessons. The files below give the build job a concrete distro and production target to select. The examples assume a Poky-based Scarthgap checkout with your layer enabled. Save this distro configuration as conf/distro/embeddex.conf in that layer. Requiring the Poky configuration gives the example a known base. The following assignments set the product identity and remove Bluetooth from the distro feature list for this product.

bitbake
require conf/distro/poky.conf

DISTRO = "embeddex"
DISTRO_NAME = "Embeddex Linux"
DISTRO_VERSION = "1.0"
DISTRO_FEATURES:remove = "bluetooth"

Save recipes-core/images/embeddex-production.bb in the same layer. This exercise uses a minimal image with an explicit os-release package and a compressed root filesystem tar archive. The tar archive lets you read target files directly on the Ubuntu host. The example leaves development image features such as debug-tweaks out of the recipe. Check the effective configuration too, because job settings can add image features.

bitbake
SUMMARY = "Embeddex production image"
LICENSE = "MIT"

IMAGE_INSTALL = "packagegroup-core-boot os-release"
IMAGE_FSTYPES = "tar.gz"

inherit core-image

From the initialized Yocto build environment, set DISTRO = "embeddex" and MACHINE = "qemux86-64" in conf/local.conf. Use the release checks in the next section before running bitbake embeddex-production if you want the same invocation to produce the image and its release evidence. In CI, use the same image target and distro settings committed for the release. Record any local settings you use in the exercise so you can explain a difference between your result and a later CI run.

With the default deploy directory settings, look under tmp/deploy/images/qemux86-64/ for the production image's .tar.gz and .manifest files. The deploy directory can contain dated files and convenience symlinks. Choose the files from your production job. Compare the candidate artifacts by build identity as well as by image name. Two builds can use the same target name, especially when a developer rebuilds after editing a recipe.

Set image_archive and image_manifest to the paths you selected. First list the archive members. Then use the second command with os_release_member set to the exact member name listed for etc/os-release, including any leading ./. If the entry is a symlink, inspect the listing for its target and use the archived member for that target. Reading the archive this way avoids extracting the whole root filesystem. tar(1): archive inspection and extraction

bash
tar -tvzf "$image_archive"
tar -xOzf "$image_archive" "$os_release_member"
head "$image_manifest"

Read ID, NAME, and VERSION_ID from the target file and compare them with DISTRO, DISTRO_NAME, and DISTRO_VERSION. Ubuntu's /etc/os-release describes the build host. The archive contains the target's identity. If the target identity is wrong, check the distro selected by the job before approving the artifact. You can inspect the expanded configuration with bitbake -e embeddex-production and find the final assignments for DISTRO_FEATURES and IMAGE_FEATURES. Confirm that Bluetooth is absent from the distro feature list. Use the manifest to check package contents, since a feature setting alone is insufficient evidence about every installed package.

The image manifest lists the installed packages with architecture and version information. It includes dependencies pulled into the image. Review it against the approved package list or a baseline from the preceding production release. For a new package, determine which image requirement or dependency brought it in and whether that addition is intentional. Keep the image manifest with the candidate. It gives reviewers a direct record of the root filesystem's package set and a starting point for the SBOM review.

Evidence from the image buildProduction buildRoot filesystem archivedistro identity in os-releaseImage manifestinstalled packages and versionsSPDX documentscomponent and license metadataProduction buildRoot filesystem archivedistro identity inos-releaseImage manifestinstalled packages andversionsSPDX documentscomponent and licensemetadata
Distro identity, package contents, and component metadata come from different artifacts
03

Decide whether the candidate can ship

4 min read

Enable the checks in the release configuration before the build. In the Poky-based Scarthgap example, use global inheritance so the classes participate in the build of the production image and its dependencies. With this configuration, the same image command produces the release evidence alongside the image. Collect that evidence from the production job's deploy directories. A report from a previous build can describe a different package set even when the filename looks familiar.

bitbake
INHERIT += "cve-check create-spdx"

The create-spdx class (the file is create-spdx.bbclass, with a hyphen, and scarthgap already enables it through INHERIT_DISTRO in defaultsetup.conf) creates an in SPDX format. In this Scarthgap setup, look in the machine image deploy directory for the image's .spdx.json document and its companion .spdx.tar.zst archive. Start with the image document and follow its references to the component documents. Use an installed zstd program with GNU tar to list the companion archive with tar --zstd -tf "$spdx_archive", after setting spdx_archive to its path. Retain the referenced documents with the image document so a reviewer can resolve those references later. tar(1): archive inspection and extraction

Pick an installed package from the image manifest and locate the corresponding package record in the SPDX evidence. Check the name and version, then identify the recipe or source component and read its license information. One recipe can produce several binary packages and the image can install a subset. Expect relationships between package and recipe documents, with their respective names and versions. If a shipped component has no usable record, investigate how the component entered the image and correct the inventory before publication. If the release also distributes separate boot or firmware files, track their coverage explicitly. The root filesystem manifest tells you which packages were installed into that filesystem.

For the license gate, compare the recorded licenses for distributed components with your approved policy. Use the underlying license texts and distribution terms when metadata is ambiguous or when you need to verify obligations. Verify that the required notices and any required source distribution materials are ready for the release. A missing required notice, an unapproved license, or unreviewed license metadata can hold the release even when the SPDX file is valid. Record the resolution against the same candidate so a later reviewer can see which obligations were checked.

cve-check compares recipe software identities and versions with vulnerability data and uses metadata such as recognized patches and explicit CVE dispositions. Collect the image CVE report from the machine's image deploy directory and record when the vulnerability data was refreshed. A successful BitBake exit can coexist with findings. The CI policy must inspect the report and enforce a decision. Treat a missing report, failed data update, or data older than the policy permits as a failed gate. A scan with no matches is useful only after checking that the report covers the expected software and that key recipes map to the correct upstream products.

Triage a finding by identifying which recipe matched, which outputs you ship, and exactly which source version and patches were built. Read the advisory and check affected versions, build options, and configuration. A vendor kernel can retain an older version string after receiving a backported fix. Verify that the actual patch is in the pinned source and covers the finding. If the checker matched an unrelated product, verify the mapping and correct the recipe's CVE_PRODUCT where appropriate. Record evidence before marking a CVE resolved or accepting an exception. Keep any exception scoped to the affected release or configuration, and give it an owner and an expiry.

Release decisionClean buildpassesCheckreleaseevidenceReviewfindingsVerifycandidatedigestExit from step 3: Policy blocksHold releasePublishcandidateClean buildpassesCheckreleaseevidenceReviewfindingsVerifycandidatedigestExit from step 3: PolicyblocksHold releasePublishcandidate
Publication requires a successful clean build and approved evidence from that candidate

For this lesson, block publication on an unresolved high-severity CVE that applies to shipped software unless the release policy authorizes a documented, time-limited exception. Hold findings whose applicability is unknown until someone reviews them. Require the expected SPDX documents, approved license evidence, and an accepted package manifest. Save the decision with the pinned inputs, image digest, and review records. If you change a patch, license notice package, or image configuration and rebuild, repeat the applicable checks on the new candidate.

In the next lesson, “Storage options and eMMC internals,” you will examine where an approved image is installed and what the storage device exposes to Linux.

Key takeaways

  • A new build directory can still restore task outputs from an sstate mirror.
  • The image reports its distro identity in os-release, while the image manifest lists installed packages.
  • SPDX inventories software and records license metadata, while cve-check reports vulnerability matches for review.
  • CI approves publication only when the candidate and its required evidence pass the documented policy.
Reflect
  1. Explain to a colleague, in two sentences: distinguish a fresh CI workspace from a build that executes tasks without shared state.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Find your next step

↑ ↓ to move · Enter to open · Esc to close