https://devmanual.gentoo.org/ebuild-writing/eapi/index.html#eapi=4 src_install() { emake DESTDIR="${D}" install nonfatal dodoc ChangeLog README } This is incorrect since the exit status is ignored. A better example would be to provide src_test() with custom error handling (see dev-vcs/git), e.g.: src_test() { if ! nonfatal emake check; then # do some log processing or something die "Tests failed" fi }
Patch?
reading the PMS itself, I am confused on when we actually need to use the nonfatal helper. Why is it bad to use it with dodoc etc? Is it only suitable for helpers that actually do some building themselves (ie emake)?
(In reply to Markos Chandras from comment #2) > reading the PMS itself, I am confused on when we actually need to use the > nonfatal helper. Why is it bad to use it with dodoc etc? Is it only suitable > for helpers that actually do some building themselves (ie emake)? It's not about what the helper does but how the result is used. Basically nonfatal replaces automatic termination with exit status return. You are expected to use the exit status -- not to ignore it. Examples of nonfatal uses: a. replacing 'die' message with a better one, b. doing some post-failure test log processing/printing before 'die', c. killing daemons spawned during test phase before 'die', d. doing some compile tests in which failure triggers another code path. As you can see, in all of those cases the ebuild checks for failure and handles it. Now, the dodoc example is bad because there's no valid use for the failure status. In particular: 1. dodoc can fail if the files don't exist. But if they don't exist, they shouldn't be passed to dodoc in the first place. Then, nonfatal is used to allow incorrect code to work rather than fixing it (though it will throw warnings at user). 2. dodoc can fail if copying failed for any other reason. But if it fails for any other reason, there's something seriously wrong going on and we definitely don't want to proceed like nothing happened (and hope something else will fail and terminate the build for us). 3. Unless I'm mistaken, PMS doesn't specify how dodoc behaves after first failure. In particular, if ChangeLog does not exist, the remaining files may not be processed at all.
Hmm I see then. Although I don't find it particularly disturbing to use nonfatal with dodoc and friends but I agree it can mask real bugs. Sounds like you need to write a patch for us since you can explain the situation much better than I would do.
Created attachment 404740 [details, diff] Patch to replace the example How about this one? It uses the code from paludis.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=b5f6752aab9664d4672c476065467039b73b2f7b commit b5f6752aab9664d4672c476065467039b73b2f7b Author: Michał Górny <mgorny@gentoo.org> AuthorDate: 2015-06-07 12:44:00 +0000 Commit: Göktürk Yüksek <gokturk@gentoo.org> CommitDate: 2017-09-25 04:25:12 +0000 ebuild-writing/eapi: Replace nonfatal example with something correct Replace the nonfatal example from a poor programming practice (nonfatal dodoc) to a code collecting logs for test failures. Based on an old version of sys-apps/paludis. Closes: https://bugs.gentoo.org/551190 ebuild-writing/eapi/text.xml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)