Skip to content

Instantly share code, notes, and snippets.

@miabbott
Created September 15, 2023 18:27
Show Gist options
  • Select an option

  • Save miabbott/f1fbfdbfee283a5ef2c7ff0a13607cdc to your computer and use it in GitHub Desktop.

Select an option

Save miabbott/f1fbfdbfee283a5ef2c7ff0a13607cdc to your computer and use it in GitHub Desktop.
Working with multiple ostree commits/refs in a single repo

Using a centralized ostree repo

  1. Assume you are using a RHEL 9.2 system with osbuild + nginx installed
  2. Create an empty blueprint selecting "rhel-92" as the distro:
name = "minimal-rhel92"
description = "minimal blueprint for ostree commit"
version = "1.0.0"
modules = []
groups = []
distro = "rhel-92"
  1. Push blueprint to server

composer-cli blueprints push minimal-rhel92.toml

  1. Compose edge-commit artifact from the blueprint

composer-cli compose start-ostree minimal-rhel92 edge-commit

  1. Retrieve the tarball and explode to disk

The location on disk /usr/share/nginx/html/repo will become the single ostree repo for all refs + commits

composer-cli compose image <rhel-92-uuid>
tar -xf <rhel-92-uuid>.tar -C /usr/share/nginx/html/
  1. Create another empty blueprint selecting "rhel-87" as the distro
name = "minimal-rhel87"
description = "minimal blueprint for ostree commit"
version = "1.0.0"
modules = []
groups = []
distro = "rhel-87"
  1. Push the blueprint and create another edge-commit artifact
composer-cli blueprints push minimal-rhel87.toml
composer-cli compose start-ostree minimal-rhel87 edge-commit
  1. Retrieve the tarball, explode to disk, pull commit to repo

Using ostree pull-local allows us to copy commit data from one local repo to another local repo.

composer-cli compose image <rhel-87-uuid>
tar -xf <rhel-87-uuid>.tar
sudo ostree --repo=/usr/share/nginx/html/repo pull-local repo
  1. (Optional) Inspect the status of the ostree repo
$ ostree --repo=/usr/share/nginx/html/repo refs
rhel/8/x86_64/edge
rhel/9/x86_64/edge

$ ostree --repo=/usr/share/nginx/html/repo show rhel/8/x86_64/edge
commit f7d4d95465fbd875f6358141f39d0c573df6a321627bafde68c73850667e5443
ContentChecksum:  41bf2f8b442a770e9bf03e096a46a286f5836e0a0702b7c3516ef4e0acec2dea
Date:  2023-09-15 16:17:04 +0000
Version: 8.7
(no subject)

$ ostree --repo=/usr/share/nginx/html/repo show rhel/9/x86_64/edge
commit 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9
ContentChecksum:  70235bfb9cae82c53f856183750e809becf0b9b076122b19c40fec92fc6d74c1
Date:  2023-09-15 15:30:24 +0000
Version: 9.2
(no subject)
  1. Modify the RHEL 9.2 blueprint to include a new package and build a new commit
name = "minimal-rhel92"
description = "minimal blueprint for ostree commit"
version = "1.1.0"
modules = []
groups = []
distro = "rhel-92"

[[packages]]
name = "strace"
version = "*"

Push the updated blueprint and create a new edge-commit, pointing the compose to the existing ostree repo

composer-cli blueprints push minimal-rhel92.toml
composer-cli compose start-ostree minimal-rhel92 edge-commit --url http://localhost/repo --ref rhel/9/x86_64/edge
  1. Retrieve the tarball, explode to disk, pull commit to repo
rm -rf repo
composer-cli compose image <rhel-92-uuid>
tar -xf <rhel-92-uuid>.tar
sudo ostree --repo=/usr/share/nginx/html/repo pull-local repo
  1. (Optional) Inspect the status of the ostree repo again
$ ostree --repo=/usr/share/nginx/html/repo refs
rhel/8/x86_64/edge
rhel/9/x86_64/edge

$ ostree --repo=/usr/share/nginx/html/repo show rhel/8/x86_64/edge
commit f7d4d95465fbd875f6358141f39d0c573df6a321627bafde68c73850667e5443
ContentChecksum:  41bf2f8b442a770e9bf03e096a46a286f5836e0a0702b7c3516ef4e0acec2dea
Date:  2023-09-15 16:17:04 +0000
Version: 8.7
(no subject)

$ ostree --repo=/usr/share/nginx/html/repo show rhel/9/x86_64/edge
commit a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9
Parent:  89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9
ContentChecksum:  2335930df6551bf7808e49f8b35c45e3aa2a11a6c84d988623fd3f36df42a1f1
Date:  2023-09-15 18:21:31 +0000
Version: 9.2
(no subject)

$ ostree --repo=/usr/share/nginx/html/repo log rhel/9/x86_64/edge
commit a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9
Parent:  89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9
ContentChecksum:  2335930df6551bf7808e49f8b35c45e3aa2a11a6c84d988623fd3f36df42a1f1
Date:  2023-09-15 18:21:31 +0000
Version: 9.2
(no subject)

commit 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9
ContentChecksum:  70235bfb9cae82c53f856183750e809becf0b9b076122b19c40fec92fc6d74c1
Date:  2023-09-15 15:30:24 +0000
Version: 9.2
(no subject)

$ rpm-ostree db diff --repo=/usr/share/nginx/html/repo 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9 a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9
ostree diff commit from: 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9
ostree diff commit to:   a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9
Added:
  elfutils-default-yama-scope-0.188-3.el9.noarch
  elfutils-libs-0.188-3.el9.x86_64
  strace-5.18-2.el9.x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment