/[gentoo-x86]/net-misc/dhcp/dhcp-3.1.3_p1.ebuild
Gentoo

Contents of /net-misc/dhcp/dhcp-3.1.3_p1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Sun May 1 09:50:20 2011 UTC (3 years, 2 months ago) by xarthisius
Branch: MAIN
Changes since 1.9: +2 -2 lines
ppc64 stable wrt #360047

(Portage version: 2.2.0_alpha29/cvs/Linux x86_64)

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/dhcp-3.1.3_p1.ebuild,v 1.9 2011/04/25 14:48:21 armin76 Exp $
4
5 inherit eutils flag-o-matic multilib toolchain-funcs versionator
6
7 #MY_PV="${PV//_alpha/a}"
8 #MY_PV="${MY_PV//_beta/b}"
9 #MY_PV="${MY_PV//_rc/rc}"
10 #MY_PV="${MY_PV//_p/p}"
11 MY_PV="$(get_version_component_range 1-2 "${PV}" )-ESV"
12 MY_P="${PN}-${MY_PV}"
13 DESCRIPTION="ISC Dynamic Host Configuration Protocol"
14 HOMEPAGE="http://www.isc.org/products/DHCP"
15 SRC_URI="ftp://ftp.isc.org/isc/dhcp/${MY_P}.tar.gz"
16
17 LICENSE="as-is BSD"
18 SLOT="0"
19 KEYWORDS="alpha amd64 arm hppa ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
20 IUSE="doc minimal static selinux kernel_linux"
21
22 DEPEND="selinux? ( sec-policy/selinux-dhcp )
23 kernel_linux? ( sys-apps/net-tools )"
24
25 S="${WORKDIR}/${MY_P}"
26
27 src_unpack() {
28 unpack ${A}
29 cd "${S}"
30
31 # Gentoo patches - these will probably never be accepted upstream
32 # Enable chroot support
33 epatch "${FILESDIR}/${PN}"-3.0-paranoia.patch
34 # Fix some permission issues
35 epatch "${FILESDIR}/${PN}"-3.0-fix-perms.patch
36 # Enable dhclient to equery NTP servers
37 epatch "${FILESDIR}/${PN}"-3.0.3-dhclient-ntp.patch
38 # resolvconf support in dhclient-script
39 epatch "${FILESDIR}/${PN}"-3.1.0a1-dhclient-resolvconf.patch
40 # Fix setting hostnames on Linux
41 # merged in 3.1.3
42 #epatch "${FILESDIR}/${PN}"-3.0.3-dhclient-hostname.patch
43 # Allow mtu settings
44 # merged in 3.1.3
45 #epatch "${FILESDIR}/${PN}"-3.0.3-dhclient-mtu.patch
46 # Allow dhclient to use IF_METRIC to set route metrics
47 # merged in 3.1.3
48 #epatch "${FILESDIR}/${PN}"-3.0.3-dhclient-metric.patch
49 # Stop downing the interface on Linux as that breaks link dameons
50 # such as wpa_supplicant and netplug
51 epatch "${FILESDIR}/${PN}"-3.1.3-dhclient-no-down.patch
52 # Quiet the isc blurb
53 epatch "${FILESDIR}/${PN}"-3.0.3-no_isc_blurb.patch
54 # Enable dhclient to get extra configuration from stdin
55 epatch "${FILESDIR}/${PN}"-3.0.4-dhclient-stdin-conf.patch
56 # Disable fallback interfaces when using BPF
57 # This allows more than one dhclient instance on the BSD's
58 epatch "${FILESDIR}/${PN}"-3.0.5-bpf-nofallback.patch
59
60 # General fixes which will probably be accepted upstream eventually
61 # Install libdst, #75544
62 epatch "${FILESDIR}/${PN}"-3.0.3-libdst.patch
63 # Fix building on Gentoo/FreeBSD
64 epatch "${FILESDIR}/${PN}"-3.0.2-gmake.patch
65
66 # NetworkManager support patches
67 # If they fail to apply to future versions they will be dropped
68 # Add dbus support to dhclient
69 epatch "${FILESDIR}/${PN}"-3.0.3-dhclient-dbus.patch
70
71 # Denial of service through mixed identifier/ethernet host definitions
72 # merged in 3.1.3
73 #epatch "${FILESDIR}/${P}"-CVE-2009-1892.patch
74
75 # Brand the version with Gentoo
76 # include revision if >0
77 local newver="${MY_PV}-Gentoo"
78 [[ ${PR} != "r0" ]] && newver="${newver}-${PR}"
79 sed -i '/^#define DHCP_VERSION[ \t]\+/ s/'"${MY_PV}/${newver}/g" \
80 includes/version.h || die
81
82 # Change the hook script locations of the scripts
83 sed -i -e 's,/etc/dhclient-exit-hooks,/etc/dhcp/dhclient-exit-hooks,g' \
84 -e 's,/etc/dhclient-enter-hooks,/etc/dhcp/dhclient-enter-hooks,g' \
85 client/scripts/* || die
86
87 # No need for the linux script to force bash, #158540.
88 sed -i -e 's,#!/bin/bash,#!/bin/sh,' client/scripts/linux || die
89
90 # Quiet the freebsd logger a little
91 sed -i -e '/LOGGER=/ s/-s -p user.notice //g' client/scripts/freebsd || die
92
93 # Remove these options from the sample config
94 sed -i -e "/\(script\|host-name\|domain-name\) / d" \
95 client/dhclient.conf || die
96
97 # Build sed man pages as we don't ever support BSD 4.4 and older, #130251.
98 local x=
99 for x in Makefile.dist $(ls */Makefile.dist) ; do
100 sed -i -e 's/$(CATMANPAGES)/$(SEDMANPAGES)/g' "${x}" || die
101 done
102
103 # Only install different man pages if we don't have en
104 if [[ " ${LINGUAS} " != *" en "* ]]; then
105 # Install Japanese man pages
106 if [[ " ${LINGUAS} " == *" ja "* && -d doc/ja_JP.eucJP ]]; then
107 einfo "Installing Japanese documention"
108 cp doc/ja_JP.eucJP/dhclient* client
109 cp doc/ja_JP.eucJP/dhcp* common
110 fi
111 fi
112
113 # Now remove the non-english docs so there are no errors later
114 [[ -d doc/ja_JP.eucJP ]] && rm -rf doc/ja_JP.eucJP
115 }
116
117 src_compile() {
118 use static && append-ldflags -static
119
120 cat <<-END >> includes/site.h
121 #define _PATH_DHCPD_CONF "/etc/dhcp/dhcpd.conf"
122 #define _PATH_DHCPD_PID "/var/run/dhcp/dhcpd.pid"
123 #define _PATH_DHCPD_DB "/var/lib/dhcp/dhcpd.leases"
124 #define _PATH_DHCLIENT_CONF "/etc/dhcp/dhclient.conf"
125 #define _PATH_DHCLIENT_DB "/var/lib/dhcp/dhclient.leases"
126 #define _PATH_DHCLIENT_PID "/var/run/dhcp/dhclient.pid"
127 #define DHCPD_LOG_FACILITY LOG_LOCAL1
128 END
129
130 cat <<-END > site.conf
131 CC = $(tc-getCC)
132 LFLAGS = ${LDFLAGS}
133 LIBDIR = /usr/$(get_libdir)
134 INCDIR = /usr/include
135 ETC = /etc/dhcp
136 VARDB = /var/lib/dhcp
137 VARRUN = /var/run/dhcp
138 ADMMANDIR = /usr/share/man/man8
139 ADMMANEXT = .8
140 FFMANDIR = /usr/share/man/man5
141 FFMANEXT = .5
142 LIBMANDIR = /usr/share/man/man3
143 LIBMANEXT = .3
144 USRMANDIR = /usr/share/man/man1
145 USRMANEXT = .1
146 MANCAT = man
147 END
148
149 ./configure --copts "-DPARANOIA -DEARLY_CHROOT ${CFLAGS}" \
150 || die "configure failed"
151
152 # Remove server support from the Makefile
153 # We still install some extra crud though
154 if use minimal ; then
155 sed -i -e 's/\(server\|relay\|dhcpctl\)/ /g' work.*/Makefile || die
156 fi
157 emake || die "compile problem"
158 }
159
160 src_install() {
161 make install DESTDIR="${D}" || die
162 use doc && dodoc README RELNOTES doc/*
163
164 insinto /etc/dhcp
165 newins client/dhclient.conf dhclient.conf.sample
166 keepdir /var/{lib,run}/dhcp
167 keepdir /var/lib/dhclient
168
169 # Install our server files
170 if ! use minimal ; then
171 insinto /etc/dhcp
172 newins server/dhcpd.conf dhcpd.conf.sample
173 newinitd "${FILESDIR}"/dhcpd.init2 dhcpd
174 newinitd "${FILESDIR}"/dhcrelay.init dhcrelay
175 newconfd "${FILESDIR}"/dhcpd.conf dhcpd
176 newconfd "${FILESDIR}"/dhcrelay.conf dhcrelay
177
178 # We never want portage to own this file
179 rm -f "${D}"/var/lib/dhcp/dhcpd.leases
180 fi
181 }
182
183 pkg_preinst() {
184 if ! use minimal ; then
185 enewgroup dhcp
186 enewuser dhcp -1 -1 /var/lib/dhcp dhcp
187 fi
188 }
189
190 pkg_postinst() {
191 use minimal && return
192
193 chown -R dhcp:dhcp "${ROOT}"/var/{lib,run}/dhcp
194
195 if [[ -e "${ROOT}"/etc/init.d/dhcp ]] ; then
196 ewarn
197 ewarn "WARNING: The dhcp init script has been renamed to dhcpd"
198 ewarn "/etc/init.d/dhcp and /etc/conf.d/dhcp need to be removed and"
199 ewarn "and dhcp should be removed from the default runlevel"
200 ewarn
201 fi
202
203 einfo "You can edit /etc/conf.d/dhcpd to customize dhcp settings."
204 einfo
205 einfo "If you would like to run dhcpd in a chroot, simply configure the"
206 einfo "DHCPD_CHROOT directory in /etc/conf.d/dhcpd and then run:"
207 einfo " emerge --config =${PF}"
208 }
209
210 pkg_config() {
211 if use minimal ; then
212 eerror "${PN} has not been compiled for server support"
213 eerror "emerge ${PN} without the minimal USE flag to use dhcp sever"
214 return 1
215 fi
216
217 local CHROOT="$(
218 sed -n -e 's/^[[:blank:]]\?DHCPD_CHROOT="*\([^#"]\+\)"*/\1/p' \
219 "${ROOT}"/etc/conf.d/dhcpd
220 )"
221
222 if [[ -z ${CHROOT} ]]; then
223 eerror "CHROOT not defined in /etc/conf.d/dhcpd"
224 return 1
225 fi
226
227 CHROOT="${ROOT}/${CHROOT}"
228
229 if [[ -d ${CHROOT} ]] ; then
230 ewarn "${CHROOT} already exists - aborting"
231 return 0
232 fi
233
234 ebegin "Setting up the chroot directory"
235 mkdir -m 0755 -p "${CHROOT}/"{dev,etc,var/lib,var/run/dhcp}
236 cp /etc/{localtime,resolv.conf} "${CHROOT}"/etc
237 cp -R /etc/dhcp "${CHROOT}"/etc
238 cp -R /var/lib/dhcp "${CHROOT}"/var/lib
239 ln -s ../../var/lib/dhcp "${CHROOT}"/etc/dhcp/lib
240 chown -R dhcp:dhcp "${CHROOT}"/var/{lib,run}/dhcp
241 eend 0
242
243 local logger="$(best_version virtual/logger)"
244 einfo "To enable logging from the dhcpd server, configure your"
245 einfo "logger (${logger}) to listen on ${CHROOT}/dev/log"
246 }

  ViewVC Help
Powered by ViewVC 1.1.20