commit:     161f0861de512991a879a50b2868c503f4715352
Author:     Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 28 10:53:53 2015 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Mon Dec  7 09:11:54 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=161f0861

virtualx.eclass: Simplify API into single virtx()

The new API runs all specified arguments to virtx() inside an XFVB,
instead of defining VIRTUALX_COMMAND and running that in virtualmake.

Xemake and Xeconf should be replaced by "virtx emake" and "virtx econf".

Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>

 eclass/virtualx.eclass | 46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/eclass/virtualx.eclass b/eclass/virtualx.eclass
index 3df3fe1..7e78205 100644
--- a/eclass/virtualx.eclass
+++ b/eclass/virtualx.eclass
@@ -89,6 +89,40 @@ esac
 virtualmake() {
        debug-print-function ${FUNCNAME} "$@"
 
+       # backcompat for maketype
+       if [[ -n ${maketype} ]]; then
+               eqawarn "ebuild is exporting \$maketype=${maketype}"
+               eqawarn "Ebuild should be migrated to use 'virtx command' 
instead."
+               VIRTUALX_COMMAND=${maketype}
+       fi
+
+       virtx "${VIRTUALX_COMMAND}" "${@}"
+}
+
+
+# @FUNCTION: virtx
+# @USAGE: <command> [command arguments]
+# @DESCRIPTION:
+# Start new Xvfb session and run commands in it.
+#
+# Example:
+#
+# @CODE
+# src_test() {
+#      virtx default
+# }
+# @CODE
+#
+# @CODE
+# python_test() {
+#      virtx py.test --verbose
+# }
+# @CODE
+virtx() {
+       debug-print-function ${FUNCNAME} "$@"
+
+       [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument"
+
        local i=0
        local retval=0
        local OLD_SANDBOX_ON="${SANDBOX_ON}"
@@ -97,14 +131,6 @@ virtualmake() {
        XVFB=$(type -p Xvfb) || die
        XHOST=$(type -p xhost) || die
 
-       # backcompat for maketype
-       if [[ -n ${maketype} ]]; then
-               eqawarn "ebuild is exporting \$maketype=${maketype}"
-               eqawarn "Ebuild should be migrated to use 
VIRTUALX_COMMAND=${maketype} instead."
-               eqawarn "Setting VIRTUALX_COMMAND to \$maketype conveniently 
for now."
-               VIRTUALX_COMMAND=${maketype}
-       fi
-
        debug-print "${FUNCNAME}: running Xvfb hack"
        export XAUTHORITY=
        # The following is derived from Mandrake's hack to allow
@@ -154,10 +180,10 @@ virtualmake() {
        # to kill Xvfb
        debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\""
        if has "${EAPI}" 2 3; then
-               ${VIRTUALX_COMMAND} "$@"
+               "$@"
                retval=$?
        else
-               nonfatal ${VIRTUALX_COMMAND} "$@"
+               nonfatal "$@"
                retval=$?
        fi
 

Reply via email to