Per 11.1 Defined Variables, D is allowed to be used in pkg_postinst. Per 13.3 [Merging and Unmerging] Regular Files: > Regular files are merged onto the filesystem (but see the notes on configuration file protection, below). The method used to perform the merge is not specified, so long as the end result is correct. In particular, merging a regular file may alter or remove the source file under D. This sounds like a bit of a contradiction because while we're allowed to access D in postinst, there's no guarantee that it will contain anything useful. Perhaps it would be less confusing to disallow that access.
Created attachment 880950 [details, diff] ebuild-env-vars.tex: Clarify that D is not valid in pkg_postinst The postinst phase was added to and removed from the scope of D several times in the history of the spec. The only commit explicitly mentioning a rationale appears to be https://gitweb.gentoo.org/proj/pms.git/commit/?id=65c4663177188da2df24e05ee514c5f2e0318c8 which says "D in pkg_postinst == bad" in its commit message. Please review attached patch.
Alternatively, we could leave pkg_postinst in place in the second column, and add "Ebuilds must not attempt to access the directory in pkg_postinst." to the description. This may be slightly more consistent with the previous change in https://gitweb.gentoo.org/proj/pms.git/commit/?id=ede65b5d136640575479c9c9a3162ee4d2be953e. (Then again, I see why an ebuild could need the value of ${D} in src_*, but I don't see it for pkg_postinst.)
(In reply to Ulrich Müller from comment #1) > Created attachment 880950 [details, diff] [details, diff] > ebuild-env-vars.tex: Clarify that D is not valid in pkg_postinst > > The postinst phase was added to and removed from the scope of D several > times in the history of the spec. The only commit explicitly mentioning a > rationale appears to be > https://gitweb.gentoo.org/proj/pms.git/commit/ > ?id=65c4663177188da2df24e05ee514c5f2e0318c8 which says "D in pkg_postinst == > bad" in its commit message. > > Please review attached patch. LGTM. Thanks!
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/proj/pms.git/commit/?id=658ead31edffc3bf431c5840830a357e3fe555da commit 658ead31edffc3bf431c5840830a357e3fe555da Author: Ulrich Müller <ulm@gentoo.org> AuthorDate: 2023-12-29 11:54:18 +0000 Commit: Ulrich Müller <ulm@gentoo.org> CommitDate: 2023-12-29 12:20:21 +0000 ebuild-env-vars.tex: Clarify that D is not valid in pkg_postinst D in pkg_* phases was first mentioned in SVN r74 (commit f627e46102c6) as a variable specific to the pkg_preinst phase function (replacing IMAGE). pkg_postinst was added in r88 (commit 3da3ee561f1a), but this was reverted in r89 (commit 65c466317718) "D in pkg_postinst == bad". pkg_postinst reappeared when the env vars section was converted to a table in commit 58d3bc0e8301. According to chapter 13 "Merging and Unmerging", the method used to perform the merge is not specified, and merging a regular file or a directory may alter or remove its source under D. Therefore, trying to access any file in D during the postinst phase is an error. The scope of ED follows that of D. Closes: https://bugs.gentoo.org/920889 Signed-off-by: Ulrich Müller <ulm@gentoo.org> ebuild-env-vars.tex | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)