Enable --enable-early-chroot so config files can be per-chroot #388395 by Touch....
authorMike Frysinger <vapier@gentoo.org>
Sun, 4 Dec 2011 22:45:07 +0000 (22:45 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 4 Dec 2011 22:45:07 +0000 (22:45 +0000)
Package-Manager: portage-2.2.0_alpha75/cvs/Linux x86_64

net-misc/dhcp/ChangeLog
net-misc/dhcp/Manifest
net-misc/dhcp/dhcp-4.2.2-r3.ebuild [new file with mode: 0644]
net-misc/dhcp/files/dhcpd.init5 [new file with mode: 0755]

index 9dcdd3a3c52122cbafaed71d6011ea9b1965913f..41bb6404f6696fc86b12c70338032ca72abfeb2b 100644 (file)
@@ -1,6 +1,13 @@
 # ChangeLog for net-misc/dhcp
 # Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/ChangeLog,v 1.197 2011/10/11 16:28:53 jer Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/ChangeLog,v 1.198 2011/12/04 22:45:06 vapier Exp $
+
+*dhcp-4.2.2-r3 (04 Dec 2011)
+
+  04 Dec 2011; Mike Frysinger <vapier@gentoo.org> +dhcp-4.2.2-r3.ebuild,
+  +files/dhcpd.init5:
+  Enable --enable-early-chroot so config files can be per-chroot #388395 by
+  Touch. Fix up path to dhcprelay pid files #309129#2 by Milan Dadok.
 
   11 Oct 2011; Jeroen Roovers <jer@gentoo.org> dhcp-4.2.2-r2.ebuild:
   Stable for HPPA (bug #378799).
index 7d7113ee8c0bdf635f47d58df9f1817f8783eea6..fd7806a00d4742cd3fd5d2e0bac76fec3c7167d1 100644 (file)
@@ -1,5 +1,5 @@
 -----BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
+Hash: SHA256
 
 AUX dhcp-3.0-fix-perms.patch 485 RMD160 3857270dffed5feee95609aeb37d0c9ef8844945 SHA1 1217265a8a7f1416b781e9f79e8dfb8304268e6c SHA256 a805a60b36e148886887aebb797e80f642386b3e55ef4a0b5132f96a2877e018
 AUX dhcp-3.0-paranoia.patch 5366 RMD160 7c64e3dac5b07ff3859fcaa7a8b0e52a0c50446c SHA1 a30103c138e480766f84644fffb1d0897709c27d SHA256 a8db9eb98397a9c1b3a0de07fc107c39dc4f6a4a331d404fc6fcc4a8dbc7aeae
@@ -33,6 +33,7 @@ AUX dhcpd.conf2 1068 RMD160 35491b4bffec15f51c64946e6bc397c9a7937826 SHA1 7a90d5
 AUX dhcpd.init2 2421 RMD160 baa01ae97b227edba7653cd51735613be2dac652 SHA1 f2068ceb2d79d7992f46b31e6a6e3277a0167dce SHA256 fef93e5a7264780044a977ade27e9cc70de824063791bcd07d3db81c11c16df5
 AUX dhcpd.init3 2525 RMD160 d56c77e6f2e3981c78c3fefad04347615e9d9d60 SHA1 c04f470d0cc3b262cf87cc766ceee5a35aec8b43 SHA256 69f5e6bee391a9a03554bead07c9dd5775e1fbb2a0ae515b7930cec328a8959c
 AUX dhcpd.init4 2902 RMD160 88a286743f43f490af36b046d271ff368369725c SHA1 c5210d65c352b35b396167a807563b7f879a2933 SHA256 6d746cf628d4dd4a191cefc4869bbe12b0fb9eb69b69c062ad4d3e3b369e9044
+AUX dhcpd.init5 2874 RMD160 a99ea016347f184b0f95207cdf8bd2b634d4de4c SHA1 62c0b3a2e4633ed189c02792f504350e963d0168 SHA256 d724ed829c8d13595f1609644308656141c8057ab06fad6cf6afe80caf0f6229
 AUX dhcrelay.conf 421 RMD160 456edbc9bcc8d3a44db5bb6dbf0c3003c3e7419c SHA1 78ecdb000382893fb49d0052ced063955b0ad9cf SHA256 409b895ed489e75c1a08f72961b45d641b93fd9357f528abc78b1fd036b7f730
 AUX dhcrelay.init 736 RMD160 04566b87bd6dbb8bb754b26409ca30b878ef3ca3 SHA1 72742b308314b2e1476b27e94212fbf4d179adc4 SHA256 cfdaff3a723be3935d06c14e171d4008f2ad3329bd05ac2e49c19bc0e14bc59c
 AUX dhcrelay.init2 712 RMD160 2baeaf7c0fb8a5796792b5721f32104907243798 SHA1 ced20da5625b6517fa6044ce179e1c5d9a17297e SHA256 6cca726147474c600662b0c2e49eb5aa148a7a9af1358dbc56f16b1d08255ae3
@@ -45,13 +46,14 @@ EBUILD dhcp-3.1.3_p1.ebuild 7741 RMD160 62ef4cf524beadef2847675416ea5982f23a3f8e
 EBUILD dhcp-4.2.1_p1.ebuild 6610 RMD160 0d058e755de185a58fc62a3d047021671de9a54a SHA1 5cf96d94250ba44b3120ae6a961c04e4f01996b5 SHA256 70534d654d5a2d02ea009d87f77bf86724ee94b7587f5b6959eef90475e5062a
 EBUILD dhcp-4.2.2-r1.ebuild 7892 RMD160 5c371acd35b9c1b287e0f476fd0b29cd8ee1e85d SHA1 b671ca999d5c7251d399c6ea6cd4bbba60abc9a0 SHA256 fbdd748e82fb55d4e222dd3846488fd273227540cd098badbc4be1bf0d7b7071
 EBUILD dhcp-4.2.2-r2.ebuild 7107 RMD160 8e380ef4e9986cd4b249c1efb9eb2aba5fc3b1ef SHA1 f900785f473a58a6ade2fb4aacf209a6dc90a455 SHA256 c9ecc844f738beb83667633adce767783e00b92b500a25cf01131d081f8d626b
+EBUILD dhcp-4.2.2-r3.ebuild 7143 RMD160 4a6450fdf6a1430e6a1c316a67dc751e4cf8f319 SHA1 57f704cc9dea37fa2e244687521d35564d7f915f SHA256 f2ce7dd86a7f37b03c832216adb08cc6b2302bb45575ba6328aeabbcc3ccfb86
 EBUILD dhcp-4.2.2.ebuild 7474 RMD160 a80b1fb2eb31ba8dc20f9d6fb914e37a5cf12174 SHA1 089b6bb9e87f07c950d7ee4261e081ba59f29fa5 SHA256 9f15f5b2d35d9ff4372250886f3751b94abb0fbebc99ea4d16e5abd74ccf9755
-MISC ChangeLog 33839 RMD160 649d392692d02b81e3ff82f91d16d898216cfbe5 SHA1 c598c90d3bd7fffe71cabfe7b841431b03a6f6ed SHA256 30a5943ff90c9e343aa503cbb1dadca7b2f3dc7bf097e95a8166a3f27b92ac16
+MISC ChangeLog 34114 RMD160 d90da574bfc8ef746793f9ac9213b8eee3acc063 SHA1 8aa6bec1a165301ddfda0ad12396a6aa1386beda SHA256 3bec7e6be149e5b010277e1f9d0e3b9f3b78b3b46a36c5dd7de8151415bb85bf
 MISC metadata.xml 500 RMD160 b5ad909ab2b12acd20e78039e33fda0a27383c9e SHA1 2fc5cee8e105e75a251195254c96085a0f3fa9a3 SHA256 e9e4edcf7671391ee2f2af0917a75fc07883f1401aaa22b72dd0133bef81601c
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v2.0.17 (GNU/Linux)
+Version: GnuPG v2.0.18 (GNU/Linux)
 
-iEYEARECAAYFAk6Ubs0ACgkQVWmRsqeSphMDHQCeK6sPEIIviOHVunCncqxMlSqE
-FewAni5wG69aku4eSjwmaS29pgHa9jCk
-=aDgI
+iF4EAREIAAYFAk7b+AEACgkQaC/OocHi7JY4hAD/UR9JbCQw/JTtGRcGiSI5ZpXA
+EE1r3tV5r/SXYOk1kAIBAJSG+7tmj7y5Ih3Sx+m8x0nMhkZm8Eet97mnWfP0HHiQ
+=v2Pt
 -----END PGP SIGNATURE-----
diff --git a/net-misc/dhcp/dhcp-4.2.2-r3.ebuild b/net-misc/dhcp/dhcp-4.2.2-r3.ebuild
new file mode 100644 (file)
index 0000000..eea1ab4
--- /dev/null
@@ -0,0 +1,234 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/dhcp-4.2.2-r3.ebuild,v 1.1 2011/12/04 22:45:06 vapier Exp $
+
+EAPI="2"
+
+inherit eutils toolchain-funcs
+
+MY_PV="${PV//_alpha/a}"
+MY_PV="${MY_PV//_beta/b}"
+MY_PV="${MY_PV//_rc/rc}"
+MY_PV="${MY_PV//_p/-P}"
+MY_P="${PN}-${MY_PV}"
+DESCRIPTION="ISC Dynamic Host Configuration Protocol (DHCP) client/server"
+HOMEPAGE="http://www.isc.org/products/DHCP"
+SRC_URI="ftp://ftp.isc.org/isc/dhcp/${MY_P}.tar.gz"
+
+LICENSE="as-is BSD"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
+IUSE="+client ipv6 kernel_linux ldap selinux +server ssl vim-syntax"
+
+DEPEND="selinux? ( sec-policy/selinux-dhcp )
+       kernel_linux? ( sys-apps/net-tools )
+       ldap? (
+               net-nds/openldap
+               ssl? ( dev-libs/openssl )
+       )"
+RDEPEND="${DEPEND}
+       vim-syntax? ( app-vim/dhcpd-syntax )"
+
+S="${WORKDIR}/${MY_P}"
+
+src_unpack() {
+       unpack ${A}
+       # handle local bind hell
+       cd "${S}"/bind
+       unpack ./bind.tar.gz
+}
+
+src_prepare() {
+       # Gentoo patches - these will probably never be accepted upstream
+       # Fix some permission issues
+       epatch "${FILESDIR}"/${PN}-3.0-fix-perms.patch
+       # Enable dhclient to equery NTP servers
+       epatch "${FILESDIR}"/${PN}-4.0-dhclient-ntp.patch
+       # resolvconf support in dhclient-script
+       epatch "${FILESDIR}"/${PN}-4.2.2-dhclient-resolvconf.patch
+       # Stop downing the interface on Linux as that breaks link daemons
+       # such as wpa_supplicant and netplug
+       epatch "${FILESDIR}"/${PN}-3.0.3-dhclient-no-down.patch
+       epatch "${FILESDIR}"/${PN}-4.2.0-errwarn-message.patch
+       # Enable dhclient to get extra configuration from stdin
+       epatch "${FILESDIR}"/${PN}-4.2.2-dhclient-stdin-conf.patch
+       epatch "${FILESDIR}"/${PN}-4.2.2-nogateway.patch #265531
+
+       # NetworkManager support patches
+       # If they fail to apply to future versions they will be dropped
+       # Add dbus support to dhclient
+       epatch "${FILESDIR}"/${PN}-3.0.3-dhclient-dbus.patch
+
+       # Brand the version with Gentoo
+       sed -i \
+               -e "/VERSION=/s:'$: Gentoo-${PR}':" \
+               configure || die
+
+       # Change the hook script locations of the scripts
+       sed -i \
+               -e 's,/etc/dhclient-exit-hooks,/etc/dhcp/dhclient-exit-hooks,g' \
+               -e 's,/etc/dhclient-enter-hooks,/etc/dhcp/dhclient-enter-hooks,g' \
+               client/scripts/* || die
+
+       # No need for the linux script to force bash #158540
+       sed -i -e 's,#!/bin/bash,#!/bin/sh,' client/scripts/linux || die
+
+       # Quiet the freebsd logger a little
+       sed -i -e '/LOGGER=/ s/-s -p user.notice //g' client/scripts/freebsd || die
+
+       # Remove these options from the sample config
+       sed -i \
+               -e "/\(script\|host-name\|domain-name\) / d" \
+               client/dhclient.conf || die
+
+       if use client && ! use server ; then
+               sed -i -r \
+                       -e '/^SUBDIRS/s:\<(dhcpctl|relay|server)\>::g' \
+                       Makefile.in || die
+       elif ! use client && use server ; then
+               sed -i -r \
+                       -e '/^SUBDIRS/s:\<client\>::' \
+                       Makefile.in || die
+       fi
+
+       # Only install different man pages if we don't have en
+       if [[ " ${LINGUAS} " != *" en "* ]]; then
+               # Install Japanese man pages
+               if [[ " ${LINGUAS} " == *" ja "* && -d doc/ja_JP.eucJP ]]; then
+                       einfo "Installing Japanese documention"
+                       cp doc/ja_JP.eucJP/dhclient* client
+                       cp doc/ja_JP.eucJP/dhcp* common
+               fi
+       fi
+       # Now remove the non-english docs so there are no errors later
+       rm -rf doc/ja_JP.eucJP
+
+       # make the bind build work
+       binddir=${S}/bind
+       cd "${binddir}" || die
+       cat <<-EOF > bindvar.tmp
+       binddir=${binddir}
+       GMAKE=${MAKE:-gmake}
+       EOF
+       epatch "${FILESDIR}"/${PN}-4.2.2-bind-disable.patch
+       cd bind-*/
+       epatch "${FILESDIR}"/${PN}-4.2.2-bind-parallel-build.patch #380717
+       epatch "${FILESDIR}"/${PN}-4.2.2-bind-build-flags.patch
+}
+
+src_configure() {
+       # bind defaults to stupid `/usr/bin/ar`
+       tc-export AR BUILD_CC
+       export ac_cv_path_AR=${AR}
+
+       # this is tested for by the bind build system, and can cause trouble
+       # when cross-building; since dhcp itself doesn't make use of libcap,
+       # simply disable it.
+       export ac_cv_lib_cap_cap_set_proc=no
+
+       # Use FHS sane paths ... some of these have configure options,
+       # but not all, so just do it all here.
+       local e="/etc/dhcp" r="/var/run/dhcp" l="/var/lib/dhcp"
+       cat <<-EOF >> includes/site.h
+       #define _PATH_DHCPD_CONF     "${e}/dhcpd.conf"
+       #define _PATH_DHCLIENT_CONF  "${e}/dhclient.conf"
+       #define _PATH_DHCPD_DB       "${l}/dhcpd.leases"
+       #define _PATH_DHCPD6_DB      "${l}/dhcpd6.leases"
+       #define _PATH_DHCLIENT_DB    "${l}/dhclient.leases"
+       #define _PATH_DHCLIENT6_DB   "${l}/dhclient6.leases"
+       #define _PATH_DHCPD_PID      "${r}/dhcpd.pid"
+       #define _PATH_DHCPD6_PID     "${r}/dhcpd6.pid"
+       #define _PATH_DHCLIENT_PID   "${r}/dhcpclient.pid"
+       #define _PATH_DHCLIENT6_PID  "${r}/dhcpclient6.pid"
+       #define _PATH_DHCRELAY_PID   "${r}/dhcrelay.pid"
+       #define _PATH_DHCRELAY6_PID  "${r}/dhcrelay6.pid"
+       EOF
+
+       econf \
+               --enable-paranoia \
+               --enable-early-chroot \
+               --sysconfdir=${e} \
+               $(use_enable ipv6 dhcpv6) \
+               $(use_with ldap) \
+               $(use ldap && use_with ssl ldapcrypto || echo --without-ldapcrypto)
+
+       # configure local bind cruft.  symtable option requires
+       # perl and we don't want to require that #383837.
+       cd bind/bind-*/ || die
+       eval econf \
+               $(sed -n '/ [.].configure /{s:^[^-]*::;s:>.*::;p}' ../Makefile) \
+               --disable-symtable \
+               --without-make-clean
+}
+
+src_compile() {
+       # build local bind cruft first
+       emake -C bind/bind-*/lib/export install || die
+       # then build standard dhcp code
+       emake || die
+}
+
+src_install() {
+       emake install DESTDIR="${D}" || die
+
+       dodoc README RELNOTES doc/{api+protocol,IANA-arp-parameters}
+       dohtml doc/References.html
+
+       if [[ -e client/dhclient ]] ; then
+               # move the client to /
+               dodir /sbin
+               mv "${D}"/usr/sbin/dhclient "${D}"/sbin/ || die
+
+               exeinto /sbin
+               if use kernel_linux ; then
+                       newexe "${S}"/client/scripts/linux dhclient-script || die
+               else
+                       newexe "${S}"/client/scripts/freebsd dhclient-script || die
+               fi
+       fi
+
+       if [[ -e server/dhcpd ]] ; then
+               if use ldap ; then
+                       insinto /etc/openldap/schema
+                       doins contrib/ldap/dhcp.* || die
+                       dosbin contrib/ldap/dhcpd-conf-to-ldap || die
+               fi
+
+               newinitd "${FILESDIR}"/dhcpd.init5 dhcpd || die
+               newconfd "${FILESDIR}"/dhcpd.conf2 dhcpd || die
+               newinitd "${FILESDIR}"/dhcrelay.init2 dhcrelay || die
+               newconfd "${FILESDIR}"/dhcrelay.conf dhcrelay || die
+       fi
+
+       # the default config files aren't terribly useful #384087
+       sed -i '/^[^#]/s:^:#:' "${D}"/etc/dhcp/*.conf || die
+}
+
+pkg_preinst() {
+       enewgroup dhcp
+       enewuser dhcp -1 -1 /var/lib/dhcp dhcp
+
+       # Keep the user files over the sample ones.  The
+       # hashing is to ignore the crappy defaults #384087.
+       local f h
+       for f in dhclient:da7c8496a96452190aecf9afceef4510 dhcpd:10979e7b71134bd7f04d2a60bd58f070 ; do
+               h=${f#*:}
+               f="/etc/dhcp/${f%:*}.conf"
+               if [ -e "${ROOT}"${f} ] ; then
+                       case $(md5sum "${ROOT}"${f}) in
+                               ${h}*) ;;
+                               *) cp -p "${ROOT}"${f} "${D}"${f};;
+                       esac
+               fi
+       done
+}
+
+pkg_postinst() {
+       if [[ -e "${ROOT}"/etc/init.d/dhcp ]] ; then
+               ewarn
+               ewarn "WARNING: The dhcp init script has been renamed to dhcpd"
+               ewarn "/etc/init.d/dhcp and /etc/conf.d/dhcp need to be removed and"
+               ewarn "and dhcp should be removed from the default runlevel"
+               ewarn
+       fi
+}
diff --git a/net-misc/dhcp/files/dhcpd.init5 b/net-misc/dhcp/files/dhcpd.init5
new file mode 100755 (executable)
index 0000000..c3bbab7
--- /dev/null
@@ -0,0 +1,114 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcpd.init5,v 1.1 2011/12/04 22:45:07 vapier Exp $
+
+extra_commands="configtest"
+
+: ${DHCPD_CONF:=/etc/dhcp/${SVCNAME}.conf}
+
+depend() {
+       need net
+       use logger dns
+}
+
+get_var() {
+       local var="$(sed -n 's/^[[:blank:]]\?'"$1"' "*\([^#";]\+\).*/\1/p' "${chroot}${DHCPD_CONF}")"
+       echo ${var:-$2}
+}
+
+checkconfig() {
+       set -- ${DHCPD_OPTS} ${chroot:+-chroot} ${chroot} -t
+
+       dhcpd "$@" 1>/dev/null 2>&1
+       local ret=$?
+       if [ ${ret} -ne 0 ] ; then
+               eerror "${SVCNAME} has detected a syntax error in your configuration files:"
+               dhcpd "$@"
+       fi
+
+       return ${ret}
+}
+
+configtest() {
+       local chroot=${DHCPD_CHROOT%/}
+
+       ebegin "Checking ${SVCNAME} configuration"
+       checkconfig
+       eend $?
+}
+
+start() {
+       local chroot=${DHCPD_CHROOT%/}
+
+       # Work out our cffile if it's in our DHCPD_OPTS
+       case " ${DHCPD_OPTS} " in
+               *" -cf "*)
+                       DHCPD_CONF=" ${DHCPD_OPTS} "
+                       DHCPD_CONF="${DHCPD_CONF##* -cf }"
+                       DHCPD_CONF="${DHCPD_CONF%% *}"
+                       ;;
+               *)      DHCPD_OPTS="${DHCPD_OPTS} -cf ${DHCPD_CONF}"
+                       ;;
+       esac
+
+       if [ -n "${chroot}" ] ; then
+               # the config test want's these to exist
+               mkdir -p \
+                       "${chroot}"/var/run/dhcp \
+                       "${chroot}"/var/lib/dhcp \
+                       "${chroot}"/etc/dhcp
+       fi
+
+       # see comment in get_var() above
+       if [ ! -f "${chroot}${DHCPD_CONF}" ] ; then
+               eerror "${chroot}${DHCPD_CONF} does not exist"
+               return 1
+       fi
+
+       checkconfig || return 1
+
+       checkpath -d -o dhcp:dhcp "${chroot}"/var/run/dhcp "${chroot}"/var/lib/dhcp
+
+       local leasefile="$(get_var lease-file-name /var/lib/dhcp/${SVCNAME}.leases)"
+       checkpath -f -o dhcp:dhcp "${chroot}${leasefile}"
+
+       # Setup LD_PRELOAD so name resolution works in our chroot.
+       if [ -n "${chroot}" ] ; then
+               checkpath -d -o root:root -m 755 "${chroot}"/dev "${chroot}"/etc "${chroot}"/proc
+               cp -pP /etc/localtime /etc/resolv.conf "${chroot}"/etc/
+               export LD_PRELOAD="${LD_PRELOAD} libresolv.so libnss_dns.so"
+               if ! mountinfo -q "${chroot}/proc" ; then
+                       mount --bind /proc "${chroot}/proc"
+               fi
+       fi
+
+       local pidfile="$(get_var pid-file-name /var/run/dhcp/${SVCNAME}.pid)"
+
+       ebegin "Starting ${chroot:+chrooted }${SVCNAME}"
+       start-stop-daemon --start --exec /usr/sbin/dhcpd \
+               --pidfile "${chroot}/${pidfile}" \
+               -- ${DHCPD_OPTS} -q -pf "${pidfile}" -lf "${leasefile}" \
+               -user dhcp -group dhcp \
+               ${chroot:+-chroot} ${chroot} ${DHCPD_IFACE}
+       eend $? \
+               && save_options chroot "${chroot}" \
+               && save_options pidfile "${pidfile}"
+}
+
+stop() {
+       local chroot="$(get_options chroot)"
+
+       ebegin "Stopping ${chroot:+chrooted }${SVCNAME}"
+       start-stop-daemon --stop --exec /usr/sbin/dhcpd \
+               --pidfile "${chroot}/$(get_options pidfile)"
+       res=$?
+
+       if [ ${res} -eq 0 ] && [ -n "${chroot}" ] ; then
+               if mountinfo -q "${chroot}/proc" ; then
+                       umount "${chroot}/proc"
+               fi
+       fi
+
+       eend $res
+}