commit:     e4902028b2cc86957fd91f411662b9710100e771
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 27 22:48:35 2018 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 23 23:01:57 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e4902028

Fix definition of ESYSROOT to use SYSROOT's prefix

For a given location, we were basing ESYSROOT on the prefix of that
location instead of the prefix used by the SYSROOT location. For
example, if BROOT=/foo, ROOT=/bar, EPREFIX=/baz, EROOT=/bar/baz, and
SYSROOT=/ then ESYSROOT should be /foo, not /baz.

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/932
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                                                   |  5 +++++
 lib/portage/package/ebuild/_config/LocationsManager.py | 11 +++++++++--
 lib/portage/package/ebuild/config.py                   |  2 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index a0463aa4c..1426a0856 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,11 @@ Bug fixes:
   fatal for now. The number of failures in bug #870412 is too large for the 
time
   being.
 
+* Fix definition of ESYSROOT to use SYSROOT's prefix. For a given location, we
+  were basing ESYSROOT on the prefix of that location instead of the prefix 
used
+  by the SYSROOT location. For example, if BROOT=/foo, ROOT=/bar, EPREFIX=/baz,
+  EROOT=/bar/baz, and SYSROOT=/ then ESYSROOT should be /foo, not /baz.
+
 portage-3.0.39 (2022-11-20)
 --------------
 

diff --git a/lib/portage/package/ebuild/_config/LocationsManager.py 
b/lib/portage/package/ebuild/_config/LocationsManager.py
index 5c3592f5d..a92407dbd 100644
--- a/lib/portage/package/ebuild/_config/LocationsManager.py
+++ b/lib/portage/package/ebuild/_config/LocationsManager.py
@@ -93,8 +93,6 @@ class LocationsManager:
                 + os.sep
             )
 
-        self.esysroot = self.sysroot.rstrip(os.sep) + self.eprefix + os.sep
-
         # TODO: Set this via the constructor using
         # PORTAGE_OVERRIDE_EPREFIX.
         self.broot = portage.const.EPREFIX
@@ -405,6 +403,15 @@ class LocationsManager:
 
         self.eroot = self.target_root.rstrip(os.sep) + self.eprefix + os.sep
 
+        # In a cross-prefix scenario where SYSROOT=/ and ROOT=/, assume we want
+        # ESYSROOT to point to the target prefix.
+        if self.sysroot == self.target_root:
+            self.esysroot = self.sysroot.rstrip(os.sep) + self.eprefix + os.sep
+        elif self.sysroot == "/":
+            self.esysroot = self.broot + os.sep
+        else:
+            self.esysroot = self.sysroot
+
         self.global_config_path = GLOBAL_CONFIG_PATH
         if portage.const.EPREFIX:
             self.global_config_path = os.path.join(

diff --git a/lib/portage/package/ebuild/config.py 
b/lib/portage/package/ebuild/config.py
index 74f7ab371..a37b373cf 100644
--- a/lib/portage/package/ebuild/config.py
+++ b/lib/portage/package/ebuild/config.py
@@ -424,7 +424,6 @@ class config:
             eprefix = locations_manager.eprefix
             config_root = locations_manager.config_root
             sysroot = locations_manager.sysroot
-            esysroot = locations_manager.esysroot
             broot = locations_manager.broot
             abs_user_config = locations_manager.abs_user_config
             make_conf_paths = [
@@ -467,6 +466,7 @@ class config:
             locations_manager.set_root_override(make_conf.get("ROOT"))
             target_root = locations_manager.target_root
             eroot = locations_manager.eroot
+            esysroot = locations_manager.esysroot
             self.global_config_path = locations_manager.global_config_path
 
             # The expand_map is used for variable substitution

Reply via email to