summaryrefslogtreecommitdiff
blob: b2cd3babde33bec90640b314d1a90f8cbb9fdf13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# Copyright 2019-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

PYTHON_COMPAT=( python3_{6,7,8} )

inherit meson linux-info python-any-r1 systemd udev vala

DESCRIPTION="A set of co-operative tools that make networking simple and straightforward"
HOMEPAGE="https://wiki.gnome.org/Projects/NetworkManager"
SRC_URI="https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/archive/${PV}/NetworkManager-${PV}.tar.bz2"

LICENSE="GPL-2+"
SLOT="0" # add subslot if libnm-util.so.2 or libnm-glib.so.4 bumps soname version
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~ppc ~ppc64 ~sparc ~x86"
IUSE="audit bluetooth +concheck connection-sharing consolekit +dhclient dhcpcd "
IUSE+="debug elogind examples +gnutls gtk-doc introspection iwd json kernel_linux "
IUSE+="libpsl lto modemmanager nss ofono ovs +policykit ppp resolvconf selinux "
IUSE+="syslog systemd teamd test +tools vala wext +wifi"

REQUIRED_USE="
	gtk-doc? ( introspection )
	iwd? ( wifi )
	vala? ( introspection )
	^^ ( gnutls nss )
	?? ( consolekit elogind systemd )
	?? ( dhclient dhcpcd )
	?? ( syslog systemd )
"

DEPEND="
	dev-libs/dbus-glib
	dev-libs/glib:2
	net-libs/libndp
	sys-apps/dbus
	sys-kernel/linux-headers
	virtual/libudev
	audit? ( sys-process/audit )
	bluetooth? ( net-wireless/bluez )
	concheck? ( net-misc/curl )
	connection-sharing? (
		net-dns/dnsmasq[dbus,dhcp]
		net-firewall/iptables
	)
	consolekit? ( sys-auth/consolekit )
	dhclient? ( net-misc/dhcp[client] )
	dhcpcd? ( net-misc/dhcpcd )
	elogind? ( sys-auth/elogind )
	gnutls? (
		dev-libs/libgcrypt:0=
		net-libs/gnutls
	)
	introspection? ( dev-libs/gobject-introspection:= )
	json? ( dev-libs/jansson )
	libpsl? ( net-libs/libpsl )
	modemmanager? (
		net-misc/mobile-broadband-provider-info
		net-misc/modemmanager
	)
	nss? ( dev-libs/nss )
	ofono? ( net-misc/ofono )
	ovs? ( dev-libs/jansson )
	policykit? ( sys-auth/polkit )
	ppp? ( net-dialup/ppp[ipv6] )
	resolvconf? ( net-dns/openresolv )
	selinux? ( sys-libs/libselinux )
	systemd? ( sys-apps/systemd:= )
	teamd? (
		dev-libs/jansson
		net-misc/libteam
	)
	tools? (
		dev-libs/newt
		sys-libs/ncurses
		sys-libs/readline:0=
	)
"
RDEPEND="${DEPEND}
	acct-group/plugdev
	|| (
		net-analyzer/arping
		net-misc/iputils[arping(+)]
	)
	wifi? (
		iwd? ( net-wireless/iwd )
		!iwd? ( net-wireless/wpa_supplicant[dbus] )
	)
"
BDEPEND="dev-util/intltool
	gtk-doc? ( dev-util/gtk-doc
		app-text/docbook-xml-dtd:4.1.2 )
	sys-devel/gettext
	virtual/pkgconfig
	introspection? (
		$(python_gen_any_dep 'dev-python/pygobject:3[${PYTHON_USEDEP}]')
		dev-libs/libxslt
		dev-lang/perl
	)
	vala? ( $(vala_depend) )
"

S="${WORKDIR}"/NetworkManager-${PV}

RESTRICT="!test? ( test )"

PATCHES=(
	"${FILESDIR}/${PN}-1.20.6-dont_call_helpers_with_full_paths.patch"
)

python_check_deps() {
	if use introspection; then
		has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
	fi

	if use test; then
		has_version "dev-python/dbus-python[${PYTHON_USEDEP}]" &&
		has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]"
	fi
}

sysfs_deprecated_check() {
	ebegin "Checking for SYSFS_DEPRECATED support"

	if { linux_chkconfig_present SYSFS_DEPRECATED_V2; }; then
		eerror "Please disable SYSFS_DEPRECATED_V2 support in your kernel config and recompile "
		eerror "your kernel or NetworkManager will not work correctly."
		eerror "See https://bugs.gentoo.org/333639 for more info."
		die "CONFIG_SYSFS_DEPRECATED_V2 support detected!"
	fi
	eend ${?}
}

pkg_pretend() {
	if use kernel_linux; then
		get_version
		if linux_config_exists; then
			sysfs_deprecated_check
		else
			ewarn "Was unable to determine your kernel .config"
			ewarn "Please note that if CONFIG_SYSFS_DEPRECATED_V2 is set in your kernel .config, "
			ewarn "NetworkManager will not work correctly."
			ewarn "See https://bugs.gentoo.org/333639 for more info."
		fi
	fi
}

pkg_setup() {
	CONFIG_CHECK="~BPF"

	if use connection-sharing; then
		if kernel_is lt 5 1; then
			CONFIG_CHECK="~NF_NAT_IPV4 ~NF_NAT_MASQUERADE_IPV4"
		else
			CONFIG_CHECK="~NF_NAT ~NF_NAT_MASQUERADE"
		fi
	fi

	linux-info_pkg_setup

	# if use introspection || use test; then
	if use introspection; then
		python-any-r1_pkg_setup
	fi
}

src_prepare() {
	default
	use vala && vala_src_prepare
}

