virtualx.eclass: Simplify API into single virtx()
authorJustin Lecher <jlec@gentoo.org>
Sat, 28 Nov 2015 10:53:53 +0000 (11:53 +0100)
committerJustin Lecher <jlec@gentoo.org>
Mon, 7 Dec 2015 09:11:54 +0000 (10:11 +0100)
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@gentoo.org>
eclass/virtualx.eclass

index 3df3fe161f22310588e41a618ce3f432c3f6dffb..7e78205e09c4d414c107037ef3d8ef345a518eda 100644 (file)
@@ -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