From abfc4d6b5af220a5c87ceeca2d73372c6db897fc Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 14 Jan 2020 18:26:55 +0100 Subject: [PATCH] stages/fix-bls: support for different prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The paths for the kernel and the initrd in the BLS snippets are meant to be relative to the root of the filesystem they are on. The current code assumes that kernel and initrd are installed under '/boot' and that '/boot' is on the root file system and thus all paths get fixed up to start with '/boot/…'. But the '/boot' directory can be on a separate partition and thus file system, and then paths need to be relative to that and should be fixed up with '/…'. Introduce a new option 'prefix' that can be used to manually specify the prefix after the fixup, defaulting to '/boot' for backwards compatibility. NB: The canonical Boot Loader Specification[1] requires that a separate partition is used boot related files and it will be mounted at '/boot' (or '/efi'). [1] https://systemd.io/BOOT_LOADER_SPECIFICATION/ --- stages/org.osbuild.fix-bls | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stages/org.osbuild.fix-bls b/stages/org.osbuild.fix-bls index 94cbb3e2..26b8f09c 100755 --- a/stages/org.osbuild.fix-bls +++ b/stages/org.osbuild.fix-bls @@ -18,13 +18,14 @@ This stage reads and (re)writes all .conf files in /boot/loader/entries. STAGE_OPTS = "" -def main(tree, _options): +def main(tree, options): """Fix broken paths in /boot/loader/entries. grub2-mkrelpath uses /proc/self/mountinfo to find the source of the file system it is installed to. This breaks in a container, because we bind-mount the tree from the host. """ + prefix = options.get("prefix", "/boot") path_re = re.compile(r"(/.*)+/boot") @@ -34,7 +35,7 @@ def main(tree, _options): with open(name, "w") as f: for line in entry: - f.write(path_re.sub("/boot", line)) + f.write(path_re.sub(prefix, line)) return 0