843a498c682f43ae6cc9fddd78c022cb01085d10
[gentoo.git] / app-mobilephone / kannel / kannel-1.5.0-r3.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 WANT_AUTOMAKE=none
6
7 inherit autotools flag-o-matic ssl-cert user
8
9 DESCRIPTION="Powerful SMS and WAP gateway"
10 HOMEPAGE="http://www.kannel.org/"
11 SRC_URI="http://www.kannel.org/download/${PV}/gateway-${PV}.tar.gz"
12
13 LICENSE="Apache-1.1"
14 SLOT="0"
15 KEYWORDS="~amd64 x86"
16 IUSE="debug doc mysql libressl pam pcre postgres sqlite ssl"
17
18 RESTRICT="test" # some tests fail with "address already in use"
19
20 RDEPEND="
21         sys-libs/e2fsprogs-libs
22         dev-libs/libxml2:2
23         dev-lang/perl
24         sys-libs/zlib
25         ssl? (
26                 libressl? ( dev-libs/libressl:0= )
27                 !libressl? ( dev-libs/openssl:0= ) )
28         mysql? ( virtual/mysql )
29         sqlite? ( dev-db/sqlite:3 )
30         postgres? ( dev-db/postgresql:=[server] )
31         pcre? ( dev-libs/libpcre:3 )
32         pam? ( virtual/pam )
33 "
34 DEPEND="${RDEPEND}
35         >=sys-devel/bison-2.2
36         doc? ( media-gfx/transfig
37                 app-text/jadetex
38                 app-text/docbook-dsssl-stylesheets
39                 app-text/docbook-sgml-dtd:3.1 )
40 "
41
42 S="${WORKDIR}/gateway-${PV}"
43
44 PATCHES=(
45         "${FILESDIR}/${PN}-1.5.0-custom-wap-ports.patch"
46         "${FILESDIR}/${PN}-1.4.3-autotools.patch"
47         "${FILESDIR}/${PN}-1.4.3-external-libuuid.patch"
48         "${FILESDIR}/${PN}-1.5.0-initgroups.patch"
49 )
50
51 pkg_setup() {
52         enewgroup kannel
53         enewuser kannel -1 -1 /var/log/kannel kannel
54 }
55
56 src_prepare() {
57         default
58
59         #by default, use current directory for logging
60         sed -i -e 's:/tmp/::' doc/examples/kannel.conf
61
62         mv configure.in configure.ac || die
63         eautoconf
64 }
65
66 src_configure() {
67         append-flags -fno-strict-aliasing # some code breaks strict aliasing
68         econf \
69                 --enable-localtime \
70                 --disable-start-stop-daemon \
71                 --without-sqlite2 \
72                 $(use_enable pam) \
73                 $(use_enable debug debug) \
74                 $(use_enable pcre) \
75                 $(use_enable doc docs) \
76                 $(use_enable ssl) \
77                 $(use_with mysql) \
78                 $(use_with sqlite sqlite3) \
79                 $(use_with postgres pgsql)
80 }
81
82 # phase disabled by RESTRICT
83 # src_test() {
84 #       emake check || die "emake check failed"
85 # }
86
87 src_install() {
88         default
89
90         if use doc; then
91                 emake -j1 DESTDIR="${D}" install-docs || die "emake install-docs failed"
92         fi
93
94         diropts -g kannel -m0750
95         dodir /etc/kannel
96         insinto /etc/kannel
97         newins doc/examples/kannel.conf kannel.conf.sample
98
99         local f
100         for f in bearerbox smsbox wapbox; do
101                 newinitd "${FILESDIR}/kannel-$f.initd" kannel-$f
102         done
103
104         diropts -g kannel -m0770
105         keepdir /var/log/kannel
106 }
107
108 pkg_postinst() {
109         if use ssl; then
110                 elog "SSL certificate can be created by running"
111                 elog "   emerge --config =${CATEGORY}/${PF}"
112         fi
113 }
114
115 pkg_config() {
116         if use ssl; then
117                 if install_cert /etc/ssl/kannel; then
118                         chown kannel "${ROOT}"etc/ssl/kannel.{pem,key}
119                         einfo "For using this certificate, you have to add following line to your kannel.conf:"
120                         einfo '   ssl-client-certkey-file = "/etc/ssl/kannel.pem"'
121                         einfo '   ssl-server-cert-file = "/etc/ssl/kannel.crt"'
122                         einfo '   ssl-server-key-file = "/etc/ssl/kannel.key"'
123                 fi
124         else
125                 eerror "This phase exists only for creating kannel SSL certificate"
126                 eerror "and ssl USE flag is disabled for this package!"
127         fi
128 }