summaryrefslogtreecommitdiff
blob: 90287cea57bb196f8db479f5a0e3cca4c3e8c9e4 (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
151
152
153
154
# 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=""
KEYWORDS=""
LICENSE="GPL-2"
SLOT="0"
IUSE="postgres mysql logrotate"
DEPEND="gnustep-libs/sope[ldap,mysql?,postgres?]
	!mysql? ( !postgres? ( virtual/postgresql-base ) )
	dev-vcs/monotone
	dev-libs/libmemcached
	net-nds/openldap"
RDEPEND="${DEPEND}
	logrotate? ( app-admin/logrotate )"

S=${WORKDIR}/${MY_PN}

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_unpack() {
	EMTN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/mtn-src"
	addwrite "${EMTN_STORE_DIR}"
	if [ ! -d "${EMTN_STORE_DIR}" ]; then
		mkdir -p "${EMTN_STORE_DIR}" || die "Can't mkdir ${EMTN_STORE_DIR}."
	fi
	cd "${EMTN_STORE_DIR}" || die "Can't chdir to ${EMTN_STORE_DIR}"

	if [ ! -f "db.mtn" ]; then
		mtn db init --db=./db.mtn || die "Failed to initialize Monotone database"
	fi

	# Pull Inverse's SOGo Monotone repository
	mtn --db=./db.mtn pull inverse.ca ca.inverse.sogo || die "Failed to pull Monotone repository"
	if [ ! -d "SOGo" ]; then
		mtn --db=./db.mtn checkout --branch ca.inverse.sogo SOGo || die "Failed to checkout SOGo branch"
	else
		cd SOGo
		mtn update
	fi

	# Pull SOGo Connector, SOGo Integrator and Lightning (Inverse Edition)
	#mtn --db=./db.mtn pull inverse.ca ca.inverse.sogo-connector
	#mtn --db=./db.mtn checkout --branch ca.inverse.sogo-connector
	#mtn --db=./db.mtn pull inverse.ca ca.inverse.sogo-integrator
	#mtn --db=./db.mtn checkout --branch ca.inverse.sogo-integrator
	#mtn --db=./db.mtn pull inverse.ca ca.inverse.calendar
	#mtn --db=./db.mtn checkout --branch ca.inverse.calendar

	mkdir -p "${S}"
	cd "${EMTN_STORE_DIR}"/SOGo
	rsync -rlpgo --exclude=".mtn-ignore" . "${S}" || die "Can't export to ${S}"

	cd "${S}"
	gnustep-base_src_prepare
}

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.1 sogod \
		|| die "init.d script installation failed"
	newconfd "${FILESDIR}"/sogod.confd sogod \
		|| die "conf.d script installation failed"
	diropts -m 0770 -o sogo -g root
	dodir /var/log/sogo
	dodir /var/run/sogod
	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
}