Search by Tags

Create OSTree Union

 
Applicable for

Article updated at 24 Apr 2019
Subscribe for this article updates

Introduction

It is possible to create unions for OSTree, which is faster than committing whole changes due to re-checksum of data that already exists. For more information, read the OSTree documentation Writing a buildsystem and managing repositories. The presented instructions go through how to create a OSTree union from an existing one provided by Toradex, as well as modify unions, commit changes and more.

This article complies to the Typographic Conventions for Torizon Documentation.

Prerequisites

  • OSTree installed in your computer
  • Have existing OSTree ( for example Toradex one - we show how to fetch it in the article )

Create the OSTree Union

This section goes through the process of creating a new root filesystem from an OSTree union.

Pull Toradex OSTree to Your Computer

Commands below will init new ostree repository inside folder toradex-os-tree and add new remote called toradex. In last step it will pull branch torizon/torizon-core-docker. Depth 1 means only latest commit.

$ mkdir toradex-os-tree
$ ostree --repo=toradex-os-tree init --mode=bare-user 
$ ostree --repo=toradex-os-tree remote add toradex  http://feeds.toradex.com/ostree/nightly/colibri-imx7/ --no-gpg-verify 
$ ostree --repo=toradex-os-tree pull toradex torizon/torizon-core-docker --depth=1

Add Example Files

Create folder for your changes:

$ mkdir my-changes

Create or add any file you want to use for this example. Here we create a text file with the directory structure as presented:

$ tree my-changes
my-changes
└── etc
        └── text.txt
$ echo "test" > my-changes/etc/test.txt

Commit Changes

Commit changes to the existing ostree repository, creating a new branch called my-changes:

$ ostree --repo=toradex-os-tree commit -b my-changes --tree=dir=my-changes 

Checkout to New Rootfs

This will checkout rootfs from ostree repository to temporary-rootfs:

$ ostree --repo=toradex-os-tree checkout -U --union torizon/torizon-core-docker temporary-rootfs    

Checkout new branch and union it with temporary-rootfs:

$ ostree --repo=toradex-os-tree checkout -U --union my-changes temporary-rootfs

Commit all our changes back to ostree with new branch name final-ostree:

$ ostree --repo=toradex-os-tree commit -b final-ostree --tree=dir=temporary-rootfs 

Finally, update information about ostree in summary file:

$ ostree --repo=toradex-os-tree summary -u

This OSTree can now be deployed to supported devices.

Note: When doing multiple changes it is wise to always commit back to same branch. This way history is tracked as it should be.

Make Changes on Already Existing Structure

This part considers that one time configuration was set and folder structure is the same as in previous sections.

Make and Commit Changes

Modify the content of a file:

$ echo "test2" > my-changes/etc/test.txt

Commit changes to existing ostree repository, to branch called my-changes:

$ ostree --repo=toradex-os-tree commit -b my-changes --tree=dir=my-changes 

Check OSTree diff

Running ostree diff command returns the status of OSTree:

$ ostree --repo=toradex-os-tree diff my-changes

Output:

> ostree --repo=toradex-os-tree diff my-changes     
M    /etc/test.txt

Checkout and Union Changes

Checkout changes and union it with temporary-rootfs:

$ ostree --repo=toradex-os-tree checkout -U --union my-changes temporary-rootfs

Commit changes back to ostree with new branch name final-ostree:

$ ostree --repo=toradex-os-tree commit -b final-ostree --tree=dir=temporary-rootfs 

Update information about ostree in summary file:

$ ostree --repo=toradex-os-tree summary -u