summaryrefslogtreecommitdiff
path: root/sys-apps/systemd-utils/systemd-utils-259.3.ebuild
blob: 32fd193dc0bde33f70174ffbb40fc063de073f7c (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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# Copyright 2022-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
PYTHON_COMPAT=( python3_{11..14} )
QA_PKGCONFIG_VERSION=$(ver_cut 1)

# Avoid QA warnings about these eclasses
TMPFILES_OPTIONAL=1
UDEV_OPTIONAL=1

inherit linux-info meson-multilib
inherit python-single-r1 secureboot shell-completion udev

DESCRIPTION="Utilities split out from systemd for OpenRC users"
HOMEPAGE="https://systemd.io/"

MY_P="systemd-${PV}"
SRC_URI="https://github.com/systemd/systemd/archive/refs/tags/v${PV}.tar.gz -> ${MY_P}.tar.gz"
S="${WORKDIR}/${MY_P}"

LICENSE="GPL-2 LGPL-2.1 MIT public-domain"
SLOT="0"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86"
IUSE="+acl boot +kmod kernel-install selinux split-usr sysusers +tmpfiles test +udev ukify"
REQUIRED_USE="
	|| ( kernel-install tmpfiles sysusers udev )
	boot? ( kernel-install )
	ukify? ( boot )
	${PYTHON_REQUIRED_USE}
"
RESTRICT="!test? ( test )"

COMMON_DEPEND="
	selinux? ( sys-libs/libselinux:0= )
	tmpfiles? (
		acl? ( sys-apps/acl:0= )
	)
	udev? (
		>=sys-apps/util-linux-2.30:0=
		acl? ( sys-apps/acl:0= )
		kmod? ( >=sys-apps/kmod-15:0= )
	)
"
DEPEND="${COMMON_DEPEND}
	virtual/libcrypt:=[${MULTILIB_USEDEP}]
	>=sys-kernel/linux-headers-3.11
"

PEFILE_DEPEND='dev-python/pefile[${PYTHON_USEDEP}]'

RDEPEND="${COMMON_DEPEND}
	virtual/libcrypt:=
	boot? ( !<sys-boot/systemd-boot-250 )
	ukify? (
		${PYTHON_DEPS}
		$(python_gen_cond_dep "${PEFILE_DEPEND}")
	)
	tmpfiles? ( !<sys-apps/systemd-tmpfiles-250 )
	udev? (
		acct-group/audio
		acct-group/cdrom
		acct-group/dialout
		acct-group/disk
		acct-group/floppy
		acct-group/input
		acct-group/kmem
		acct-group/kvm
		acct-group/lp
		acct-group/render
		acct-group/sgx
		acct-group/tape
		acct-group/tty
		acct-group/usb
		acct-group/video
		!sys-apps/gentoo-systemd-integration
		!<sys-fs/udev-250
		!sys-fs/eudev
	)
	!sys-apps/systemd
"
PDEPEND="
	udev? ( >=sys-fs/udev-init-scripts-34 )
"
BDEPEND="
	app-text/docbook-xml-dtd:4.2
	app-text/docbook-xml-dtd:4.5
	app-text/docbook-xsl-stylesheets
	dev-libs/libxslt
	dev-util/gperf
	dev-util/patchelf
	>=sys-apps/coreutils-8.16
	sys-devel/gettext
	virtual/pkgconfig
	$(python_gen_cond_dep "
		dev-python/jinja2[\${PYTHON_USEDEP}]
		boot? (
			>=dev-python/pyelftools-0.30[\${PYTHON_USEDEP}]
			test? ( ${PEFILE_DEPEND} )
		)
	")
"

QA_EXECSTACK="usr/lib/systemd/boot/efi/*"
QA_FLAGS_IGNORED="usr/lib/systemd/boot/efi/.*"

CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED
	~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~UNIX"

pkg_setup() {
	if [[ ${MERGE_TYPE} != buildonly ]] && use udev; then
		linux-info_pkg_setup
	fi
	use boot && secureboot_pkg_setup
}

src_configure() {
	python_setup
	meson-multilib_src_configure
}

multilib_src_configure() {
	local emesonargs=(
		--auto-features=disabled
		--localstatedir="${EPREFIX}/var"
		-Ddocdir="share/doc/${PF}"

		# default is developer, bug 918671
		-Dmode=release
		-Dlibc=$(usex elibc_musl musl glibc)
		-Dsysvinit-path=

		$(meson_native_use_feature boot bootloader)
		$(meson_native_use_bool kernel-install)
		$(meson_native_enabled man)
		$(meson_native_use_feature selinux)
		$(meson_use split-usr split-bin)
		$(meson_native_use_bool sysusers)
		$(meson_native_use_bool tmpfiles)
		$(meson_native_use_feature udev blkid)
		$(meson_native_use_feature udev libmount)
		$(meson_use udev hwdb)
		$(meson_native_use_feature ukify)

		-Dadm-group=false
		-Danalyze=false
		-Dbacklight=false
		-Dbinfmt=false
		-Dcreate-log-dirs=false
		-Dcoredump=false
		-Ddns-over-tls=false
		-Denvironment-d=false
		-Dhibernate=false
		-Dhostnamed=false
		-Didn=false
		-Dima=false
		-Dinitrd=false
		-Dipe=false
		-Dfirstboot=false
		-Dldconfig=false
		-Dlocaled=false
		-Dlogind=false
		-Dmachined=false
		-Dmountfsd=false
		-Dnetworkd=false
		-Dnsresourced=false
		-Dnss-myhostname=false
		-Dnss-systemd=false
		-Doomd=false
		-Dportabled=false
		-Dpstore=false
		-Dquotacheck=false
		-Drandomseed=false
		-Dresolve=false
		-Drfkill=false
		-Dsmack=false
		-Dstoragetm=false
		-Dsysext=false
		-Dtimedated=false
		-Dtimesyncd=false
		-Dtpm=false
		-Durlify=false
		-Duserdb=false
		-Dutmp=false
		-Dvconsole=false
		-Dwheel-group=false
		-Dxdg-autostart=false
		-Dxenctrl=false

		-Dbashcompletiondir=no
		-Ddbus-interfaces-dir=no
		-Drpmmacrosdir=no
		-Dshellprofiledir=no
		-Dsshconfdir=no
		-Dsshdconfdir=no
		-Dsshdprivsepdir=no
		-Dzshcompletiondir=no
	)

	# workaround for bug 969103
	if [[ ${CHOST} == riscv32* ]] ; then
		emesonargs+=( -Dtests=true )
	else
		emesonargs+=( $(meson_use test tests) )
	fi

	if use tmpfiles || use udev; then
		emesonargs+=( $(meson_native_use_feature acl) )
	fi

	if use udev; then
		emesonargs+=( $(meson_native_use_feature kmod) )
	fi

	meson_src_configure
}

multilib_src_compile() {
	if multilib_is_native_abi; then
		meson_src_compile
	elif use udev; then
		meson_src_compile libudev src/libudev/libudev.pc
	fi
}

multilib_src_test() {
	local args=()
	use udev && args+=( --suite libudev )
	if multilib_is_native_abi; then
		use boot && args+=( --suite boot )
		use kernel-install && args+=( --suite kernel-install )
		use sysusers && args+=( --suite sysusers )
		use tmpfiles && args+=( --suite tmpfiles )
		use udev && args+=( --suite udev )
	fi
	if [[ ${#args[@]} -gt 0 ]]; then
		meson_src_test "${args[@]}"
	fi
}

installx() {
	local dir f
	for f in "$@"; do
		dir="${f%/*}"
		dir="/${dir#/}"
		dodir "${dir}"
		mv -v "${ed}"/${f#/} "${ED}${dir}/" || die
	done
}

multilib_src_install() {
	local d="${WORKDIR}/install"
	local ed="${d}${EPREFIX}"

	if use udev; then
		meson_install --no-rebuild --tags libudev
		insinto "/usr/$(get_libdir)/pkgconfig"
		doins src/libudev/libudev.pc
	fi

	multilib_is_native_abi || return

	meson_install --no-rebuild --destdir "${d}"

	installx "usr/$(get_libdir)/systemd/libsystemd-shared-${PV%%.*}.so"
	installx usr/share/locale
	installx usr/lib/sysctl.d

	if use boot; then
		installx usr/bin/bootctl
		installx usr/share/man/man1/bootctl.1
		installx usr/lib/systemd/boot
	fi

	if use kernel-install; then
		installx usr/bin/kernel-install
		installx usr/share/man/man8/kernel-install.8
		installx usr/lib/kernel
	fi

	if use sysusers; then
		installx usr/bin/systemd-sysusers
		installx usr/share/man/{man5/sysusers.d.5,man8/systemd-sysusers.8}
	fi

	if use tmpfiles; then
		installx usr/bin/systemd-tmpfiles
		installx usr/lib/tmpfiles.d/{etc,home,static-nodes-permissions,var}.conf
		installx usr/share/man/{man5/tmpfiles.d.5,man8/systemd-tmpfiles.8}
	fi

	if use udev; then
		installx etc/udev
		installx usr/bin/systemd-hwdb
		installx usr/bin/udevadm
		if use split-usr; then
			# elogind installs udev rules that hard-code /bin/udevadm
			dosym ../usr/bin/udevadm /bin/udevadm
		fi
		installx usr/lib/systemd/systemd-sysctl
		installx usr/lib/systemd/systemd-udevd
		installx usr/lib/systemd/network/99-default.link
		installx usr/lib/udev
		installx usr/share/pkgconfig/udev.pc
		installx usr/share/man/man5/{iocost.conf.5,systemd.link.5,udev.conf.5}
		installx usr/share/man/man7/{hwdb.7,udev.7}
		installx usr/share/man/man8/{systemd-hwdb.8,udevadm.8}
		mv -v "${ed}"/usr/share/man/man8/systemd-udevd.service.8 \
			"${ED}"/usr/share/man/man8/systemd-udevd.8 || die
		installx usr/share/man/man3/libudev.3 "usr/share/man/man3/udev_*"
	fi

	if use ukify; then
		installx usr/bin/ukify usr/lib/systemd/ukify
		installx usr/share/man/man1/ukify.1
	fi
}

multilib_src_install_all() {
	einstalldocs

	if use boot; then
		dobashcomp shell-completion/bash/bootctl
		dozshcomp shell-completion/zsh/_bootctl
	fi

	if use kernel-install; then
		dobashcomp shell-completion/bash/kernel-install
		dozshcomp shell-completion/zsh/_kernel-install

		# Dummy config, remove to make room for sys-kernel/installkernel
		rm "${ED}/usr/lib/kernel/install.conf" || die
	fi

	if use tmpfiles; then
		#dobashcomp shell-completion/zsh/systemd-tmpfiles
		dozshcomp shell-completion/zsh/_systemd-tmpfiles
		insinto /usr/lib/tmpfiles.d
		doins "${FILESDIR}"/{legacy,tmp}.conf
		doinitd "${FILESDIR}"/systemd-tmpfiles-setup
		doinitd "${FILESDIR}"/systemd-tmpfiles-setup-dev
		exeinto /etc/cron.daily
		doexe "${FILESDIR}"/systemd-tmpfiles-clean
	fi

	if use udev; then
		doheader src/libudev/libudev.h
		dobashcomp shell-completion/bash/udevadm
		dozshcomp shell-completion/zsh/_udevadm
		# Avoid udev_dorules to avoid picking up stale udevdir from pkg-config
		insinto /usr/lib/udev/rules.d
		doins "${FILESDIR}"/40-gentoo.rules
	fi

	use ukify && python_fix_shebang "${ED}"
	use boot && secureboot_auto_sign
}

add_service() {
	local initd=$1
	local runlevel=$2

	ebegin "Adding '${initd}' service to the '${runlevel}' runlevel"
	mkdir -p "${EROOT}/etc/runlevels/${runlevel}" &&
	ln -snf "${EPREFIX}/etc/init.d/${initd}" "${EROOT}/etc/runlevels/${runlevel}/${initd}"
	eend $?
}

pkg_preinst() {
	# Migrate /lib/{systemd,udev} to /usr/lib
	if use split-usr; then
		local d
		for d in systemd udev; do
			dosym ../usr/lib/${d} /lib/${d}
			if [[ -e ${EROOT}/lib/${d} && ! -L ${EROOT}/lib/${d} ]]; then
				einfo "Copying files from '${EROOT}/lib/${d}' to '${EROOT}/usr/lib/${d}'"
				cp -rpPT "${EROOT}/lib/${d}" "${EROOT}/usr/lib/${d}" || die
				einfo "Removing '${EROOT}/lib/${d}'"
				rm -r "${EROOT}/lib/${d}" || die
			fi
		done
	fi
}

pkg_postinst() {
	if [[ -z ${REPLACING_VERSIONS} ]]; then
		add_service systemd-tmpfiles-setup-dev sysinit
		add_service systemd-tmpfiles-setup boot
	fi
	if use udev; then
		ebegin "Updating hwdb"
		systemd-hwdb --root="${ROOT}" update
		eend $?
		udev_reload
	fi
}