Gentoo Archives: gentoo-portage-dev

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

Replies