Gentoo Archives: gentoo-dev

From: Sam James <sam@g.o>
To: gentoo-dev@l.g.o
Cc: qa@g.o, pms@g.o, Sam James <sam@g.o>
Subject: [gentoo-dev] [PATCH v3 1/1] edo.eclass: add new eclass
Date: Sun, 17 Apr 2022 14:04:26
Message-Id: 20220417140329.79898-2-sam@gentoo.org
In Reply to: [gentoo-dev] [PATCH v3 0/1] Add edo.eclass by Sam James
1 Bug: https://bugs.gentoo.org/744880
2 Signed-off-by: Sam James <sam@g.o>
3 ---
4 eclass/edo.eclass | 45 +++++++++++++++++++++++++++++++++++++++++++++
5 1 file changed, 45 insertions(+)
6 create mode 100644 eclass/edo.eclass
7
8 diff --git a/eclass/edo.eclass b/eclass/edo.eclass
9 new file mode 100644
10 index 000000000000..e7b3b95df4ae
11 --- /dev/null
12 +++ b/eclass/edo.eclass
13 @@ -0,0 +1,45 @@
14 +# Copyright 2022 Gentoo Authors
15 +# Distributed under the terms of the GNU General Public License v2
16 +
17 +# @ECLASS: edo.class
18 +# @MAINTAINER:
19 +# QA Team <qa@g.o>
20 +# @AUTHOR:
21 +# Sam James <sam@g.o>
22 +# @SUPPORTED_EAPIS: 7 8
23 +# @BLURB: Convenience function to run commands verbosely and die on failure
24 +# @DESCRIPTION:
25 +# This eclass provides the 'edo' command, and an 'edob' variant for ebegin/eend,
26 +# which dies (exits) on failure and logs the command used verbosely.
27 +#
28 +
29 +case ${EAPI:-0} in
30 + 7|8) ;;
31 + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
32 +esac
33 +
34 +if [[ -z ${_EDO_ECLASS} ]] ; then
35 +_EDO_ECLASS=1
36 +
37 +# @FUNCTION: edo
38 +# @USAGE: <command> [<args>...]
39 +# @DESCRIPTION:
40 +# Executes a short 'command' with any given arguments and exits on failure unless
41 +# called under 'nonfatal'.
42 +edo() {
43 + einfo "$@"
44 + "$@" || die -n "Failed to run command: $@"
45 +}
46 +
47 +# @FUNCTION: edob
48 +# @USAGE: <command> [<args>...]
49 +# @DESCRIPTION:
50 +# Executes 'command' with ebegin & eend with any given arguments and exits
51 +# on failure unless called under 'nonfatal'.
52 +edob() {
53 + ebegin "Running $@"
54 + "$@"
55 + eend $? || die -n "Failed to run command: $@"
56 +}
57 +
58 +fi
59 --
60 2.35.1

Replies

Subject Author
[gentoo-dev] Re: [PATCH v3 1/1] edo.eclass: add new eclass Ulrich Mueller <ulm@g.o>