diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-07 22:56:02 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-28 21:35:37 +0300 |
commit | 9dc5671c4803eccae7444ffb4adff8e279edf29b (patch) | |
tree | b98a080c0cd99a34b5a58d8ba531693e64d71be5 /meta-phosphor/classes/obmc-phosphor-systemd.bbclass | |
parent | 553eccbccb8eef4616ad15c49adb67a42f7b6625 (diff) | |
download | openbmc-9dc5671c4803eccae7444ffb4adff8e279edf29b.tar.xz |
classes-systemd: General refactoring
Take the more idiomatic approach of iterating on
SYSTEMD_PACKAGES to find service files.
The OBMC_SYSTEMD_SERVICE variable isn't meant to be used directly by
recipes. Rename it to something that seems less public.
Change-Id: If031937d4716b9c7e6ac1be506457e41109b69c1
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-phosphor/classes/obmc-phosphor-systemd.bbclass')
-rw-r--r-- | meta-phosphor/classes/obmc-phosphor-systemd.bbclass | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass index f882bfcfe..3df5ee44a 100644 --- a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass @@ -8,41 +8,41 @@ # # Alternatively this class can just be inherited and # ${PN}.service will be added to the main package. + +inherit obmc-phosphor-utils inherit systemd +_INSTALL_SD_UNITS="" + python() { + def add_sd_unit(d, unit, pkg): + searchpaths = d.getVar('FILESPATH', True) + path = bb.utils.which(searchpaths, '%s' % unit) + if not os.path.isfile(path): + bb.fatal('Did not find unit file "%s"' % unit) + set_append(d, 'SRC_URI', 'file://%s' % unit) + set_append(d, 'FILES_%s' % pkg, '%s/%s' \ + % (d.getVar('systemd_system_unitdir', True), unit)) + set_append(d, '_INSTALL_SD_UNITS', '%s' % unit) + pn = d.getVar('PN', True) - searchpaths = d.getVar('FILESPATH', True) - - services = d.getVar('SYSTEMD_SERVICE_' + pn, True) - - if services: - services = services.split() - else: - services = [pn + '.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_%s" %(pn), " %s/%s" \ - % (d.getVar('systemd_system_unitdir', True), file)) - d.appendVar('OBMC_SYSTEMD_SERVICES', ' ' + file) - if file not in (d.getVar('SYSTEMD_SERVICE_' + pn, True) or "").split(): - d.appendVar('SYSTEMD_SERVICE_' + pn, ' ' + file) - else: - bb.error("Could not find service file: %s" % file) + if d.getVar('SYSTEMD_SERVICE_%s' % pn, True) is None: + d.setVar('SYSTEMD_SERVICE_%s' % pn, '%s.service' % pn) + + for pkg in listvar_to_list(d, 'SYSTEMD_PACKAGES'): + for unit in listvar_to_list(d, 'SYSTEMD_SERVICE_%s' % pkg): + add_sd_unit(d, unit, pkg) } + do_install_append() { # install systemd service/socket/template files - if [ "${OBMC_SYSTEMD_SERVICES}" ]; then + [ -z "${_INSTALL_SD_UNITS}" ] || \ install -d ${D}${systemd_system_unitdir} - fi - for s in ${OBMC_SYSTEMD_SERVICES}; do - install -m 0644 ${WORKDIR}/$s ${D}${systemd_system_unitdir} + for s in ${_INSTALL_SD_UNITS}; do + install -m 0644 ${WORKDIR}/$s \ + ${D}${systemd_system_unitdir}/$s sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ -e 's,@BINDIR@,${bindir},g' \ -e 's,@SBINDIR@,${sbindir},g' \ |