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
2016-05-02 22:41:33 +03:00
- [buildsystem-and-repos ](https://ostree.readthedocs.io/en/latest/manual/buildsystem-and-repos/ )
- [repository-management ](https://ostree.readthedocs.io/en/latest/manual/repository-management/ )
## Generating OSTree commits from a CentOS base
2018-04-25 20:44:43 +03:00
First, you'll need a copy of `rpm-ostree` . The current recommendation is to use
a privileged container, but you can also install `rpm-ostree` directly to a
physical or virtual machine.
2016-05-02 22:41:33 +03:00
2018-04-25 20:44:43 +03:00
It's included in the package collection for Fedora, and there
are [CentOS Core packages ](http://buildlogs.centos.org/centos/7/atomic/x86_64/Packages/ ) as
well as [bleeding edge CentOS builds ](https://ci.centos.org/job/atomic-rdgo-centos7/ ).
2016-05-02 22:41:33 +03:00
2018-04-25 20:44:43 +03:00
You can create a privileged container with e.g. `podman` via: `podman run
--privileged registry.fedoraproject.org/fedora:27 ...`. However you create the
environment, run `yum -y install rpm-ostree` .
A good first thing to try would be using
the
[CentOS Atomic Host ](https://github.com/CentOS/sig-atomic-buildscripts/tree/downstream ) metadata
to generate a custom host.
One time setup, where we clone the git repository, then make two OSTree repos,
one for doing builds, one for export via HTTP:
2016-05-02 22:41:33 +03:00
```
# mkdir /srv/centos-atomic
# cd /srv/centos-atomic
# git clone https://github.com/CentOS/sig-atomic-buildscripts -b downstream
# mkdir build-repo
# ostree --repo=build-repo init --mode=bare-user
# mkdir repo
2018-04-25 20:44:43 +03:00
# ostree --repo=repo init --mode=archive
```
We'll also want to cache downloaded RPMs:
```
# mkdir cache
2016-05-02 22:41:33 +03:00
```
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
2018-04-25 20:44:43 +03:00
The input format is a JSON "treefile". See examples in
`api-doc/treefile-examples` . More real-world examples include the manifest
for
2018-06-22 16:43:20 +03:00
[Fedora Atomic ](https://pagure.io/fedora-atomic/blob/master/f/fedora-atomic-host.json ) and
2018-04-25 20:44:43 +03:00
[CentOS Atomic ](https://github.com/CentOS/sig-atomic-buildscripts/blob/downstream/centos-atomic-host.json ).
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
```
2018-04-25 20:44:43 +03:00
# rpm-ostree compose tree --cachedir=cache --repo=/srv/centos-atomic/build-repo sig-atomic-buildscripts/centos-atomic-host.json
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
```
# ostree --repo=repo pull-local build-repo centos-atomic-host/7/x86_64/standard
```
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
## More information
2018-04-25 20:44:43 +03:00
* [run-treecompose script from FAHC ](https://pagure.io/fedora-atomic-host-continuous/blob/2f1214c9ff35e55ec111db86be96e14d4b6040d6/f/centos-ci/run-treecompose )
2016-06-26 06:46:12 +03:00
* [Build Your Own Atomic ](https://github.com/jasonbrooks/byo-atomic )
* [Build Your Own Atomic Image, Updated ](http://www.projectatomic.io/blog/2014/08/build-your-own-atomic-centos-or-fedora/ )
2016-07-05 10:30:34 +03:00
* [Creating custom Atomic trees, images, and installers, part 1 ](http://developerblog.redhat.com/2015/01/08/creating-custom-atomic-trees-images-and-installers-part-1/ )
* [Creating custom Atomic trees, images, and installers, part 2 ](http://developerblog.redhat.com/2015/01/15/creating-custom-atomic-trees-images-and-installers-part-2/ )