summaryrefslogtreecommitdiff
blob: 869a760b34ea49749838cb3218cd09ee26d38440 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/depend.apache.eclass,v 1.5 2004/07/24 08:50:23 robbat2 Exp $

ECLASS="depend.apache"
INHERITED="$INHERITED $ECLASS"
IUSE="apache apache2"

# remember to set MY_SLOT if you want to include something like ${PVR} in
# the slot information
# SLOT="apache? ( 1{$MY_SLOT} ) apache2? ( 2{$MY_SLOT} ) !apache1? ( !apache2? ( 2${MY_SLOT} ) )"

DEPEND="$DEPEND apache? ( =net-www/apache-1* ) apache2? ( =net-www/apache-2* )
	    !apache? ( !apache2? ( =net-www/apache-2* ) )"

# call this function to work out which version of the apache web server
# your ebuild should be installing itself to use

detect_apache_useflags() {
	USE_APACHE1=
	USE_APACHE2=
	USE_APACHE_MULTIPLE=

	useq apache2 && USE_APACHE2=1
	useq apache  && USE_APACHE1=1

	[ -n "$USE_APACHE1" ] && [ -n "$USE_APACHE2" ] && USE_APACHE_MULTIPLE=1
}

detect_apache_installed() {
	HAS_APACHE1=
	HAS_APACHE2=
	HAS_APACHE_MULTIPLE=
	HAS_APACHE_ANY=

	has_version '=net-www/apache-1*' && HAS_APACHE1=1 && HAS_APACHE_ANY=1
	has_version '=net-www/apache-2*' && HAS_APACHE2=1 && HAS_APACHE_ANY=1

	[ -n "${HAVE_APACHE1}" ] && [ -n "${HAVE_APACHE2}" ] && HAVE_APACHE_MULTIPLE=1
}

# call this function from your pkg_setup

depend_apache() {
	detect_apache_installed
	detect_apache_useflags

	# deal with the multiple cases first - much easier
	if [ -n "$USE_APACHE_MULTIPLE" ]; then
		echo
		eerror "You have both the apache and apache2 USE flags set"
		eerror
		eerror "Please set only ONE of these USE flags, and try again"
		echo
		die "Multiple Apache USE flags set - you can only have one set at a time"
	fi

	if [ -n "$USE_APACHE2" ] ; then
		if  [ -z "$HAS_APACHE2" -a -n "$HAS_APACHE_ANY" ] ; then
			echo
			eerror "You have the 'apache2' USE flag set, but only have Apache v1 installed"
			eerror "If you really meant to upgrade to Apache v2, please install Apache v2"
			eerror "before installing $CATEGORY/${PN}-${PVR}"
			echo
			die "Automatic upgrade of Apache would be forced; avoiding"
		else
			einfo "Apache 2 support enabled"
			DETECT_APACHE=2
			return
		fi
	fi

	if [ -n "$USE_APACHE1" ]; then
		if [ -z "$HAS_APACHE1" -a -n "$HAS_APACHE_ANY" ]; then
			echo
			eerror "You have the 'apache' USE flag set, but only have a later version of"
			eerror "Apache installed on your computer.  Please use the 'apache2' USE flag"
			eerror "or downgrade to Apache v1 before installing $CATEGORY/${PN}-${PVR}"
			echo
			die "Avoiding installing older version of Apache"
		else
			einfo "Apache 1 support enabled"
			DETECT_APACHE=1
			return
		fi
	fi

	[ -z "$DETECT_APACHE" ] && DETECT_APACHE=2
}