summaryrefslogtreecommitdiff
blob: 1ebf4834882e403695264023e5a1e21a667b3393 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/ser/ser-0.9.4.ebuild,v 1.9 2010/06/17 21:56:41 patrick Exp $

inherit eutils flag-o-matic

IUSE="ipv6 mysql radius postgres jabber ldap ssl"

ETHZ_PV="1.0"
LDAP_PV="1.0"
LDAPS_PV="1.0"
SILOMAIL_PV="1.0"

DESCRIPTION="SIP Express Router"
HOMEPAGE="http://www.iptel.org/ser"
SRC_URI="ftp://ftp.berlios.de/pub/ser/${PV}/src/${P}_src.tar.gz
	 mirror://gentoo/silomail-${SILOMAIL_PV}-${PN}-0.9.0.tar.gz
	 mirror://gentoo/ethz-${ETHZ_PV}-${PN}-0.9.0.tar.gz
	 ldap? ( mirror://gentoo/ldap-${LDAP_PV}-${PN}-0.9.0.tar.gz
		 mirror://gentoo/ldaps-${LDAPS_PV}-${PN}-0.9.0.tar.gz )"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~ppc ~sparc x86"

RDEPEND="
	mysql? ( virtual/mysql )
	radius? ( >=net-dialup/radiusclient-ng-0.5.0 )
	postgres? ( dev-db/postgresql-server )
	jabber? ( dev-libs/expat )
	ldap? (
		net-nds/openldap
		ssl? ( dev-libs/openssl )
	)"

DEPEND="${RDEPEND}
	>=sys-devel/bison-1.35
	>=sys-devel/flex-2.5.4a"

pkg_setup() {
	enewgroup ser
	enewuser  ser -1 -1 /dev/null ser
}

src_unpack() {
	local modules extmodules MY_A

	# unpack ser source
	unpack ${P}_src.tar.gz

	cd ${S}
	use ipv6 || \
		sed -i -e "s/-DUSE_IPV6//g" Makefile.defs

	# external modules
	extmodules="silomail ethz"

	use mysql && \
		modules="${modules} mysql"

	use radius && \
		modules="${modules} auth_radius group_radius uri_radius avp_radius"

	use jabber && \
		modules="${modules} jabber"

	use postgres && \
		modules="${modules} postgres"

	use ldap && \
		extmodules="${extmodules} ldap"

	use ldap && use ssl && \
		extmodules="${extmodules} ldaps"

	# put list of modules into Makefile, we need the list
	# during compile and install phase...
	sed -i -e "s:^\(include_modules.*\):\1 ${modules} ${extmodules}:" \
		Makefile

	# fix ser.cfg
	sed -i -e "/force_send_socket(smaug:5080);/ d" \
		etc/ser.cfg

	# unpack external modules
	# ugly i know...
	for x in ${extmodules}; do
		MY_A=$(eval echo ${x}-\${$(echo ${x} | tr "[:lower:]" "[:upper:]")_PV}-${PN}-0.9.0)
		mkdir -p ${S}/modules/${x}
		cd ${S}/modules/${x}
		unpack ${MY_A}.tar.gz
		# fix makefiles
		if [[ -f ${FILESDIR}/${MY_A}.diff ]]; then
			epatch ${FILESDIR}/${MY_A}.diff
		fi
	done

	if use mysql || use postgres; then
		sed -i -e "s:^#DEFS+=-DSQL_ACC$:DEFS+=-DSQL_ACC:" \
			${S}/modules/acc/Makefile
	fi

	# remove sasl if openldap hasn't been built with it
	if use ldap && ! built_with_use net-nds/openldap sasl; then
		sed -i -e "s:-lsasl::g" \
			${S}/modules/ldap/Makefile

		if use ssl; then
			sed -i -e "s:-lsasl::g" \
				${S}/modules/ldaps/Makefile
		fi
	fi
}

src_compile() {
	# add -fPIC
	append-flags -fPIC

	make all \
		CFLAGS="${CFLAGS}" \
		cfg-prefix=/ \
		cfg-target=/etc/ser/ \
		${myconf} || die
}

src_install () {
	make install \
		prefix="" \
		bin-prefix=${D}/usr/sbin \
		bin-dir="" \
		cfg-prefix=${D}/etc \
		cfg-dir=ser/ \
		cfg-target=/etc/ser/ \
		modules-prefix=${D}/usr/lib/ser \
		modules-dir=modules \
		modules-target=/usr/lib/ser/modules/ \
		man-prefix=${D}/usr/share/man \
		man-dir="" \
		doc-prefix=${D}/usr/share/doc \
		doc-dir=${P} || die

	newinitd ${FILESDIR}/ser.rc6 ser
	newconfd ${FILESDIR}/ser.confd ser
	exeinto /usr/sbin
	newexe scripts/harv_ser.sh harv_ser.sh
	newexe scripts/sc serctl
	newexe scripts/ser_mysql.sh ser_mysql.sh

	chown -R root:ser ${D}/etc/ser
	chmod 750 ${D}/etc/ser
	chmod 640 ${D}/etc/ser/*

	# fix manpages
	sed -i	-e "s:^.B /ser-${PV}AUTHORS:.B /usr/share/doc/${PF}/AUTHORS:" \
		-e "s:^.B /ser:.B /usr/sbin/ser:" \
		${D}/usr/share/man/*/*
}

pkg_preinst() {
	has_version "${CATEGORY}/${PN}"
	previous_installed_version=$?
}

pkg_postinst() {
	if [[ $previous_installed_version = 0 ]] ; then
		einfo "Changing permissions on ${ROOT}etc/ser"

		chown -R root:ser ${ROOT}/etc/ser
		chmod 750 ${ROOT}/etc/ser
		chmod 640 ${ROOT}/etc/ser/*
	fi
}