From dfd59a38d9ec7458944f9a901a6aa6e1202a7efb Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Tue, 12 Dec 2023 22:58:14 -0500 Subject: [PATCH] osbuild/mounts: adjust the source path to use when mounting devices Adjust the source path to just have /dev in front (i.e. /dev/loop0) and not be a path to the temporary dev directory that was prepared. We do this because some tools (like grub2-install) consult mountinfo to try to canonicalize paths for mounts. Fixes https://github.com/osbuild/osbuild/issues/1492 --- osbuild/mounts.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osbuild/mounts.py b/osbuild/mounts.py index 54fc5b17..76a143cc 100644 --- a/osbuild/mounts.py +++ b/osbuild/mounts.py @@ -58,7 +58,18 @@ class MountManager: def mount(self, mount: Mount) -> Dict: + # Get the absolute path to the source device inside the + # temporary filesystem (i.e. /run/osbuild/osbuild-dev-xyz/loop0) + # and also the relative path to the source device inside + # that filesystem (i.e. loop0). If the device also exists on the + # host in `/dev` (like /dev/loop0), we'll use that path for the + # mount because some tools (like grub2-install) consult mountinfo + # to try to canonicalize paths for mounts and inside the bwrap env + # the device will be under `/dev`. https://github.com/osbuild/osbuild/issues/1492 source = self.devices.device_abspath(mount.device) + relpath = self.devices.device_relpath(mount.device) + if relpath and os.path.exists(os.path.join('/dev', relpath)): + source = os.path.join('/dev', relpath) root = os.fspath(self.root)