Compose server 组合服务器

  1. Managing RPM based OSTree commits
    管理基于 RPM 的 OSTree 提交
  2. Using higher level build tooling
    使用更高级别的构建工具
  3. Background on managing an OSTree repository
    管理 OSTree 存储库的背景
  4. Choosing a base config
    选择基本配置
  5. Running rpm-ostree compose tree 运行 rpm-ostree compose tree
  6. Granular tree compose with install|postprocess|commit
    install|postprocess|commit 组成的细粒树
  7. Generating OSTree commits in a container
    在容器中生成 OSTree 提交
  8. More information 更多信息

Managing RPM based OSTree commits
管理基于 RPM 的 OSTree 提交

With rpm-ostree compose you get a tool to compose your own ostree commits based on a treefile configuration, a couple of RPMs, some post-processing and possibly some custom modifications directly in the resulting tree.
使用 rpm-ostree compose ,您可以获得一个工具,根据树文件配置、一些 RPM 包、一些后处理以及可能直接在生成的树中进行一些自定义修改,来组合自己的 ostree 提交。

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.
该工具允许一次性构建一个树提交,使用单个命令: rpm-ostree compose tree 。或者将该过程分解为较小的块,使用 rpm-ostree compose install ,然后是 rpm-ostree compose postprocess ,最后是 rpm-ostree compose commit 。虽然前一种方法非常完整,可以满足大多数用例,但后一种方法在您需要对生成的文件系统进行更多自定义时非常有用。比树文件的沙盒后处理功能允许的更多自定义。

In most scenarios you’ll want to consider using a more “high level” tool, than rpm-ostree compose.
在大多数情况下,您会希望考虑使用比 rpm-ostree compose 更“高级”的工具。

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.
最初 rpm-ostree compose tree 旨在成为一个“高级”工具,但在实践中并不奏效。今天,您应该将其视为低级别工具。例如,大多数想要生成 OSTree 提交的人也想要生成可引导的磁盘映像,而 rpm-ostree 与此无关。

One example higher level tool that takes care of both OSTree commit generation and bootable disk images is coreos-assembler; it is strongly oriented towards “CoreOS-like” systems which include rpm-ostree and Ignition.
一个示例更高级别的工具,它负责 OSTree 提交生成和可引导磁盘映像的是 coreos-assembler;它主要面向“类似 CoreOS”的系统,其中包括 rpm-ostree 和 Ignition。

The osbuild project has some support for rpm-ostree based systems. See the project documentation for example.
osbuild 项目对基于 rpm-ostree 的系统有一些支持。请参阅项目文档以获取示例。

Background on managing an OSTree repository
管理 OSTree 存储库的背景信息

Before you get started, it’s recommended to read (at least) these two sections of the OSTree manual:
在开始之前,建议阅读 OSTree 手册中的(至少)这两个部分:

Choosing a base config
选择基本配置

Currently, rpm-ostree is fairly coupled to the Fedora project. We are open to supporting other distributions however.
目前,rpm-ostree 与 Fedora 项目有较强的耦合性。但我们也愿意支持其他发行版。

Example base rpm-ostree “manifest repositories” are:
示例基本 rpm-ostree “清单存储库”包括:

Running rpm-ostree compose tree 运行 rpm-ostree compose tree

This program takes as input a manifest file that describes the target system, and commits the result to an OSTree repository.
该程序以描述目标系统的清单文件作为输入,并将结果提交到 OSTree 存储库。

The input format is a YAML (or JSON) “treefile”.
输入格式是 YAML(或 JSON)“treefile”。

If you’re doing this multiple times, it’s strongly recommended to create a cache directory:
如果您需要多次执行此操作,强烈建议创建一个缓存目录:

# rpm-ostree compose tree --unified-core --cachedir=cache --repo=./build-repo /path/to/manifest.yaml

This will download RPMs from the referenced repos, and commit the result to the OSTree repository, using the ref named by ref.
这将从引用的存储库下载 RPM,并将结果提交到 OSTree 存储库,使用由 ref 命名的引用。

Once we have that commit, let’s export it:
一旦我们有了该提交,让我们将其导出:

# ostree --repo=/srv/deploy-repo pull-local ./build-repo exampleos/8/x86_64/stable

You can tell client systems to rebase to it by combining ostree remote add, and rpm-ostree rebase on the client side.
您可以通过在客户端上组合 ostree remote addrpm-ostree rebase 来告诉客户端系统重新基于它。

Granular tree compose with install|postprocess|commit
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.
为了获得更多控制,我们将 rpm-ostree compose tree 分成 rpm-ostree compose install ,然后是 rpm-ostree compose postprocess ,最后是 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:
类似于 rpm-ostree compose tree ,我们将使用“treefile”。我们还将指定一个目标目录,作为我们正在进行的 rootfs 的根目录:

# rpm-ostree compose install --unified-core --cachedir=cache --repo=./build-repo /path/to/manifest.yaml ./sysroot

This will download RPMs from the referenced repos and execute any specified post-process scripts.
这将从引用的存储库下载 RPM,并执行任何指定的后处理脚本。

We now can alter anything found under ./sysroot/rootfs.
现在我们可以更改在 ./sysroot/rootfs 下找到的任何内容。

Next we can run more postprocessing:
接下来我们可以运行更多的后处理:

# rpm-ostree compose postprocess ./sysroot/rootfs /path/to/manifest.yaml

When we are finished with our manual changes we can now create the commit:
当我们完成手动更改后,现在可以创建提交:

# rpm-ostree compose commit --repo=./build-repo /path/to/manifest.yaml ./sysroot/rootfs

Once we have that commit, let’s export it:
一旦我们有了那个提交,让我们将其导出:

# ostree --repo=/srv/deploy-repo pull-local ./build-repo exampleos/8/x86_64/stable

You can tell client systems to rebase to it by combining ostree remote add, and rpm-ostree rebase on the client side.
您可以通过在客户端上组合 ostree remote addrpm-ostree rebase ,告诉客户端系统重新基于它。

Generating OSTree commits in a container
在容器中生成 OSTree 提交

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.
rpm-ostree compose tree 在非特权(或“以 root 用户身份运行”)的 podman 容器中运行良好。您也可以使用其他容器工具,它们只是测试频率较低。

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.
您也可以直接在传统的 yum/rpm 基础虚拟(或物理)机器上安装 rpm-ostree - 这不会影响您的主机。然而,推荐使用容器。

More information 更多信息

  • https://osbuild.org/docs/on-premises/commandline/building-ostree-images/
  • https://github.com/coreos/coreos-assembler