src_configure() {
	local emesonargs=(
		-D systemdsystemunitdir=$(systemd_get_systemunitdir)
		-D system_ca_path=/etc/ssl/certs
		-D udev_dir=$(get_udevdir)
		-D dbus_conf_dir=/usr/share/dbus-1/system.d
		-D kernel_firmware_dir=/lib/firmware
		-D iptables=/sbin/iptables
		#-D dnsmasq=
		#-D dnssec_trigger=

		-D dist_version=${PVR}
		$(meson_use policykit polkit)
		-D modify_system=true
		$(meson_use policykit polkit_agent)
		$(meson_use policykit config_auth_polkit_default)
		$(meson_use selinux)
		$(meson_use systemd systemd_journal)
		-D hostname_persist=gentoo
		-D libaudit=$(usex audit yes no)

		$(meson_use wext)
		$(meson_use wifi)
		$(meson_use iwd)
		$(meson_use ppp)
		#-D pppd='path to pppd binary'
		#-D pppd_plugin_dir='path to the pppd plugins directory'
		$(meson_use modemmanager modem_manager)
		$(meson_use ofono)
		$(meson_use concheck)
		$(meson_use teamd teamdctl)
		$(meson_use ovs)
		$(meson_use tools nmcli)
		$(meson_use tools nmtui)
		$(meson_use tools nm_cloud_setup)
		$(meson_use bluetooth bluez5_dun)
		-D ebpf=true

		-D config_plugins_default=keyfile
		-D ifcfg_rh=false
		-D ifupdown=false

		$(meson_feature resolvconf)
		-D netconfig=disable
		-D config_dns_rc_manager_default=symlink

		$(meson_feature dhclient)
		-D dhcpcanon=disable
		$(meson_feature dhcpcd)

		$(meson_use introspection)
		$(meson_use vala vapi)
		$(meson_use gtk-doc docs)
		# $(meson_use debug more_asserts)
		-D more_asserts=0
		$(meson_use debug more_logging)
		-D valgrind=no
		-D valgrind_suppressions=
		$(meson_use debug ld_gc)
		$(meson_use libpsl)
		$(meson_use json json_validation)
		-D qt=false

		$(meson_use lto b_lto)
	)

	if use consolekit; then
		emesonargs+=( -D session_tracking_consolekit=true )
		emesonargs+=( -D session_tracking=no )
		emesonargs+=( -D suspend_resume=consolekit )
	elif use systemd; then
		emesonargs+=( -D session_tracking_consolekit=false )
		emesonargs+=( -D session_tracking=systemd )
		emesonargs+=( -D suspend_resume=systemd )
	elif use elogind; then
		emesonargs+=( -D session_tracking_consolekit=false )
		emesonargs+=( -D session_tracking=elogind )
		emesonargs+=( -D suspend_resume=elogind )
	else
		emesonargs+=( -D session_tracking_consolekit=false )
		emesonargs+=( -D session_tracking=none )
		emesonargs+=( -D suspend_resume=auto )
	fi

	if use syslog; then
		emesonargs+=( -D config_logging_backend_default=syslog )
	elif use systemd; then
		emesonargs+=( -D config_logging_backend_default=journal )
	else
		emesonargs+=( -D config_logging_backend_default=default )
	fi

	if use dhclient; then
		emesonargs+=( -D config_dhcp_default=dhclient )
	elif use dhcpcd; then
		emesonargs+=( -D config_dhcp_default=dhcpcd )
	else
		emesonargs+=( -D config_dhcp_default=internal )
	fi

	if use nss; then
		emesonargs+=( -D crypto=nss )
	else
		emesonargs+=( -D crypto=gnutls )
	fi

	meson_src_configure
}

src_install() {
	meson_src_install

	newinitd "${FILESDIR}/init.d.NetworkManager-r2" NetworkManager
	newconfd "${FILESDIR}/conf.d.NetworkManager" NetworkManager

	# Need to keep the /etc/NetworkManager/dispatched.d for dispatcher scripts
	keepdir /etc/NetworkManager/dispatcher.d

	# Provide openrc net dependency only when nm is connected
	exeinto /etc/NetworkManager/dispatcher.d
	newexe "${FILESDIR}/10-openrc-status-r4" 10-openrc-status
	sed -e "s:@EPREFIX@:${EPREFIX}:g" \
		-i "${ED}/etc/NetworkManager/dispatcher.d/10-openrc-status" || die

	keepdir /etc/NetworkManager/system-connections
	chmod 0600 "${ED}"/etc/NetworkManager/system-connections/.keep* || die

	# Allow users in plugdev group to modify system connections
	insinto /usr/share/polkit-1/rules.d/
	doins "${FILESDIR}/01-org.freedesktop.NetworkManager.settings.modify.system.rules"

	if use iwd; then
		insinto /usr/lib/NetworkManager/conf.d/
		newins - iwd.conf <<- _EOF_
			[device]
			wifi.backend=iwd
		_EOF_
	fi

	if use examples; then
		dodoc -r "${S}"/examples/

		insinto /usr/lib/NetworkManager/conf.d
		doins "${S}"/examples/nm-conf.d/{30-anon,31-mac-addr-change}.conf

		# Temporary workaround
		cp "${ED}"/usr/share/doc/NetworkManager/examples/server.conf \
			"${ED}"/usr/share/doc/${PF}/examples/ ||
			die "Failed to copy server.conf example."
	fi

	# Temporary workaround,
	# The file will be installed regargless of 'examples' USE.
	rm "${ED}"/usr/share/doc/NetworkManager/examples/server.conf || die
	rm -r "${ED}"/usr/share/doc/NetworkManager || die

	# Empty dirs
	rm -r "${ED}/var" || die
}

pkg_postinst() {
	systemd_reenable NetworkManager.service
}