Closed jlebon closed 4 months ago
Instead of having to care about yet another package set/repos, we can use the target system itself (after compose but before creating disks) as the buildroot.
👍
but critically here, it requires python
to be in the buildroot to run the OSBuild stages. Since FCOS doesn't include python it means we can't use this for FCOS, which is OK since COSA is Fedora based and so is FCOS. RHCOS does include python, so it should be fine.
This will require at least one change upstream because right now the buildroot code has never considered that a buildroot tree could be an OSTree filesystem layout so we'd need something like:
diff --git a/osbuild/buildroot.py b/osbuild/buildroot.py
index 02b1b9f2..072d355b 100644
--- a/osbuild/buildroot.py
+++ b/osbuild/buildroot.py
@@ -18,7 +18,7 @@ import time
from typing import Set
from osbuild.api import BaseAPI
-from osbuild.util import linux
+from osbuild.util import linux, ostree
__all__ = [
"BuildRoot",
@@ -200,8 +200,15 @@ class BuildRoot(contextlib.AbstractContextManager):
if self.mount_boot:
imports.insert(0, "boot")
+ # If this is an OSTree tree let's actually make the deployment
+ # path the root of the tree
+ rootdir = self._rootdir
+ if os.path.exists(os.path.join(rootdir, 'ostree')):
+ osname, ref, serial = ostree.parse_deployment_option(rootdir, {default: True})
+ rootdir = ostree.deployment_path(rootdir, osname, ref, serial)
+
for p in imports:
- source = os.path.join(self._rootdir, p)
+ source = os.path.join(rootdir, p)
if os.path.isdir(source) and not os.path.islink(source):
mounts += ["--ro-bind", source, os.path.join("/", p)]
If fcos aligns with bootc then I think we get this for free, as we already have distinct "buildroot"s materialized as a container image in bootc-image-builder.
https://github.com/osbuild/osbuild/pull/1790 should help here (pending review upstream).
alternate implementation in https://github.com/coreos/coreos-assembler/pull/3808
Fixed by #3808
Using Fedora tools to build RHEL images has caused us many problems in the past. osbuild has the concept of a buildroot where we can give it a different tree, so let's use that. Instead of having to care about yet another package set/repos, we can use the target system itself (after compose but before creating disks) as the buildroot.