systemd: move systemd-systemctl-native PACKAGE_WRITE_DEPS to systemd.bb
PATCH v2 1/7 systemd: move systemd-systemctl-native PACKAGE_WRITE_DEPS to systemd.bb
PACKAGE_WRITE_DEPS[1] is used to define package dependencies that are needed at rootfs time, for example when a postinst can use a native tool.
We allow distros to build recipes that support both systemd and sysv at the same time, and the post-install script generated by systemd.bbclass will use systemctl (via systemd-systemctl-native) at rootfs time to install the units and thus generate the required symlinks.
Presently the dependency on systemctl-native is added to recipes via systemd.bbclass but this results in all recipes that inherit that class having the dependencies. This is actually suboptimal: at rootfs time the key requirement is to install the units if and only if systemd is being used.
We can move the PACKAGE_WRITE_DEPS dependency on systemd-systemctl-native from each recipe (via the class) to systemd itself so units are installed if systemd is present, and not otherwise.
This means recipes don't depend on systemd-systemctl-native (which has non-trivial build dependencies itself), and the units are not installed in non-systemd deployments.
[1] https://docs.yoctoproject.org/ref-manual/variables.html#term-PACKAGE_WRITE_DEPS
--- meta/classes-recipe/systemd.bbclass | 1 - meta/recipes-core/systemd/systemd_259.5.bb | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
meta/classes-recipe/systemd.bbclass +0 -1
@@ -22,7 +22,6 @@ python __anonymous() { # redundant init files. if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d): d.appendVar("DEPENDS", " systemd-systemctl-native") - d.appendVar("PACKAGE_WRITE_DEPS", " systemd-systemctl-native") d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") }
meta/recipes-core/systemd/systemd_259.5.bb +4 -0
@@ -22,6 +22,10 @@ REQUIRED_DISTRO_FEATURES += "systemd" # this and hence we can no longer support it CONFLICT_DISTRO_FEATURES += "sysvinit" +# Ensure that the native tools are available when we're building a rootfs with systemd in, +# so that systemctl can be used in postinst scripts +PACKAGE_WRITE_DEPS += "systemd-systemctl-native" + SRC_URI += " \ file://touchscreen.rules \ file://00-create-volatile.conf \
Signature · 1 line
2.43.0
PATCH v2 2/7 classes/systemd: remove obsolete DEPENDS
Recipes that use systemd don't need systemctl at build time, so this dependency can be removed.
It was added in [1] but no rationale was given or is obvious.
[1] oe-core e9444649f4 ("systemd: Restore mask and preset targets, fix instance creation")
--- meta/classes-recipe/systemd.bbclass | 1 - 1 file changed, 1 deletion(-)
meta/classes-recipe/systemd.bbclass +0 -1
@@ -21,7 +21,6 @@ python __anonymous() { # Inhibit update-rcd from doing any work so that systemd images don't have # redundant init files. if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d): - d.appendVar("DEPENDS", " systemd-systemctl-native") d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") }
Signature · 1 line
2.43.0
PATCH v2 3/7 keymaps: remove obsolete systemd masking
In reply to Ross Burtonsystemd no longer has sysvinit compatibility[1], so it won't try and run the init script in this recipe that is also implemented by systemd.
Remove the explicit systemd unit masking, effectively reverting [2].
[1] oe-core d9ec9e20eeb ("systemd: Stop supporting sysvinit compatibility")
[2] oe-core 8cfba07e24 ("keymaps: mask keymap when necessary")
--- meta/recipes-bsp/keymaps/keymaps_1.0.bb | 17 ----------------- 1 file changed, 17 deletions(-)
meta/recipes-bsp/keymaps/keymaps_1.0.bb +0 -17
@@ -11,13 +11,6 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" INHIBIT_DEFAULT_DEPS = "1" -# As the recipe doesn't inherit systemd.bbclass, we need to set this variable -# manually to avoid unnecessary postinst/preinst generated. -python __anonymous() { - if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): - d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") -} - inherit update-rc.d SRC_URI = "file://keymap.sh"
@@ -36,14 +29,4 @@ do_install () { fi } -PACKAGE_WRITE_DEPS:append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','systemd-systemctl-native','',d)}" -pkg_postinst:${PN} () { - if ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','true','false',d)}; then - if [ -n "$D" ]; then - OPTS="--root=$D" - fi - systemctl $OPTS mask keymap.service - fi -} - ALLOW_EMPTY:${PN} = "1"
Signature · 1 line
2.43.0
PATCH v2 4/7 initscripts: remove obsolete systemd masking
In reply to Ross Burtonsystemd no longer has sysvinit compatibility[1], so it won't try and run the init script in this recipe that is also implemented by systemd.
Remove the explicit systemd unit masking, effectively reverting [2].
[1] oe-core d9ec9e20eeb ("systemd: Stop supporting sysvinit compatibility")
[2] oe-core 844f897710 ("initscripts: mask initscripts from systemd")
--- .../initscripts/initscripts_1.0.bb | 26 ------------------- 1 file changed, 26 deletions(-)
meta/recipes-core/initscripts/initscripts_1.0.bb +0 -26
@@ -41,7 +41,6 @@ S = "${UNPACKDIR}" KERNEL_VERSION = "" DEPENDS:append = " update-rc.d-native" -PACKAGE_WRITE_DEPS:append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd-systemctl-native','',d)}" PACKAGES =+ "${PN}-functions ${PN}-sushell" RDEPENDS:${PN} = "initd-functions \
@@ -154,32 +153,7 @@ do_install () { update-rc.d -r ${D} dmesg.sh start 38 S . } -MASKED_SCRIPTS = " \ - banner \ - bootmisc \ - checkfs \ - checkroot \ - devpts \ - dmesg \ - hostname \ - mountall \ - mountnfs \ - populate-volatile \ - read-only-rootfs-hook \ - rmnologin \ - sysfs \ - urandom" - pkg_postinst:${PN} () { - if type systemctl >/dev/null 2>/dev/null; then - if [ -n "$D" ]; then - OPTS="--root=$D" - fi - for SERVICE in ${MASKED_SCRIPTS}; do - systemctl $OPTS mask $SERVICE.service - done - fi - # Delete any old volatile cache script, as directories may have moved if [ -z "$D" ]; then rm -f "/etc/volatile.cache"
Signature · 1 line
2.43.0
PATCH v2 5/7 modutils-initscripts: remove obsolete systemd masking
In reply to Ross Burtonsystemd no longer has sysvinit compatibility[1], so it won't try and run the init script in this recipe that is also implemented by systemd.
Remove the explicit systemd unit masking, effectively reverting [2].
[1] oe-core d9ec9e20eeb ("systemd: Stop supporting sysvinit compatibility")
[2] oe-core 8fc304a59b ("modutils-initscripts: mask modutils in case of systemd")
--- .../modutils-initscripts/modutils-initscripts.bb | 10 ---------- 1 file changed, 10 deletions(-)
meta/recipes-kernel/modutils-initscripts/modutils-initscripts.bb +0 -10
@@ -18,13 +18,3 @@ do_install () { install -d ${D}${sysconfdir}/init.d/ install -m 0755 ${S}/modutils.sh ${D}${sysconfdir}/init.d/ } - -PACKAGE_WRITE_DEPS:append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd-systemctl-native','',d)}" -pkg_postinst:${PN} () { - if type systemctl >/dev/null 2>/dev/null; then - if [ -n "$D" ]; then - OPTS="--root=$D" - fi - systemctl $OPTS mask modutils.service - fi -}
Signature · 1 line
2.43.0
PATCH v2 6/7 systemd-systemctl-native: rename to systemd-tools-native
In reply to Ross BurtonWe plan on building more than just systemctl in this recipe, so rename it to -tools-.
---
meta/conf/distro/include/maintainers.inc | 2 +-
...-systemctl-native_259.5.bb => systemd-tools-native_259.5.bb} | 2 +-
meta/recipes-core/systemd/systemd_259.5.bb | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename meta/recipes-core/systemd/{systemd-systemctl-native_259.5.bb => systemd-tools-native_259.5.bb} (93%)meta/conf/distro/include/maintainers.inc +1 -1
@@ -833,7 +833,7 @@ RECIPE_MAINTAINER:pn-systemd-bootconf = "Chen Qi <[email protected]>" RECIPE_MAINTAINER:pn-systemd-conf = "Chen Qi <[email protected]>" RECIPE_MAINTAINER:pn-systemd-machine-units = "Chen Qi <[email protected]>" RECIPE_MAINTAINER:pn-systemd-serialgetty = "Chen Qi <[email protected]>" -RECIPE_MAINTAINER:pn-systemd-systemctl-native = "Chen Qi <[email protected]>" +RECIPE_MAINTAINER:pn-systemd-tools-native = "Chen Qi <[email protected]>" RECIPE_MAINTAINER:pn-systemtap = "Victor Kamensky <[email protected]>" RECIPE_MAINTAINER:pn-systemtap-native = "Victor Kamensky <[email protected]>" RECIPE_MAINTAINER:pn-sysvinit = "Ross Burton <[email protected]>"
meta/recipes-core/systemd/systemd-tools-native_259.5.bb renamed from meta/recipes-core/systemd/systemd-systemctl-native_259.5.bb +1 -1
@@ -1,6 +1,6 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/systemd:" -SUMMARY = "Systemctl executable from systemd" +SUMMARY = "native tools from systemd" require systemd.inc
meta/recipes-core/systemd/systemd_259.5.bb +1 -1
@@ -24,7 +24,7 @@ CONFLICT_DISTRO_FEATURES += "sysvinit" # Ensure that the native tools are available when we're building a rootfs with systemd in, # so that systemctl can be used in postinst scripts -PACKAGE_WRITE_DEPS += "systemd-systemctl-native" +PACKAGE_WRITE_DEPS += "systemd-tools-native" SRC_URI += " \ file://touchscreen.rules \
Signature · 1 line
2.43.0
PATCH v2 7/7 systemd-tools-native: reduce dependencies, add comments
In reply to Ross BurtonPass "--auto-features disabled" to disable all optional dependencies by default, and remove build dependencies that are not needed.
Reorganise the recipe to make logical sense and so that the SUMMARY isn't overwritten by systemd.inc, and add comments.
--- .../systemd/systemd-tools-native_259.5.bb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
meta/recipes-core/systemd/systemd-tools-native_259.5.bb +13 -5
@@ -1,19 +1,27 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/systemd:" -SUMMARY = "native tools from systemd" - require systemd.inc -DEPENDS = "gperf-native libcap-native util-linux-native python3-jinja2-native" +SUMMARY = "native tools from systemd" + +# We don't actually need jinja to generate code, but it's checked for at configure time +DEPENDS = "gperf-native python3-jinja2-native" inherit pkgconfig meson native -MESON_TARGET = "systemctl" -MESON_INSTALL_TAGS = "systemctl" +# Disable everything that is auto-detected by default +EXTRA_OEMESON += "--auto-features disabled" + +# Link systemctl statically EXTRA_OEMESON += "-Dlink-systemctl-shared=false" + +# Ensure unused build paths are not in the binary EXTRA_OEMESON += "-Dsysvinit-path= -Dsysvrcnd-path=" # Systemctl is supposed to operate on target, but the target sysroot is not # determined at run-time, but rather set during configure # More details are here https://github.com/systemd/systemd/issues/35897#issuecomment-2665405887 EXTRA_OEMESON += "--sysconfdir ${sysconfdir_native}" + +MESON_TARGET = "systemctl" +MESON_INSTALL_TAGS = "systemctl"
Signature · 1 line
2.43.0