bind-9.11.0_p2.ebuild 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # Re dlz/mysql and threads, needs to be verified..
  4. # MySQL uses thread local storage in its C api. Thus MySQL
  5. # requires that each thread of an application execute a MySQL
  6. # thread initialization to setup the thread local storage.
  7. # This is impossible to do safely while staying within the DLZ
  8. # driver API. This is a limitation caused by MySQL, and not the DLZ API.
  9. # Because of this BIND MUST only run with a single thread when
  10. # using the MySQL driver.
  11. EAPI="5"
  12. PYTHON_COMPAT=( python2_7 python3_4 )
  13. inherit python-r1 eutils autotools toolchain-funcs flag-o-matic multilib db-use user systemd
  14. MY_PV="${PV/_p/-P}"
  15. MY_PV="${MY_PV/_rc/rc}"
  16. MY_P="${PN}-${MY_PV}"
  17. SDB_LDAP_VER="1.1.0-fc14"
  18. RRL_PV="${MY_PV}"
  19. NSLINT_DIR="contrib/nslint-3.0a2/"
  20. # SDB-LDAP: http://bind9-ldap.bayour.com/
  21. DESCRIPTION="BIND - Berkeley Internet Name Domain - Name Server"
  22. HOMEPAGE="http://www.isc.org/software/bind"
  23. SRC_URI="ftp://ftp.isc.org/isc/bind9/${MY_PV}/${MY_P}.tar.gz
  24. doc? ( mirror://gentoo/dyndns-samples.tbz2 )"
  25. # sdb-ldap? (
  26. # http://ftp.disconnected-by-peer.at/pub/bind-sdb-ldap-${SDB_LDAP_VER}.patch.bz2
  27. # )"
  28. LICENSE="Apache-2.0 BSD BSD-2 GPL-2 HPND ISC MPL-2.0"
  29. SLOT="0"
  30. KEYWORDS="alpha amd64 ~arm ~hppa ~ia64 ~mips ppc ~ppc64 ~s390 ~sh ~sparc x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
  31. # -berkdb by default re bug 602682
  32. IUSE="-berkdb +caps dlz dnstap doc filter-aaaa fixed-rrset geoip gost gssapi idn ipv6
  33. json ldap libressl lmdb mysql nslint odbc postgres python rpz seccomp selinux ssl static-libs
  34. +threads urandom xml +zlib"
  35. # sdb-ldap - patch broken
  36. # no PKCS11 currently as it requires OpenSSL to be patched, also see bug 409687
  37. REQUIRED_USE="postgres? ( dlz )
  38. berkdb? ( dlz )
  39. mysql? ( dlz !threads )
  40. odbc? ( dlz )
  41. ldap? ( dlz )
  42. gost? ( !libressl ssl )
  43. threads? ( caps )
  44. dnstap? ( threads )"
  45. # sdb-ldap? ( dlz )
  46. DEPEND="
  47. ssl? (
  48. !libressl? ( dev-libs/openssl:0[-bindist] )
  49. libressl? ( dev-libs/libressl )
  50. )
  51. mysql? ( >=virtual/mysql-4.0 )
  52. odbc? ( >=dev-db/unixODBC-2.2.6 )
  53. ldap? ( net-nds/openldap )
  54. idn? ( net-dns/idnkit )
  55. postgres? ( dev-db/postgresql:= )
  56. caps? ( >=sys-libs/libcap-2.1.0 )
  57. xml? ( dev-libs/libxml2 )
  58. geoip? ( >=dev-libs/geoip-1.4.6 )
  59. gssapi? ( virtual/krb5 )
  60. gost? ( >=dev-libs/openssl-1.0.0:0[-bindist] )
  61. seccomp? ( sys-libs/libseccomp )
  62. json? ( dev-libs/json-c )
  63. lmdb? ( dev-db/lmdb )
  64. zlib? ( sys-libs/zlib )
  65. dnstap? ( dev-libs/fstrm dev-libs/protobuf-c )
  66. python? ( dev-python/ply[${PYTHON_USEDEP}] )"
  67. # sdb-ldap? ( net-nds/openldap )
  68. RDEPEND="${DEPEND}
  69. selinux? ( sec-policy/selinux-bind )
  70. || ( sys-process/psmisc >=sys-freebsd/freebsd-ubin-9.0_rc sys-process/fuser-bsd )"
  71. S="${WORKDIR}/${MY_P}"
  72. # bug 479092, requires networking
  73. RESTRICT="test"
  74. pkg_setup() {
  75. ebegin "Creating named group and user"
  76. enewgroup named 40
  77. enewuser named 40 -1 /etc/bind named
  78. eend ${?}
  79. }
  80. src_prepare() {
  81. # Adjusting PATHs in manpages
  82. for i in bin/{named/named.8,check/named-checkconf.8,rndc/rndc.8} ; do
  83. sed -i \
  84. -e 's:/etc/named.conf:/etc/bind/named.conf:g' \
  85. -e 's:/etc/rndc.conf:/etc/bind/rndc.conf:g' \
  86. -e 's:/etc/rndc.key:/etc/bind/rndc.key:g' \
  87. "${i}" || die "sed failed, ${i} doesn't exist"
  88. done
  89. # if use dlz; then
  90. # # sdb-ldap patch as per bug #160567
  91. # # Upstream URL: http://bind9-ldap.bayour.com/
  92. # # New patch take from bug 302735
  93. # if use sdb-ldap; then
  94. # epatch "${WORKDIR}"/${PN}-sdb-ldap-${SDB_LDAP_VER}.patch
  95. # cp -fp contrib/sdb/ldap/ldapdb.[ch] bin/named/
  96. # cp -fp contrib/sdb/ldap/{ldap2zone.1,ldap2zone.c} bin/tools/
  97. # cp -fp contrib/sdb/ldap/{zone2ldap.1,zone2ldap.c} bin/tools/
  98. # fi
  99. # fi
  100. # should be installed by bind-tools
  101. sed -i -r -e "s:(nsupdate|dig|delv) ::g" bin/Makefile.in || die
  102. # Disable tests for now, bug 406399
  103. sed -i '/^SUBDIRS/s:tests::' bin/Makefile.in lib/Makefile.in || die
  104. if use nslint; then
  105. sed -i -e 's:/etc/named.conf:/etc/bind/named.conf:' ${NSLINT_DIR}/nslint.{c,8} || die
  106. fi
  107. # bug #220361
  108. rm aclocal.m4
  109. rm -rf libtool.m4/
  110. eautoreconf
  111. }
  112. src_configure() {
  113. local myconf=""
  114. if use urandom; then
  115. myconf="${myconf} --with-randomdev=/dev/urandom"
  116. else
  117. myconf="${myconf} --with-randomdev=/dev/random"
  118. fi
  119. use geoip && myconf="${myconf} --with-geoip"
  120. # bug #158664
  121. # gcc-specs-ssp && replace-flags -O[23s] -O
  122. # To include db.h from proper path
  123. use berkdb && append-flags "-I$(db_includedir)"
  124. export BUILD_CC=$(tc-getBUILD_CC)
  125. econf \
  126. --sysconfdir=/etc/bind \
  127. --localstatedir=/var \
  128. --with-libtool \
  129. --enable-full-report \
  130. --without-readline \
  131. $(use_enable caps linux-caps) \
  132. $(use_enable filter-aaaa) \
  133. $(use_enable fixed-rrset) \
  134. $(use_enable ipv6) \
  135. $(use_enable rpz rpz-nsdname) \
  136. $(use_enable rpz rpz-nsip) \
  137. $(use_enable seccomp) \
  138. $(use_enable threads) \
  139. $(use_with berkdb dlz-bdb) \
  140. $(use_with dlz dlopen) \
  141. $(use_with dlz dlz-filesystem) \
  142. $(use_with dlz dlz-stub) \
  143. $(use_with gost) \
  144. $(use_with gssapi) \
  145. $(use_with idn) \
  146. $(use_with json libjson) \
  147. $(use_with ldap dlz-ldap) \
  148. $(use_with mysql dlz-mysql) \
  149. $(use_with odbc dlz-odbc) \
  150. $(use_with postgres dlz-postgres) \
  151. $(use_with lmdb) \
  152. $(use_with python) \
  153. $(use_with ssl ecdsa) \
  154. $(use_with ssl openssl "${EPREFIX}"/usr) \
  155. $(use_with xml libxml2) \
  156. $(use_with zlib) \
  157. ${myconf}
  158. # $(use_enable static-libs static) \
  159. # bug #151839
  160. echo '#undef SO_BSDCOMPAT' >> config.h
  161. if use nslint; then
  162. cd $NSLINT_DIR
  163. econf
  164. fi
  165. }
  166. src_compile() {
  167. emake
  168. if use nslint; then
  169. emake -C $NSLINT_DIR CCOPT="${CFLAGS}"
  170. fi
  171. }
  172. src_install() {
  173. emake DESTDIR="${D}" install
  174. if use nslint; then
  175. cd $NSLINT_DIR
  176. dobin nslint
  177. doman nslint.8
  178. cd "${S}"
  179. fi
  180. dodoc CHANGES FAQ README
  181. if use idn; then
  182. dodoc contrib/idn/README.idnkit
  183. fi
  184. if use doc; then
  185. dodoc doc/arm/Bv9ARM.pdf
  186. docinto misc
  187. dodoc doc/misc/*
  188. # might a 'html' useflag make sense?
  189. docinto html
  190. dohtml -r doc/arm/*
  191. docinto contrib
  192. dodoc contrib/scripts/{nanny.pl,named-bootconf.sh}
  193. # some handy-dandy dynamic dns examples
  194. pushd "${D}"/usr/share/doc/${PF} 1>/dev/null
  195. tar xf "${DISTDIR}"/dyndns-samples.tbz2 || die
  196. popd 1>/dev/null
  197. fi
  198. insinto /etc/bind
  199. newins "${FILESDIR}"/named.conf-r8 named.conf
  200. # ftp://ftp.rs.internic.net/domain/named.cache:
  201. insinto /var/bind
  202. newins "${FILESDIR}"/named.cache-r3 named.cache
  203. insinto /var/bind/pri
  204. newins "${FILESDIR}"/localhost.zone-r3 localhost.zone
  205. newinitd "${FILESDIR}"/named.init-r13 named
  206. newconfd "${FILESDIR}"/named.confd-r7 named
  207. if use gost; then
  208. sed -i -e 's/^OPENSSL_LIBGOST=${OPENSSL_LIBGOST:-0}$/OPENSSL_LIBGOST=${OPENSSL_LIBGOST:-1}/' "${D}/etc/init.d/named" || die
  209. else
  210. sed -i -e 's/^OPENSSL_LIBGOST=${OPENSSL_LIBGOST:-1}$/OPENSSL_LIBGOST=${OPENSSL_LIBGOST:-0}/' "${D}/etc/init.d/named" || die
  211. fi
  212. newenvd "${FILESDIR}"/10bind.env 10bind
  213. # Let's get rid of those tools and their manpages since they're provided by bind-tools
  214. rm -f "${D}"/usr/share/man/man1/{dig,host,nslookup}.1*
  215. rm -f "${D}"/usr/share/man/man8/nsupdate.8*
  216. rm -f "${D}"/usr/bin/{dig,host,nslookup,nsupdate}
  217. rm -f "${D}"/usr/sbin/{dig,host,nslookup,nsupdate}
  218. for tool in dsfromkey importkey keyfromlabel keygen \
  219. revoke settime signzone verify; do
  220. rm -f "${D}"/usr/{,s}bin/dnssec-"${tool}"
  221. rm -f "${D}"/usr/share/man/man8/dnssec-"${tool}".8*
  222. done
  223. # bug 405251, library archives aren't properly handled by --enable/disable-static
  224. if ! use static-libs; then
  225. find "${D}" -type f -name '*.a' -delete || die
  226. fi
  227. # bug 405251
  228. find "${D}" -type f -name '*.la' -delete || die
  229. if use python; then
  230. install_python_tools() {
  231. dosbin bin/python/dnssec-{checkds,coverage}
  232. }
  233. python_foreach_impl install_python_tools
  234. python_replicate_script "${D}usr/sbin/dnssec-checkds"
  235. python_replicate_script "${D}usr/sbin/dnssec-coverage"
  236. fi
  237. # bug 450406
  238. dosym named.cache /var/bind/root.cache
  239. dosym /var/bind/pri /etc/bind/pri
  240. dosym /var/bind/sec /etc/bind/sec
  241. dosym /var/bind/dyn /etc/bind/dyn
  242. keepdir /var/bind/{pri,sec,dyn}
  243. dodir /var/log/named
  244. fowners root:named /{etc,var}/bind /var/log/named /var/bind/{sec,pri,dyn}
  245. fowners root:named /var/bind/named.cache /var/bind/pri/localhost.zone /etc/bind/{bind.keys,named.conf}
  246. fperms 0640 /var/bind/named.cache /var/bind/pri/localhost.zone /etc/bind/{bind.keys,named.conf}
  247. fperms 0750 /etc/bind /var/bind/pri
  248. fperms 0770 /var/log/named /var/bind/{,sec,dyn}
  249. systemd_newunit "${FILESDIR}/named.service-r1" named.service
  250. systemd_dotmpfilesd "${FILESDIR}"/named.conf
  251. exeinto /usr/libexec
  252. doexe "${FILESDIR}/generate-rndc-key.sh"
  253. }
  254. pkg_postinst() {
  255. if [ ! -f '/etc/bind/rndc.key' ]; then
  256. if use urandom; then
  257. einfo "Using /dev/urandom for generating rndc.key"
  258. /usr/sbin/rndc-confgen -r /dev/urandom -a
  259. echo
  260. else
  261. einfo "Using /dev/random for generating rndc.key"
  262. /usr/sbin/rndc-confgen -a
  263. echo
  264. fi
  265. chown root:named /etc/bind/rndc.key
  266. chmod 0640 /etc/bind/rndc.key
  267. fi
  268. einfo
  269. einfo "You can edit /etc/conf.d/named to customize named settings"
  270. einfo
  271. use mysql || use postgres || use ldap && {
  272. elog "If your named depends on MySQL/PostgreSQL or LDAP,"
  273. elog "uncomment the specified rc_named_* lines in your"
  274. elog "/etc/conf.d/named config to ensure they'll start before bind"
  275. einfo
  276. }
  277. einfo "If you'd like to run bind in a chroot AND this is a new"
  278. einfo "install OR your bind doesn't already run in a chroot:"
  279. einfo "1) Uncomment and set the CHROOT variable in /etc/conf.d/named."
  280. einfo "2) Run \`emerge --config '=${CATEGORY}/${PF}'\`"
  281. einfo
  282. CHROOT=$(source /etc/conf.d/named 2>/dev/null; echo ${CHROOT})
  283. if [[ -n ${CHROOT} ]]; then
  284. elog "NOTE: As of net-dns/bind-9.4.3_p5-r1 the chroot part of the init-script got some major changes!"
  285. elog "To enable the old behaviour (without using mount) uncomment the"
  286. elog "CHROOT_NOMOUNT option in your /etc/conf.d/named config."
  287. elog "If you decide to use the new/default method, ensure to make backup"
  288. elog "first and merge your existing configs/zones to /etc/bind and"
  289. elog "/var/bind because bind will now mount the needed directories into"
  290. elog "the chroot dir."
  291. fi
  292. }
  293. pkg_config() {
  294. CHROOT=$(source /etc/conf.d/named; echo ${CHROOT})
  295. CHROOT_NOMOUNT=$(source /etc/conf.d/named; echo ${CHROOT_NOMOUNT})
  296. CHROOT_GEOIP=$(source /etc/conf.d/named; echo ${CHROOT_GEOIP})
  297. if [[ -z "${CHROOT}" ]]; then
  298. eerror "This config script is designed to automate setting up"
  299. eerror "a chrooted bind/named. To do so, please first uncomment"
  300. eerror "and set the CHROOT variable in '/etc/conf.d/named'."
  301. die "Unset CHROOT"
  302. fi
  303. if [[ -d "${CHROOT}" ]]; then
  304. ewarn "NOTE: As of net-dns/bind-9.4.3_p5-r1 the chroot part of the init-script got some major changes!"
  305. ewarn "To enable the old behaviour (without using mount) uncomment the"
  306. ewarn "CHROOT_NOMOUNT option in your /etc/conf.d/named config."
  307. ewarn
  308. ewarn "${CHROOT} already exists... some things might become overridden"
  309. ewarn "press CTRL+C if you don't want to continue"
  310. sleep 10
  311. fi
  312. echo; einfo "Setting up the chroot directory..."
  313. mkdir -m 0750 -p ${CHROOT}
  314. mkdir -m 0755 -p ${CHROOT}/{dev,etc,var/log,run}
  315. mkdir -m 0750 -p ${CHROOT}/etc/bind
  316. mkdir -m 0770 -p ${CHROOT}/var/{bind,log/named} ${CHROOT}/run/named/
  317. # As of bind 9.8.0
  318. if has_version net-dns/bind[gost]; then
  319. if [ "$(get_libdir)" = "lib64" ]; then
  320. mkdir -m 0755 -p ${CHROOT}/usr/lib64/engines
  321. ln -s lib64 ${CHROOT}/usr/lib
  322. else
  323. mkdir -m 0755 -p ${CHROOT}/usr/lib/engines
  324. fi
  325. fi
  326. chown root:named ${CHROOT} ${CHROOT}/var/{bind,log/named} ${CHROOT}/run/named/ ${CHROOT}/etc/bind
  327. mknod ${CHROOT}/dev/null c 1 3
  328. chmod 0666 ${CHROOT}/dev/null
  329. mknod ${CHROOT}/dev/zero c 1 5
  330. chmod 0666 ${CHROOT}/dev/zero
  331. if use urandom; then
  332. mknod ${CHROOT}/dev/urandom c 1 9
  333. chmod 0666 ${CHROOT}/dev/urandom
  334. else
  335. mknod ${CHROOT}/dev/random c 1 8
  336. chmod 0666 ${CHROOT}/dev/random
  337. fi
  338. if [ "${CHROOT_NOMOUNT:-0}" -ne 0 ]; then
  339. cp -a /etc/bind ${CHROOT}/etc/
  340. cp -a /var/bind ${CHROOT}/var/
  341. fi
  342. if [ "${CHROOT_GEOIP:-0}" -eq 1 ]; then
  343. mkdir -m 0755 -p ${CHROOT}/usr/share/GeoIP
  344. fi
  345. elog "You may need to add the following line to your syslog-ng.conf:"
  346. elog "source jail { unix-stream(\"${CHROOT}/dev/log\"); };"
  347. }