aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2024-06-19 10:08:04 +0200
committerUlrich Müller <ulm@gentoo.org>2024-06-19 20:17:06 +0200
commit4d17764863896903df4d18fe7c6b45635a18f6c4 (patch)
treec91fecebbb322647e1e7c7874883f7534e49a2ab
parentebuild: fix typo in comment (diff)
downloadportage-4d17764863896903df4d18fe7c6b45635a18f6c4.tar.gz
portage-4d17764863896903df4d18fe7c6b45635a18f6c4.tar.bz2
portage-4d17764863896903df4d18fe7c6b45635a18f6c4.zip
vartree, movefile: Warn when rewriting a symlink
See PMS section 13.4.1 (Rewriting): Any absolute symlink whose link starts with D must be rewritten with the leading D removed. The package manager should issue a notice when doing this. Bug: https://bugs.gentoo.org/934514 Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--NEWS2
-rw-r--r--lib/portage/dbapi/vartree.py10
-rw-r--r--lib/portage/util/movefile.py5
3 files changed, 17 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index b4b378e7a..d5a03533d 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,8 @@ Bug fixes:
working ebuilds. Future EAPIs will need to adjust the logic
added by this change. See bug #907061.
+* vartree, movefile: Warn when rewriting a symlink (bug #934514).
+
portage-3.0.65 (2024-06-04)
--------------
diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index beb1a6486..0c41d408c 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -5563,6 +5563,16 @@ class dblink:
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 :]
# 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
diff --git a/lib/portage/util/movefile.py b/lib/portage/util/movefile.py
index 75100a3ac..7b880d2e3 100644
--- a/lib/portage/util/movefile.py
+++ b/lib/portage/util/movefile.py
@@ -210,6 +210,11 @@ def movefile(
try:
target = os.readlink(src)
if mysettings and "D" in mysettings and target.startswith(mysettings["D"]):
+ writemsg(
+ f"!!! {_('Absolute symlink points to image directory.')}\n",
+ noiselevel=-1,
+ )
+ writemsg(f"!!! {dest} -> {target}\n", noiselevel=-1)
target = target[len(mysettings["D"]) - 1 :]
# Atomically update the path if it exists.
try: