2020-09-30 19:17:28 +03:00
---
nav_order: 4
---
# Compose server
{: .no_toc }
1. TOC
{:toc}
2021-03-23 20:42:46 +03:00
## Managing RPM based OSTree commits
With `rpm-ostree compose` you get a tool to compose your own ostree commits based on a
[treefile ](https://coreos.github.io/rpm-ostree/treefile/ ) configuration, a couple of RPMs,
some post-processing and possibly some custom modifications directly in the resulting tree.
The tool allows to either build a tree commit in one go with a single command: `rpm-ostree compose tree` .
Or to split that process up into smaller chunks with the usage of `rpm-ostree compose install` ,
followed by `rpm-ostree compose postprocess` and finally `rpm-ostree compose commit` . While
the former approach is pretty complete and allows most use-cases the latter is useful if you need
some more customization on the resulting filesystem. More customization than the sandboxed
post-process functionality of the treefile allows.
In most scenarios you'll want to consider using a more "high level" tool, than `rpm-ostree compose` .
2020-05-17 18:06:35 +03:00
## Using higher level build tooling
Originally `rpm-ostree compose tree` was intended to be a "high level" tool,
but that didn't work out very well in practice. Today, you should consider
it as a low level tool. For example, most people that want to generate
OSTree commits *also* want to generate bootable disk images, and rpm-ostree
has nothing to do with that.
One example higher level tool that takes care of both OSTree commit generation
2021-02-12 23:33:25 +03:00
and bootable disk images is [coreos-assembler ](https://github.com/coreos/coreos-assembler );
it is strongly oriented towards "CoreOS-like" systems which include rpm-ostree
and Ignition.
The [osbuild ](https://www.osbuild.org/ ) project has some support for
rpm-ostree based systems. See [this blog entry ](https://www.osbuild.org/news/2020-06-01-how-to-ostree-anaconda.html )
for example.
2020-05-17 18:06:35 +03:00
2016-05-02 22:41:33 +03:00
## Background on managing an OSTree repository
2014-10-31 21:39:57 +03:00
2016-05-02 22:41:33 +03:00
Before you get started, it's recommended to read (at least) these two sections
of the OSTree manual:
2014-10-31 21:39:57 +03:00
2020-11-17 14:39:19 +03:00
- [buildsystem-and-repos ](https://ostreedev.github.io/ostree/buildsystem-and-repos/ )
- [repository-management ](https://ostreedev.github.io/ostree/repository-management/ )
2016-05-02 22:41:33 +03:00
2021-02-12 23:33:25 +03:00
## Choosing a base config
2018-04-25 20:44:43 +03:00
2021-02-12 23:33:25 +03:00
Currently, rpm-ostree is fairly coupled to the Fedora project. We are open to supporting
other distributions however.
2018-04-25 20:44:43 +03:00
2021-02-12 23:33:25 +03:00
Example base rpm-ostree "manifest repositories" are:
2018-04-25 20:44:43 +03:00
2021-02-12 23:33:25 +03:00
- [Silverblue ](https://pagure.io/workstation-ostree-config )
- [IoT ](https://pagure.io/fedora-iot/ostree )
- [Fedora CoreOS ](https://github.com/coreos/fedora-coreos-config/ )
2014-10-31 21:39:57 +03:00
## Running `rpm-ostree compose tree`
2018-04-25 20:44:43 +03:00
This program takes as input a manifest file that describes the target system,
and commits the result to an OSTree repository.
2014-10-31 21:39:57 +03:00
2021-02-12 23:33:25 +03:00
The input format is a YAML (or JSON) "treefile".
2016-09-23 00:16:56 +03:00
2018-04-25 20:44:43 +03:00
If you're doing this multiple times, it's strongly recommended to create a cache
directory:
2014-10-31 21:39:57 +03:00
2016-05-02 22:41:33 +03:00
```
2021-03-24 15:26:25 +03:00
# rpm-ostree compose tree --unified-core --cachedir=cache --repo=./build-repo /path/to/manifest.yaml
2016-05-02 22:41:33 +03:00
```
2014-10-31 21:39:57 +03:00
2018-04-25 20:44:43 +03:00
This will download RPMs from the referenced repos, and commit the result to the
OSTree repository, using the ref named by `ref` .
2014-10-31 21:39:57 +03:00
2016-05-02 22:41:33 +03:00
Once we have that commit, let's export it:
2014-10-31 21:39:57 +03:00
2016-05-02 22:41:33 +03:00
```
2021-03-24 15:26:25 +03:00
# ostree --repo=/srv/deploy-repo pull-local ./build-repo exampleos/8/x86_64/stable
2016-05-02 22:41:33 +03:00
```
2014-10-31 21:39:57 +03:00
2018-04-25 20:44:43 +03:00
You can tell client systems to rebase to it by combining `ostree remote add` ,
and `rpm-ostree rebase` on the client side.
2016-05-20 14:44:59 +03:00
2021-03-23 20:54:15 +03:00
## Granular tree compose with `install|postprocess|commit`
In order to get even more control we split `rpm-ostree compose tree` into
`rpm-ostree compose install` , followed by `rpm-ostree compose postprocess`
and finally `rpm-ostree compose commit` .
Similar to `rpm-ostree compose tree` we'll use a "treefile". We'll also specify a target directory
serving as our work-in-progress rootfs:
```
2021-03-24 15:26:25 +03:00
# rpm-ostree compose install --unified-core --cachedir=cache --repo=./build-repo /path/to/manifest.yaml ./sysroot
2021-03-23 20:54:15 +03:00
```
This will download RPMs from the referenced repos and execute any specified post-process scripts.
2021-03-24 15:26:25 +03:00
We now can alter anything found under `./sysroot/rootfs` .
2021-03-23 20:54:15 +03:00
Next we can run more postprocessing:
```
2021-03-24 15:26:25 +03:00
# rpm-ostree compose postprocess ./sysroot/rootfs /path/to/manifest.yaml
2021-03-23 20:54:15 +03:00
```
When we are finished with our manual changes we can now create the commit:
```
2021-03-24 15:26:25 +03:00
# rpm-ostree compose commit --repo=./build-repo /path/to/manifest.yaml ./sysroot/rootfs
2021-03-23 20:54:15 +03:00
```
Once we have that commit, let's export it:
```
2021-03-24 15:26:25 +03:00
# ostree --repo=/srv/deploy-repo pull-local ./build-repo exampleos/8/x86_64/stable
2021-03-23 20:54:15 +03:00
```
You can tell client systems to rebase to it by combining `ostree remote add` ,
and `rpm-ostree rebase` on the client side.
2021-03-23 20:27:04 +03:00
## Generating OSTree commits in a container
`rpm-ostree compose tree` runs well in an unprivileged (or "run as root")
podman container. You can also use other container tools, they are just less
frequently tested.
You can also directly install `rpm-ostree` on a traditional `yum/rpm` based
virtual (or physical) machine - it won't affect your host. However, containers
are encouraged.
2016-05-20 14:44:59 +03:00
## More information
2021-02-12 23:33:25 +03:00
- https://www.osbuild.org/news/2020-06-01-how-to-ostree-anaconda.html
- https://github.com/coreos/coreos-assembler