systemd.bbclass: allow recipe to inherit systemd with empty SYSTEMD_SERVICE

* I have use case where common recipe does inherit systemd and only some BSP's are bbappending some SERVICEs to it
* install was moved intentionaly, so that /lib/systemd/system is not
  created if there is no .service file (causing QA Warning about
  unpackaged dir)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
This commit is contained in:
Martin Jansa 2012-04-24 15:11:44 +02:00
parent 21d048aecf
commit 154d0bb399

View File

@ -58,8 +58,6 @@ def systemd_after_parse(d):
for pkg_systemd in systemd_pkgs.split():
service_pkg = 'SYSTEMD_SERVICE' + "_" + pkg_systemd
systemd_services = d.getVar(service_pkg, 1) or d.getVar('SYSTEMD_SERVICE', 1) or ""
if systemd_services == "":
raise bb.build.FuncFailed, "\n\n%s inherits systemd but doesn't set SYSTEMD_SERVICE / %s" % (bb_filename, service_pkg)
# prepend systemd-packages not already included
def systemd_create_package(pkg_systemd):
@ -84,11 +82,11 @@ python __anonymous() {
# automatically install all *.service and *.socket supplied in recipe's SRC_URI
do_install_append() {
install -d ${D}${systemd_unitdir}/system
for service in `find ${WORKDIR} -maxdepth 1 -name '*.service' -o -name '*.socket'` ; do
# ensure installing systemd-files only (e.g not avahi *.service)
if grep -q '\[Unit\]' $service ; then
install -m 644 $service ${D}${systemd_unitdir}/system
install -d ${D}${systemd_unitdir}/system
install -m 644 $service ${D}${systemd_unitdir}/system
fi
done
}
@ -203,7 +201,8 @@ python populate_packages_prepend () {
# run all modifications once when creating package
if os.path.exists('${D}'):
for pkg_systemd in d.getVar('SYSTEMD_PACKAGES', 1).split():
systemd_generate_package_scripts(pkg_systemd)
systemd_add_rdepends(pkg_systemd)
if d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1) and d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1).strip():
systemd_generate_package_scripts(pkg_systemd)
systemd_add_rdepends(pkg_systemd)
systemd_check_services()
}