]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
systemd-compat-units: generate masks at build time
authorRoss Burton <ross.burton@arm.com>
Tue, 13 Jan 2026 18:46:32 +0000 (18:46 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 19 Jan 2026 17:46:18 +0000 (17:46 +0000)
Originally, this recipe masked the units at rootfs-time by looking to see
if the init script to be masked existed, and masking it if so.

That however suffers from a race condition where the postinst script may
be executed before the package that provides a script has been installed
so this was changed to be an on-target postinst[1], so we know that all
of the packages have been installed.

However, this now means that you can't have an image that install this
package _and_ is read-only, because we have an on-target postinst to
execute.

There's also another problem that with on-target package management, it
would be possible to install a package that should be masked after the
postinst has been executed, so the mask won't exist.

Taking a step back, a systemd unit mask is just a symlink to /dev/null
with the right name in the right path.  So instead of masking in a post-
install script, we can generate all the masks at build-time.

This change reduces this package to just a number of symlinks, with no
post-install scripts.

[ YOCTO #16109 ]
[1] oe-core e88f22da19 ("systemd-compat-units: execute postinst on target")

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/systemd/systemd-compat-units.bb

index d6da34e9b8044e5d630a2ac9e8c9a55e6ecc60d1..6839101037172c14fc05ce0c4d7aab890f455eb7 100644 (file)
@@ -2,18 +2,14 @@ SUMMARY = "Enhances systemd compatilibity with existing SysVinit scripts"
 HOMEPAGE = "http://www.freedesktop.org/wiki/Software/systemd"
 LICENSE = "MIT"
 
-PACKAGE_WRITE_DEPS += "systemd-systemctl-native"
+DEPENDS = "systemd-systemctl-native"
+INHIBIT_DEFAULT_DEPS = "1"
 
 S = "${UNPACKDIR}"
 
 inherit features_check
 
-INHIBIT_DEFAULT_DEPS = "1"
-
-ALLOW_EMPTY:${PN} = "1"
-
-REQUIRED_DISTRO_FEATURES += "systemd"
-REQUIRED_DISTRO_FEATURES += "usrmerge"
+REQUIRED_DISTRO_FEATURES = "systemd"
 
 SYSTEMD_DISABLED_SYSV_SERVICES = " \
   busybox-udhcpc \
@@ -24,26 +20,8 @@ SYSTEMD_DISABLED_SYSV_SERVICES = " \
   syslog.busybox \
 "
 
-pkg_postinst_ontarget:${PN} () {
-
-       test -d $D${sysconfdir}/init.d  ||  exit 0
-       cd $D${sysconfdir}/init.d
-
-       echo "Disabling the following sysv scripts: "
-
-       if [ -n "$D" ]; then
-               OPTS="--root=$D"
-       else
-               OPTS=""
-       fi
-
-       for i in ${SYSTEMD_DISABLED_SYSV_SERVICES} ; do
-               if [ -e $i -o -e $i.sh ]  &&   ! [ -e $D${sysconfdir}/systemd/system/$i.service -o -e $D${systemd_system_unitdir}/$i.service ] ; then
-                       echo -n "$i: "
-                       systemctl $OPTS mask $i.service
-               fi
+do_install() {
+       for unit in ${SYSTEMD_DISABLED_SYSV_SERVICES} ; do
+               systemctl --root ${D} mask $unit
        done
-       echo
 }
-
-RDEPENDS:${PN} = "systemd"