summaryrefslogtreecommitdiff
path: root/net-mail/sympa/sympa-6.0.6.ebuild
blob: 6408b31220dd7b14203f698b08933baa2d8706c7 (plain) (blame)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5

inherit eutils depend.apache multilib autotools versionator

SYMPA_VERSION="$(get_version_component_range 1-2)"
SYMPA_RELEASE="$(get_version_component_range 3-)"

if [[ ${SYMPA_VERSION} == "9999" ]] ; then
	# Development version
	ESVN_REPO_URI="http://svn.cru.fr/sympa/trunk"
	inherit subversion
elif [[ ${SYMPA_RELEASE} == "9999" ]] ; then
	# Latest stable
	ESVN_REPO_URI="http://svn.cru.fr/sympa/branches/sympa-${SYMPA_VERSION}-branch"
	inherit subversion
else
	# Release
	SRC_URI="http://www.sympa.org/distribution/${P}.tar.gz http://www.sympa.org/distribution/old/${P}.tar.gz"
fi

DESCRIPTION="A feature-rich open source mailing list software"
HOMEPAGE="http://www.sympa.org/features.html"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~x86 ~amd64"
IUSE="mysql postgres sqlite sqlite3 apache2 clamav -compat fastcgi ldap nfs nls soap ssl"

# See http://www.sympa.org/manual/installing-sympa#required_cpan_modules
RDEPEND="
	>=dev-lang/perl-5.8
	${DEPEND_APACHE}
	>=dev-perl/CGI-3.35
	>=virtual/perl-DB_File-1.75
	>=virtual/perl-Digest-MD5-2.00
	>=virtual/perl-File-Spec-0.8
	>=virtual/perl-MIME-Base64-3.03
	>=virtual/perl-Time-HiRes-1.29
	virtual/perl-libnet
	>=dev-perl/Archive-Zip-1.05
	>=dev-perl/DBI-1.48
	>=dev-perl/Email-Date-Format-1.002
	>=dev-perl/File-Copy-Recursive-0.36
	dev-perl/HTML-Format
	>=dev-perl/HTML-StripScripts-Parser-1.0
	dev-perl/HTML-Tree
	dev-perl/IO-stringy
	>=dev-perl/MIME-Charset-0.04.1
	>=dev-perl/MIME-EncWords-0.040
	>=dev-perl/MIME-Lite-3.024
	>=dev-perl/MIME-Lite-HTML-1.23
	>=dev-perl/MIME-tools-5.423
	>=dev-perl/MailTools-1.51
	>=dev-perl/Net-Netmask-1.901.500
	dev-perl/Template-Toolkit
	>=dev-perl/Term-ProgressBar-2.09
	dev-perl/XML-LibXML
	dev-perl/libintl-perl
	dev-perl/libwww-perl
	dev-perl/regexp-common
	>=net-mail/mhonarc-2.6.0
	clamav? ( app-antivirus/clamav )
	compat? ( >=dev-perl/Crypt-CipherSaber-0.50 )
	fastcgi? ( >=dev-perl/FCGI-0.67 )
	ldap? ( >=dev-perl/perl-ldap-0.27 )
	mysql? ( >=dev-perl/DBD-mysql-2.0407 )
	nfs? ( dev-perl/File-NFSLock )
	postgres? ( >=dev-perl/DBD-Pg-0.90 )
	soap? ( >=dev-perl/SOAP-Lite-0.60 )
	sqlite? ( dev-perl/DBD-SQLite2 )
	sqlite3? ( dev-perl/DBD-SQLite )
	ssl? ( >=dev-perl/IO-Socket-SSL-0.90
		>=dev-perl/Net-SSLeay-1.16
		dev-libs/openssl )
	virtual/mta
	"
DEPEND="${RDEPEND}
	sys-devel/gettext
	"

SYMPA_USER="sympa"
SYMPA_GROUP="sympa"

pkg_setup() {
	if ! ( useq mysql || useq postgres || useq sqlite || useq sqlite3 ); then
		eerror
		eerror "You have not specified any supported database backend in your USE flags"
		eerror "Supported database backends:"
		eerror "mysql, postgres, sqlite & sqlite3"
		eerror
		die "No database backend specified"
	fi
	enewgroup ${SYMPA_GROUP}
	enewuser ${SYMPA_USER} -1 -1 -1 ${SYMPA_GROUP}
}

src_unpack() {
	if [[ ${SYMPA_VERSION} == "9999" ]] ; then
		subversion_src_unpack
	elif [[ ${SYMPA_RELEASE} == "9999" ]] ; then
		subversion_src_unpack
	else
		unpack ${A}
		cd ${S}
	fi
	cd ${S}
	# Override defaults for certain options
	epatch ${FILESDIR}/${PN}-${SYMPA_VERSION}.fix.defaults.patch
	# Gentoo specific: redefine some defaults
	sed -i -e 's|^\(\s*staticdir=\).*|\1/var/spool/sympa/static_content|' \
		-e 's|^\(\s*bouncedir=\).*|\1/var/spool/sympa/bounce|' \
		-e 's|^\(\s*arcdir=\).*|\1/var/spool/sympa/arc|' \
		configure.ac
	eautoreconf
}

