Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] ebuild.sh: Fail on command-not-found in global scope
Date: Thu, 31 Aug 2017 17:42:33
Message-Id: 17f21b3a-3fce-e505-9f09-926192fa752f@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] ebuild.sh: Fail on command-not-found in global scope by "Michał Górny"
1 On 08/31/2017 07:56 AM, Michał Górny wrote:
2 > The PMS specifies that ebuilds must not call external commands in global
3 > scope. We can not prevent that from happening at the moment since a few
4 > ebuilds in Gentoo are still doing that.
5 >
6 > Instead, start increasing strictness by explicitly failing if ebuilds
7 > call external commands that are not found. This is not going to really
8 > break any ebuilds that are not broken already (since command-not-found
9 > usually indicates something is going wrong), and it will help noticing
10 > typos and reliance on non-common external commands.
11 >
12 > A similar change has been tested in pkgcore, and confirmed not to cause
13 > any failures with the current state of the Gentoo repository.
14 >
15 > Closes: https://github.com/gentoo/portage/pull/198
16 > ---
17 > bin/ebuild.sh | 4 ++++
18 > 1 file changed, 4 insertions(+)
19 >
20 > diff --git a/bin/ebuild.sh b/bin/ebuild.sh
21 > index f1ac3f278..c23561651 100755
22 > --- a/bin/ebuild.sh
23 > +++ b/bin/ebuild.sh
24 > @@ -79,6 +79,10 @@ else
25 > eval "${x}() { die \"\${FUNCNAME}() calls are not allowed in global scope\"; }"
26 > done
27 > unset funcs x
28 > +
29 > + command_not_found_handle() {
30 > + die "Command not found while sourcing ebuild: ${*}"
31 > + }
32 > fi
33 >
34 > # Don't use sandbox's BASH_ENV for new shells because it does
35 >
36
37 Looks good. Please merge.
38 --
39 Thanks,
40 Zac

Replies