diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-06-09 05:03:59 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-06-13 19:31:31 +0300 |
commit | e36358c598e688e308b43299e686fc8fa057cf84 (patch) | |
tree | a6f818ea982acb351e4c36a8a509181bd1f031fe /meta-phosphor/classes | |
parent | 73a644099913b30391f7757edc3b7c4aaf6a32f0 (diff) | |
download | openbmc-e36358c598e688e308b43299e686fc8fa057cf84.tar.xz |
Support multiple systemd service files
Enhance obmc-phosphor-systemd such that an array of service/template
socket files in SYSTEMD_SERVICES_${PN} works.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-phosphor/classes')
-rw-r--r-- | meta-phosphor/classes/obmc-phosphor-systemd.bbclass | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass index 12e0bc168..b07174f9f 100644 --- a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass @@ -1,14 +1,52 @@ -# Common code for Phosphor OpenBMC systemd services. - +# Common code for systemd based services. +# +# Prior to inheriting this class, recipes can define services like this: +# +# SYSTEMD_SERVICE_${PN} = "foo.service bar.socket baz@.service" +# +# and these files will be added to the main package if they exist. +# +# Alternatively this class can just be inherited and +# ${BPN}.service will be added to the main package. inherit systemd -SYSTEMD_SERVICE_${PN} = "${BPN}.service" -SRC_URI += " \ - file://${BPN}.service \ - " + +python() { + bpn = d.getVar('BPN', True) + searchpaths = d.getVar('FILESPATH', True) + + services = d.getVar('SYSTEMD_SERVICE_' + bpn, True) + + if services: + services = services.split() + else: + services = [bpn + '.service'] + + for s in services: + file = s + path = bb.utils.which(searchpaths, file) + if os.path.isfile(path): + d.appendVar('SRC_URI', ' file://' + file) + d.appendVar( + 'FILES_' + bpn, ' ' + + d.getVar('systemd_system_unitdir', True) + file) + d.appendVar('OBMC_SYSTEMD_SERVICES', ' ' + file) + if file not in (d.getVar('SYSTEMD_SERVICE_' + bpn, True) or "").split(): + d.appendVar('SYSTEMD_SERVICE_' + bpn, ' ' + file) + else: + bb.error("Could not find service file: %s" % file) +} do_install_append() { - # install systemd unit files - install -d ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/${BPN}.service ${D}${systemd_unitdir}/system + # install systemd service/socket/template files + if [ "${OBMC_SYSTEMD_SERVICES}" ]; then + install -d ${D}${systemd_system_unitdir} + fi + for s in ${OBMC_SYSTEMD_SERVICES}; do + install -m 0644 ${WORKDIR}/$s ${D}${systemd_system_unitdir} + sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ + -e 's,@BINDIR@,${bindir},g' \ + -e 's,@SBINDIR@,${sbindir},g' \ + ${D}${systemd_system_unitdir}/$s + done } |