summaryrefslogtreecommitdiff
blob: 5638effab5e0716edb72b699f6c097159c5534f6 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake

DESCRIPTION="Anope IRC Services"
HOMEPAGE="https://anope.org/ https://github.com/anope/anope/"
SRC_URI="https://github.com/anope/anope/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 arm arm64 x86"
IUSE="gnutls ldap mysql pcre sql sqlite ssl tre"
REQUIRED_USE="sql? ( || ( mysql sqlite ) )"

DEPEND="
	acct-group/anope
	acct-user/anope
	mysql? ( dev-db/mysql-connector-c:0= )
	ssl? ( dev-libs/openssl:0= )
	gnutls? (
		net-libs/gnutls:0=
		dev-libs/libgcrypt:0=
	)
	ldap? ( net-nds/openldap:= )
	pcre? ( dev-libs/libpcre )
	sqlite? ( dev-db/sqlite:3 )
	tre? ( dev-libs/tre )
	virtual/libintl
"
RDEPEND="${DEPEND}"
BDEPEND="sys-devel/gettext"

PATCHES=(
	"${FILESDIR}/${PN}-2.0.6-example.conf-pid-path.patch"
	"${FILESDIR}/${PN}-2.0.7-example.conf-user.patch"
)

src_prepare() {
	anope_enable_mod() {
		local modulefile=${1}
		ln -s "extra/${modulefile}" "modules/" || \
			die "Failed to use ${modulefile}"
	}

	# These all require MySQL specifically
	if use mysql ; then
		anope_enable_mod "m_mysql.cpp"
		anope_enable_mod "stats/irc2sql/irc2sql.cpp"
		anope_enable_mod "stats/irc2sql/irc2sql.h"
		anope_enable_mod "stats/irc2sql/tables.cpp"
		anope_enable_mod "stats/irc2sql/utils.cpp"
		anope_enable_mod "stats/m_chanstats.cpp"
		anope_enable_mod "stats/cs_fantasy_top.cpp"
		anope_enable_mod "stats/cs_fantasy_stats.cpp"
		anope_enable_mod "m_sql_log.cpp"
		anope_enable_mod "m_sql_oper.cpp"
	fi

	use sqlite && anope_enable_mod "m_sqlite.cpp"

	# Any SQL implementation
	if use sql ; then
		anope_enable_mod "m_sql_authentication.cpp"
	fi

	if use ldap ; then
		anope_enable_mod "m_ldap.cpp"
		anope_enable_mod "m_ldap_authentication.cpp"
		anope_enable_mod "m_ldap_oper.cpp"
	fi

	use gnutls && anope_enable_mod "m_ssl_gnutls.cpp"
	use pcre && anope_enable_mod "m_regex_pcre.cpp"
	use ssl && anope_enable_mod "m_ssl_openssl.cpp"
	use tre && anope_enable_mod "m_regex_tre.cpp"

	# Unconditional modules
	anope_enable_mod "m_regex_posix.cpp"

	# Avoid a silly sandbox error - tries to delete /usr/lib/modules
	sed -i '/install.*REMOVE_RECURSE.*/d' CMakeLists.txt || die

	# Copy anope.conf for fixup to comply w/ prefix
	cp "${FILESDIR}"/anope-conf.d-v2 "${T}" || die

	# Look in the right place for modules
	sed -i "s~%LIBDIR%~${EPREFIX}/usr/$(get_libdir)/anope/~" \
		"${T}"/anope-conf.d-v2 || die

	cmake_src_prepare
}

src_configure() {
	local mycmakeargs=(
		-DBIN_DIR="libexec/anope"
		-DDB_DIR="../var/lib/anope"
		-DDOC_DIR="share/doc/${PF}"
		-DLIB_DIR="$(get_libdir)/anope"
		-DLOCALE_DIR="share/locale"
		-DCONF_DIR="/etc/anope"
		-DLOGS_DIR="../var/log/anope/"
	)

	cmake_src_configure
}

src_install() {
	cmake_src_install

	newinitd "${FILESDIR}"/anope-init.d ${PN}
	newconfd "${T}"/anope-conf.d-v2 ${PN}

	dosym ../libexec/anope/services /usr/bin/services
	dosym ../libexec/anope/anopesmtp /usr/bin/anopesmtp

	keepdir /var/log/anope /var/lib/anope/backups
	fowners anope:anope /var/{lib,log}/anope /var/lib/anope/backups

	dodoc -r docs/* data/example.conf

	insinto /etc/anope
	newins data/example.conf services.conf

	fowners anope:anope /var/log/anope
	fowners anope:anope /var/lib/anope/backups/
}

pkg_postinst() {
	if [[ -z "${REPLACING_VERSIONS}" ]] ; then
		# Only tell them about this on a fresh install.
		ewarn "Anope won't run out of the box, you still have to configure it to match your IRCd's configuration."
		ewarn "Edit /etc/anope/services.conf to configure Anope."
	else
		# We're replacing some versions. Find out which.
		local ver
		for ver in ${REPLACING_VERSIONS} ; do
			if ver_test ${ver} -lt 2.0.7 ; then
				# In this version, we introduced correct FHS structure
				# We need the users to make some changes to their services.conf
				ewarn "Please modify your services.conf to include the following directive:"
				ewarn "in options{}, please include user=\"anope\" and group=\"anope\""
				ewarn "This is needed because Anope now starts as root and drops down."
				ewarn "Reference: https://wiki.anope.org/index.php/2.0/Configuration#Services_Process_Options"
			fi
		done
	fi
}