public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/portage/, lib/portage/dbapi/, lib/portage/util/
@ 2025-08-17 19:06 Ulrich Müller
  0 siblings, 0 replies; only message in thread
From: Ulrich Müller @ 2025-08-17 19:06 UTC (permalink / raw
  To: gentoo-commits

commit:     f2c5663e90afa9f0f715aad0f6b0a863cf7914df
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 10 11:23:45 2025 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Aug 17 19:00:38 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f2c5663e

EAPI 9 no longer rewrites absolute symlinks

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 lib/portage/dbapi/vartree.py | 35 ++++++++++++++++++++---------------
 lib/portage/eapi.py          |  7 +++++++
 lib/portage/util/movefile.py | 11 +++++++++--
 3 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index 590bca92e8..d17432f5f5 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2023 Gentoo Authors
+# Copyright 1998-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ["vardbapi", "vartree", "dblink"] + ["write_contents", "tar_contents"]
@@ -15,7 +15,7 @@ portage.proxy.lazyimport.lazyimport(
     "portage.dbapi._SyncfsProcess:SyncfsProcess",
     "portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list,"
     + "use_reduce,_slot_separator,_repo_separator",
-    "portage.eapi:_get_eapi_attrs",
+    "portage.eapi:_get_eapi_attrs,eapi_rewrites_symlinks",
     "portage.elog:collect_ebuild_messages,collect_messages,"
     + "elog_process,_merge_logentries",
     "portage.locks:lockdir,unlockdir,lockfile,unlockfile",
@@ -5561,19 +5561,24 @@ class dblink:
                 if myabsto.startswith(srcroot):
                     myabsto = myabsto[len(srcroot) :]
                 myabsto = myabsto.lstrip(sep)
-                if self.settings and self.settings["D"]:
-                    if myto.startswith(self.settings["D"]):
-                        self._eqawarn(
-                            "preinst",
-                            [
-                                _(
-                                    "QA Notice: Absolute symlink %s points to %s inside the image directory.\n"
-                                    "Removing the leading %s from its path."
-                                )
-                                % (mydest, myto, self.settings["D"])
-                            ],
-                        )
-                        myto = myto[len(self.settings["D"]) - 1 :]
+                if (
+                    self.settings
+                    and "EAPI" in self.settings
+                    and eapi_rewrites_symlinks(self.settings["EAPI"])
+                    and self.settings["D"]
+                    and myto.startswith(self.settings["D"])
+                ):
+                    self._eqawarn(
+                        "preinst",
+                        [
+                            _(
+                                "QA Notice: Absolute symlink %s points to %s inside the image directory.\n"
+                                "Removing the leading %s from its path."
+                            )
+                            % (mydest, myto, self.settings["D"])
+                        ],
+                    )
+                    myto = myto[len(self.settings["D"]) - 1 :]
                 # myrealto contains the path of the real file to which this symlink points.
                 # we can simply test for existence of this file to see if the target has been merged yet
                 myrealto = normalize_path(os.path.join(destroot, myabsto))

diff --git a/lib/portage/eapi.py b/lib/portage/eapi.py
index e0a9fc61a4..523156892e 100644
--- a/lib/portage/eapi.py
+++ b/lib/portage/eapi.py
@@ -148,6 +148,10 @@ def eapi_has_sysroot(eapi: str) -> bool:
     return _get_eapi_attrs(eapi).sysroot
 
 
+def eapi_rewrites_symlinks(eapi: str) -> bool:
+    return _get_eapi_attrs(eapi).symlink_rewrite
+
+
 _eapi_attrs = collections.namedtuple(
     "_eapi_attrs",
     (
@@ -184,6 +188,7 @@ _eapi_attrs = collections.namedtuple(
         "src_uri_arrows",
         "stablemask",
         "strong_blocks",
+        "symlink_rewrite",
         "sysroot",
         "use_deps",
         "use_dep_defaults",
@@ -264,6 +269,7 @@ def _get_eapi_attrs(eapi_str: Optional[str]) -> _eapi_attrs:
             src_uri_arrows=True,
             stablemask=True,
             strong_blocks=True,
+            symlink_rewrite=False,
             sysroot=True,
             use_deps=True,
             use_dep_defaults=True,
@@ -304,6 +310,7 @@ def _get_eapi_attrs(eapi_str: Optional[str]) -> _eapi_attrs:
             src_uri_arrows=eapi >= Eapi("2"),
             stablemask=eapi >= Eapi("5"),
             strong_blocks=eapi >= Eapi("2"),
+            symlink_rewrite=eapi <= Eapi("8"),
             sysroot=eapi >= Eapi("7"),
             use_deps=eapi >= Eapi("2"),
             use_dep_defaults=eapi >= Eapi("4"),

diff --git a/lib/portage/util/movefile.py b/lib/portage/util/movefile.py
index 7b880d2e3e..4fae97a199 100644
--- a/lib/portage/util/movefile.py
+++ b/lib/portage/util/movefile.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2020 Gentoo Authors
+# Copyright 2010-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ["movefile"]
@@ -21,6 +21,7 @@ from portage import (
     _unicode_module_wrapper,
 )
 from portage.const import MOVE_BINARY
+from portage.eapi import eapi_rewrites_symlinks
 from portage.exception import OperationNotSupported
 from portage.localization import _
 from portage.process import spawn
@@ -209,7 +210,13 @@ def movefile(
     if stat.S_ISLNK(sstat[stat.ST_MODE]):
         try:
             target = os.readlink(src)
-            if mysettings and "D" in mysettings and target.startswith(mysettings["D"]):
+            if (
+                mysettings
+                and "EAPI" in mysettings
+                and eapi_rewrites_symlinks(mysettings["EAPI"])
+                and "D" in mysettings
+                and target.startswith(mysettings["D"])
+            ):
                 writemsg(
                     f"!!! {_('Absolute symlink points to image directory.')}\n",
                     noiselevel=-1,


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-08-17 19:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-17 19:06 [gentoo-commits] proj/portage:master commit in: lib/portage/, lib/portage/dbapi/, lib/portage/util/ Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox