summaryrefslogtreecommitdiff
blob: 681c422a072aa5bcdd2046e3ba916b488dc74622 (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=2

inherit gnustep-base flag-o-matic

MY_PN="SOGo"
MY_PV="${PV/_/}"

DESCRIPTION="Groupware server built around OpenGroupware.org and the SOPE application server"
HOMEPAGE="http://sogo.opengroupware.org/"
SRC_URI="http://www.scalableogo.org/files/downloads/${MY_PN}/Sources/${MY_PN}-${MY_PV}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="postgres mysql logrotate"
DEPEND="gnustep-libs/sope[ldap,mysql?,postgres?]
	!mysql? ( !postgres? ( virtual/postgresql-base ) )
	dev-libs/libmemcached
	net-nds/openldap"
RDEPEND="${DEPEND}
	logrotate? ( app-admin/logrotate )"

S=${WORKDIR}/${MY_PN}-${MY_PV}

pkg_setup() {
	gnustep-base_pkg_setup
	local myLDFLAGS="$(gnustep-config --variable=LDFLAGS 2>/dev/null)"
	if [ -n "${myLDFLAGS}" ] && (echo "${myLDFLAGS}" | grep -q "\-\-a\(dd\|s\)\-needed" 2>/dev/null); then
		ewarn
		ewarn "You seem to have compiled GNUstep with custom LDFLAGS:"
		for foo in $(gnustep-config --variable=LDFLAGS); do
			ewarn "  "${foo}
		done
		ewarn
		ewarn "SOGo is very sensitive regarding custom LDFLAGS. Especially with:"
		ewarn "  --add-needed"
		ewarn "  --as-needed"
		ewarn
		ewarn "If your SOGo install does not work as expected then please re-emerge SOGo,"
		ewarn "SOPE and your GNUstep (base and make) without any LDFLAGS before filing bugs."
		ewarn
	fi
	append-ldflags -Wl,--no-as-needed
}

src_configure() {
	egnustep_env
	./configure \
		$(use_enable debug) \
		$(use_enable debug strip) \
		$(use_enable ldap ldap-config) \
			|| die "configure failed"
}

src_test() {
	# SOGo tends to break horribly if gnustep-make is build with LDFLAGS such as
	# -Wl,--add-needed or -Wl,--as-needed. So we check here some vital binaries.
	# Check if Appointments.SOGo, Contacts.SOGo, Mailer.SOGo is correctly build/linked
	local myAppointmentsLDD=$(ldd -d "${S}"/SoObjects/Appointments/Appointments.SOGo/Appointments 2>&1 | grep "lib\(OGoContentStore\|NG\(Cards\|ObjWeb\|Mime\|Streams\|Extensions\)\|SOGo\|GDL\(Access\|ContentStore\)\|EOControl\|DOM\|SaxObjC\|XmlRpc\)\.so\." | wc -l)
	local myContactsLDD=$(ldd -d "${S}"/SoObjects/Contacts/Contacts.SOGo/Contacts 2>&1 | grep "lib\(OGoContentStore\|NG\(Cards\|ObjWeb\|Mime\|Streams\|Extensions\)\|SOGo\|GDL\(Access\|ContentStore\)\|EOControl\|DOM\|SaxObjC\|XmlRpc\)\.so\." | wc -l)
	local myMailerLDD=$(ldd -d "${S}"/SoObjects/Mailer/Mailer.SOGo/Mailer 2>&1 | grep "lib\(OGoContentStore\|NG\(Cards\|ObjWeb\|Mime\|Streams\|Extensions\)\|SOGo\|GDL\(Access\|ContentStore\)\|EOControl\|DOM\|SaxObjC\|XmlRpc\)\.so\." | wc -l)
	if [ -z "${myAppointmentsLDD}" -o -z "${myContactsLDD}" -o -z "${myMailerLDD}" -o "${myAppointmentsLDD}" != "13" -o "${myContactsLDD}" != "13" -o "${myMailerLDD}" != "13" ]; then
		ewarn
		ewarn "This SOGo installtion is not correctly build. Probably you are using"
		ewarn "LDFLAGS to build SOGo that are not correctly handled in SOGo or you"
		ewarn "have emerged gnustep-base/gnustep-make with LDFLAGS which are"
		ewarn "preventing SOGo to link the needed libraries into it's own binaries."
		ewarn "Please remerge gnustep-base/gnustep-make and/or SOGo with empty LDFLAGS."
		ewarn
		die "SOGo build is not complete (Appointments.SOGo, Contacts.SOGo, Mailer.SOGo)"
	fi
	# We could do the same for AdministrationUI.SOGo, CommonUI.SOGo, ContactsUI.SOGo,
	# MailPartViewers.SOGo, MailerUI.SOGo, MainUI.SOGo, SOGoElements.wox and SchedulerUI.SOGo
	# but if Appointments.SOGo, Contacts.SOGo and Mailer.SOGo are build correctly then the
	# chance that the others are build/linked correctly is pretty high. So we don't test again.
}

src_install() {
	gnustep-base_src_install
	newinitd "${FILESDIR}"/sogod.initd sogod \
		|| die "Init script installation failed"
	if use logrotate; then
		insopts -m644 -o root -g root
		insinto /etc/logrotate.d
		newins Scripts/logrotate SOGo || die "Failed to install logrotate.d file"
	fi
	newdoc Apache/SOGo.conf SOGo-Apache.conf
}

pkg_preinst() {
	enewuser sogo -1 /bin/bash /var/lib/sogo
}

pkg_postinst() {
	gnustep-base_pkg_postinst
	elog
	elog "Now follow the steps from the SOGo documentation:"
	elog "http://www.inverse.ca/contributions/sogo/documentation.html#c803"
	elog "The sogo user home directory is /var/lib/sogo"
	elog
	elog "Then you can start/stop sogo with /etc/init.d/sogod"
	elog
	elog "If you plan to use SOGo with Apache then please have a look at the"
	elog "'SOGo-Apache.conf' included in the documentation directory of this"
	elog "SOGo installation and don't forget to add '-D PROXY' to your"
	elog "APACHE2_OPTS."
	elog
}