Skip to content

Commit 7a6e3a0

Browse files
PeaceRebeljlebon
authored andcommitted
Patch osbuild to generate osname from os-release file
Treefile.json from rpm-ostree doesn't contain `name` in the `metadata` field from images built using podman build.
1 parent fd9b7da commit 7a6e3a0

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

build.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,25 @@ write_archive_info() {
177177
}
178178

179179
patch_osbuild() {
180-
return # we have no patches right now
181180
## Add a few patches that either haven't made it into a release or
182181
## that will be obsoleted with other work that will be done soon.
183182

184183
## To make it easier to apply patches we'll move around the osbuild
185184
## code on the system first:
186-
#rmdir /usr/lib/osbuild/osbuild
187-
#mv /usr/lib/python3.13/site-packages/osbuild /usr/lib/osbuild/
188-
#mkdir /usr/lib/osbuild/tools
189-
#mv /usr/bin/osbuild-mpp /usr/lib/osbuild/tools/
185+
rmdir /usr/lib/osbuild/osbuild
186+
mv /usr/lib/python3.13/site-packages/osbuild /usr/lib/osbuild/
187+
mkdir /usr/lib/osbuild/tools
188+
mv /usr/bin/osbuild-mpp /usr/lib/osbuild/tools/
190189

191190
## Now all the software is under the /usr/lib/osbuild dir and we can patch
192191
#cat foo.patch | patch -d /usr/lib/osbuild -p1
193-
#
192+
patch -d /usr/lib/osbuild -p1 < /usr/lib/coreos-assembler/0001-live-artifacts-read-os-name-from-usr-lib-os-release.patch
193+
194194
## And then move the files back; supermin appliance creation will need it back
195195
## in the places delivered by the RPM.
196-
#mv /usr/lib/osbuild/tools/osbuild-mpp /usr/bin/osbuild-mpp
197-
#mv /usr/lib/osbuild/osbuild /usr/lib/python3.13/site-packages/osbuild
198-
#mkdir /usr/lib/osbuild/osbuild
196+
mv /usr/lib/osbuild/tools/osbuild-mpp /usr/bin/osbuild-mpp
197+
mv /usr/lib/osbuild/osbuild /usr/lib/python3.13/site-packages/osbuild
198+
mkdir /usr/lib/osbuild/osbuild
199199
}
200200

201201
if [ $# -ne 0 ]; then
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From 7593b65dc77bf5dbb26fe9c54386759ab7f740a7 Mon Sep 17 00:00:00 2001
2+
From: Bipin B Narayan <[email protected]>
3+
Date: Mon, 14 Jul 2025 19:43:12 +0530
4+
Subject: [PATCH] live-artifacts: read os name from /usr/lib/os-release
5+
6+
With importing ociarchive, the treefile.json doesn't contain osname.
7+
---
8+
stages/org.osbuild.coreos.live-artifacts.mono | 6 ++----
9+
1 file changed, 2 insertions(+), 4 deletions(-)
10+
11+
diff --git a/stages/org.osbuild.coreos.live-artifacts.mono b/stages/org.osbuild.coreos.live-artifacts.mono
12+
index 1384a343..4a95b607 100755
13+
--- a/stages/org.osbuild.coreos.live-artifacts.mono
14+
+++ b/stages/org.osbuild.coreos.live-artifacts.mono
15+
@@ -131,10 +131,8 @@ def make_stream_hash(src, dest):
16+
17+
18+
def get_os_name(tree):
19+
- file = os.path.join(tree, 'usr/share/rpm-ostree/treefile.json')
20+
- with open(file, encoding='utf8') as f:
21+
- treefile = json.load(f)
22+
- return treefile['metadata']['name']
23+
+ os_release = osrelease.parse_files(os.path.join(tree, 'usr', 'lib', 'os-release'))
24+
+ return f"{os_release['ID']}-{os_release['VARIANT_ID']}"
25+
26+
27+
def ensure_glob(pathname, n="", **kwargs):
28+
--
29+
2.50.1
30+

0 commit comments

Comments
 (0)