• [gentoo-dev] [PATCH v3 0/1] Add edo.eclass

    From Sam James@21:1/5 to All on Sun Apr 17 16:10:02 2022
    Changes since v2:
    - Fix typo in eclass guard
    - Rework description of edob
    - Use 'einfo', not 'elog'
    - Change die message for clarity

    Changes since v1:
    - Add EAPI 7 support (useful for e.g. base-system@ ebuilds)
    - Add 'edob' (edo with ebegin/eend for better logs log-running commands, UX) Sam James (1):
    edo.eclass: add new eclass

    eclass/edo.eclass | 45 +++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 45 insertions(+)
    create mode 100644 eclass/edo.eclass

    --
    2.35.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to All on Sun Apr 17 16:10:01 2022
    Bug: https://bugs.gentoo.org/744880
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/edo.eclass | 45 +++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 45 insertions(+)
    create mode 100644 eclass/edo.eclass

    diff --git a/eclass/edo.eclass b/eclass/edo.eclass
    new file mode 100644
    index 000000000000..e7b3b95df4ae
    --- /dev/null
    +++ b/eclass/edo.eclass
    @@ -0,0 +1,45 @@
    +# Copyright 2022 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +# @ECLASS: edo.class
    +# @MAINTAINER:
    +# QA Team <qa@gentoo.org>
    +# @AUTHOR:
    +# Sam James <sam@gentoo.org>
    +# @SUPPORTED_EAPIS: 7 8
    +# @BLURB: Convenience function to run commands verbosely and die on failure
    +# @DESCRIPTION:
    +# This eclass provides the 'edo' command, and an 'edob' variant for ebegin/eend,
    +# which dies (exits) on failure and logs the command used verbosely.
    +#
    +
    +case ${EAPI:-0} in
    + 7|8) ;;
    + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
    +esac
    +
    +if [[ -z ${_EDO_ECLASS} ]] ; then
    +_EDO_ECLASS=1
    +
    +# @FUNCTION: edo
    +# @USAGE: <command> [<args>...]
  • From Ulrich Mueller@21:1/5 to All on Sun Apr 17 19:10:01 2022
    On Sun, 17 Apr 2022, Sam James wrote:

    --- /dev/null
    +++ b/eclass/edo.eclass
    @@ -0,0 +1,45 @@
    +# Copyright 2022 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +# @ECLASS: edo.class
    +# @MAINTAINER:
    +# QA Team <qa@gentoo.org>
    +# @AUTHOR:
    +# Sam James <sam@gentoo.org>
    +# @SUPPORTED_EAPIS: 7 8
    +# @BLURB: Convenience function to run commands verbosely and die on failure +# @DESCRIPTION:
    +# This eclass provides the 'edo' command, and an 'edob' variant for ebegin/eend,
    +# which dies (exits) on failure and logs the command used verbosely.
    +#
    +
    +case ${EAPI:-0} in

    Just ${EAPI} here, the fallback isn't necessary.

    + 7|8) ;;
    + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
    +esac
    +
    +if [[ -z ${_EDO_ECLASS} ]] ; then
    +_EDO_ECLASS=1
    +
    +# @FUNCTION: edo
    +# @USAGE: <command> [<args>...]
    +# @DESCRIPTION:
    +# Executes a short 'command' with any given arguments and exits on failure unless

    Long line.

    +# called under 'nonfatal'.
    +edo() {
    + einfo "$@"
    + "$@" || die -n "Failed to run command: $@"
    +}
    +
    +# @FUNCTION: edob
    +# @USAGE: <command> [<args>...]
    +# @DESCRIPTION:
    +# Executes 'command' with ebegin & eend with any given arguments and exits +# on failure unless called under 'nonfatal'.
    +edob() {
    + ebegin "Running $@"
    + "$@"
    + eend $? || die -n "Failed to run command: $@"
    +}
    +
    +fi

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmJcSQEPHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4uMwkH/2NAgyPNM18IDFwjKFWdznQnuQqxwifWwgKl +nJks4u3/3EJ8NULB8Pz5JI6O10K4mGrl59PaK0YI/r8BM1LISkyJbOwrVwHzLwb kcNXYjr7o1vwTVNJIN4IGX9q1IqFjMJQPtp272sc8+U4fYzhRrYI9JCfLBK0GMkd DfpZyxOHVGd8aVDrajCR1Th3nN0QE8OBzipkf6+wQEjxl76La3HjnWUpQV1+lcgC miMIX6dQXpvVLWRV0b/VmOvGIAgztZmX5YyA7Bc9CRR8pYiRNh4ODgUWHZgeDcq2 5E5LfXOQHfEcTVYpgXgoFzKS0aUbQFvyI12d46TtQE+4ZxxL6yI=
    =TarK
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)