aboutsummaryrefslogtreecommitdiff
blob: 3ad4979127de1b87b3b1626d82920ce177bff60e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Based on virtualx.eclass

# @ECLASS: virtualdbus.eclass
# @MAINTAINER:
#  kde@gentoo.org
# @BLURB: This eclass can be used for packages that needs a working dbus session bus during test phase. UNTESTED SO FAR.

# @ECLASS_VARIABLE: VIRTUALDBUS_REQUIRED
# @DESCRIPTION:
#  Is a dependency on dbus etc needed?
#  Valid values are "always", "optional", and "manual".
#  "tests" is a synonym for "optional".
: ${VIRTUALDBUS_REQUIRED:=optional}

# @ECLASS_VARIABLE: VIRTUALDBUS_USE
# @DESCRIPTION:
#  If VIRTUALDBUS_REQUIRED=optional, what USE flag should control
#  the dependency?
: ${VIRTUALDBUS_USE:=test}

# @ECLASS_VARIABLE: VIRTUALDBUS_DEPEND
# @DESCRIPTION:
#  Dep string available for use outside of eclass, in case a more
#  complicated dep is needed.
VIRTUALDBUS_DEPEND="dev-util/dbus-test-runner"

case ${VIRTUALDBUS_REQUIRED} in
	always)
		DEPEND="${VIRTUALDBUS_DEPEND}"
		RDEPEND=""
		;;
	optional|tests)
		DEPEND="${VIRTUALDBUS_USE}? ( ${VIRTUALDBUS_DEPEND} )"
		RDEPEND=""
		IUSE="${VIRTUALDBUS_USE}"
		;;
	manual)
		;;
	*)
		eerror "Invalid value (${VIRTUALDBUS_REQUIRED}) for VIRTUALDBUS_REQUIRED"
		eerror "Valid values are:"
		eerror "  always"
		eerror "  optional (default if unset)"
		eerror "  manual"
		die "Invalid value (${VIRTUALDBUS_REQUIRED}) for VIRTUALDBUS_REQUIRED"
		;;
esac

# @FUNCTION: virtualdbus_start
# @DESCRIPTION: 
#  Runs its argument with a test dbus session activated
virtualdbus_start() {
	dbus-test-runner "$@"
}