src_compile() {
	econf \
		--prefix=/usr \
		--libdir=/usr/$(get_libdir)/sympa \
		--libexec=/usr/libexec/sympa \
		--localstatedir=/var \
		--docdir=/usr/share/doc/${P} \
		--with-localedir=/usr/share/locale \
		--sysconfdir=/etc/sympa \
		--with-confdir=/etc/sympa \
		--with-piddir=/var/run/sympa \
		--with-spooldir=/var/spool/sympa \
		--with-modulesdir=/usr/$(get_libdir)/sympa \
		--with-cgidir=/usr/libexec/sympa \
		--with-expldir=/var/lib/sympa/lists \
		--with-scriptdir=/usr/share/sympa/scripts \
		--with-initdir=/usr/share/sympa/scripts \
		--with-defaultdir=/usr/share/sympa/default \
		--with-user=${SYMPA_USER} \
		--with-group=${SYMPA_GROUP} \
		--enable-fhs \
		$(use_enable nls) \
		|| die "econf failed"
	emake CFLAGS="${CFLAGS} -Wl,-z,now" || die "emake failed."
}

src_install() {

	emake DESTDIR="${D}" install || die "emake install failed"
	
	# Set permissions and ownership on config dir
	fowners -R root:${SYMPA_GROUP} /etc/sympa
	fperms -R u=rwX,g=rX,o= /etc/sympa
	# Elevate some permissions to read config files
	fperms g+s /usr/libexec/sympa/{bouncequeue,familyqueue,queue}

	# Docs
	dodoc AUTHORS COPYING ChangeLog INSTALL NEWS README README.charset

	# Startup script
	newinitd ${FILESDIR}/${PN}-${SYMPA_VERSION}.initd ${PN}

	# Create pidfile dir
	keepdir /var/run/sympa
	fowners ${SYMPA_USER}:${SYMPA_GROUP} /var/run/sympa

	# Set proper fastcgi flag
	if useq fastcgi; then
		sed -i -r "s:^(\s*use_fast_cgi\s*).*:\11:" ${D}/etc/sympa/wwsympa.conf
	else
		sed -i -r "s:^(\s*use_fast_cgi\s*).*:\10:" ${D}/etc/sympa/wwsympa.conf
	fi	
	# Update antivirus config
	if useq clamav; then
		sed -i -r \
			-e 's:^#?\s*antivirus_path\s*/.*:antivirus_path /usr/bin/clamscan:' \
			-e 's:^#?\s*antivirus_args\s*.*:antivirus_args --stdout:' \
			${D}/etc/sympa/sympa.conf
	else
		sed -i -r \
			-e 's:^(\s*antivirus_path\s*/.*):#\1:' \
			-e 's:^(\s*antivirus_args\s*.*):#\1:' \
			${D}/etc/sympa/sympa.conf
	fi
	# Update openssl config
	if useq ssl; then
		sed -i -r \
			-e 's:^#?\s*openssl\s*/.*:openssl /usr/bin/openssl:' \
			-e 's:^#?\s*capath\s*/.*:capath /etc/ssl/certs:' \
			-e 's:^#?\s*cafile\s*/.*:cafile /etc/ssl/certs/ca-certificates.crt:' \
			${D}/etc/sympa/sympa.conf
	else
		sed -i -r \
			-e 's:^(\s*openssl\s*/.*):#\1:' \
			-e 's:^(\s*capath\s*/.*):#\1:' \
			-e 's:^(\s*cafile\s*/.*):#\1:' \
			${D}/etc/sympa/sympa.conf
	fi
	# Queue dirs
	keepdir /var/spool/sympa
	local SYMPA_DIRS="arc auth automatic bounce digest distribute expire \
		moderation msg outgoing qbounce static_content subscribe task tmp topic"
	local DIR
	for DIR in ${SYMPA_DIRS}; do
		keepdir /var/spool/sympa/${DIR}
		fowners ${SYMPA_USER}:${SYMPA_GROUP} /var/spool/sympa/${DIR}
		case "${DIR}" in
			"static_content" )
				fperms 755 /var/spool/sympa/${DIR}
			;;
			* )
				fperms 750 /var/spool/sympa/${DIR}
			;;
		esac
	done
	keepdir /var/lib/sympa
	keepdir /var/lib/sympa/lists

	newdoc ${FILESDIR}/${PN}-apache.conf apache.conf || \
		die "newdoc failed"
	newdoc ${FILESDIR}/${PN}-apache_soap.conf apache_soap.conf || \
		die "newdoc failed"
	newdoc ${FILESDIR}/${PN}-lighttpd.conf lighttpd.conf ||\
		die "newdoc failed"
	newdoc ${FILESDIR}/${PN}-lighttpd_soap.conf lighttpd_soap.conf ||\
		die "newdoc failed"
}

pkg_postinst() {
	elog
	elog "You need to create a database with associated database account"
	elog "prior to use Sympa. That account will need general"
	elog "access privileges to the Sympa database."
	elog
	elog "The Sympa web interface needs to be setup in your webserver."
	elog "For more information please consult Sympa documentation at"
	elog "http://www.sympa.org/manual/web-interface#web_server_setup"
	elog "Sample configs are installed in /usr/share/doc/${P}"
	elog

	if useq clamav; then
		elog "By default we use clamscan antivirus scanner"
		elog "(antivirus_path option in sympa.conf). For performance"
		elog "reason you might want to use clamdscan which is much faster."
		elog "To use it you need to do the following:"
		elog
		elog "# gpasswd -a clamav sympa"
		elog "# /etc/init.d/clamd restart"
		elog
	fi

	ewarn "If you are upgrading from version < ${SYMPA_VERSION} make sure"
	ewarn "compat use flag is set while emerging. Pleae run:"
	ewarn
	ewarn "# sympa.pl --upgrade"
	ewarn
	ewarn "to upgrade your data structures and"
	ewarn
	ewarn "# sympa.pl --md5_encode_password"
	ewarn
	ewarn "to convert your passwords. When completed compat use flag"
	ewarn "can be removed"
}