dev-python/csv23: arm64 keyworded (bug #719700)
[gentoo.git] / net-misc / dhcpcd / dhcpcd-8.1.9.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit systemd toolchain-funcs
7
8 if [[ ${PV} == "9999" ]]; then
9         inherit git-r3
10         EGIT_REPO_URI="https://roy.marples.name/git/dhcpcd.git"
11 else
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}"
18 fi
19
20 DESCRIPTION="A fully featured, yet light weight RFC2131 compliant DHCP client"
21 HOMEPAGE="https://roy.marples.name/projects/dhcpcd"
22 LICENSE="BSD-2"
23 SLOT="0"
24 IUSE="elibc_glibc +embedded ipv6 kernel_linux +udev"
25
26 COMMON_DEPEND="udev? ( virtual/udev )"
27 DEPEND="${COMMON_DEPEND}"
28 RDEPEND="${COMMON_DEPEND}"
29
30 src_configure() {
31         local myeconfargs=(
32                 --dbdir="${EPREFIX}/var/lib/dhcpcd"
33                 --libexecdir="${EPREFIX}/lib/dhcpcd"
34                 --localstatedir="${EPREFIX}/var"
35                 --prefix="${EPREFIX}"
36                 --with-hook=ntp.conf
37                 $(use_enable embedded)
38                 $(use_enable ipv6)
39                 $(usex elibc_glibc '--with-hook=yp.conf' '')
40                 $(usex kernel_linux '--rundir=${EPREFIX}/run' '')
41                 $(usex udev '' '--without-dev --without-udev')
42                 CC="$(tc-getCC)"
43         )
44         econf "${myeconfargs[@]}"
45 }
46
47 src_install() {
48         default
49         keepdir /var/lib/dhcpcd
50         newinitd "${FILESDIR}"/${PN}.initd ${PN}
51         systemd_dounit "${FILESDIR}"/${PN}.service
52 }
53
54 pkg_postinst() {
55         local dbdir="${EROOT}"/var/lib/dhcpcd old_files=()
56
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}"
64                 fi
65
66                 # Move the duid to /etc, a more sensible location
67                 if [[ ! -e "${old_duid}" ]] ; then
68                         cp -p "${old_old_duid}" "${new_duid}"
69                 fi
70                 old_files+=( "${old_old_duid}" )
71         fi
72
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}"
77                 fi
78                 old_files+=( "${old_duid}" )
79         fi
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}"
85                 fi
86                 old_files+=( "${old_secret}" )
87         fi
88
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}"
95                 fi
96                 old_files+=( "${old_rdm}" )
97         fi
98         local lease=
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}"
105         done
106
107         # Warn about removing stale files
108         if [[ -n "${old_files[@]}" ]] ; then
109                 elog
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."
114                 elog
115                 elog "You should remove these files if you don't plan on reverting"
116                 elog "to an older version:"
117                 local old_file=
118                 for old_file in ${old_files[@]}; do
119                         elog "  ${old_file}"
120                 done
121         fi
122
123         if [ -z "${REPLACING_VERSIONS}" ]; then
124                 elog
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."
132
133                 elog
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"
137         fi
138
139         if ! has_version net-dns/bind-tools; then
140                 elog
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."
143         fi
144 }