gentoo-ebuilds/eclass/tests/systemd.sh
Eli Schwartz 31153db1f4
systemd.eclass: make all fallback paths use /usr/lib
Back in 2018, the eclass was changed to ensure that the canonical path
used for results was in /lib, since that works for split-usr systems
running systemd while also supporting merged-usr systems due to portage
following symlinks at install time. It even works for binpkgs.

But here and now in 2025, systemd doesn't support split-usr at all.
There is no point in having unit files install conservatively in
/lib/systemd. Update the path to accommodate the new reality.

This mostly has no effect. On openrc profiles, or for packages that use
systemd_dounit without pulling in pkgconfig, binpkgs will be created
with a different, but still working path, which then triggers iwdevtools
warnings when you reinstall a former binpkg from source, as it thinks
the file has "moved". e.g.

```
 * CMP: =net-misc/radvd-2.19-r7 with net-misc/radvd-2.20/image
 *  FILES:-lib/systemd/system/radvd.service
 *  FILES:+usr/lib/systemd/system/radvd.service
 * ------> FILES(+1,-1)
```

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Sam James <sam@gentoo.org>
2025-04-23 16:17:40 +01:00

50 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
source tests-common.sh || exit
inherit systemd
test_system_dir() {
local exp1="${EPREFIX}$1"
local exp2="${EPREFIX}/usr$1"
shift
tbegin "$@"
local act=$("$@")
[[ ${act} == ${exp1} || ${act} == ${exp2} ]]
tend $?
}
test_user_dir() {
local exp="${EPREFIX}$1"
shift
tbegin "$@"
local act=$("$@")
[[ ${act} == ${exp} ]]
tend $?
}
test_systemd_unprefix() {
local exp=$1
local EPREFIX=$2
shift 2
tbegin "EPREFIX=${EPREFIX} _systemd_unprefix $@"
[[ "$(_systemd_unprefix "$@")" == "${exp}" ]]
tend $?
}
test_system_dir /usr/lib/systemd/system systemd_get_systemunitdir
test_system_dir /usr/lib/systemd systemd_get_utildir
test_system_dir /usr/lib/systemd/system-generators systemd_get_systemgeneratordir
test_system_dir /usr/lib/systemd/system-preset systemd_get_systempresetdir
test_system_dir /usr/lib/systemd/system-sleep systemd_get_sleepdir
test_user_dir /usr/lib/systemd/user systemd_get_userunitdir
test_systemd_unprefix /lib/systemd /prefix echo /prefix/lib/systemd
test_systemd_unprefix /lib/systemd '' echo /lib/systemd
test_systemd_unprefix /lib/systemd '/*' echo '/*/lib/systemd'
texit