From 4d17764863896903df4d18fe7c6b45635a18f6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20M=C3=BCller?= Date: Wed, 19 Jun 2024 10:08:04 +0200 Subject: [PATCH] vartree, movefile: Warn when rewriting a symlink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- NEWS | 2 ++ lib/portage/dbapi/vartree.py | 10 ++++++++++ lib/portage/util/movefile.py | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/NEWS b/NEWS index b4b378e7a0..d5a03533d9 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 beb1a6486f..0c41d408c3 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -5563,6 +5563,16 @@ def mergeme( 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 75100a3acd..7b880d2e3e 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: