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