Gentoo Archives: gentoo-dev

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

Replies

Subject Author
Re: [gentoo-dev] [PATCH v2 1/1] edo.eclass: add new eclass Ionen Wolkens <ionen@g.o>