How to freeze a Yocto repository using a Manifest file

From RidgeRun Developer Wiki


Description

When working with Yocto and especially with the Google repo tool[1], it is frequent that each time you create a new build, each project revision is changed with the latest version available at the URL repository. This is usually okay but it could bring some issues if you are already trying to freeze the code for production and you want to avoid any unexpected changes in the entire project. It happens that in some cases those version updates could break the entire build, which would be catastrophic for product development.

In this wiki, it is presented a way to freeze a Yocto build and keep it unchanged on each repo initialization ensuring you will always work with the same recipes version.

The repo manifest

The repo tool works based on an XML manifest[2] that lists all the required elements on a Yocto build. It includes a description of each repository and the required branches to be fetched. A default manifest looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>

  <default sync-j="4" revision="pyro"/>

  <remote fetch="https://git.yoctoproject.org/git" name="yocto"/>
  <remote fetch="https://github.com/Freescale" name="freescale"/>
  <remote fetch="https://github.com/openembedded" name="oe"/>

  <project remote="yocto" revision="pyro" name="poky" path="sources/poky"/>
  <project remote="yocto" revision="pyro" name="meta-freescale" path="sources/meta-freescale"/>

  <project remote="oe" revision="pyro" name="meta-openembedded" path="sources/meta-openembedded"/>

  <project remote="freescale" revision="pyro" name="fsl-community-bsp-base" path="sources/base">
	<linkfile dest="README" src="README"/>
	<linkfile dest="setup-environment" src="setup-environment"/>
  </project>

  <project remote="freescale" revision="pyro" name="meta-freescale-3rdparty" path="sources/meta-freescale-3rdparty"/>
  <project remote="freescale" revision="pyro" name="meta-freescale-distro" path="sources/meta-freescale-distro"/>
  <project remote="freescale" revision="pyro" name="Documentation" path="sources/Documentation"/>

</manifest>

Getting the static manifest

In order to define a set of static versions for each component in the manifest, we need to extract the static manifest from an already existent Yocto build which would be the version we want to freeze. In order to get the static manifest just go to your Yocto directory and run:

STATIC_MANIFEST=my_manifest.xml
repo manifest -r -o $STATIC_MANIFEST

This will create a new XML file named my_manifest.xml which would look like follows:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote fetch="https://github.com/Freescale" name="freescale"/>
  <remote fetch="https://github.com/openembedded" name="oe"/>
  <remote fetch="https://git.yoctoproject.org/git" name="yocto"/>
  
  <default revision="pyro" sync-j="4"/>
  
  <project name="Documentation" path="sources/Documentation" remote="freescale" revision="5f7341e7fa3af8aaf09504938056cb8e83485dc0" upstream="pyro"/>
  <project name="fsl-community-bsp-base" path="sources/base" remote="freescale" revision="5d2f6d94efe4aad365a082d3c090a5e5f31cfa43" upstream="pyro">
    <linkfile dest="README" src="README"/>
    <linkfile dest="setup-environment" src="setup-environment"/>
  </project>
  <project name="meta-freescale" path="sources/meta-freescale" remote="yocto" revision="522cbc53e56efb9ca3b9b775e8ee1bb095fc220a" upstream="pyro"/>
  <project name="meta-freescale-3rdparty" path="sources/meta-freescale-3rdparty" remote="freescale" revision="9613dbc02ca970122a01c935bc9e5789ced73a9d" upstream="pyro"/>
  <project name="meta-freescale-distro" path="sources/meta-freescale-distro" remote="freescale" revision="cd5c7a2539f40004f74126e9fdf08254fd9a6390" upstream="pyro"/>
  <project name="meta-openembedded" path="sources/meta-openembedded" remote="oe" revision="dfbdd28d206a74bf264c2f7ee0f7b3e5af587796" upstream="pyro"/>
  <project name="poky" path="sources/poky" remote="yocto" revision="ebb42af2829edfca1a23c7a51a431c656ffc2090" upstream="pyro"/>
</manifest>

In this case, each project element has been linked to a specific revision number, corresponding to the revision used for the current build. The next step is to create a new Yocto build with our static manifest.

Creating a new build with an existent static manifest

Once you have extracted the static manifest from an existent build, you can replicate your Yocto setup at any time by using it to initialize repo. For instance, a common initialization line would be:

repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b pyro

where -b pyro specifies the branch for the Yocto components but assumes the latest version will be fetched. In order to use an existent static manifest just run:

repo init -u https://github.com/Freescale/fsl-community-bsp-platform -m /tmp/my_manifest.xml

where the option -m specifies the URL to the manifest to be used.

Once repo has been initialized using the static manifest you can proceed with the synchronization as usual.

References

[1] https://source.android.com/setup/develop

[2] https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md

[3] https://pelux.io/software-factory/PELUX-3.0/swf-blueprint/docs/articles/baseplatform/reproducible-yocto-builds.html



For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.