1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 GNOME_ORG_MODULE="NetworkManager"
7 VALA_USE_DEPEND="vapigen"
8 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
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
13 DESCRIPTION="A set of co-operative tools that make networking simple and straightforward"
14 HOMEPAGE="https://wiki.gnome.org/Projects/NetworkManager"
17 SLOT="0" # add subslot if libnm-util.so.2 or libnm-glib.so.4 bumps soname version
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"
23 vala? ( introspection )
26 ?? ( consolekit elogind systemd )
29 KEYWORDS="~alpha amd64 ~arm ~arm64 ~ia64 ppc ppc64 ~sparc x86"
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)
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}]
43 sys-apps/util-linux[${MULTILIB_USEDEP}]
45 >=virtual/libudev-175:=[${MULTILIB_USEDEP}]
46 audit? ( sys-process/audit )
47 bluetooth? ( >=net-wireless/bluez-5 )
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-219 )
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= )
70 >=net-misc/libteam-1.9
73 RDEPEND="${COMMON_DEPEND}
75 net-misc/iputils[arping(+)]
78 wifi? ( >=net-wireless/wpa_supplicant-0.7.3-r3[dbus] )
80 DEPEND="${COMMON_DEPEND}
81 dev-util/gdbus-codegen
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}]
88 $(python_gen_any_dep 'dev-python/pygobject:3[${PYTHON_USEDEP}]')
92 vala? ( $(vala_depend) )
94 $(python_gen_any_dep '
95 dev-python/dbus-python[${PYTHON_USEDEP}]
96 dev-python/pygobject:3[${PYTHON_USEDEP}]')
100 python_check_deps() {
101 if use introspection; then
102 has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
105 has_version "dev-python/dbus-python[${PYTHON_USEDEP}]" &&
106 has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]"
110 sysfs_deprecated_check() {
111 ebegin "Checking for SYSFS_DEPRECATED support"
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!"
123 if use kernel_linux; then
125 if linux_config_exists; then
126 sysfs_deprecated_check
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."
137 if use connection-sharing; then
138 CONFIG_CHECK="~NF_NAT_IPV4 ~NF_NAT_MASQUERADE_IPV4"
142 if use introspection || use test; then
143 python-any-r1_pkg_setup
148 DOC_CONTENTS="To modify system network connections without needing to enter the
149 root password, add your user account to the 'plugdev' group."
151 use vala && vala_src_prepare
155 multilib_src_configure() {
157 --disable-more-warnings
161 --disable-config-plugin-ibft
162 # ifnet plugin always disabled until someone volunteers to actively
163 # maintain and fix it
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
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)
183 $(multilib_native_use_enable introspection)
184 $(multilib_native_use_enable json json-validation)
185 $(multilib_native_use_enable ppp)
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)
197 $(multilib_native_use_with wext)
198 $(multilib_native_use_enable wifi)
201 if multilib_is_native_abi && use policykit; then
202 myconf+=( --enable-polkit=yes )
204 myconf+=( --enable-polkit=disabled )
207 # Same hack as net-dialup/pptpd to get proper plugin dir for ppp, bug #519986
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} )
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)" )
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
225 ECONF_SOURCE=${S} runstatedir="/run" gnome2_src_configure "${myconf[@]}"
228 multilib_src_compile() {
229 if multilib_is_native_abi; then
234 libnm-util/libnm-util.la
235 libnm-glib/libnm-glib.la
236 libnm-glib/libnm-glib-vpn.la
238 emake "${targets[@]}"
242 multilib_src_test() {
243 if use test && multilib_is_native_abi; then
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)"
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
267 emake DESTDIR="${D}" "${targets[@]}"
271 multilib_src_install_all() {
272 ! use systemd && readme.gentoo_create_doc
274 newinitd "${FILESDIR}/init.d.NetworkManager-r1" NetworkManager
275 newconfd "${FILESDIR}/conf.d.NetworkManager" NetworkManager
277 # Need to keep the /etc/NetworkManager/dispatched.d for dispatcher scripts
278 keepdir /etc/NetworkManager/dispatcher.d
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
286 keepdir /etc/NetworkManager/system-connections
287 chmod 0600 "${ED}"/etc/NetworkManager/system-connections/.keep* # bug #383765, upstream bug #754594
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"
296 systemd_reenable NetworkManager.service
297 ! use systemd && readme.gentoo_print_elog
299 if [[ -e "${EROOT}etc/NetworkManager/nm-system-settings.conf" ]]; then
300 ewarn "The ${PN} system configuration file has moved to a new location."
301 ewarn "You must migrate your settings from ${EROOT}/etc/NetworkManager/nm-system-settings.conf"
302 ewarn "to ${EROOT}etc/NetworkManager/NetworkManager.conf"
304 ewarn "After doing so, you can remove ${EROOT}etc/NetworkManager/nm-system-settings.conf"
307 # NM fallbacks to plugin specified at compile time (upstream bug #738611)
308 # but still show a warning to remember people to have cleaner config file
309 if [[ -e "${EROOT}etc/NetworkManager/NetworkManager.conf" ]]; then
310 if grep plugins "${EROOT}etc/NetworkManager/NetworkManager.conf" | grep -q ifnet; then
312 ewarn "You seem to use 'ifnet' plugin in ${EROOT}etc/NetworkManager/NetworkManager.conf"
313 ewarn "Since it won't be used, you will need to stop setting ifnet plugin there."
318 # NM shows lots of errors making nmcli neither unusable, bug #528748 upstream bug #690457
319 if grep -r "psk-flags=1" "${EROOT}"/etc/NetworkManager/; then
320 ewarn "You have psk-flags=1 setting in above files, you will need to"
321 ewarn "either reconfigure affected networks or, at least, set the flag"
322 ewarn "value to '0'."