1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils systemd toolchain-funcs user
9 MY_PV="${PV//_alpha/a}"
10 MY_PV="${MY_PV//_beta/b}"
11 MY_PV="${MY_PV//_rc/rc}"
12 MY_PV="${MY_PV//_p/-P}"
14 DESCRIPTION="ISC Dynamic Host Configuration Protocol (DHCP) client/server"
15 HOMEPAGE="http://www.isc.org/products/DHCP"
16 SRC_URI="ftp://ftp.isc.org/isc/dhcp/${MY_P}.tar.gz
17 ftp://ftp.isc.org/isc/dhcp/${MY_PV}/${MY_P}.tar.gz"
19 LICENSE="ISC BSD SSLeay GPL-2" # GPL-2 only for init script
21 KEYWORDS="~alpha amd64 arm ~arm64 hppa ia64 ~m68k ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
22 IUSE="+client ipv6 kernel_linux ldap libressl selinux +server ssl vim-syntax"
27 ipv6? ( sys-apps/iproute2 )
34 !libressl? ( dev-libs/openssl:0 )
35 libressl? ( dev-libs/libressl )
39 selinux? ( sec-policy/selinux-dhcp )
40 vim-syntax? ( app-vim/dhcpd-syntax )"
42 S="${WORKDIR}/${MY_P}"
46 # handle local bind hell
52 # Gentoo patches - these will probably never be accepted upstream
53 # Fix some permission issues
54 "${FILESDIR}/${PN}-3.0-fix-perms.patch"
56 # Enable dhclient to equery NTP servers
57 "${FILESDIR}/${PN}-4.3.4-dhclient-ntp.patch"
58 "${FILESDIR}/${PN}-4.3.1-dhclient-resolvconf.patch"
60 # Stop downing the interface on Linux as that breaks link daemons
61 # such as wpa_supplicant and netplug
62 "${FILESDIR}/${PN}-3.0.3-dhclient-no-down.patch"
64 # Enable dhclient to get extra configuration from stdin
65 "${FILESDIR}/${PN}-4.2.2-dhclient-stdin-conf.patch"
66 "${FILESDIR}/${PN}-4.2.2-nogateway.patch" #265531
67 "${FILESDIR}/${PN}-4.2.4-quieter-ping.patch" #296921
68 "${FILESDIR}/${PN}-4.2.4-always-accept-4.patch" #437108
69 "${FILESDIR}/${PN}-4.2.5-iproute2-path.patch" #480636
70 "${FILESDIR}/${PN}-4.2.5-bindtodevice-inet6.patch" #471142
71 "${FILESDIR}/${PN}-4.3.3-ldap-ipv6-client-id.patch" #559832
75 epatch "${PATCHES[@]}"
77 # Brand the version with Gentoo
79 -e "/VERSION=/s:'$: Gentoo-${PR}':" \
82 # Change the hook script locations of the scripts
84 -e 's,/etc/dhclient-exit-hooks,/etc/dhcp/dhclient-exit-hooks,g' \
85 -e 's,/etc/dhclient-enter-hooks,/etc/dhcp/dhclient-enter-hooks,g' \
86 client/scripts/* || die
88 # No need for the linux script to force bash #158540
89 sed -i -e 's,#!/bin/bash,#!/bin/sh,' client/scripts/linux || die
91 # Quiet the freebsd logger a little
92 sed -i -e '/LOGGER=/ s/-s -p user.notice //g' client/scripts/freebsd || die
94 # Remove these options from the sample config
96 -e "/(script|host-name|domain-name) /d" \
97 client/dhclient.conf.example || die
99 if use client && ! use server ; then
101 -e '/^SUBDIRS/s:\<(dhcpctl|relay|server)\>::g' \
103 elif ! use client && use server ; then
105 -e '/^SUBDIRS/s:\<client\>::' \
109 # Only install different man pages if we don't have en
110 if [[ " ${LINGUAS} " != *" en "* ]]; then
111 # Install Japanese man pages
112 if [[ " ${LINGUAS} " == *" ja "* && -d doc/ja_JP.eucJP ]]; then
113 einfo "Installing Japanese documention"
114 cp doc/ja_JP.eucJP/dhclient* client
115 cp doc/ja_JP.eucJP/dhcp* common
118 # Now remove the non-english docs so there are no errors later
119 rm -rf doc/ja_JP.eucJP
121 # make the bind build work
123 cd "${binddir}" || die
124 cat <<-EOF > bindvar.tmp
128 epatch "${FILESDIR}"/${PN}-4.3.4-bind-disable.patch
130 epatch "${FILESDIR}"/${PN}-4.2.2-bind-parallel-build.patch #380717
131 epatch "${FILESDIR}"/${PN}-4.2.2-bind-build-flags.patch
135 # bind defaults to stupid `/usr/bin/ar`
136 tc-export AR BUILD_CC
137 export ac_cv_path_AR=${AR}
139 # this is tested for by the bind build system, and can cause trouble
140 # when cross-building; since dhcp itself doesn't make use of libcap,
142 export ac_cv_lib_cap_cap_set_proc=no
144 # Use FHS sane paths ... some of these have configure options,
145 # but not all, so just do it all here.
146 local e="/etc/dhcp" r="/var/run/dhcp" l="/var/lib/dhcp"
147 cat <<-EOF >> includes/site.h
148 #define _PATH_DHCPD_CONF "${e}/dhcpd.conf"
149 #define _PATH_DHCLIENT_CONF "${e}/dhclient.conf"
150 #define _PATH_DHCPD_DB "${l}/dhcpd.leases"
151 #define _PATH_DHCPD6_DB "${l}/dhcpd6.leases"
152 #define _PATH_DHCLIENT_DB "${l}/dhclient.leases"
153 #define _PATH_DHCLIENT6_DB "${l}/dhclient6.leases"
154 #define _PATH_DHCPD_PID "${r}/dhcpd.pid"
155 #define _PATH_DHCPD6_PID "${r}/dhcpd6.pid"
156 #define _PATH_DHCLIENT_PID "${r}/dhcpclient.pid"
157 #define _PATH_DHCLIENT6_PID "${r}/dhcpclient6.pid"
158 #define _PATH_DHCRELAY_PID "${r}/dhcrelay.pid"
159 #define _PATH_DHCRELAY6_PID "${r}/dhcrelay6.pid"
164 --enable-early-chroot \
166 $(use_enable ipv6 dhcpv6) \
168 $(use ldap && use_with ssl ldapcrypto || echo --without-ldapcrypto)
170 # configure local bind cruft. symtable option requires
171 # perl and we don't want to require that #383837.
172 cd bind/bind-*/ || die
174 $(sed -n '/^bindconfig =/,/^$/{:a;N;$!ba;s,^[^-]*,,;s,\\\s*\n\s*--,--,g;s, @[[:upper:]]\+@,,g;P;D}' ../Makefile.in) \
180 # build local bind cruft first
181 emake -C bind/bind-*/lib/export install
182 # then build standard dhcp code
183 emake AR="$(tc-getAR)"
189 dodoc README RELNOTES doc/{api+protocol,IANA-arp-parameters}
190 dohtml doc/References.html
192 if [[ -e client/dhclient ]] ; then
193 # move the client to /
195 mv "${D}"/usr/sbin/dhclient "${D}"/sbin/ || die
198 if use kernel_linux ; then
199 newexe "${S}"/client/scripts/linux dhclient-script
201 newexe "${S}"/client/scripts/freebsd dhclient-script
205 if [[ -e server/dhcpd ]] ; then
207 insinto /etc/openldap/schema
208 doins contrib/ldap/dhcp.*
209 dosbin contrib/ldap/dhcpd-conf-to-ldap
212 newinitd "${FILESDIR}"/dhcpd.init5 dhcpd
213 newconfd "${FILESDIR}"/dhcpd.conf2 dhcpd
214 newinitd "${FILESDIR}"/dhcrelay.init3 dhcrelay
215 newconfd "${FILESDIR}"/dhcrelay.conf dhcrelay
216 newinitd "${FILESDIR}"/dhcrelay.init3 dhcrelay6
217 newconfd "${FILESDIR}"/dhcrelay6.conf dhcrelay6
219 systemd_newtmpfilesd "${FILESDIR}"/dhcpd.tmpfiles dhcpd.conf
220 systemd_dounit "${FILESDIR}"/dhcpd4.service
221 systemd_dounit "${FILESDIR}"/dhcpd6.service
222 systemd_dounit "${FILESDIR}"/dhcrelay4.service
223 systemd_dounit "${FILESDIR}"/dhcrelay6.service
224 systemd_install_serviced "${FILESDIR}"/dhcrelay4.service.conf
225 systemd_install_serviced "${FILESDIR}"/dhcrelay6.service.conf
227 sed -i "s:#@slapd@:$(usex ldap slapd ''):" "${ED}"/etc/init.d/* || die #442560
230 # the default config files aren't terribly useful #384087
232 for f in "${ED}"/etc/dhcp/*.conf.example ; do
233 mv "${f}" "${f%.example}" || die
235 sed -i '/^[^#]/s:^:#:' "${ED}"/etc/dhcp/*.conf || die
240 enewuser dhcp -1 -1 /var/lib/dhcp dhcp
242 # Keep the user files over the sample ones. The
243 # hashing is to ignore the crappy defaults #384087.
245 for f in dhclient:da7c8496a96452190aecf9afceef4510 dhcpd:10979e7b71134bd7f04d2a60bd58f070 ; do
247 f="/etc/dhcp/${f%:*}.conf"
248 if [ -e "${EROOT}"${f} ] ; then
249 case $(md5sum "${EROOT}"${f}) in
251 *) cp -p "${EROOT}"${f} "${ED}"${f};;
258 if [[ -e "${ROOT}"/etc/init.d/dhcp ]] ; then
260 ewarn "WARNING: The dhcp init script has been renamed to dhcpd"
261 ewarn "/etc/init.d/dhcp and /etc/conf.d/dhcp need to be removed and"
262 ewarn "and dhcp should be removed from the default runlevel"