| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2004 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.20 2005/06/07 14:26:03 azarah Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/virtualx.eclass,v 1.23 2005/07/11 15:08:06 swegener Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Martin Schlemmer <azarah@gentoo.org> |
5 | # Author: Martin Schlemmer <azarah@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # This eclass can be used for packages that needs a working X environment to build |
7 | # This eclass can be used for packages that needs a working X environment to build |
| 8 | |
8 | |
| 9 | ECLASS=virtualx |
|
|
| 10 | INHERITED="$INHERITED $ECLASS" |
|
|
| 11 | DEPEND="X? ( virtual/x11 )" |
9 | DEPEND="X? ( virtual/x11 )" |
|
|
10 | IUSE="X" |
| 12 | |
11 | |
| 13 | DESCRIPTION="Based on the $ECLASS eclass" |
12 | DESCRIPTION="Based on the $ECLASS eclass" |
| 14 | |
13 | |
| 15 | # |
14 | # |
| 16 | # Brian Harring <ferringb@gentoo.org> 11/04/2004 |
15 | # Brian Harring <ferringb@gentoo.org> 11/04/2004 |
| … | |
… | |
| 37 | |
36 | |
| 38 | einfo "Scanning for a open DISPLAY to start Xvfb ..." |
37 | einfo "Scanning for a open DISPLAY to start Xvfb ..." |
| 39 | |
38 | |
| 40 | # We really do not want SANDBOX enabled here |
39 | # We really do not want SANDBOX enabled here |
| 41 | export SANDBOX_DISABLED="1" |
40 | export SANDBOX_DISABLED="1" |
| 42 | |
41 | |
| 43 | local i=0 |
42 | local i=0 |
| 44 | XDISPLAY=$(i=0; while [[ -f /tmp/.X${i}-lock ]] ; do i=$((${i}+1));done; echo ${i}) |
43 | XDISPLAY=$(i=0; while [[ -f /tmp/.X${i}-lock ]] ; do i=$((${i}+1));done; echo ${i}) |
| 45 | |
44 | |
| 46 | # If we are in a chrooted environment, and there is already a |
45 | # If we are in a chrooted environment, and there is already a |
| 47 | # X server started outside of the chroot, Xvfb will fail to start |
46 | # X server started outside of the chroot, Xvfb will fail to start |
| 48 | # on the same display (most cases this is :0 ), so make sure |
47 | # on the same display (most cases this is :0 ), so make sure |
| 49 | # Xvfb is started, else bump the display number |
48 | # Xvfb is started, else bump the display number |
| 50 | # |
49 | # |
| … | |
… | |
| 56 | # |
55 | # |
| 57 | # Sven Wegener <swegener@gentoo.org> - 22 Aug 2004 |
56 | # Sven Wegener <swegener@gentoo.org> - 22 Aug 2004 |
| 58 | # |
57 | # |
| 59 | ${XVFB} :${XDISPLAY} -screen 0 800x600x24 &>/dev/null & |
58 | ${XVFB} :${XDISPLAY} -screen 0 800x600x24 &>/dev/null & |
| 60 | sleep 2 |
59 | sleep 2 |
| 61 | |
60 | |
| 62 | local start=${XDISPLAY} |
61 | local start=${XDISPLAY} |
| 63 | while [[ ! -f /tmp/.X${XDISPLAY}-lock ]] ; do |
62 | while [[ ! -f /tmp/.X${XDISPLAY}-lock ]] ; do |
| 64 | # Stop trying after 15 tries |
63 | # Stop trying after 15 tries |
| 65 | if [[ $((${XDISPLAY} - ${start})) -gt 15 ]] ; then |
64 | if [[ $((${XDISPLAY} - ${start})) -gt 15 ]] ; then |
| 66 | |
65 | |
| … | |
… | |
| 83 | |
82 | |
| 84 | # Now enable SANDBOX again if needed. |
83 | # Now enable SANDBOX again if needed. |
| 85 | export SANDBOX_DISABLED="${OLD_SANDBOX_DISABLED}" |
84 | export SANDBOX_DISABLED="${OLD_SANDBOX_DISABLED}" |
| 86 | |
85 | |
| 87 | einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..." |
86 | einfo "Starting Xvfb on \$DISPLAY=${XDISPLAY} ..." |
| 88 | |
87 | |
| 89 | export DISPLAY=:${XDISPLAY} |
88 | export DISPLAY=:${XDISPLAY} |
| 90 | #Do not break on error, but setup $retval, as we need |
89 | #Do not break on error, but setup $retval, as we need |
| 91 | #to kill Xvfb |
90 | #to kill Xvfb |
| 92 | ${maketype} $* |
91 | ${maketype} $* |
| 93 | retval=$? |
92 | retval=$? |