summaryrefslogtreecommitdiff
blob: 11612fd2e26412662325e7738721c6856f18c7d5 (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
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-irc/anope/anope-1.8.7-r1.ebuild,v 1.2 2013/02/18 18:48:48 gurligebis Exp $

EAPI=4

inherit autotools eutils multilib versionator user

DESCRIPTION="Anope IRC Services"
HOMEPAGE="http://www.anope.org"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="mysql"

DEPEND="mysql? ( virtual/mysql )"
RDEPEND="${DEPEND}"

pkg_pretend() {
	local replaced_version
	for replaced_version in ${REPLACING_VERSIONS} ; do
		if ! version_is_at_least 1.8.7 ${replaced_version} && [[ -f ${ROOT}opt/anope/data/nick.db ]]; then
			eerror "It looks like you have an older version of Anope installed."
			eerror "To upgrade, shut down Anope and copy your databases to"
			eerror "${ROOT}var/lib/anope and your configuration to ${ROOT}etc/anope"
			eerror "You can do this by:"
			eerror "# mkdir -p ${ROOT}var/lib/anope ${ROOT}etc/anope"
			eerror "# chown anope:anope ${ROOT}var/lib/anope"
			eerror "# mv ${ROOT}opt/anope/data/*.db ${ROOT}var/lib/anope"
			eerror "# mv ${ROOT}opt/anope/data/services.conf ${ROOT}etc/anope"
			die "Please move your anope database files from /opt/anope/data"
		fi
	done
}

pkg_setup() {
	enewgroup anope
	enewuser anope -1 -1 -1 anope
}

src_prepare() {
	epatch "${FILESDIR}/pid-patch.diff"
	epatch "${FILESDIR}/${P}-ldflags-fix.patch"
	epatch "${FILESDIR}/${P}-libdir-gentoo.patch"
	epatch "${FILESDIR}"/${P}-mariadb.patch # bug 381119
	eautoconf
}

src_configure() {
	local myconf
	if ! use mysql; then
		myconf="${myconf} --without-mysql"
	fi

	econf \
		${myconf} \
		--with-bindir=/usr/bin/ \
		--with-datadir=/var/lib/anope \
		--with-libdir=/usr/$(get_libdir)/anope/ \
		--with-rungroup=anope \
		--with-permissions=077

	sed -i -e "/^build:/s:$: language:g" "${S}"/Makefile || die "sed failed"
}

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

	local baselibdir
	baselibdir="${D}/usr/$(get_libdir)/anope"

	dodir /usr/$(get_libdir)/anope/{lang,modules}
	emake DATDEST="${baselibdir}" \
		BINDEST="${D}/usr/bin" \
		MODULE_PATH="${baselibdir}/modules" \
		install

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

	dodoc Changes Changes.conf Changes.lang Changes.mysql docs/* data/example.conf
	use mysql && dodoc data/tables.sql

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

pkg_preinst() {
	if has_version net-irc/anope ; then
		local directory
		directory="${ROOT}"var/lib/anope/pre-update
		elog "Making a backup of your databases to ${directory}"
		if [ ! -d "${directory}" ]; then
			mkdir -p "${directory}" || die "failed to create backup directory"
			chown anope:anope "${directory}"/../ || die "failed to chown data directory"
		fi
		# don't die otherwise merge will fail if there are no existing databases
		cp "${ROOT}"/var/lib/anope/*.db "${directory}"
	fi
}

pkg_postinst() {
	echo
	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."

	if use mysql; then
		echo
		ewarn "!!! ATTENTION !!!"
		ewarn "Be sure to read Changes.mysql to update your MySQL"
		ewarn "tables or anope will break after restart"
		ewarn "!!! ATTENTION !!!"
		echo
		einfo "The mysql script for updating the tables is located in the"
		einfo "/usr/share/doc/${PF} directory"
	fi
}