EAPI 7 specifies that nonfatal has to be implemented both as a bash
function and a fallback executable, so that it can be used e.g. via
find/xargs.

Bug: https://bugs.gentoo.org/622894
---
 bin/eapi.sh                 |  4 ++++
 bin/ebuild-helpers/nonfatal | 14 ++++++++++++++
 2 files changed, 18 insertions(+)
 create mode 100755 bin/ebuild-helpers/nonfatal

diff --git a/bin/eapi.sh b/bin/eapi.sh
index fa254485c..67563bed8 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -72,6 +72,10 @@ ___eapi_has_nonfatal() {
        [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
+___eapi_has_nonfatal_as_executable() {
+       [[ ! ${1-${EAPI-0}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]]
+}
+
 ___eapi_has_doheader() {
        [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
diff --git a/bin/ebuild-helpers/nonfatal b/bin/ebuild-helpers/nonfatal
new file mode 100755
index 000000000..5618aa16b
--- /dev/null
+++ b/bin/ebuild-helpers/nonfatal
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
+
+if ! ___eapi_has_nonfatal_as_executable; then
+       die "$FUNCNAME() not supported as fallback helper in this EAPI"
+fi
+if [[ $# -lt 1 ]]; then
+       die "$FUNCNAME(): Missing argument"
+fi
+
+PORTAGE_NONFATAL=1 exec "$@"
-- 
2.16.2


Reply via email to