From 00043b06aac0290931d5908541846e9033d603d7 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Thu, 27 Jul 2023 12:37:16 +0200 Subject: [PATCH] bootstrap_image and the local repositories We can not use user_mountpoints because these aren't (historically, not sure what are the reasons) mounted too late during the Buildroot preparation (after the self._init_pkg_management()). This isn't actually an issue when 'use_bootstrap_image == False' because we use the package manager on host (so it actually sees the repository on host). So newly we place the local_repo mount points into the "managed" category, which seems even semantically better now. We though need to call the 'self.mounts.mountall_managed()' method a little bit later than before, when the local repo BindMountPoints are already defined by self.pkg_manager.initialize(). This problem has been triggered by the LVM test-case that creates a custom local_repo (on host) with `baseurl=/tmp/foo` that needs to be bind-mounted into the bootstrap chroot properly. Closes: #1167 --- mock/py/mockbuild/buildroot.py | 6 +++++- mock/py/mockbuild/package_manager.py | 16 +++++++++++++--- mock/tests/test_package_manager.py | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/mock/py/mockbuild/buildroot.py b/mock/py/mockbuild/buildroot.py index 53dc9f423..bc69b2ee0 100644 --- a/mock/py/mockbuild/buildroot.py +++ b/mock/py/mockbuild/buildroot.py @@ -241,14 +241,18 @@ def _init(self, prebuild): self._setup_devices() self._setup_files() - self.mounts.mountall_managed() # write out config details self.root_log.debug('rootdir = %s', self.make_chroot_path()) self.root_log.debug('resultdir = %s', self.resultdir) self.set_package_manager() + + # this creates some managed mounts self.pkg_manager.initialize() + + self.mounts.mountall_managed() + self._setup_resolver_config() self._setup_katello_ca() diff --git a/mock/py/mockbuild/package_manager.py b/mock/py/mockbuild/package_manager.py index 9562608c2..ed54bb614 100644 --- a/mock/py/mockbuild/package_manager.py +++ b/mock/py/mockbuild/package_manager.py @@ -476,9 +476,19 @@ def _bind_mount_repos_to_bootstrap(self): bind_mount_point = BindMountPoint(srcpath=srcpath, bindpath=bindpath) - # we need to use user mounts as essential mounts are used - # only for installing into bootstrap chroot - self.buildroot.mounts.add_user_mount(bind_mount_point) + # This is a very tricky hack. Note we configure the + # package_manager for the "bootstrap" chroot here, but these + # "local repo" mountpoints are actually needed by both + # "bootstrap" and "build" chroots. The "bootstrap" chroot + # needs this with the 'bootstrap_image' feature (we use + # package manager _in bootstrap_, not on host, to install + # into the bootstrap) and the "build" chroot package manager + # always needs this (but also mounted in bootstrap). That's + # why we are not using "essential mounts"; these are only + # automatically mounted by the corresponding package manager + # (we wouldn't mount bootstrap's mountpoints when installing + # into the "build" chroot). + self.buildroot.mounts.add(bind_mount_point) def initialize_config(self): # there may be configs we get from container image diff --git a/mock/tests/test_package_manager.py b/mock/tests/test_package_manager.py index fd6fcbe14..c26d6cc76 100644 --- a/mock/tests/test_package_manager.py +++ b/mock/tests/test_package_manager.py @@ -79,7 +79,7 @@ def get_user_bind_mounts_from_config(self, config): pm.pkg_manager_config = config pm.initialize_config() pm._bind_mount_repos_to_bootstrap() - return self.bootstrap_buildroot.mounts.user_mounts + return self.bootstrap_buildroot.mounts.managed_mounts def test_absolute_path_name_in_baseurl(self): repo_directory = os.path.join(self.workdir, 'repo')