/[gentoo-x86]/eclass/virtualx.eclass
Gentoo

Diff of /eclass/virtualx.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.30 Revision 1.35
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/virtualx.eclass,v 1.30 2009/10/19 21:12:07 abcd Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/virtualx.eclass,v 1.35 2010/05/15 05:40:46 dirtyepic Exp $
4#
5# Author: Martin Schlemmer <azarah@gentoo.org>
6#
7# This eclass can be used for packages that needs a working X environment to build
8 4
9# Is a dependency on xorg-server and xhost needed? 5# Original author: Martin Schlemmer <azarah@gentoo.org>
10# Valid values are "always", "tests", and "manual"
11VIRTUALX_REQUIRED="${VIRTUALX_REQUIRED:-tests}"
12 6
7# @ECLASS: virtualx.eclass
8# @MAINTAINER:
9# x11@gentoo.org
10# @BLURB: This eclass can be used for packages that needs a working X environment to build.
11
12# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
13# @DESCRIPTION:
14# Is a dependency on xorg-server and xhost needed?
15# Valid values are "always", "optional", and "manual".
16# "tests" is a synonym for "optional".
17: ${VIRTUALX_REQUIRED:=optional}
18
19# @ECLASS-VARIABLE: VIRTUALX_USE
20# @DESCRIPTION:
21# If VIRTUALX_REQUIRED=optional, what USE flag should control
22# the dependency?
23: ${VIRTUALX_USE:=test}
24
25# @ECLASS-VARIABLE: VIRTUALX_DEPEND
26# @DESCRIPTION:
13# Dep string available for use outside of eclass, in case a more 27# Dep string available for use outside of eclass, in case a more
14# complicated dep is needed 28# complicated dep is needed.
15VIRTUALX_DEPEND="x11-base/xorg-server 29VIRTUALX_DEPEND="!prefix? ( x11-base/xorg-server )
16 x11-apps/xhost" 30 x11-apps/xhost"
17 31
18case ${VIRTUALX_REQUIRED} in 32case ${VIRTUALX_REQUIRED} in
19 always) 33 always)
20 DEPEND="${VIRTUALX_DEPEND}" 34 DEPEND="${VIRTUALX_DEPEND}"
21 RDEPEND="" 35 RDEPEND=""
22 ;; 36 ;;
23 tests) 37 optional|tests)
24 DEPEND="test? ( ${VIRTUAX_DEPEND} )" 38 DEPEND="${VIRTUALX_USE}? ( ${VIRTUALX_DEPEND} )"
25 RDEPEND="" 39 RDEPEND=""
26 IUSE="test" 40 IUSE="${VIRTUALX_USE}"
27 ;; 41 ;;
28 manual) 42 manual)
29 ;; 43 ;;
30 *) 44 *)
31 eerror "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED" 45 eerror "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED"
32 eerror "Valid values are:" 46 eerror "Valid values are:"
33 eerror " always" 47 eerror " always"
34 eerror " tests" 48 eerror " optional (default if unset)"
35 eerror " manual" 49 eerror " manual"
36 die "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED" 50 die "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED"
37 ;; 51 ;;
38esac 52esac
39 53
40DESCRIPTION="Based on the $ECLASS eclass"
41
42#
43# Brian Harring <ferringb@gentoo.org> 11/04/2004
44# do not disable the sandbox during the depend phase.
45# ebuilds shouldn't touch the fs during depend phase, nor screw with the sandbox.
46#
47if [[ ${EBUILD_PHASE/depend} == "${EBUILD_PHASE}" ]] ; then
48 [[ -z ${SANDBOX_DISABLED} ]] && export SANDBOX_DISABLED="0" || :
49fi
50
51virtualmake() { 54virtualmake() {
52 local retval=0 55 local retval=0
53 local OLD_SANDBOX_DISABLED="${SANDBOX_DISABLED}" 56 local OLD_SANDBOX_ON="${SANDBOX_ON}"
54 local XVFB=$(type -p Xvfb) 57 local XVFB=$(type -p Xvfb)
55 local XHOST=$(type -p xhost) 58 local XHOST=$(type -p xhost)
56 59
57 # If $DISPLAY is not set, or xhost cannot connect to an X 60 # If $DISPLAY is not set, or xhost cannot connect to an X
58 # display, then do the Xvfb hack. 61 # display, then do the Xvfb hack.
63 # compiling without the X display 66 # compiling without the X display
64 67
65 einfo "Scanning for an open DISPLAY to start Xvfb ..." 68 einfo "Scanning for an open DISPLAY to start Xvfb ..."
66 69
67 # We really do not want SANDBOX enabled here 70 # We really do not want SANDBOX enabled here
68 export SANDBOX_DISABLED="1" 71 export SANDBOX_ON="0"
69 72
70 local i=0 73 local i=0
71 XDISPLAY=$(i=0; while [[ -f /tmp/.X${i}-lock ]] ; do ((i++));done; echo ${i}) 74 XDISPLAY=$(i=0; while [[ -f /tmp/.X${i}-lock ]] ; do ((i++));done; echo ${i})
72 75
73 # If we are in a chrooted environment, and there is already a 76 # If we are in a chrooted environment, and there is already a
112 ${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24 &>/dev/null & 115 ${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24 &>/dev/null &
113 sleep 2 116 sleep 2
114 done 117 done
115 118
116 # Now enable SANDBOX again if needed. 119 # Now enable SANDBOX again if needed.
117 export SANDBOX_DISABLED="${OLD_SANDBOX_DISABLED}" 120 export SANDBOX_ON="${OLD_SANDBOX_ON}"
118 121
119 einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..." 122 einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..."
120 123
121 export DISPLAY=:${XDISPLAY} 124 export DISPLAY=:${XDISPLAY}
122 #Do not break on error, but setup $retval, as we need 125 #Do not break on error, but setup $retval, as we need
133 fi 136 fi
134 137
135 return ${retval} 138 return ${retval}
136} 139}
137 140
141# @FUNCTION: Xmake
142# @DESCRIPTION:
138#Same as "make", but setup the Xvfb hack if needed 143# Same as "make", but set up the Xvfb hack if needed.
139Xmake() { 144Xmake() {
140 export maketype="make" 145 export maketype="make"
141 virtualmake "$@" 146 virtualmake "$@"
142} 147}
143 148
149# @FUNCTION: Xemake
150# @DESCRIPTION:
144#Same as "emake", but setup the Xvfb hack if needed 151# Same as "emake", but set up the Xvfb hack if needed.
145Xemake() { 152Xemake() {
146 export maketype="emake" 153 export maketype="emake"
147 virtualmake "$@" 154 virtualmake "$@"
148} 155}
149 156
157# @FUNCTION: Xeconf
158# @DESCRIPTION:
150#Same as "econf", but setup the Xvfb hack if needed 159# Same as "econf", but set up the Xvfb hack if needed.
151Xeconf() { 160Xeconf() {
152 export maketype="econf" 161 export maketype="econf"
153 virtualmake "$@" 162 virtualmake "$@"
154} 163}

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.35

  ViewVC Help
Powered by ViewVC 1.1.20