1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit systemd toolchain-funcs
8 if [[ ${PV} == "9999" ]]; then
10 EGIT_REPO_URI="https://roy.marples.name/cgit/dhcpcd.git"
12 MY_P="${P/_alpha/-alpha}"
13 MY_P="${MY_P/_beta/-beta}"
14 MY_P="${MY_P/_rc/-rc}"
15 SRC_URI="https://roy.marples.name/downloads/${PN}/${MY_P}.tar.xz"
16 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
17 S="${WORKDIR}/${MY_P}"
20 DESCRIPTION="A fully featured, yet light weight RFC2131 compliant DHCP client"
21 HOMEPAGE="https://roy.marples.name/projects/dhcpcd"
24 IUSE="debug elibc_glibc +embedded ipv6 kernel_linux +privsep +udev"
26 COMMON_DEPEND="udev? ( virtual/udev )"
27 DEPEND="${COMMON_DEPEND}"
38 --dbdir="${EPREFIX}/var/lib/dhcpcd"
39 --libexecdir="${EPREFIX}/lib/dhcpcd"
40 --localstatedir="${EPREFIX}/var"
44 $(use_enable embedded)
47 $(usex elibc_glibc '--with-hook=yp.conf' '')
48 $(usex kernel_linux '--rundir=${EPREFIX}/run' '')
49 $(usex privsep '--privsepuser=dhcpcd' '')
50 $(usex udev '' '--without-dev --without-udev')
53 econf "${myeconfargs[@]}"
58 keepdir /var/lib/dhcpcd
59 newinitd "${FILESDIR}"/${PN}.initd ${PN}
60 systemd_dounit "${FILESDIR}"/${PN}.service
64 local dbdir="${EROOT}"/var/lib/dhcpcd old_files=()
66 local old_old_duid="${EROOT}"/var/lib/dhcpcd/dhcpcd.duid
67 local old_duid="${EROOT}"/etc/dhcpcd.duid
68 local new_duid="${dbdir}"/duid
69 if [[ -e "${old_old_duid}" ]] ; then
70 # Upgrade the duid file to the new format if needed
71 if ! grep -q '..:..:..:..:..:..' "${old_old_duid}"; then
72 sed -i -e 's/\(..\)/\1:/g; s/:$//g' "${old_old_duid}"
75 # Move the duid to /etc, a more sensible location
76 if [[ ! -e "${old_duid}" ]] ; then
77 cp -p "${old_old_duid}" "${new_duid}"
79 old_files+=( "${old_old_duid}" )
82 # dhcpcd-7 moves the files out of /etc
83 if [[ -e "${old_duid}" ]] ; then
84 if [[ ! -e "${new_duid}" ]] ; then
85 cp -p "${old_duid}" "${new_duid}"
87 old_files+=( "${old_duid}" )
89 local old_secret="${EROOT}"/etc/dhcpcd.secret
90 local new_secret="${dbdir}"/secret
91 if [[ -e "${old_secret}" ]] ; then
92 if [[ ! -e "${new_secret}" ]] ; then
93 cp -p "${old_secret}" "${new_secret}"
95 old_files+=( "${old_secret}" )
98 # dhcpcd-7 renames some files in /var/lib/dhcpcd
99 local old_rdm="${dbdir}"/dhcpcd-rdm.monotonic
100 local new_rdm="${dbdir}"/rdm_monotonic
101 if [[ -e "${old_rdm}" ]] ; then
102 if [[ ! -e "${new_rdm}" ]] ; then
103 cp -p "${old_rdm}" "${new_rdm}"
105 old_files+=( "${old_rdm}" )
108 for lease in "${dbdir}"/dhcpcd-*.lease*; do
109 [[ -f "${lease}" ]] || continue
110 old_files+=( "${lease}" )
111 local new_lease=$(basename "${lease}" | sed -e "s/dhcpcd-//")
112 [[ -e "${dbdir}/${new_lease}" ]] && continue
113 cp "${lease}" "${dbdir}/${new_lease}"
116 # dhcpcd-9 introduced privesep support in a chroot
117 if use privsep ; then
118 local dhcpcd_libdir="/var/lib/dhcpcd"
119 local chroot_base="${EROOT}/var/chroot/dhcpcd"
120 local chroot_dir="${chroot_base}${dhcpcd_libdir}"
121 local chroot_retval=0
122 # Set up proper chroot.
123 if [[ ! -e "${chroot_dir}" ]] ; then
124 mkdir -p "${chroot_dir}" || chroot_retval=1
125 cp -a "${EROOT}${dhcpcd_libdir}" "${chroot_dir}" || chroot_retval=1
126 chown -R dhcpcd:dhcpcd "${chroot_dir}" || chroot_retval=1
127 elif [[ ! -d "${chroot_dir}" ]] ; then
128 ewarn "${chroot_dir} is not a directory!"
129 ewarn "Did not set up ${PN} chroot!"
131 if [[ "${chroot_retval}" -ne 0 ]] ; then
132 ewarn "There were issues setting up ${PN} chroot."
136 # Warn about removing stale files
137 if [[ -n "${old_files[@]}" ]] ; then
139 elog "dhcpcd-7 has copied dhcpcd.duid and dhcpcd.secret from"
140 elog "${EROOT}/etc to ${dbdir}"
141 elog "and copied leases in ${dbdir} to new files with the dhcpcd-"
142 elog "prefix dropped."
144 elog "You should remove these files if you don't plan on reverting"
145 elog "to an older version:"
147 for old_file in ${old_files[@]}; do
152 if [ -z "${REPLACING_VERSIONS}" ]; then
154 elog "dhcpcd has zeroconf support active by default."
155 elog "This means it will always obtain an IP address even if no"
156 elog "DHCP server can be contacted, which will break any existing"
157 elog "failover support you may have configured in your net configuration."
158 elog "This behaviour can be controlled with the noipv4ll configuration"
159 elog "file option or the -L command line switch."
160 elog "See the dhcpcd and dhcpcd.conf man pages for more details."
163 elog "Dhcpcd has duid enabled by default, and this may cause issues"
164 elog "with some dhcp servers. For more information, see"
165 elog "https://bugs.gentoo.org/show_bug.cgi?id=477356"
168 if ! has_version net-dns/bind-tools; then
170 elog "If you activate the lookup-hostname hook to look up your hostname"
171 elog "using the dns, you need to install net-dns/bind-tools."