Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 920889 - PMS specifies D is available in postinst but gives no guarantees about the contents being available
Summary: PMS specifies D is available in postinst but gives no guarantees about the co...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Package Manager Specification
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-28 15:36 UTC by Michał Górny
Modified: 2024-01-01 14:34 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
ebuild-env-vars.tex: Clarify that D is not valid in pkg_postinst (0001-ebuild-env-vars.tex-Clarify-that-D-is-not-valid-in-p.patch,2.33 KB, patch)
2023-12-29 12:03 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-12-28 15:36:28 UTC
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.
Comment 1 Ulrich Müller gentoo-dev 2023-12-29 12:03:33 UTC
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.
Comment 2 Ulrich Müller gentoo-dev 2023-12-29 12:15:13 UTC
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.)
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-12-29 14:35:06 UTC
(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!
Comment 4 Larry the Git Cow gentoo-dev 2024-01-01 14:34:12 UTC
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(-)