Skip to content

Commit 74bda44

Browse files
committed
build.sh: fast-track osbuild patch for volume ID fix
I.e. osbuild/osbuild#2169.
1 parent c26652b commit 74bda44

File tree

2 files changed

+132
-19
lines changed

2 files changed

+132
-19
lines changed

build.sh

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,24 @@ write_archive_info() {
193193
}
194194

195195
patch_osbuild() {
196-
return # we have no patches right now
197-
## Add a few patches that either haven't made it into a release or
198-
## that will be obsoleted with other work that will be done soon.
199-
200-
## To make it easier to apply patches we'll move around the osbuild
201-
## code on the system first:
202-
#rmdir /usr/lib/osbuild/osbuild
203-
#mv /usr/lib/python3.13/site-packages/osbuild /usr/lib/osbuild/
204-
#mkdir /usr/lib/osbuild/tools
205-
#mv /usr/bin/osbuild-mpp /usr/lib/osbuild/tools/
206-
207-
## Now all the software is under the /usr/lib/osbuild dir and we can patch
208-
#cat foo.patch | patch -d /usr/lib/osbuild -p1
209-
#
210-
## And then move the files back; supermin appliance creation will need it back
211-
## in the places delivered by the RPM.
212-
#mv /usr/lib/osbuild/tools/osbuild-mpp /usr/bin/osbuild-mpp
213-
#mv /usr/lib/osbuild/osbuild /usr/lib/python3.13/site-packages/osbuild
214-
#mkdir -p /usr/lib/osbuild/osbuild
196+
# Add a few patches that either haven't made it into a release or
197+
# that will be obsoleted with other work that will be done soon.
198+
199+
# To make it easier to apply patches we'll move around the osbuild
200+
# code on the system first:
201+
rmdir /usr/lib/osbuild/osbuild
202+
mv /usr/lib/python3.13/site-packages/osbuild /usr/lib/osbuild/
203+
mkdir /usr/lib/osbuild/tools
204+
mv /usr/bin/osbuild-mpp /usr/lib/osbuild/tools/
205+
206+
# Now all the software is under the /usr/lib/osbuild dir and we can patch
207+
patch -d /usr/lib/osbuild -p1 < /usr/lib/coreos-assembler/0001-stages-coreos.live-artifacts-rework-volume-ID-handli.patch
208+
209+
# And then move the files back; supermin appliance creation will need it back
210+
# in the places delivered by the RPM.
211+
mv /usr/lib/osbuild/tools/osbuild-mpp /usr/bin/osbuild-mpp
212+
mv /usr/lib/osbuild/osbuild /usr/lib/python3.13/site-packages/osbuild
213+
mkdir -p /usr/lib/osbuild/osbuild
215214
}
216215

