From f33c69ca1546765da370dea09f53fa4cadf18d0c Mon Sep 17 00:00:00 2001 From: Lei YU Date: Thu, 14 Mar 2019 13:29:07 +0800 Subject: obmc-phosphor-systemd: allow systemd unit from repo If a recipe inherits obmc-phosphor-systemd, all the systemd units defined in the recipe shall exist in the code tree, otherwise it reports "Did not find unit file" error. This commit changes the behavior, and do not report the error if a unit does not exist in code tree. This allows the system unit to be installed from repo, as long as the repo does install the systemd unit to expected path. Tested: Verify the below case passes the build and the unit is installed correctly in the built image: * Put a systemd unit in repo; * In repo, install the unit into /lib/systemd/system * The repo's recipe defines SYSTEMD_SERVICE_${PN} without putting the unit in openbmc tree And verify if the systemd unit in repo is not installed, the build fails due to missing the unit. (From meta-phosphor rev: 5f56aaf1204a39035da1a493a97e86a73650000f) Change-Id: I9ec9c188357c2995d3e8ddbf2675c60f5e17560e Signed-off-by: Lei YU Signed-off-by: Andrew Geissler --- meta-phosphor/classes/obmc-phosphor-systemd.bbclass | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass index 3a3234f5e8..e892302129 100644 --- a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass @@ -110,7 +110,9 @@ python() { searchpaths = d.getVar('FILESPATH', True) path = bb.utils.which(searchpaths, '%s' % unit.name) if not os.path.isfile(path): - bb.fatal('Did not find unit file "%s"' % unit.name) + # Unit does not exist in tree. Allow it to install from repo. + # Return False here to indicate it does not exist. + return False parser = systemd_parse_unit(d, path) inhibit = listvar_to_list(d, 'INHIBIT_SYSTEMD_RESTART_POLICY_WARNING') @@ -120,6 +122,7 @@ python() { not parser.has_option('Service', 'Restart'): bb.warn('Systemd unit \'%s\' does not ' 'have a restart policy defined.' % unit.name) + return True def add_default_subs(d, file): @@ -134,7 +137,12 @@ python() { '%s:%s:%s' % (x, d.getVar(x, True), file)) - def add_sd_unit(d, unit, pkg): + def add_sd_unit(d, unit, pkg, unit_exist): + # Do not add unit if it does not exist in tree. + # It will be installed from repo. + if not unit_exist: + return + name = unit.name unit_dir = d.getVar('systemd_system_unitdir', True) set_append(d, 'SRC_URI', 'file://%s' % name) @@ -216,8 +224,8 @@ python() { svc = [x for x in svc if not x.is_instance] for unit in tmpl + svc: - check_sd_unit(d, unit) - add_sd_unit(d, unit, pkg) + unit_exist = check_sd_unit(d, unit) + add_sd_unit(d, unit, pkg, unit_exist) add_sd_user(d, unit.name, pkg) for name in listvar_to_list(d, 'SYSTEMD_ENVIRONMENT_FILE_%s' % pkg): add_env_file(d, name, pkg) -- cgit v1.2.3