freeradius-3.0.12-r1.ebuild 5.6 KB

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