summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorJustin Lecher <jlec@gentoo.org>2015-11-26 11:17:13 +0100
committerJustin Lecher <jlec@gentoo.org>2015-11-26 11:26:01 +0100
commite00275cad8aa0f5979c50d2fc9b317ebf754f9c2 (patch)
treee0a7202377f4cf42b937e64e3adbaab72b933d4c /eclass
parentdev-python/pandas: Use virtualx during doc building (diff)
downloadgentoo-e00275cad8aa0f5979c50d2fc9b317ebf754f9c2.tar.gz
gentoo-e00275cad8aa0f5979c50d2fc9b317ebf754f9c2.tar.bz2
gentoo-e00275cad8aa0f5979c50d2fc9b317ebf754f9c2.zip
virtualx.eclass: Always start Xvfb session
In order to have guarantee the same X env, we should always create a Xvfb session instead of attaching to a running X session. Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=374141 Signed-off-by: Justin Lecher <jlec@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/virtualx.eclass112
1 files changed, 50 insertions, 62 deletions
diff --git a/eclass/virtualx.eclass b/eclass/virtualx.eclass
index 69d9230b2df8..5d27ed984a8f 100644
--- a/eclass/virtualx.eclass
+++ b/eclass/virtualx.eclass
@@ -71,7 +71,7 @@ esac
# @FUNCTION: virtualmake
# @DESCRIPTION:
-# Function which attach to running X session or start new Xvfb session
+# Function which start new Xvfb session
# where the VIRTUALX_COMMAND variable content gets executed.
virtualmake() {
debug-print-function ${FUNCNAME} "$@"
@@ -91,77 +91,65 @@ virtualmake() {
VIRTUALX_COMMAND=${maketype}
fi
- # If $DISPLAY is not set, or xhost cannot connect to an X
- # display, then do the Xvfb hack.
- if [[ -n ${XVFB} && -n ${XHOST} ]] && \
- ( [[ -z ${DISPLAY} ]] || ! (${XHOST} &>/dev/null) ) ; then
- debug-print "${FUNCNAME}: running Xvfb hack"
- export XAUTHORITY=
- # The following is derived from Mandrake's hack to allow
- # compiling without the X display
-
- einfo "Scanning for an open DISPLAY to start Xvfb ..."
- # If we are in a chrooted environment, and there is already a
- # X server started outside of the chroot, Xvfb will fail to start
- # on the same display (most cases this is :0 ), so make sure
- # Xvfb is started, else bump the display number
- #
- # Azarah - 5 May 2002
- XDISPLAY=$(i=0; while [[ -f /tmp/.X${i}-lock ]] ; do ((i++));done; echo ${i})
- debug-print "${FUNCNAME}: XDISPLAY=${XDISPLAY}"
-
- # We really do not want SANDBOX enabled here
- export SANDBOX_ON="0"
-
+ debug-print "${FUNCNAME}: running Xvfb hack"
+ export XAUTHORITY=
+ # The following is derived from Mandrake's hack to allow
+ # compiling without the X display
+
+ einfo "Scanning for an open DISPLAY to start Xvfb ..."
+ # If we are in a chrooted environment, and there is already a
+ # X server started outside of the chroot, Xvfb will fail to start
+ # on the same display (most cases this is :0 ), so make sure
+ # Xvfb is started, else bump the display number
+ #
+ # Azarah - 5 May 2002
+ XDISPLAY=$(i=0; while [[ -f /tmp/.X${i}-lock ]] ; do ((i++));done; echo ${i})
+ debug-print "${FUNCNAME}: XDISPLAY=${XDISPLAY}"
+
+ # We really do not want SANDBOX enabled here
+ export SANDBOX_ON="0"
+
+ debug-print "${FUNCNAME}: ${XVFB} :${XDISPLAY} ${xvfbargs}"
+ ${XVFB} :${XDISPLAY} ${xvfbargs} &>/dev/null &
+ sleep 2
+
+ local start=${XDISPLAY}
+ while [[ ! -f /tmp/.X${XDISPLAY}-lock ]]; do
+ # Stop trying after 15 tries
+ if ((XDISPLAY - start > 15)) ; then
+ eerror "'${XVFB} :${XDISPLAY} ${xvfbargs}' returns:"
+ echo
+ ${XVFB} :${XDISPLAY} ${xvfbargs}
+ echo
+ eerror "If possible, correct the above error and try your emerge again."
+ die "Unable to start Xvfb"
+ fi
+ ((XDISPLAY++))
debug-print "${FUNCNAME}: ${XVFB} :${XDISPLAY} ${xvfbargs}"
${XVFB} :${XDISPLAY} ${xvfbargs} &>/dev/null &
sleep 2
+ done
- local start=${XDISPLAY}
- while [[ ! -f /tmp/.X${XDISPLAY}-lock ]]; do
- # Stop trying after 15 tries
- if ((XDISPLAY - start > 15)) ; then
- eerror "'${XVFB} :${XDISPLAY} ${xvfbargs}' returns:"
- echo
- ${XVFB} :${XDISPLAY} ${xvfbargs}
- echo
- eerror "If possible, correct the above error and try your emerge again."
- die "Unable to start Xvfb"
- fi
+ # Now enable SANDBOX again if needed.
+ export SANDBOX_ON="${OLD_SANDBOX_ON}"
- ((XDISPLAY++))
- debug-print "${FUNCNAME}: ${XVFB} :${XDISPLAY} ${xvfbargs}"
- ${XVFB} :${XDISPLAY} ${xvfbargs} &>/dev/null &
- sleep 2
- done
-
- # Now enable SANDBOX again if needed.
- export SANDBOX_ON="${OLD_SANDBOX_ON}"
-
- einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..."
-
- export DISPLAY=:${XDISPLAY}
- # Do not break on error, but setup $retval, as we need
- # to kill Xvfb
- debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\""
- if has "${EAPI}" 2 3; then
- ${VIRTUALX_COMMAND} "$@"
- retval=$?
- else
- nonfatal ${VIRTUALX_COMMAND} "$@"
- retval=$?
- fi
+ einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..."
- # Now kill Xvfb
- kill $(cat /tmp/.X${XDISPLAY}-lock)
- else
- debug-print "${FUNCNAME}: attaching to running X display"
- # Normal make if we can connect to an X display
- debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\""
+ export DISPLAY=:${XDISPLAY}
+ # Do not break on error, but setup $retval, as we need
+ # to kill Xvfb
+ debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\""
+ if has "${EAPI}" 2 3; then
${VIRTUALX_COMMAND} "$@"
retval=$?
+ else
+ nonfatal ${VIRTUALX_COMMAND} "$@"
+ retval=$?
fi
+ # Now kill Xvfb
+ kill $(cat /tmp/.X${XDISPLAY}-lock)
+
# die if our command failed
[[ ${retval} -ne 0 ]] && die "${FUNCNAME}: the ${VIRTUALX_COMMAND} failed."