1 |
Let's get this straight: |
2 |
|
3 |
VIRTUALX_COMMAND="foo" virtualmake --bar --baz |
4 |
|
5 |
is just ugly. Instead, introduce a function which can be used as: |
6 |
|
7 |
virtualx foo --bar -baz |
8 |
--- |
9 |
gx86/eclass/virtualx.eclass | 45 ++++++++++++++++++++++++++++----------------- |
10 |
1 file changed, 28 insertions(+), 17 deletions(-) |
11 |
|
12 |
diff --git a/gx86/eclass/virtualx.eclass b/gx86/eclass/virtualx.eclass |
13 |
index 0621b18..47116fd 100644 |
14 |
--- a/gx86/eclass/virtualx.eclass |
15 |
+++ b/gx86/eclass/virtualx.eclass |
16 |
@@ -1,4 +1,4 @@ |
17 |
-# Copyright 1999-2012 Gentoo Foundation |
18 |
+# Copyright 1999-2013 Gentoo Foundation |
19 |
# Distributed under the terms of the GNU General Public License v2 |
20 |
# $Header: /var/cvsroot/gentoo-x86/eclass/virtualx.eclass,v 1.43 2012/10/03 22:47:12 chithanh Exp $ |
21 |
|
22 |
@@ -69,11 +69,12 @@ case ${VIRTUALX_REQUIRED} in |
23 |
;; |
24 |
esac |
25 |
|
26 |
-# @FUNCTION: virtualmake |
27 |
+# @FUNCTION: virtualx |
28 |
+# @USAGE: <argv>... |
29 |
# @DESCRIPTION: |
30 |
-# Function which attach to running X session or start new Xvfb session |
31 |
-# where the VIRTUALX_COMMAND variable content gets executed. |
32 |
-virtualmake() { |
33 |
+# Attach to a running X session or start a new Xvfb session, then run |
34 |
+# the command passed as arguments. |
35 |
+virtualx() { |
36 |
debug-print-function ${FUNCNAME} "$@" |
37 |
|
38 |
local i=0 |
39 |
@@ -83,14 +84,6 @@ virtualmake() { |
40 |
local XHOST=$(type -p xhost) |
41 |
local xvfbargs="-screen 0 1280x1024x24" |
42 |
|
43 |
- # backcompat for maketype |
44 |
- if [[ -n ${maketype} ]]; then |
45 |
- ewarn "QA: ebuild is exporting \$maketype=${maketype}" |
46 |
- ewarn "QA: Ebuild should be migrated to use VIRTUALX_COMMAND=${maketype} instead." |
47 |
- ewarn "QA: Setting VIRTUALX_COMMAND to \$maketype conveniently for now." |
48 |
- VIRTUALX_COMMAND=${maketype} |
49 |
- fi |
50 |
- |
51 |
# If $DISPLAY is not set, or xhost cannot connect to an X |
52 |
# display, then do the Xvfb hack. |
53 |
if [[ -n ${XVFB} && -n ${XHOST} ]] && \ |
54 |
@@ -145,10 +138,10 @@ virtualmake() { |
55 |
# to kill Xvfb |
56 |
debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\"" |
57 |
if has "${EAPI}" 2 3; then |
58 |
- ${VIRTUALX_COMMAND} "$@" |
59 |
+ "$@" |
60 |
retval=$? |
61 |
else |
62 |
- nonfatal ${VIRTUALX_COMMAND} "$@" |
63 |
+ nonfatal "$@" |
64 |
retval=$? |
65 |
fi |
66 |
|
67 |
@@ -158,16 +151,34 @@ virtualmake() { |
68 |
debug-print "${FUNCNAME}: attaching to running X display" |
69 |
# Normal make if we can connect to an X display |
70 |
debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\"" |
71 |
- ${VIRTUALX_COMMAND} "$@" |
72 |
+ "$@" |
73 |
retval=$? |
74 |
fi |
75 |
|
76 |
# die if our command failed |
77 |
- [[ ${retval} -ne 0 ]] && die "${FUNCNAME}: the ${VIRTUALX_COMMAND} failed." |
78 |
+ [[ ${retval} -ne 0 ]] && die "${FUNCNAME}: ${1} failed." |
79 |
|
80 |
return 0 # always return 0, it can be altered by failed kill for Xvfb |
81 |
} |
82 |
|
83 |
+# @FUNCTION: virtualmake |
84 |
+# @DESCRIPTION: |
85 |
+# Function which attach to running X session or start new Xvfb session |
86 |
+# where the VIRTUALX_COMMAND variable content gets executed. |
87 |
+virtualmake() { |
88 |
+ debug-print-function ${FUNCNAME} "$@" |
89 |
+ |
90 |
+ # backcompat for maketype |
91 |
+ if [[ -n ${maketype} ]]; then |
92 |
+ ewarn "QA: ebuild is exporting \$maketype=${maketype}" |
93 |
+ ewarn "QA: Ebuild should be migrated to use VIRTUALX_COMMAND=${maketype} instead." |
94 |
+ ewarn "QA: Setting VIRTUALX_COMMAND to \$maketype conveniently for now." |
95 |
+ VIRTUALX_COMMAND=${maketype} |
96 |
+ fi |
97 |
+ |
98 |
+ virtualx ${VIRTUALX_COMMAND} "$@" |
99 |
+} |
100 |
+ |
101 |
# @FUNCTION: Xmake |
102 |
# @DESCRIPTION: |
103 |
# Same as "make", but set up the Xvfb hack if needed. |
104 |
-- |
105 |
1.8.1.2 |