app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / net-misc / networkmanager / networkmanager-1.8.0.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 GNOME_ORG_MODULE="NetworkManager"
6 GNOME2_LA_PUNT="yes"
7 VALA_USE_DEPEND="vapigen"
8 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
9
10 inherit bash-completion-r1 gnome2 linux-info multilib python-any-r1 systemd \
11         user readme.gentoo-r1 toolchain-funcs vala versionator virtualx udev multilib-minimal
12
13 DESCRIPTION="A set of co-operative tools that make networking simple and straightforward"
14 HOMEPAGE="https://wiki.gnome.org/Projects/NetworkManager"
15
16 LICENSE="GPL-2+"
17 SLOT="0" # add subslot if libnm-util.so.2 or libnm-glib.so.4 bumps soname version
18
19 IUSE="audit bluetooth connection-sharing consolekit +dhclient dhcpcd elogind gnutls +introspection json kernel_linux +nss +modemmanager ncurses ofono policykit +ppp resolvconf selinux systemd teamd test vala +wext +wifi"
20
21 REQUIRED_USE="
22         modemmanager? ( ppp )
23         vala? ( introspection )
24         wext? ( wifi )
25         ^^ ( nss gnutls )
26         ?? ( consolekit elogind systemd )
27 "
28
29 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~ppc ~ppc64 ~sparc ~x86"
30
31 # gobject-introspection-0.10.3 is needed due to gnome bug 642300
32 # wpa_supplicant-0.7.3-r3 is needed due to bug 359271
33 # TODO: need multilib janson (linked to libnm.so)
34 COMMON_DEPEND="
35         >=sys-apps/dbus-1.2[${MULTILIB_USEDEP}]
36         >=dev-libs/dbus-glib-0.100[${MULTILIB_USEDEP}]
37         >=dev-libs/glib-2.37.6:2[${MULTILIB_USEDEP}]
38         >=dev-libs/libnl-3.2.8:3=[${MULTILIB_USEDEP}]
39         policykit? ( >=sys-auth/polkit-0.106 )
40         net-libs/libndp[${MULTILIB_USEDEP}]
41         net-misc/curl
42         net-misc/iputils
43         sys-apps/util-linux[${MULTILIB_USEDEP}]
44         sys-libs/readline:0=
45         >=virtual/libudev-175:=[${MULTILIB_USEDEP}]
46         audit? ( sys-process/audit )
47         bluetooth? ( >=net-wireless/bluez-5 )
48         connection-sharing? (
49                 net-dns/dnsmasq[dbus,dhcp]
50                 net-firewall/iptables )
51         consolekit? ( >=sys-auth/consolekit-1.0.0 )
52         dhclient? ( >=net-misc/dhcp-4[client] )
53         dhcpcd? ( net-misc/dhcpcd )
54         elogind? ( sys-auth/elogind )
55         gnutls? (
56                 dev-libs/libgcrypt:0=[${MULTILIB_USEDEP}]
57                 >=net-libs/gnutls-2.12:=[${MULTILIB_USEDEP}] )
58         introspection? ( >=dev-libs/gobject-introspection-0.10.3:= )
59         json? ( dev-libs/jansson )
60         modemmanager? ( >=net-misc/modemmanager-0.7.991:0= )
61         ncurses? ( >=dev-libs/newt-0.52.15 )
62         nss? ( >=dev-libs/nss-3.11:=[${MULTILIB_USEDEP}] )
63         ofono? ( net-misc/ofono )
64         ppp? ( >=net-dialup/ppp-2.4.5:=[ipv6] )
65         resolvconf? ( net-dns/openresolv )
66         selinux? ( sys-libs/libselinux )
67         systemd? ( >=sys-apps/systemd-209:0= )
68         teamd? (
69                 dev-libs/jansson
70                 >=net-misc/libteam-1.9
71         )
72 "
73 RDEPEND="${COMMON_DEPEND}
74         || (
75                 net-misc/iputils[arping(+)]
76                 net-analyzer/arping
77         )
78         wifi? ( >=net-wireless/wpa_supplicant-0.7.3-r3[dbus] )
79 "
80 DEPEND="${COMMON_DEPEND}
81         dev-util/gdbus-codegen
82         dev-util/gtk-doc-am
83         >=dev-util/intltool-0.40
84         >=sys-devel/gettext-0.17
85         >=sys-kernel/linux-headers-2.6.29
86         virtual/pkgconfig[${MULTILIB_USEDEP}]
87         introspection? (
88                 $(python_gen_any_dep 'dev-python/pygobject:3[${PYTHON_USEDEP}]')
89                 dev-lang/perl
90                 dev-libs/libxslt
91         )
92         vala? ( $(vala_depend) )
93         test? (
94                 $(python_gen_any_dep '
95                         dev-python/dbus-python[${PYTHON_USEDEP}]
96                         dev-python/pygobject:3[${PYTHON_USEDEP}]')
97         )
98 "
99
100 python_check_deps() {
101         if use introspection; then
102                 has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
103         fi
104         if use test; then
105                 has_version "dev-python/dbus-python[${PYTHON_USEDEP}]" &&
106                 has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]"
107         fi
108 }
109
110 sysfs_deprecated_check() {
111         ebegin "Checking for SYSFS_DEPRECATED support"
112
113         if { linux_chkconfig_present SYSFS_DEPRECATED_V2; }; then
114                 eerror "Please disable SYSFS_DEPRECATED_V2 support in your kernel config and recompile your kernel"
115                 eerror "or NetworkManager will not work correctly."
116                 eerror "See https://bugs.gentoo.org/333639 for more info."
117                 die "CONFIG_SYSFS_DEPRECATED_V2 support detected!"
118         fi
119         eend $?
120 }
121
122 pkg_pretend() {
123         if use kernel_linux; then
124                 get_version
125                 if linux_config_exists; then
126                         sysfs_deprecated_check
127                 else
128                         ewarn "Was unable to determine your kernel .config"
129                         ewarn "Please note that if CONFIG_SYSFS_DEPRECATED_V2 is set in your kernel .config, NetworkManager will not work correctly."
130                         ewarn "See https://bugs.gentoo.org/333639 for more info."
131                 fi
132
133         fi
134 }
135
136 pkg_setup() {
137         if use connection-sharing; then
138                 CONFIG_CHECK="~NF_NAT_IPV4 ~NF_NAT_MASQUERADE_IPV4"
139                 linux-info_pkg_setup
140         fi
141         enewgroup plugdev
142         if use introspection || use test; then
143                 python-any-r1_pkg_setup
144         fi
145 }
146
147 src_prepare() {
148         DOC_CONTENTS="To modify system network connections without needing to enter the
149                 root password, add your user account to the 'plugdev' group."
150
151         use vala && vala_src_prepare
152         gnome2_src_prepare
153 }
154
155 multilib_src_configure() {
156         local myconf=(
157                 --disable-more-warnings
158                 --disable-static
159                 --localstatedir=/var
160                 --disable-lto
161                 --disable-config-plugin-ibft
162                 # ifnet plugin always disabled until someone volunteers to actively
163                 # maintain and fix it
164                 --disable-ifnet
165                 --disable-qt
166                 --without-netconfig
167                 --with-dbus-sys-dir=/etc/dbus-1/system.d
168                 # We need --with-libnm-glib (and dbus-glib dep) as reverse deps are
169                 # still not ready for removing that lib
170                 --with-libnm-glib
171                 --with-nmcli=yes
172                 --with-udev-dir="$(get_udevdir)"
173                 --with-config-plugins-default=keyfile
174                 --with-iptables=/sbin/iptables
175                 $(multilib_native_enable concheck)
176                 --with-crypto=$(usex nss nss gnutls)
177                 --with-session-tracking=$(multilib_native_usex systemd systemd $(multilib_native_usex elogind elogind $(multilib_native_usex consolekit consolekit no)))
178                 --with-suspend-resume=$(multilib_native_usex systemd systemd $(multilib_native_usex elogind elogind consolekit))
179                 $(multilib_native_use_with audit libaudit)
180                 $(multilib_native_use_enable bluetooth bluez5-dun)
181                 $(use_with dhclient)
182                 $(use_with dhcpcd)
183                 $(multilib_native_use_enable introspection)
184                 $(multilib_native_use_enable json json-validation)
185                 $(multilib_native_use_enable ppp)
186                 --without-libpsl
187                 $(multilib_native_use_with modemmanager modem-manager-1)
188                 $(multilib_native_use_with ncurses nmtui)
189                 $(multilib_native_use_with ofono)
190                 $(multilib_native_use_with resolvconf)
191                 $(multilib_native_use_with selinux)
192                 $(multilib_native_use_with systemd systemd-journal)
193                 $(multilib_native_use_enable teamd teamdctl)
194                 $(multilib_native_use_enable test tests)
195                 $(multilib_native_use_enable vala)
196                 --without-valgrind
197                 $(multilib_native_use_with wext)
198                 $(multilib_native_use_enable wifi)
199         )
200
201         if multilib_is_native_abi && use policykit; then
202                 myconf+=( --enable-polkit=yes )
203         else
204                 myconf+=( --enable-polkit=disabled )
205         fi
206
207         # Same hack as net-dialup/pptpd to get proper plugin dir for ppp, bug #519986
208         if use ppp; then
209                 local PPPD_VER=`best_version net-dialup/ppp`
210                 PPPD_VER=${PPPD_VER#*/*-} #reduce it to ${PV}-${PR}
211                 PPPD_VER=${PPPD_VER%%[_-]*} # main version without beta/pre/patch/revision
212                 myconf+=( --with-pppd-plugin-dir=/usr/$(get_libdir)/pppd/${PPPD_VER} )
213         fi
214
215         # unit files directory needs to be passed only when systemd is enabled,
216         # otherwise systemd support is not disabled completely, bug #524534
217         use systemd && myconf+=( --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" )
218
219         if multilib_is_native_abi; then
220                 # work-around man out-of-source brokenness, must be done before configure
221                 ln -s "${S}/docs" docs || die
222                 ln -s "${S}/man" man || die
223         fi
224
225         ECONF_SOURCE=${S} runstatedir="/run" gnome2_src_configure "${myconf[@]}"
226 }
227
228 multilib_src_compile() {
229         if multilib_is_native_abi; then
230                 emake
231         else
232                 local targets=(
233                         libnm/libnm.la
234                         libnm-util/libnm-util.la
235                         libnm-glib/libnm-glib.la
236                         libnm-glib/libnm-glib-vpn.la
237                 )
238                 emake "${targets[@]}"
239         fi
240 }
241
242 multilib_src_test() {
243         if use test && multilib_is_native_abi; then
244                 python_setup
245                 virtx emake check
246         fi
247 }
248
249 multilib_src_install() {
250         if multilib_is_native_abi; then
251                 # Install completions at proper place, bug #465100
252                 gnome2_src_install completiondir="$(get_bashcompdir)"
253         else
254                 local targets=(
255                         install-libLTLIBRARIES
256                         install-libdeprecatedHEADERS
257                         install-libnm_glib_libnmvpnHEADERS
258                         install-libnm_glib_libnmincludeHEADERS
259                         install-libnm_util_libnm_util_includeHEADERS
260                         install-libnmincludeHEADERS
261                         install-nodist_libnm_glib_libnmincludeHEADERS
262                         install-nodist_libnm_glib_libnmvpnHEADERS
263                         install-nodist_libnm_util_libnm_util_includeHEADERS
264                         install-nodist_libnmincludeHEADERS
265                         install-pkgconfigDATA
266                 )
267                 emake DESTDIR="${D}" "${targets[@]}"
268         fi
269 }
270
271 multilib_src_install_all() {
272         ! use systemd && readme.gentoo_create_doc
273
274         newinitd "${FILESDIR}/init.d.NetworkManager-r1" NetworkManager
275         newconfd "${FILESDIR}/conf.d.NetworkManager" NetworkManager
276
277         # Need to keep the /etc/NetworkManager/dispatched.d for dispatcher scripts
278         keepdir /etc/NetworkManager/dispatcher.d
279
280         # Provide openrc net dependency only when nm is connected
281         exeinto /etc/NetworkManager/dispatcher.d
282         newexe "${FILESDIR}/10-openrc-status-r4" 10-openrc-status
283         sed -e "s:@EPREFIX@:${EPREFIX}:g" \
284                 -i "${ED}/etc/NetworkManager/dispatcher.d/10-openrc-status" || die
285
286         keepdir /etc/NetworkManager/system-connections
287         chmod 0600 "${ED}"/etc/NetworkManager/system-connections/.keep* # bug #383765, upstream bug #754594
288
289         # Allow users in plugdev group to modify system connections
290         insinto /usr/share/polkit-1/rules.d/
291         doins "${FILESDIR}/01-org.freedesktop.NetworkManager.settings.modify.system.rules"
292 }
293
294 pkg_postinst() {
295         gnome2_pkg_postinst
296         ! use systemd && readme.gentoo_print_elog
297
298         if [[ -e "${EROOT}etc/NetworkManager/nm-system-settings.conf" ]]; then
299                 ewarn "The ${PN} system configuration file has moved to a new location."
300                 ewarn "You must migrate your settings from ${EROOT}/etc/NetworkManager/nm-system-settings.conf"
301                 ewarn "to ${EROOT}etc/NetworkManager/NetworkManager.conf"
302                 ewarn
303                 ewarn "After doing so, you can remove ${EROOT}etc/NetworkManager/nm-system-settings.conf"
304         fi
305
306         # NM fallbacks to plugin specified at compile time (upstream bug #738611)
307         # but still show a warning to remember people to have cleaner config file
308         if [[ -e "${EROOT}etc/NetworkManager/NetworkManager.conf" ]]; then
309                 if grep plugins "${EROOT}etc/NetworkManager/NetworkManager.conf" | grep -q ifnet; then
310                         ewarn
311                         ewarn "You seem to use 'ifnet' plugin in ${EROOT}etc/NetworkManager/NetworkManager.conf"
312                         ewarn "Since it won't be used, you will need to stop setting ifnet plugin there."
313                         ewarn
314                 fi
315         fi
316
317         # NM shows lots of errors making nmcli neither unusable, bug #528748 upstream bug #690457
318         if grep -r "psk-flags=1" "${EROOT}"/etc/NetworkManager/; then
319                 ewarn "You have psk-flags=1 setting in above files, you will need to"
320                 ewarn "either reconfigure affected networks or, at least, set the flag"
321                 ewarn "value to '0'."
322         fi
323 }