Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd-osbuild: Add support for LiveISO #3861

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ patch_osbuild() {
/usr/lib/coreos-assembler/0002-parsing-treat-locations-without-scheme-as-belonging-.patch \
/usr/lib/coreos-assembler/0003-org.osbuild.selinux-support-operating-on-mounts.patch \
/usr/lib/coreos-assembler/0004-org.osbuild.selinux-support-for-specifying-where-fil.patch \
/usr/lib/coreos-assembler/0001-util-osrelease.py-improve-whitespace-and-quote-strip.patch \
/usr/lib/coreos-assembler/0002-util-chroot-Add-support-for-custom-directory-bind-mo.patch \
/usr/lib/coreos-assembler/0003-stages-add-coreos.live-iso-stage.patch \
| patch -d /usr/lib/osbuild -p1

# And then move the files back; supermin appliance creation will need it back
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 106e632a410e7391e1d667f5aa7062776ed19179 Mon Sep 17 00:00:00 2001
From: Renata Ravanelli <[email protected]>
Date: Tue, 12 Nov 2024 15:12:52 -0300
Subject: [PATCH 1/3] util/osrelease.py: improve whitespace and quote stripping

- Enhanced the value stripping logic in osrelease parsing
to handle leading and trailing spaces, newlines, tabs,
and both single and double quotes.
- This ensures cleaner and more accurate key-value assignments.

Signed-off-by: Renata Ravanelli <[email protected]>
(cherry picked from commit 066f1ea89fbda6e886a5d88119586c0f09b0a234)
---
osbuild/util/osrelease.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/osbuild/util/osrelease.py b/osbuild/util/osrelease.py
index b8d56e73..a2b61d26 100644
--- a/osbuild/util/osrelease.py
+++ b/osbuild/util/osrelease.py
@@ -33,7 +33,7 @@ def parse_files(*paths):
if line[0] == "#":
continue
key, value = line.split("=", 1)
- osrelease[key] = value.strip('"')
+ osrelease[key] = value.strip(" \n\t'\"")

return osrelease

--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From f5f269eb31100c22390d35fd658bdd236a0a880e Mon Sep 17 00:00:00 2001
From: Renata Ravanelli <[email protected]>
Date: Thu, 31 Oct 2024 14:13:50 -0300
Subject: [PATCH 2/3] util/chroot: Add support for custom directory bind mounts

- Add optional bind_mounts parameter to __init__ method;
- Enhanced methods to accept an optional `bind_mounts`.
This allows for more flexible for configurations when setting
up bind mounts.

Signed-off-by: Renata Ravanelli <[email protected]>
(cherry picked from commit 9b5fbadee6b170455d62c57eb315e20d57173110)
---
osbuild/util/chroot.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/osbuild/util/chroot.py b/osbuild/util/chroot.py
index da14bf44..4090456b 100644
--- a/osbuild/util/chroot.py
+++ b/osbuild/util/chroot.py
@@ -12,8 +12,9 @@ class Chroot:
This mounts /proc, /dev, and /sys.
"""

- def __init__(self, root: str):
+ def __init__(self, root: str, bind_mounts=None):
self.root = root
+ self._bind_mounts = bind_mounts or []

def __enter__(self):
for d in ["/proc", "/dev", "/sys"]:
@@ -33,6 +34,13 @@ class Chroot:
"sysfs", f"{self.root}/sys"],
check=True)

+ for d in self._bind_mounts:
+ target_path = os.path.join(self.root, d.lstrip("/"))
+ if not os.path.exists(target_path):
+ print(f"Making missing chroot directory: {d}")
+ os.makedirs(target_path)
+ subprocess.run(["mount", "--rbind", d, target_path], check=True)
+
return self

def __exit__(self, exc_type, exc_value, tracebk):
@@ -43,6 +51,10 @@ class Chroot:
if failed_umounts:
print(f"Error unmounting paths from chroot: {failed_umounts}")

+ for d in self._bind_mounts[::-1]:
+ target_path = os.path.join(self.root, d.lstrip("/"))
+ if subprocess.run(["umount", "--lazy", target_path], check=False).returncode != 0:
+ print(f"Error unmounting paths from chroot: {d}")
def run(self, cmd, **kwargs):
cmd = ["chroot", self.root] + cmd
# pylint: disable=subprocess-run-check
--
2.47.0

Loading
Loading