From ccb26806fc8c0ce1792c1963e4e737c75f37cd9f Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 29 Oct 2021 12:37:20 +0200 Subject: [PATCH] buildroot: make mounting /boot optional Currently, we take to paths from the root file system supplied to the `BuildRoot` class: `/boot` and `/usr`. The reason for mounting `/boot` is that grub2 and shim install efi binaries there and for certain images we want to copy the binaries from the build root and not install the respective packages. However, if we build to build root itself, we probably don't want the mount the hosts' `/boot` since we don't want to copy anything from there. This change should give us the ability to do exactly that. --- osbuild/buildroot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osbuild/buildroot.py b/osbuild/buildroot.py index 5834c712..4e07d12b 100644 --- a/osbuild/buildroot.py +++ b/osbuild/buildroot.py @@ -69,6 +69,7 @@ class BuildRoot(contextlib.AbstractContextManager): self._apis = [] self.dev = None self.var = None + self.mount_boot = True @staticmethod def _mknod(path, name, mode, major, minor): @@ -154,7 +155,11 @@ class BuildRoot(contextlib.AbstractContextManager): mounts = [] # Import directories from the caller-provided root. - for p in ["boot", "usr"]: + imports = ["usr"] + if self.mount_boot: + imports.insert(0, "boot") + + for p in imports: source = os.path.join(self._rootdir, p) if os.path.isdir(source) and not os.path.islink(source): mounts += ["--ro-bind", source, os.path.join("/", p)]