commit:     d4903c231ad2b338e1cb2e2ef9d8585b68e737df
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  3 10:52:38 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sat Aug  3 10:52:38 2024 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d4903c23

stagebase: Move ROOT repo bind mount logic to stagebase instead of stage1

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 catalyst/base/stagebase.py | 21 ++++++++++++++++++++-
 catalyst/targets/stage1.py | 21 ---------------------
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 2975236e..a23b1d90 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -223,13 +223,32 @@ class StageBase(TargetBase, ClearBase, GenBase):
         for path, name, _ in self.repos:
             name = get_repo_name(path)
             mount_id = f'repo_{name}'
+            root_mount_id = f'root_repo_{name}'
+            repo_loc = self.get_repo_location(name)
 
             self.mount[mount_id] = {
                 'enable': True,
                 'source': path,
-                'target': self.get_repo_location(name)
+                'target': repo_loc
             }
 
+            # In e.g. the stage1 build we need to make sure that the ebuild 
repositories are
+            # accessible within $ROOT too... otherwise relative symlinks may 
point nowhere
+            # and, e.g., portageq may malfunction due to missing profile.
+            # In the meantime we specifically fixed make.profile to point 
outside ROOT, so
+            # this may not be necessary at the moment anymore. Having it can 
prevent future
+            # surprises though.
+            # Create a second, bind mount entry for each repository. We need to
+            # take as source not the original source but the original target, 
since
+            # otherwise we may end up trying to mount the same squashfs twice 
instead
+            # of a bind mount
+            if self.settings['root_path'] != "/":
+                self.mount[root_mount_id] = {
+                    'enable': True,
+                    'source': self.settings['chroot_path'] / 
repo_loc.relative_to('/'),
+                    'target': self.settings['root_path'] / 
repo_loc.relative_to('/')
+                }
+
         self.mount['distdir']['source'] = self.settings['distdir']
         self.mount["distdir"]['target'] = self.settings['target_distdir']
 

diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index ae27cd0a..66f21a9c 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -23,27 +23,6 @@ class stage1(StageBase):
 
     def __init__(self, spec, addlargs):
         StageBase.__init__(self, spec, addlargs)
-        # In the stage1 build we need to make sure that the ebuild 
repositories are
-        # accessible within $ROOT too... otherwise relative symlinks may point 
nowhere
-        # and, e.g., portageq may malfunction due to missing profile.
-        # Create a second, bind mount entry for each repository. We need to
-        #  * take as source not the original source but the original target, 
since
-        #    otherwise we may end up trying to mount the same squashfs twice 
instead
-        #    of a bind mount
-        #  * take the directory inside the chroot as source, not the host 
directory
-        # In the meantime we fixed make.profile to point outside ROOT, so this 
may not
-        # be necessary at the moment anymore. Having it can prevent future 
surprises
-        # though.
-        self.set_chroot_path()
-        for path, name, _ in self.repos:
-            name = get_repo_name(path)
-            mount_id = f'root_repo_{name}'
-            repo_loc = self.get_repo_location(name)
-            self.mount[mount_id] = {
-                'enable': True,
-                'source': self.settings['chroot_path'] / 
repo_loc.relative_to('/'),
-                'target': normpath("/tmp/stage1root") / 
repo_loc.relative_to('/')
-            }
 
     def set_root_path(self):
         # sets the root path, relative to 'chroot_path', of the stage1 root

Reply via email to