systemd class, and more enabling
cover systemd class, and more enabling
Hi,
This series introduces a systemd class (largely based on the work in meta-systemd) and changes update-rc.d.bbclass so that it doesn't do anything if systemd.bbclass was also inherited *and* systemd is enabled.
As examples, avahi, connman and wpa-supplicant are updated to use the new class.
Note that the new class does have slightly different semantics to the meta-systemd class, so merging the rest of the changes in meta-systemd that are relevant to oe-core should happen sooner rather than later.
Ross
The following changes since commit 20b4dcace222d6b1d659a8813b4affad075ec0c6:
dbus-native: Don't install dbus-launch (2013-02-08 14:50:38 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib ross/systemd
for you to fetch changes up to cba1dc1c04201b8f08fca587a7433238a5ddaa33:
wpa-supplicant: Enabling with systemd (2013-02-08 21:50:34 +0000)
----------------------------------------------------------------
Radu Moisan (3):
connman: Enabling with systemd
avahi: Enabling with systemd
wpa-supplicant: Enabling with systemd
Ross Burton (2):
systemd.bbclass: helper class for recipes with systemd units update-rc.d: don't do anything if systemd.bbclass is inherited
meta/classes/systemd.bbclass | 158 ++++++++++++++++++++ meta/classes/update-rc.d.bbclass | 19 ++- meta/recipes-connectivity/avahi/avahi.inc | 21 ++- meta/recipes-connectivity/connman/connman.inc | 11 +- .../wpa-supplicant/wpa-supplicant-2.0.inc | 13 +- 5 files changed, 200 insertions(+), 22 deletions(-) create mode 100644 meta/classes/systemd.bbclass
Radu Moisan (3):
connman: Enabling with systemd
avahi: Enabling with systemd
wpa-supplicant: Enabling with systemd
Ross Burton (2):
systemd.bbclass: helper class for recipes with systemd units update-rc.d: don't do anything if systemd.bbclass is inherited
meta/classes/systemd.bbclass | 158 ++++++++++++++++++++ meta/classes/update-rc.d.bbclass | 19 ++- meta/recipes-connectivity/avahi/avahi.inc | 21 ++- meta/recipes-connectivity/connman/connman.inc | 11 +- .../wpa-supplicant/wpa-supplicant-2.0.inc | 13 +- 5 files changed, 200 insertions(+), 22 deletions(-) create mode 100644 meta/classes/systemd.bbclass
Signature · 1 line
1.7.10.4
PATCH 1/5 systemd.bbclass: helper class for recipes with systemd units
This class adds postinst/prerm scripts to start/stop/enable/disable the services as relevant, and some magic to ensure the service files are installed.
Based on (but not the same as) the systemd.bbclass in meta-systemd, so thanks to the following for their work there:
Enrico Scholz <[email protected]>
Khem Raj <[email protected]>
Martin Jansa <[email protected]>
Andreas Müller <[email protected]>
Koen Kooi <[email protected]>
--- meta/classes/systemd.bbclass | 158 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 meta/classes/systemd.bbclass
meta/classes/systemd.bbclass new file +158 -0
@@ -0,0 +1,158 @@ +# The list of packages that should have systemd packaging scripts added. For +# each entry, optionally have a SYSTEMD_SERVICE_[package] that lists the service +# files in this package. If this variable isn't set, [package].service is used. +SYSTEMD_PACKAGES ?= "${PN}" + +# Whether to enable or disable the services on installation. +SYSTEMD_AUTO_ENABLE ??= "enable" + +# This class will be included in any recipe that supports systemd init scripts, +# even if the systemd DISTRO_FEATURE isn't enabled. As such don't make any +# changes directly but check the DISTRO_FEATURES first. +python __anonymous() { + if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + d.appendVar("DEPENDS", " systemd-systemctl-native") + # Set a variable so that update-rcd.bbclass knows we're active and can + # disable itself. + d.setVar("SYSTEMD_BBCLASS_ENABLED", "1") +} + +systemd_postinst() { +OPTS="" + +if [ -n "$D" ]; then + OPTS="--root=$D" +fi + +systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE} + +if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then + systemctl start ${SYSTEMD_SERVICE} +fi +} + +systemd_prerm() { +if [ -z "$D" ]; then + systemctl stop ${SYSTEMD_SERVICE} +fi + +systemctl disable ${SYSTEMD_SERVICE} +} + +def systemd_populate_packages(d): + def get_package_var(d, var, pkg): + val = (d.getVar('%s_%s' % (var, pkg), True) or "").strip() + if val == "": + val = (d.getVar(var, True) or "").strip() + return val + + + # Add a runtime dependency on systemd to pkg + def systemd_add_rdepends(pkg): + rdepends = d.getVar('RDEPENDS_' + pkg, True) or "" + if not 'systemd' in rdepends.split(): + rdepends = '%s %s' % (rdepends, 'systemd') + d.setVar('RDEPENDS_' + pkg, rdepends) + + + def systemd_generate_package_scripts(pkg): + bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg) + + # Add pkg to the overrides so that it finds the SYSTEMD_SERVICE_pkg + # variable. + localdata = d.createCopy() + localdata.prependVar("OVERRIDES", pkg + ":") + bb.data.update_data(localdata) + + postinst = d.getVar('pkg_postinst_%s' % pkg, True) + if not postinst: + postinst = '#!/bin/sh\n' + postinst += localdata.getVar('systemd_postinst', True) + d.setVar('pkg_postinst_%s' % pkg, postinst) + + prerm = d.getVar('pkg_prerm_%s' % pkg, True) + if not prerm: + prerm = '#!/bin/sh\n' + prerm += localdata.getVar('systemd_prerm', True) + d.setVar('pkg_prerm_%s' % pkg, prerm) + + + # Add files to FILES_*-systemd if existent and not already done + def systemd_append_file(pkg_systemd, file_append): + appended = False + if os.path.exists(oe.path.join(d.getVar("D", True), file_append)): + var_name = "FILES_" + pkg_systemd + files = d.getVar(var_name, False) or "" + if file_append not in files.split(): + d.appendVar(var_name, " " + file_append) + appended = True + return appended + + # Add systemd files to FILES_*-systemd, parse for Also= and follow recursive + def systemd_add_files_and_parse(pkg_systemd, path, service, keys): + # avoid infinite recursion + if systemd_append_file(pkg_systemd, oe.path.join(path, service)): + fullpath = oe.path.join(d.getVar("D", True), path, service) + if service.find('.service') != -1: + # for *.service add *@.service + service_base = service.replace('.service', '') + systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) + if service.find('.socket') != -1: + # for *.socket add *.service and *@.service + service_base = service.replace('.socket', '') + systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service', keys) + systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) + for key in keys.split(): + # recurse all dependencies found in keys ('Also';'Conflicts';..) and add to files + cmd = "grep %s %s | sed 's,%s=,,g' | tr ',' '\\n'" % (key, fullpath, key) + pipe = os.popen(cmd, 'r') + line = pipe.readline() + while line: + line = line.replace('\n', '') + systemd_add_files_and_parse(pkg_systemd, path, line, keys) + line = pipe.readline() + pipe.close() + + # Check service-files and call systemd_add_files_and_parse for each entry + def systemd_check_services(): + base_libdir = d.getVar('base_libdir', True) + searchpaths = [oe.path.join(d.getVar("sysconfdir", True), "systemd", "system"),] + searchpaths.append(oe.path.join(d.getVar("base_libdir", True), "systemd", "system")) + searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "system")) + searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "user")) + systemd_packages = d.getVar('SYSTEMD_PACKAGES', True) + has_exactly_one_service = len(systemd_packages.split()) == 1 + if has_exactly_one_service: + has_exactly_one_service = len(get_package_var(d, 'SYSTEMD_SERVICE', systemd_packages).split()) == 1 + + keys = 'Also' # Conflicts?? + if has_exactly_one_service: + # single service gets also the /dev/null dummies + keys = 'Also Conflicts' + # scan for all in SYSTEMD_SERVICE[] + for pkg_systemd in systemd_packages.split(): + for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): + path_found = '' + for path in searchpaths: + if os.path.exists(oe.path.join(d.getVar("D", True), path, service)): + path_found = path + break + if path_found != '': + systemd_add_files_and_parse(pkg_systemd, path_found, service, keys) + else: + raise bb.build.FuncFailed, "\n\nSYSTEMD_SERVICE_%s value %s does not exist" % \ + (pkg_systemd, service) + + # Run all modifications once when creating package + if os.path.exists(d.getVar("D", True)): + for pkg in d.getVar('SYSTEMD_PACKAGES', True).split(): + if d.getVar('SYSTEMD_SERVICE_' + pkg, True): + systemd_generate_package_scripts(pkg) + systemd_add_rdepends(pkg) + systemd_check_services() + + +python populate_packages_prepend () { + if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + systemd_populate_packages (d) +}
Signature · 1 line
1.7.10.4
PATCH 2/5 update-rc.d: don't do anything if systemd.bbclass is inherited
In reply to Ross BurtonWe need the update-rc.d class to work when systemd is being used so that packages that only have SysV init scripts still work. However if a recipe supports both we don't want to install SysV and systemd files under systemd.
To solve this, before doing real work in update-rc.d check if the systemd class has been inherited and don't do anything if it has.
--- meta/classes/update-rc.d.bbclass | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
meta/classes/update-rc.d.bbclass +11 -8
@@ -75,12 +75,15 @@ python populate_packages_updatercd () { postrm += d.getVar('updatercd_postrm', True) d.setVar('pkg_postrm_%s' % pkg, postrm) - pkgs = d.getVar('INITSCRIPT_PACKAGES', True) - if pkgs == None: - pkgs = d.getVar('UPDATERCPN', True) - packages = (d.getVar('PACKAGES', True) or "").split() - if not pkgs in packages and packages != []: - pkgs = packages[0] - for pkg in pkgs.split(): - update_rcd_package(pkg) + # If the systemd class has also been inherited, then don't do anything as + # the systemd units will override anything created by update-rc.d. + if not d.getVar("SYSTEMD_BBCLASS_ENABLED", True): + pkgs = d.getVar('INITSCRIPT_PACKAGES', True) + if pkgs == None: + pkgs = d.getVar('UPDATERCPN', True) + packages = (d.getVar('PACKAGES', True) or "").split() + if not pkgs in packages and packages != []: + pkgs = packages[0] + for pkg in pkgs.split(): + update_rcd_package(pkg) }
Signature · 1 line
1.7.10.4
PATCH 3/5 connman: Enabling with systemd
In reply to Ross BurtonFrom: Radu Moisan <[email protected]>
--- meta/recipes-connectivity/connman/connman.inc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
meta/recipes-connectivity/connman/connman.inc +8 -3
@@ -40,11 +40,14 @@ EXTRA_OECONF += "\ --disable-polkit \ --disable-client \ --enable-fake \ + ${@base_contains('DISTRO_FEATURES', 'systemd', '--with-systemdunitdir=${systemd_unitdir}/system/', '', d)} \ " INITSCRIPT_NAME = "connman" INITSCRIPT_PARAMS = "start 05 5 2 3 . stop 22 0 1 6 ." +SYSTEMD_SERVICE_${PN} = "connman.service" + # IMPORTANT: because xuser is shared with rootless X, please make sure the # USERADD_PARAM is in sync with the one in xserver-nodm-init.bb USERADD_PACKAGES = "${PN}"
@@ -52,7 +55,7 @@ USERADD_PARAM_${PN} = "--create-home \ --groups video,tty,audio \ --user-group xuser" -inherit autotools gtk-doc pkgconfig update-rc.d useradd +inherit autotools gtk-doc pkgconfig systemd update-rc.d useradd # This allows *everyone* to access ConnMan over DBus, without any access # control. Really the at_console flag should work, which would mean that
@@ -62,8 +65,10 @@ do_compile_append() { } do_install_append() { - install -d ${D}${sysconfdir}/init.d - install -m 0755 ${WORKDIR}/connman ${D}${sysconfdir}/init.d/connman + if ${@base_contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/connman ${D}${sysconfdir}/init.d/connman + fi install -d ${D}${bindir} install -m 0755 ${S}/tools/*-test ${D}${bindir}
Signature · 1 line
1.7.10.4
PATCH 4/5 avahi: Enabling with systemd
In reply to Ross BurtonFrom: Radu Moisan <[email protected]>
--- meta/recipes-connectivity/avahi/avahi.inc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
meta/recipes-connectivity/avahi/avahi.inc +13 -8
@@ -37,10 +37,13 @@ USERADD_PARAM_avahi-autoipd = "--system --home /var/run/avahi-autoipd \ -c \"Avahi autoip daemon\" \ avahi-autoipd" -inherit autotools pkgconfig update-rc.d gettext useradd +inherit autotools pkgconfig update-rc.d gettext systemd useradd -EXTRA_OECONF = "--with-distro=debian \ - --disable-introspection \ +SYSTEMD_PACKAGES = "${PN}-daemon ${PN}-dnsconfd" +SYSTEMD_SERVICE_avahi-daemon = "avahi-daemon.service" +SYSTEMD_SERVICE_avahi-dnsconfd = "avahi-dnsconfd.service" + +EXTRA_OECONF = "--disable-introspection \ --with-avahi-priv-access-group=adm \ --disable-stack-protector \ --disable-gdbm \
@@ -50,10 +53,15 @@ EXTRA_OECONF = "--with-distro=debian \ --disable-qt4 \ --disable-python \ --disable-doxygen-doc \ - --with-systemdsystemunitdir=${systemd_unitdir}/system/ \ + ${EXTRA_OECONF_SYSVINIT} \ + ${EXTRA_OECONF_SYSTEMD} \ ${AVAHI_GTK} \ " +# The distro choice determines what init scripts are installed +EXTRA_OECONF_SYSVINIT = "${@base_contains('DISTRO_FEATURES','sysvinit','--with-distro=debian','--with-distro=none',d)}" +EXTRA_OECONF_SYSTEMD = "${@base_contains('DISTRO_FEATURES','systemd','--with-systemdsystemunitdir=${systemd_unitdir}/system/','',d)}" + AVAHI_GTK ?= "--disable-gtk --disable-gtk3" LDFLAGS_append_libc-uclibc = " -lintl"
@@ -64,9 +72,8 @@ do_configure_prepend() { } -PACKAGES =+ "avahi-systemd avahi-daemon libavahi-common libavahi-core libavahi-client avahi-dnsconfd libavahi-glib libavahi-ui avahi-autoipd avahi-utils" +PACKAGES =+ "avahi-daemon libavahi-common libavahi-core libavahi-client avahi-dnsconfd libavahi-glib libavahi-ui avahi-autoipd avahi-utils" -FILES_avahi-systemd = "${systemd_unitdir}" FILES_avahi-autoipd = "${sbindir}/avahi-autoipd \ ${sysconfdir}/avahi/avahi-autoipd.action \ ${sysconfdir}/dhcp/*/avahi-autoipd \
@@ -94,8 +101,6 @@ FILES_libavahi-glib = "${libdir}/libavahi-glib.so.*" FILES_libavahi-gobject = "${libdir}/libavahi-gobject.so.*" FILES_avahi-utils = "${bindir}/avahi-*" -RDEPENDS_avahi-systemd = "avahi-daemon" - RDEPENDS_avahi-daemon = "sysvinit-pidof" # uclibc has no nss
Signature · 1 line
1.7.10.4
PATCH 5/5 wpa-supplicant: Enabling with systemd
In reply to Ross BurtonFrom: Radu Moisan <[email protected]>
--- .../wpa-supplicant/wpa-supplicant-2.0.inc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
meta/recipes-connectivity/wpa-supplicant/wpa-supplicant-2.0.inc +10 -3
@@ -9,6 +9,11 @@ LIC_FILES_CHKSUM = "file://../COPYING;md5=ab87f20cd7e8c0d0a6539b34d3791d0e \ DEPENDS = "gnutls dbus libnl" RRECOMMENDS_${PN} = "wpa-supplicant-passphrase wpa-supplicant-cli" +inherit systemd + +SYSTEMD_SERVICE_${PN} = "wpa_supplicant.service [email protected] [email protected]" +SYSTEMD_AUTO_ENABLE = "disable" + SRC_URI = "http://hostap.epitest.fi/releases/wpa_supplicant-${PV}.tar.gz \ file://defconfig-gnutls \ file://wpa-supplicant.sh \
@@ -21,7 +26,7 @@ S = "${WORKDIR}/wpa_supplicant-${PV}/wpa_supplicant" PACKAGES_prepend = "wpa-supplicant-passphrase wpa-supplicant-cli " FILES_wpa-supplicant-passphrase = "${bindir}/wpa_passphrase" FILES_wpa-supplicant-cli = "${sbindir}/wpa_cli" -FILES_${PN} += "${datadir}/dbus-1/system-services/* ${systemd_unitdir}/system/*" +FILES_${PN} += "${datadir}/dbus-1/system-services/*" CONFFILES_${PN} += "${sysconfdir}/wpa_supplicant.conf" do_configure () {
@@ -63,8 +68,10 @@ do_install () { install -d ${D}/${datadir}/dbus-1/system-services install -m 644 ${S}/dbus/*.service ${D}/${datadir}/dbus-1/system-services - install -d ${D}/${systemd_unitdir}/system - install -m 644 ${S}/systemd/wpa_supplicant.service ${D}/${systemd_unitdir}/system + if ${@base_contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}/${systemd_unitdir}/system + install -m 644 ${S}/systemd/*.service ${D}/${systemd_unitdir}/system + fi install -d ${D}/etc/default/volatiles install -m 0644 ${WORKDIR}/99_wpa_supplicant ${D}/etc/default/volatiles
Signature · 1 line
1.7.10.4
Re: [PATCH 1/5] systemd.bbclass: helper class for recipes with systemd units
In reply to Ross BurtonQuoted 171 lines · Ross Burton
This class adds postinst/prerm scripts to start/stop/enable/disable the services as relevant, and some magic to ensure the service files are installed.
Based on (but not the same as) the systemd.bbclass in meta-systemd, so thanks to the following for their work there:
Enrico Scholz <[email protected]>
Khem Raj <[email protected]>
Martin Jansa <[email protected]>
Andreas Müller <[email protected]>
Koen Kooi <[email protected]>Signed-off-by Ross Burton <[email protected]>--- meta/classes/systemd.bbclass | 158 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 meta/classes/systemd.bbclassmeta/classes/systemd.bbclass new file +147
-0@@ -0,0 +1,158 @@ +# The list of packages that should have systemd packaging scripts added. For +# each entry, optionally have a SYSTEMD_SERVICE_[package] that lists the service +# files in this package. If this variable isn't set, [package].service is used. +SYSTEMD_PACKAGES ?= "${PN}" + +# Whether to enable or disable the services on installation. +SYSTEMD_AUTO_ENABLE ??= "enable" + +# This class will be included in any recipe that supports systemd init scripts, +# even if the systemd DISTRO_FEATURE isn't enabled. As such don't make any +# changes directly but check the DISTRO_FEATURES first. +python __anonymous() { + if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + d.appendVar("DEPENDS", " systemd-systemctl-native") + # Set a variable so that update-rcd.bbclass knows we're active and can + # disable itself. + d.setVar("SYSTEMD_BBCLASS_ENABLED", "1") +} +systemd_postinst() { +OPTS="" + +if [ -n "$D" ]; then + OPTS="--root=$D" +fi + +systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE} + +if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then + systemctl start ${SYSTEMD_SERVICE} +fi +} + +systemd_prerm() { +if [ -z "$D" ]; then + systemctl stop ${SYSTEMD_SERVICE} +fi + +systemctl disable ${SYSTEMD_SERVICE} +} + +def systemd_populate_packages(d): + def get_package_var(d, var, pkg): + val = (d.getVar('%s_%s' % (var, pkg), True) or "").strip() + if val == "": + val = (d.getVar(var, True) or "").strip() + return val + + + # Add a runtime dependency on systemd to pkg + def systemd_add_rdepends(pkg): + rdepends = d.getVar('RDEPENDS_' + pkg, True) or "" + if not 'systemd' in rdepends.split(): + rdepends = '%s %s' % (rdepends, 'systemd') + d.setVar('RDEPENDS_' + pkg, rdepends) + + + def systemd_generate_package_scripts(pkg): + bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg) + + # Add pkg to the overrides so that it finds the SYSTEMD_SERVICE_pkg + # variable. + localdata = d.createCopy() + localdata.prependVar("OVERRIDES", pkg + ":") + bb.data.update_data(localdata) + + postinst = d.getVar('pkg_postinst_%s' % pkg, True) + if not postinst: + postinst = '#!/bin/sh\n' + postinst += localdata.getVar('systemd_postinst', True) + d.setVar('pkg_postinst_%s' % pkg, postinst) + + prerm = d.getVar('pkg_prerm_%s' % pkg, True) + if not prerm: + prerm = '#!/bin/sh\n' + prerm += localdata.getVar('systemd_prerm', True) + d.setVar('pkg_prerm_%s' % pkg, prerm) + + + # Add files to FILES_*-systemd if existent and not already done + def systemd_append_file(pkg_systemd, file_append): + appended = False + if os.path.exists(oe.path.join(d.getVar("D", True), file_append)): + var_name = "FILES_" + pkg_systemd + files = d.getVar(var_name, False) or "" + if file_append not in files.split(): + d.appendVar(var_name, " " + file_append) + appended = True + return appended + + # Add systemd files to FILES_*-systemd, parse for Also= and follow recursive + def systemd_add_files_and_parse(pkg_systemd, path, service, keys): + # avoid infinite recursion + if systemd_append_file(pkg_systemd, oe.path.join(path, service)): + fullpath = oe.path.join(d.getVar("D", True), path, service) + if service.find('.service') != -1: + # for *.service add *@.service + service_base = service.replace('.service', '') + systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) + if service.find('.socket') != -1: + # for *.socket add *.service and *@.service + service_base = service.replace('.socket', '') + systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service', keys) + systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) + for key in keys.split(): + # recurse all dependencies found in keys ('Also';'Conflicts';..) and add to files + cmd = "grep %s %s | sed 's,%s=,,g' | tr ',' '\\n'" % (key, fullpath, key) + pipe = os.popen(cmd, 'r') + line = pipe.readline() + while line: + line = line.replace('\n', '') + systemd_add_files_and_parse(pkg_systemd, path, line, keys) + line = pipe.readline() + pipe.close() + + # Check service-files and call systemd_add_files_and_parse for each entry + def systemd_check_services(): + base_libdir = d.getVar('base_libdir', True) + searchpaths = [oe.path.join(d.getVar("sysconfdir", True), "systemd", "system"),] + searchpaths.append(oe.path.join(d.getVar("base_libdir", True), "systemd", "system")) + searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "system")) + searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "user")) + systemd_packages = d.getVar('SYSTEMD_PACKAGES', True) + has_exactly_one_service = len(systemd_packages.split()) == 1 + if has_exactly_one_service: + has_exactly_one_service = len(get_package_var(d, 'SYSTEMD_SERVICE', systemd_packages).split()) == 1 + + keys = 'Also' # Conflicts?? + if has_exactly_one_service: + # single service gets also the /dev/null dummies + keys = 'Also Conflicts' + # scan for all in SYSTEMD_SERVICE[] + for pkg_systemd in systemd_packages.split(): + for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): + path_found = '' + for path in searchpaths: + if os.path.exists(oe.path.join(d.getVar("D", True), path, service)): + path_found = path + break + if path_found != '': + systemd_add_files_and_parse(pkg_systemd, path_found, service, keys) + else: + raise bb.build.FuncFailed, "\n\nSYSTEMD_SERVICE_%s value %s does not exist" % \ + (pkg_systemd, service) + + # Run all modifications once when creating package + if os.path.exists(d.getVar("D", True)): + for pkg in d.getVar('SYSTEMD_PACKAGES', True).split():
meta/classes/systemd.bbclass line 157
Quoted 10 lines
meta/classes/systemd.bbclass new file +10
-0+ if d.getVar('SYSTEMD_SERVICE_' + pkg, True): + systemd_generate_package_scripts(pkg) + systemd_add_rdepends(pkg) + systemd_check_services() + + +python populate_packages_prepend () { + if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + systemd_populate_packages (d) +}
I know this has been a long time in the works so I'll merge but could you follow up with a change:
PACKAGESPLITFUNCS_prepend = "systemd_populate_packages "
and just put the
oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d) into systemd_populate_packages with a return? You'll need to drop the d as a parameter and turn it into a python xxxx() { style function. The nice thing is this then shows up nicely on the profiles too. I'm aiming to stamp out use of populate_packages_prepend entirely.
Cheers,
Richard