Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 563362 | Differences between
and this patch

Collapse All | Expand All

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

Return to bug 563362