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/git/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="elibc_glibc +embedded ipv6 kernel_linux +udev"
26 COMMON_DEPEND="udev? ( virtual/udev )"
27 DEPEND="${COMMON_DEPEND}"
28 RDEPEND="${COMMON_DEPEND}"
32 --dbdir="${EPREFIX}/var/lib/dhcpcd"
33 --libexecdir="${EPREFIX}/lib/dhcpcd"
34 --localstatedir="${EPREFIX}/var"
37 $(use_enable embedded)
39 $(usex elibc_glibc '--with-hook=yp.conf' '')
40 $(usex kernel_linux '--rundir=${EPREFIX}/run' '')
41 $(usex udev '' '--without-dev --without-udev')
44 econf "${myeconfargs[@]}"
49 keepdir /var/lib/dhcpcd
50 newinitd "${FILESDIR}"/${PN}.initd ${PN}
51 systemd_dounit "${FILESDIR}"/${PN}.service
55 local dbdir="${EROOT}"/var/lib/dhcpcd old_files=()
57 local old_old_duid="${EROOT}"/var/lib/dhcpcd/dhcpcd.duid
58 local old_duid="${EROOT}"/etc/dhcpcd.duid
59 local new_duid="${dbdir}"/duid
60 if [[ -e "${old_old_duid}" ]] ; then
61 # Upgrade the duid file to the new format if needed
62 if ! grep -q '..:..:..:..:..:..' "${old_old_duid}"; then
63 sed -i -e 's/\(..\)/\1:/g; s/:$//g' "${old_old_duid}"
66 # Move the duid to /etc, a more sensible location
67 if [[ ! -e "${old_duid}" ]] ; then
68 cp -p "${old_old_duid}" "${new_duid}"
70 old_files+=( "${old_old_duid}" )
73 # dhcpcd-7 moves the files out of /etc
74 if [[ -e "${old_duid}" ]] ; then
75 if [[ ! -e "${new_duid}" ]] ; then
76 cp -p "${old_duid}" "${new_duid}"
78 old_files+=( "${old_duid}" )
80 local old_secret="${EROOT}"/etc/dhcpcd.secret
81 local new_secret="${dbdir}"/secret
82 if [[ -e "${old_secret}" ]] ; then
83 if [[ ! -e "${new_secret}" ]] ; then
84 cp -p "${old_secret}" "${new_secret}"
86 old_files+=( "${old_secret}" )
89 # dhcpcd-7 renames some files in /var/lib/dhcpcd
90 local old_rdm="${dbdir}"/dhcpcd-rdm.monotonic
91 local new_rdm="${dbdir}"/rdm_monotonic
92 if [[ -e "${old_rdm}" ]] ; then
93 if [[ ! -e "${new_rdm}" ]] ; then
94 cp -p "${old_rdm}" "${new_rdm}"
96 old_files+=( "${old_rdm}" )
99 for lease in "${dbdir}"/dhcpcd-*.lease*; do
100 [[ -f "${lease}" ]] || continue
101 old_files+=( "${lease}" )
102 local new_lease=$(basename "${lease}" | sed -e "s/dhcpcd-//")
103 [[ -e "${dbdir}/${new_lease}" ]] && continue
104 cp "${lease}" "${dbdir}/${new_lease}"
107 # Warn about removing stale files
108 if [[ -n "${old_files[@]}" ]] ; then
110 elog "dhcpcd-7 has copied dhcpcd.duid and dhcpcd.secret from"
111 elog "${EROOT}/etc to ${dbdir}"
112 elog "and copied leases in ${dbdir} to new files with the dhcpcd-"
113 elog "prefix dropped."
115 elog "You should remove these files if you don't plan on reverting"
116 elog "to an older version:"
118 for old_file in ${old_files[@]}; do
123 if [ -z "${REPLACING_VERSIONS}" ]; then
125 elog "dhcpcd has zeroconf support active by default."
126 elog "This means it will always obtain an IP address even if no"
127 elog "DHCP server can be contacted, which will break any existing"
128 elog "failover support you may have configured in your net configuration."
129 elog "This behaviour can be controlled with the noipv4ll configuration"
130 elog "file option or the -L command line switch."
131 elog "See the dhcpcd and dhcpcd.conf man pages for more details."
134 elog "Dhcpcd has duid enabled by default, and this may cause issues"
135 elog "with some dhcp servers. For more information, see"
136 elog "https://bugs.gentoo.org/show_bug.cgi?id=477356"
139 if ! has_version net-dns/bind-tools; then
141 elog "If you activate the lookup-hostname hook to look up your hostname"
142 elog "using the dns, you need to install net-dns/bind-tools."