diff --git a/build.sh b/build.sh index 30ad6f80ee..ad91881e8e 100755 --- a/build.sh +++ b/build.sh @@ -174,9 +174,7 @@ patch_osbuild() { # Now all the software is under the /usr/lib/osbuild dir and we can patch cat /usr/lib/coreos-assembler/0001-osbuild-remoteloop-add-more-loop-device-options.patch \ - /usr/lib/coreos-assembler/0002-osbuild-loop-make-the-loop-device-if-missing.patch \ - /usr/lib/coreos-assembler/0003-util-osrelease.py-improve-whitespace-and-quote-strip.patch \ - /usr/lib/coreos-assembler/0004-util-chroot-Add-support-for-custom-directory-bind-mo.patch \ + /usr/lib/coreos-assembler/0001-util-osrelease.py-Replaced-string-stripping-with-shl.patch \ /usr/lib/coreos-assembler/0005-stages-add-coreos.live-artifacts.mono-stage.patch \ | patch -d /usr/lib/osbuild -p1 diff --git a/src/0001-osbuild-remoteloop-add-more-loop-device-options.patch b/src/0001-osbuild-remoteloop-add-more-loop-device-options.patch index 7521b0d4fa..b063fbf6c7 100644 --- a/src/0001-osbuild-remoteloop-add-more-loop-device-options.patch +++ b/src/0001-osbuild-remoteloop-add-more-loop-device-options.patch @@ -1,7 +1,7 @@ -From 9edf8572ad4797033e7342c308ac617aa284f3ae Mon Sep 17 00:00:00 2001 +From f4b899873b1f108edbf12d81ee5dbed037238a7e Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Fri, 22 Nov 2024 19:02:57 -0500 -Subject: [PATCH 1/5] osbuild/remoteloop: add more loop device options +Subject: [PATCH] osbuild/remoteloop: add more loop device options This adds lock, partscan, read_only, sector_size to _create_device() similar to make_loop() from devices/org.osbuild.loopback. diff --git a/src/0001-util-osrelease.py-Replaced-string-stripping-with-shl.patch b/src/0001-util-osrelease.py-Replaced-string-stripping-with-shl.patch new file mode 100644 index 0000000000..c1068855b0 --- /dev/null +++ b/src/0001-util-osrelease.py-Replaced-string-stripping-with-shl.patch @@ -0,0 +1,44 @@ +From 07d4f6955dd5dd5535b3e2f8e4722eb20f95e613 Mon Sep 17 00:00:00 2001 +From: Renata Ravanelli +Date: Tue, 12 Nov 2024 15:12:52 -0300 +Subject: [PATCH] util/osrelease.py: Replaced string stripping with + `shlex.split()` + +- Replaced string stripping with `shlex.split()` to properly +handle values in the os-release file; +- This ensures cleaner and more accurate key-value assignments, +follwing a broader set of shell-like parsing rules; +- Add os-release file for Fedora CoreOS 40 for testing. + +Signed-off-by: Renata Ravanelli +--- + osbuild/util/osrelease.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/osbuild/util/osrelease.py b/osbuild/util/osrelease.py +index b8d56e73..cc97faf5 100644 +--- a/osbuild/util/osrelease.py ++++ b/osbuild/util/osrelease.py +@@ -5,6 +5,7 @@ related documentation can be found in `os-release(5)`. + """ + + import os ++import shlex + + # The default paths where os-release is located, as per os-release(5) + DEFAULT_PATHS = [ +@@ -33,7 +34,10 @@ def parse_files(*paths): + if line[0] == "#": + continue + key, value = line.split("=", 1) +- osrelease[key] = value.strip('"') ++ split_value = shlex.split(value) ++ if not split_value or len(split_value) > 1: ++ raise ValueError(f"Key '{key}' has an empty value or more than one token: {value}") ++ osrelease[key] = split_value[0] + + return osrelease + +-- +2.47.0 + diff --git a/src/0002-osbuild-loop-make-the-loop-device-if-missing.patch b/src/0002-osbuild-loop-make-the-loop-device-if-missing.patch deleted file mode 100644 index 41866da3fc..0000000000 --- a/src/0002-osbuild-loop-make-the-loop-device-if-missing.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 4f09c4d4c1ad2026346a98e63f0e13155d0f0487 Mon Sep 17 00:00:00 2001 -From: Dusty Mabe -Date: Mon, 25 Nov 2024 16:29:10 -0500 -Subject: [PATCH 2/5] osbuild/loop: make the loop device if missing - -A few times during development I saw an error where the loop -device wasn't getting created. Maybe it was some weird state -issue with my system (i.e. loopback devices are global), or -maybe not. Either way maybe it won't hurt to create it if -it doesn't exist. ---- - osbuild/loop.py | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/osbuild/loop.py b/osbuild/loop.py -index ec6d3619..b768af22 100644 ---- a/osbuild/loop.py -+++ b/osbuild/loop.py -@@ -126,6 +126,12 @@ class Loop: - if not dir_fd: - dir_fd = os.open("/dev", os.O_DIRECTORY) - stack.callback(lambda: os.close(dir_fd)) -+ # If the loopdev didn't show up for some reason let's -+ # create it manually -+ try: -+ os.stat(self.devname, dir_fd=dir_fd) -+ except FileNotFoundError: -+ self.mknod(dir_fd) - self.fd = os.open(self.devname, os.O_RDWR, dir_fd=dir_fd) - - info = os.stat(self.fd) --- -2.47.0 - diff --git a/src/0003-util-osrelease.py-improve-whitespace-and-quote-strip.patch b/src/0003-util-osrelease.py-improve-whitespace-and-quote-strip.patch deleted file mode 100644 index 8a4f6a4fa3..0000000000 --- a/src/0003-util-osrelease.py-improve-whitespace-and-quote-strip.patch +++ /dev/null @@ -1,32 +0,0 @@ -From a835c409a19a9c72b5e669a70664ea960d873704 Mon Sep 17 00:00:00 2001 -From: Renata Ravanelli -Date: Tue, 12 Nov 2024 15:12:52 -0300 -Subject: [PATCH 3/5] 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 -(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 - diff --git a/src/0004-util-chroot-Add-support-for-custom-directory-bind-mo.patch b/src/0004-util-chroot-Add-support-for-custom-directory-bind-mo.patch deleted file mode 100644 index 66dec676c3..0000000000 --- a/src/0004-util-chroot-Add-support-for-custom-directory-bind-mo.patch +++ /dev/null @@ -1,60 +0,0 @@ -From c367e6506ed9d4c674795ccc2da7a850c367398e Mon Sep 17 00:00:00 2001 -From: Renata Ravanelli -Date: Thu, 31 Oct 2024 14:13:50 -0300 -Subject: [PATCH 4/5] 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 -(cherry picked from commit 9b5fbadee6b170455d62c57eb315e20d57173110) ---- - osbuild/util/chroot.py | 15 ++++++++++++++- - 1 file changed, 14 insertions(+), 1 deletion(-) - -diff --git a/osbuild/util/chroot.py b/osbuild/util/chroot.py -index da14bf44..11245bbd 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,11 @@ 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 - diff --git a/src/osbuild-manifests/platform.live.ipp.yaml b/src/osbuild-manifests/platform.live.ipp.yaml old mode 100755 new mode 100644