217216
if [ $# -ne 0 ]; then
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
From 55a25d1428a35f713fce62f68db35243d64ed564 Mon Sep 17 00:00:00 2001
2+
From: Jonathan Lebon <[email protected]>
3+
Date: Wed, 20 Aug 2025 12:14:44 -0400
4+
Subject: [PATCH] stages/coreos.live-artifacts: rework volume ID handling
5+
6+
In https://github.com/osbuild/osbuild/pull/2148, we changed the logic to
7+
generate the volume ID from the data in `/usr/lib/os-release` to sever
8+
the reliance on metadata in the embedded treefile that will no longer
9+
exist.
10+
11+
This had no effect in FCOS, but had an effect in RHCOS, which
12+
went from a volume ID of `rhcos-...` to `rhel-coreos-...`.
13+
This was considered harmless at the time, but in fact ended
14+
up affecting the OpenShift Assisted Image Service. See e.g.
15+
https://github.com/openshift/assisted-image-service/pull/477 which
16+
attempted to adapt that code. But in the end, it felt safer and less
17+
work to just revert back to the previous volume ID. So here we are.
18+
19+
But we still don't want to go back to using the embedded treefile.
20+
Instead, we now have access to the OS name to use as a label on the
21+
container image. This label gets serialized into the aleph during the
22+
creation of the metal image (via the `org.osbuild.ostree.aleph` stage)
23+
which we have access here when mounting the metal image via loopback.
24+
25+
So pick it up from there and use that. But in case it's missing,
26+
fallback to the previous logic rather than hard fail to make this easier
27+
to ratchet in.
28+
---
29+
stages/org.osbuild.coreos.live-artifacts.mono | 27 +++++++++++--------
30+
1 file changed, 16 insertions(+), 11 deletions(-)
31+
32+
diff --git a/stages/org.osbuild.coreos.live-artifacts.mono b/stages/org.osbuild.coreos.live-artifacts.mono
33+
index 4a95b607..8c1ce2ad 100755
34+
--- a/stages/org.osbuild.coreos.live-artifacts.mono
35+
+++ b/stages/org.osbuild.coreos.live-artifacts.mono
36+
@@ -130,11 +130,6 @@ def make_stream_hash(src, dest):
37+
outf.write(hashlib.sha256(buf).hexdigest() + '\n')
38+
39+
40+
-def get_os_name(tree):
41+
- os_release = osrelease.parse_files(os.path.join(tree, 'usr', 'lib', 'os-release'))
42+
- return f"{os_release['ID']}-{os_release['VARIANT_ID']}"
43+
-
44+
-
45+
def ensure_glob(pathname, n="", **kwargs):
46+
"""
47+
Call glob.glob() and fail if there are no results or
48+
@@ -300,7 +295,7 @@ def genisoargs_s390x(paths, test_fixture, volid, name_version):
49+
os.path.join(os.path.relpath(paths["iso/images"], paths["iso"]), 'cdboot.img')]
50+
51+
52+
-def gen_live_artifacts(paths, tree, filenames, deployed_tree, loop_client, version, blsentry_kargs):
53+
+def gen_live_artifacts(paths, tree, filenames, deployed_tree, loop_client, version, blsentry_kargs, osname):
54+
"""
55+
Generate the ISO image.
56+
Based on the Lorax templates [1].
57+
@@ -310,7 +305,7 @@ def gen_live_artifacts(paths, tree, filenames, deployed_tree, loop_client, versi
58+
[2] https://fedoraproject.org/wiki/User:Pjones/BootableCDsForBIOSAndUEFI
59+
"""
60+
61+
- base_name = get_os_name(tree=deployed_tree)
62+
+ base_name = osname
63+
name_version = f'{base_name}-{version}'
64+
# The short volume ID can only be 32 characters (bytes probably). We may in
65+
# the future want to shorten this more intelligently, otherwise we truncate the
66+
@@ -555,7 +550,7 @@ def mkrootfs_metal(paths, workdir, img_metal, fstype, fsoptions, loop_client):
67+
Mounts a copy of the metal image and modifies it accordingly to create a (fstype) rootfs from its contents for the
68+
live ISO. fstype must be squashfs or erofs.
69+
70+
- Returns the bls entry kernel arguments for the ISO bootloader.
71+
+ Returns the bls entry kernel arguments for the ISO bootloader and the OS name extracted from the aleph.
72+
"""
73+
basearch = os.uname().machine
74+
tmp_rootfs_dir = os.path.join(workdir, 'tmp-rootfs-dir')
75+
@@ -637,7 +632,15 @@ def mkrootfs_metal(paths, workdir, img_metal, fstype, fsoptions, loop_client):
76+
if len(blsentry_kargs) == 0:
77+
raise ValueError("found no kargs in metal image")
78+
79+
- return blsentry_kargs
80+
+ # while we're here, also get the OS name from the aleph since we'll
81+
+ # need that for the volume ID
82+
+ ALEPH_FILENAME = ".aleph-version.json"
83+
+ with open(os.path.join(tmp_rootfs_dir, ALEPH_FILENAME), encoding='utf8') as f:
84+
+ aleph = json.load(f)
85+
+
86+
+ osname = aleph.get('container-image', {}).get('image-labels', {}).get('com.coreos.osname')
87+
+
88+
+ return (blsentry_kargs, osname)
89+
90+
91+
# pylint: disable=too-many-branches
92+
@@ -923,7 +926,9 @@ def main(workdir, tree, inputs, options, loop_client):
93+
94+
mk_osmet_files(deployed_tree, img_metal, img_metal4k, loop_client, paths, os_release)
95+
96+
- blsentry_kargs = mkrootfs_metal(paths, workdir, img_metal, fstype, fsoptions, loop_client)
97+
+ (blsentry_kargs, osname) = mkrootfs_metal(paths, workdir, img_metal, fstype, fsoptions, loop_client)
98+
+ if not osname:
99+
+ osname = f"{os_release['ID']}-{os_release['VARIANT_ID']}"
100+
101+
# Generate rootfs image
102+
# The rootfs must be uncompressed because the ISO mounts root.squashfs
103+
@@ -951,7 +956,7 @@ def main(workdir, tree, inputs, options, loop_client):
104+
extend_initramfs(initramfs=paths["iso/images/pxeboot/initrd.img"], tree=paths["initrd"])
105+
106+
filenames = options['filenames']
107+
- gen_live_artifacts(paths, tree, filenames, deployed_tree, loop_client, version, blsentry_kargs)
108+
+ gen_live_artifacts(paths, tree, filenames, deployed_tree, loop_client, version, blsentry_kargs, osname)
109+
110+
111+
if __name__ == "__main__":
112+
--
113+
2.50.1
114+

0 commit comments

Comments
 (0)