dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / net-misc / dhcpcd / dhcpcd-9.0.1.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/cgit/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="debug elibc_glibc +embedded ipv6 kernel_linux +privsep +udev"
25
26 COMMON_DEPEND="udev? ( virtual/udev )"
27 DEPEND="${COMMON_DEPEND}"
28 RDEPEND="
29         ${COMMON_DEPEND}
30         privsep? (
31                 acct-group/dhcpcd
32                 acct-user/dhcpcd
33         )
34 "
35
36 src_configure() {
37         local myeconfargs=(
38                 --dbdir="${EPREFIX}/var/lib/dhcpcd"
39                 --libexecdir="${EPREFIX}/lib/dhcpcd"
40                 --localstatedir="${EPREFIX}/var"
41                 --prefix="${EPREFIX}"
42                 --with-hook=ntp.conf
43                 $(use_enable debug)
44                 $(use_enable embedded)
45                 $(use_enable ipv6)
46                 $(use_enable privsep)
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')
51                 CC="$(tc-getCC)"
52         )
53         econf "${myeconfargs[@]}"
54 }
55
56 src_install() {
57         default
58         keepdir /var/lib/dhcpcd
59         newinitd "${FILESDIR}"/${PN}.initd ${PN}
60         systemd_dounit "${FILESDIR}"/${PN}.service
61 }
62
63 pkg_postinst() {
64         local dbdir="${EROOT}"/var/lib/dhcpcd old_files=()
65
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}"
73                 fi
74
75                 # Move the duid to /etc, a more sensible location
76                 if [[ ! -e "${old_duid}" ]] ; then
77                         cp -p "${old_old_duid}" "${new_duid}"
78                 fi
79                 old_files+=( "${old_old_duid}" )
80         fi
81
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}"
86                 fi
87                 old_files+=( "${old_duid}" )
88         fi
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}"
94                 fi
95                 old_files+=( "${old_secret}" )
96         fi
97
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}"
104                 fi
105                 old_files+=( "${old_rdm}" )
106         fi
107         local lease=
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}"
114         done
115
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!"
130                 fi
131                 if [[ "${chroot_retval}" -ne 0 ]] ; then
132                         ewarn "There were issues setting up ${PN} chroot."
133                 fi
134         fi
135
136         # Warn about removing stale files
137         if [[ -n "${old_files[@]}" ]] ; then
138                 elog
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."
143                 elog
144                 elog "You should remove these files if you don't plan on reverting"
145                 elog "to an older version:"
146                 local old_file=
147                 for old_file in ${old_files[@]}; do
148                         elog "  ${old_file}"
149                 done
150         fi
151
152         if [ -z "${REPLACING_VERSIONS}" ]; then
153                 elog
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."
161
162                 elog
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"
166         fi
167
168         if ! has_version net-dns/bind-tools; then
169                 elog
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."
172         fi
173 }