Use https by default
[gentoo.git] / net-dialup / freeradius / freeradius-2.2.5.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 PYTHON_COMPAT=( python2_7 )
8 inherit autotools eutils pam python-any-r1 user
9
10 PATCHSET=4
11
12 MY_P="${PN}-server-${PV}"
13
14 DESCRIPTION="Highly configurable free RADIUS server"
15 SRC_URI="
16         ftp://ftp.freeradius.org/pub/radius/${MY_P}.tar.gz
17         ftp://ftp.freeradius.org/pub/radius/old/${MY_P}.tar.gz
18         https://dev.gentoo.org/~flameeyes/${PN}/${PN}-2.2.0-patches-${PATCHSET}.tar.xz
19
20 "
21 HOMEPAGE="http://www.freeradius.org/"
22
23 KEYWORDS="amd64 ~ppc ~ppc64 ~sparc x86 ~x86-fbsd"
24 LICENSE="GPL-2"
25 SLOT="0"
26
27 IUSE="
28         debug firebird iodbc kerberos ldap mysql odbc oracle pam pcap
29         postgres python readline sqlite ssl
30 "
31 RESTRICT="firebird? ( bindist )"
32
33 RDEPEND="!net-dialup/cistronradius
34         !net-dialup/gnuradius
35         sys-devel/libtool
36         dev-lang/perl
37         sys-libs/gdbm
38         python? ( ${PYTHON_DEPS} )
39         readline? ( sys-libs/readline )
40         pcap? ( net-libs/libpcap )
41         mysql? ( virtual/mysql )
42         postgres? ( dev-db/postgresql )
43         firebird? ( dev-db/firebird )
44         pam? ( virtual/pam )
45         ssl? ( dev-libs/openssl )
46         ldap? ( net-nds/openldap )
47         kerberos? ( virtual/krb5 )
48         sqlite? ( dev-db/sqlite:3 )
49         odbc? ( dev-db/unixODBC )
50         iodbc? ( dev-db/libiodbc )
51         oracle? ( dev-db/oracle-instantclient-basic )"
52 DEPEND="${RDEPEND}"
53
54 S="${WORKDIR}/${MY_P}"
55
56 pkg_setup() {
57         enewgroup radius
58         enewuser radius -1 -1 /var/log/radius radius
59
60         python-any-r1_pkg_setup
61         export PYTHONBIN="${EPYTHON}"
62 }
63
64 src_prepare() {
65         epatch \
66                 "${WORKDIR}"/patches/0002*patch \
67                 "${WORKDIR}"/patches/0004*patch \
68                 "${FILESDIR}"/${P}-gentoo.patch
69
70         # most of the configuration options do not appear as ./configure
71         # switches. Instead it identifies the directories that are available
72         # and run through them. These might check for the presence of
73         # various libraries, in which case they are not built.  To avoid
74         # automagic dependencies, we just remove all the modules that we're
75         # not interested in using.
76
77         use ssl || rm -r src/modules/rlm_eap/types/rlm_eap_{tls,ttls,peap}
78         use ldap || rm -r src/modules/rlm_ldap
79         use kerberos || rm -r src/modules/rlm_krb5
80         use pam || rm -r src/modules/rlm_pam
81         use python || rm -r src/modules/rlm_python
82         # Do not install ruby rlm module, bug #483108
83         rm -r src/modules/rlm_ruby
84
85         # these are all things we don't have in portage/I don't want to deal
86         # with myself
87         rm -r src/modules/rlm_eap/types/rlm_eap_tnc # requires TNCS library
88         rm -r src/modules/rlm_eap/types/rlm_eap_ikev2 # requires libeap-ikev2
89         rm -r src/modules/rlm_opendirectory # requires some membership.h
90         rm -r src/modules/rlm_redis{,who} # requires redis
91         rm -r src/modules/rlm_sql/drivers/rlm_sql_{db2,freetds,sybase}
92
93         # sql drivers that are not part of experimental are loaded from a
94         # file, so we have to remove them from the file itself when we
95         # remove them.
96         usesqldriver() {
97                 local flag=$1
98                 local driver=rlm_sql_${2:-${flag}}
99
100                 if ! use ${flag}; then
101                         rm -r src/modules/rlm_sql/drivers/${driver} || die
102                         sed -i -e /${driver}/d src/modules/rlm_sql/stable || die
103                 fi
104         }
105
106         usesqldriver mysql
107         usesqldriver postgres postgresql
108         usesqldriver firebird
109         usesqldriver iodbc
110         usesqldriver odbc unixodbc
111         usesqldriver oracle
112         usesqldriver sqlite
113
114         # remove bundled ltdl to avoid conflicts
115         rm -r libltdl
116
117         epatch_user
118
119         eautoreconf
120 }
121
122 src_configure() {
123         # fix bug #77613
124         if has_version app-crypt/heimdal; then
125                 myconf="${myconf} --enable-heimdal-krb5"
126         fi
127
128         use readline || export ac_cv_lib_readline=no
129         use pcap || export ac_cv_lib_pcap_pcap_open_live=no
130
131         # do not try to enable static with static-libs; upstream is a
132         # massacre of libtool best practices so you also have to make sure
133         # to --enable-shared explicitly.
134         econf \
135                 --enable-shared --disable-static \
136                 --disable-ltdl-install \
137                 --with-system-libtool \
138                 --with-system-libltdl \
139                 --with-ascend-binary \
140                 --with-udpfromto \
141                 --with-dhcp \
142                 --with-iodbc-include-dir=/usr/include/iodbc \
143                 --with-experimental-modules \
144                 --with-docdir=/usr/share/doc/${PF} \
145                 --with-logdir=/var/log/radius \
146                 $(use_enable debug developer) \
147                 $(use_with ldap edir) \
148                 $(use_with ssl openssl) \
149                 ${myconf}
150 }
151
152 src_compile() {
153         emake LIBTOOL=libtool
154 }
155
156 src_install() {
157         dodir /etc
158         diropts -m0750 -o root -g radius
159         dodir /etc/raddb
160         diropts -m0750 -o radius -g radius
161         dodir /var/log/radius
162         keepdir /var/log/radius/radacct
163         diropts
164
165         emake LIBTOOL=libtool R="${D}" install
166
167         fowners -R root:radius /etc/raddb
168
169         sed -i \
170                 -e 's:/var/run/radiusd:/run/radiusd:' \
171                 "${D}"/etc/raddb/radiusd.conf || die
172
173         pamd_mimic_system radiusd auth account password session
174
175         dodoc CREDITS
176
177         rm "${D}/usr/sbin/rc.radiusd"
178
179         newinitd "${FILESDIR}/radius.init-r3" radiusd
180         newconfd "${FILESDIR}/radius.conf-r3" radiusd
181 }
182
183 pkg_config() {
184         if use ssl; then
185                 cd "${ROOT}"/etc/raddb/certs
186                 ./bootstrap
187         fi
188 }
189
190 pkg_preinst() {
191         if ! has_version ${CATEGORY}/${PN} && use ssl; then
192                 elog "You have to run \`emerge --config =${CATEGORY}/${PF}\` to be able"
193                 elog "to start the radiusd service."
194         fi
195 }