Skip to content

Commit

Permalink
vartree, movefile: Warn when rewriting a symlink
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ulm committed Jun 19, 2024
1 parent 819c863 commit 4d17764
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
--------------

Expand Down
10 changes: 10 additions & 0 deletions lib/portage/dbapi/vartree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/portage/util/movefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4d17764

Please sign in to comment.