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