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

Diff of /eclass/virtualx.eclass

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

Revision 1.32 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.32 2009/10/21 23:59:51 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
5# Original author: Martin Schlemmer <azarah@gentoo.org>
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:
9# Is a dependency on xorg-server and xhost needed? 14# Is a dependency on xorg-server and xhost needed?
10# Valid values are "always", "optional", and "manual" 15# Valid values are "always", "optional", and "manual".
11# "tests" is treated as a synonym for "optional" 16# "tests" is a synonym for "optional".
12: ${VIRTUALX_REQUIRED:=optional} 17: ${VIRTUALX_REQUIRED:=optional}
13 18
19# @ECLASS-VARIABLE: VIRTUALX_USE
20# @DESCRIPTION:
14# If VIRTUALX_REQUIRED=optional, what use flag should control 21# If VIRTUALX_REQUIRED=optional, what USE flag should control
15# the dependency? Default is "test" 22# the dependency?
16: ${VIRTUALX_USE:=test} 23: ${VIRTUALX_USE:=test}
17 24
25# @ECLASS-VARIABLE: VIRTUALX_DEPEND
26# @DESCRIPTION:
18# 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
19# complicated dep is needed 28# complicated dep is needed.
20VIRTUALX_DEPEND="x11-base/xorg-server 29VIRTUALX_DEPEND="!prefix? ( x11-base/xorg-server )
21 x11-apps/xhost" 30 x11-apps/xhost"
22 31
23case ${VIRTUALX_REQUIRED} in 32case ${VIRTUALX_REQUIRED} in
24 always) 33 always)
25 DEPEND="${VIRTUALX_DEPEND}" 34 DEPEND="${VIRTUALX_DEPEND}"
40 eerror " manual" 49 eerror " manual"
41 die "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED" 50 die "Invalid value (${VIRTUALX_REQUIRED}) for VIRTUALX_REQUIRED"
42 ;; 51 ;;
43esac 52esac
44 53
45DESCRIPTION="Based on the $ECLASS eclass"
46
47#
48# Brian Harring <ferringb@gentoo.org> 11/04/2004
49# do not disable the sandbox during the depend phase.
50# ebuilds shouldn't touch the fs during depend phase, nor screw with the sandbox.
51#
52if [[ ${EBUILD_PHASE/depend} == "${EBUILD_PHASE}" ]] ; then
53 [[ -z ${SANDBOX_DISABLED} ]] && export SANDBOX_DISABLED="0" || :
54fi
55
56virtualmake() { 54virtualmake() {
57 local retval=0 55 local retval=0
58 local OLD_SANDBOX_DISABLED="${SANDBOX_DISABLED}" 56 local OLD_SANDBOX_ON="${SANDBOX_ON}"
59 local XVFB=$(type -p Xvfb) 57 local XVFB=$(type -p Xvfb)
60 local XHOST=$(type -p xhost) 58 local XHOST=$(type -p xhost)
61 59
62 # 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
63 # display, then do the Xvfb hack. 61 # display, then do the Xvfb hack.
68 # compiling without the X display 66 # compiling without the X display
69 67
70 einfo "Scanning for an open DISPLAY to start Xvfb ..." 68 einfo "Scanning for an open DISPLAY to start Xvfb ..."
71 69
72 # We really do not want SANDBOX enabled here 70 # We really do not want SANDBOX enabled here
73 export SANDBOX_DISABLED="1" 71 export SANDBOX_ON="0"
74 72
75 local i=0 73 local i=0
76 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})
77 75
78 # 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
117 ${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24 &>/dev/null & 115 ${XVFB} :${XDISPLAY} -fp built-ins -screen 0 800x600x24 &>/dev/null &
118 sleep 2 116 sleep 2
119 done 117 done
120 118
121 # Now enable SANDBOX again if needed. 119 # Now enable SANDBOX again if needed.
122 export SANDBOX_DISABLED="${OLD_SANDBOX_DISABLED}" 120 export SANDBOX_ON="${OLD_SANDBOX_ON}"
123 121
124 einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..." 122 einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..."
125 123
126 export DISPLAY=:${XDISPLAY} 124 export DISPLAY=:${XDISPLAY}
127 #Do not break on error, but setup $retval, as we need 125 #Do not break on error, but setup $retval, as we need
138 fi 136 fi
139 137
140 return ${retval} 138 return ${retval}
141} 139}
142 140
141# @FUNCTION: Xmake
142# @DESCRIPTION:
143#Same as "make", but setup the Xvfb hack if needed 143# Same as "make", but set up the Xvfb hack if needed.
144Xmake() { 144Xmake() {
145 export maketype="make" 145 export maketype="make"
146 virtualmake "$@" 146 virtualmake "$@"
147} 147}
148 148
149# @FUNCTION: Xemake
150# @DESCRIPTION:
149#Same as "emake", but setup the Xvfb hack if needed 151# Same as "emake", but set up the Xvfb hack if needed.
150Xemake() { 152Xemake() {
151 export maketype="emake" 153 export maketype="emake"
152 virtualmake "$@" 154 virtualmake "$@"
153} 155}
154 156
157# @FUNCTION: Xeconf
158# @DESCRIPTION:
155#Same as "econf", but setup the Xvfb hack if needed 159# Same as "econf", but set up the Xvfb hack if needed.
156Xeconf() { 160Xeconf() {
157 export maketype="econf" 161 export maketype="econf"
158 virtualmake "$@" 162 virtualmake "$@"
159} 163}

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

  ViewVC Help
Powered by ViewVC 1.1.20