Gentoo Archives: gentoo-dev

From: Justin Lecher <jlec@g.o>
To: gentoo-dev@l.g.o
Cc: Justin Lecher <jlec@g.o>
Subject: [gentoo-dev] [PATCH 8/8] virtualx.eclass: Simplify API into single virtx()
Date: Sat, 28 Nov 2015 13:26:49
Message-Id: 1448717061-11581-9-git-send-email-jlec@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/8] virtualx.eclass: New API and EAPI=6 support by Justin Lecher
1 The new API runs all specified arguments to virtx() inside an XFVB,
2 instead of defining VIRTUALX_COMMAND and running that in virtualmake.
3
4 Xemake and Xeconf should be replaced by "virtx emake" and "virtx econf".
5
6 Signed-off-by: Justin Lecher <jlec@g.o>
7 ---
8 eclass/virtualx.eclass | 42 ++++++++++++++++++++++++++++++++----------
9 1 file changed, 32 insertions(+), 10 deletions(-)
10
11 diff --git a/eclass/virtualx.eclass b/eclass/virtualx.eclass
12 index f9fa879..ca6a1f9 100644
13 --- a/eclass/virtualx.eclass
14 +++ b/eclass/virtualx.eclass
15 @@ -90,22 +90,38 @@ esac
16 virtualmake() {
17 debug-print-function ${FUNCNAME} "$@"
18
19 - local i=0
20 - local retval=0
21 - local OLD_SANDBOX_ON="${SANDBOX_ON}"
22 - local XVFB XHOST XDISPLAY
23 - local xvfbargs="-screen 0 1280x1024x24"
24 - XVFB=$(type -p Xvfb) || die
25 - XHOST=$(type -p xhost) || die
26 + [[ ${EAPI} == [2345] ]] || die "${FUNCNAME} is unsupported in EAPI > 5, please use virtx"
27
28 # backcompat for maketype
29 if [[ -n ${maketype} ]]; then
30 + [[ ${EAPI} == [2345] ]] || die "maketype is banned in EAPI > 5"
31 eqawarn "ebuild is exporting \$maketype=${maketype}"
32 eqawarn "Ebuild should be migrated to use VIRTUALX_COMMAND=${maketype} instead."
33 eqawarn "Setting VIRTUALX_COMMAND to \$maketype conveniently for now."
34 VIRTUALX_COMMAND=${maketype}
35 fi
36
37 + virtx "${VIRTUALX_COMMAND}" "${@}"
38 +}
39 +
40 +
41 +# @FUNCTION: virtx
42 +# @USAGE: <command> [comman arguments]
43 +# @DESCRIPTION:
44 +# Function which start new Xvfb session where the command gets executed.
45 +virtx() {
46 + debug-print-function ${FUNCNAME} "$@"
47 +
48 + [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument"
49 +
50 + local i=0
51 + local retval=0
52 + local OLD_SANDBOX_ON="${SANDBOX_ON}"
53 + local XVFB XHOST XDISPLAY
54 + local xvfbargs="-screen 0 1280x1024x24"
55 + XVFB=$(type -p Xvfb) || die
56 + XHOST=$(type -p xhost) || die
57 +
58 debug-print "${FUNCNAME}: running Xvfb hack"
59 export XAUTHORITY=
60 # The following is derived from Mandrake's hack to allow
61 @@ -155,10 +171,10 @@ virtualmake() {
62 # to kill Xvfb
63 debug-print "${FUNCNAME}: ${VIRTUALX_COMMAND} \"$@\""
64 if has "${EAPI}" 2 3; then
65 - ${VIRTUALX_COMMAND} "$@"
66 + "$@"
67 retval=$?
68 else
69 - nonfatal ${VIRTUALX_COMMAND} "$@"
70 + nonfatal "$@"
71 retval=$?
72 fi
73
74 @@ -179,7 +195,7 @@ Xmake() {
75 debug-print-function ${FUNCNAME} "$@"
76
77 [[ ${EAPI} == [2345] ]] \
78 - || die "${FUNCNAME} is removed in EAPI > 5; use Xemake -j1 instead"
79 + || die "${FUNCNAME} is unsupported in EAPI > 5, please use 'virtx emake -j1 ....'"
80
81 eqawarn "you should not execute make directly"
82 eqawarn "rather execute Xemake -j1 if you have issues with parallel make"
83 @@ -192,6 +208,9 @@ Xmake() {
84 Xemake() {
85 debug-print-function ${FUNCNAME} "$@"
86
87 + [[ ${EAPI} == [2345] ]] \
88 + || die "${FUNCNAME} is unsupported in EAPI > 5, please use 'virtx emake ....'"
89 +
90 VIRTUALX_COMMAND="emake" virtualmake "$@"
91 }
92
93 @@ -201,6 +220,9 @@ Xemake() {
94 Xeconf() {
95 debug-print-function ${FUNCNAME} "$@"
96
97 + [[ ${EAPI} == [2345] ]] \
98 + || die "${FUNCNAME} is unsupported in EAPI > 5, please use 'virtx econf ....'"
99 +
100 VIRTUALX_COMMAND="econf" virtualmake "$@"
101 }
102
103 --
104 2.6.3

Replies