From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1PqQFO-0007e1-0V for garchives@archives.gentoo.org; Fri, 18 Feb 2011 13:19:46 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 74D91E04ED; Fri, 18 Feb 2011 13:19:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 30AE6E04ED for ; Fri, 18 Feb 2011 13:19:38 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 88AD51B40A5 for ; Fri, 18 Feb 2011 13:19:37 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id DD7708006A for ; Fri, 18 Feb 2011 13:19:36 +0000 (UTC) From: "Tomas Chvatal" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Tomas Chvatal" Message-ID: Subject: [gentoo-commits] proj/x11:master commit in: eclass/ X-VCS-Repository: proj/x11 X-VCS-Files: eclass/virtualx.eclass X-VCS-Directories: eclass/ X-VCS-Committer: scarabeus X-VCS-Committer-Name: Tomas Chvatal X-VCS-Revision: b496f16a827a4634278de5b7c095092efdb68aca Date: Fri, 18 Feb 2011 13:19:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: f3fdb5e995b0b3eeffe1a8350a70cf91 commit: b496f16a827a4634278de5b7c095092efdb68aca Author: Tomas Chvatal gentoo org> AuthorDate: Fri Feb 18 12:46:23 2011 +0000 Commit: Tomas Chvatal gentoo org> CommitDate: Fri Feb 18 12:46:23 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/x11.git;a=3Dc= ommit;h=3Db496f16a Import virtualx.eclass from cvs. --- eclass/virtualx.eclass | 163 ++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 163 insertions(+), 0 deletions(-) diff --git a/eclass/virtualx.eclass b/eclass/virtualx.eclass new file mode 100644 index 0000000..52d1284 --- /dev/null +++ b/eclass/virtualx.eclass @@ -0,0 +1,163 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/virtualx.eclass,v 1.35 2010/05= /15 05:40:46 dirtyepic Exp $ + +# Original author: Martin Schlemmer + +# @ECLASS: virtualx.eclass +# @MAINTAINER: +# x11@gentoo.org +# @BLURB: This eclass can be used for packages that needs a working X en= vironment to build. + +# @ECLASS-VARIABLE: VIRTUALX_REQUIRED +# @DESCRIPTION: +# Is a dependency on xorg-server and xhost needed? +# Valid values are "always", "optional", and "manual". +# "tests" is a synonym for "optional". +: ${VIRTUALX_REQUIRED:=3Doptional} + +# @ECLASS-VARIABLE: VIRTUALX_USE +# @DESCRIPTION: +# If VIRTUALX_REQUIRED=3Doptional, what USE flag should control +# the dependency? +: ${VIRTUALX_USE:=3Dtest} + +# @ECLASS-VARIABLE: VIRTUALX_DEPEND +# @DESCRIPTION: +# Dep string available for use outside of eclass, in case a more +# complicated dep is needed. +VIRTUALX_DEPEND=3D"!prefix? ( x11-base/xorg-server ) + x11-apps/xhost" + +case ${VIRTUALX_REQUIRED} in + always) + DEPEND=3D"${VIRTUALX_DEPEND}" + RDEPEND=3D"" + ;; + optional|tests) + DEPEND=3D"${VIRTUALX_USE}? ( ${VIRTUALX_DEPEND} )" + RDEPEND=3D"" + IUSE=3D"${VIRTUALX_USE}" + ;; + manual) + ;; + *) + eerror "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED" + eerror "Valid values are:" + eerror " always" + eerror " optional (default if unset)" + eerror " manual" + die "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED" + ;; +esac + +virtualmake() { + local retval=3D0 + local OLD_SANDBOX_ON=3D"${SANDBOX_ON}" + local XVFB=3D$(type -p Xvfb) + local XHOST=3D$(type -p xhost) + + # 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 + export XAUTHORITY=3D + # The following is derived from Mandrake's hack to allow + # compiling without the X display + + einfo "Scanning for an open DISPLAY to start Xvfb ..." + + # We really do not want SANDBOX enabled here + export SANDBOX_ON=3D"0" + + local i=3D0 + XDISPLAY=3D$(i=3D0; while [[ -f /tmp/.X${i}-lock ]] ; do ((i++));done;= echo ${i}) + + # 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 + # + # Changed the mode from 800x600x32 to 800x600x24 because the mfb + # support has been dropped in Xvfb in the xorg-x11 pre-releases. + # For now only depths up to 24-bit are supported. + # + # Sven Wegener - 22 Aug 2004 + # + # Use "-fp built-ins" because it's only part of the default font path + # for Xorg but not the other DDXs (Xvfb, Kdrive, etc). Temporarily fix= es + # bug 278487 until xorg-server is properly patched + # + # R=C3=A9mi Cardona (10 Aug 2009) + ${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24 &>/dev/null & + sleep 2 + + local start=3D${XDISPLAY} + while [[ ! -f /tmp/.X${XDISPLAY}-lock ]] ; do + # Stop trying after 15 tries + if ((XDISPLAY - start > 15)) ; then + + eerror "" + eerror "Unable to start Xvfb." + eerror "" + eerror "'${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24' re= turns:" + eerror "" + ${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24 + eerror "" + eerror "If possible, correct the above error and try your emerge aga= in." + eerror "" + die + fi + + ((XDISPLAY++)) + ${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24 &>/dev/null & + sleep 2 + done + + # Now enable SANDBOX again if needed. + export SANDBOX_ON=3D"${OLD_SANDBOX_ON}" + + einfo "Starting Xvfb on \$DISPLAY=3D${XDISPLAY} ..." + + export DISPLAY=3D:${XDISPLAY} + #Do not break on error, but setup $retval, as we need + #to kill Xvfb + ${maketype} "$@" + retval=3D$? + + #Now kill Xvfb + kill $(cat /tmp/.X${XDISPLAY}-lock) + else + #Normal make if we can connect to an X display + ${maketype} "$@" + retval=3D$? + fi + + return ${retval} +} + +# @FUNCTION: Xmake +# @DESCRIPTION:=20 +# Same as "make", but set up the Xvfb hack if needed. +Xmake() { + export maketype=3D"make" + virtualmake "$@" +} + +# @FUNCTION: Xemake +# @DESCRIPTION:=20 +# Same as "emake", but set up the Xvfb hack if needed. +Xemake() { + export maketype=3D"emake" + virtualmake "$@" +} + +# @FUNCTION: Xeconf +# @DESCRIPTION:=20 +# Same as "econf", but set up the Xvfb hack if needed. +Xeconf() { + export maketype=3D"econf" + virtualmake "$@" +}