diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-08-19 06:59:44 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-09-06 14:13:39 +0300 |
commit | 9ca070ccdba1a518c0f3a901c46c474bde67b50e (patch) | |
tree | d91708ba9999470aabd202a8c4d7eddc347161aa /meta-phosphor/classes/obmc-phosphor-systemd.bbclass | |
parent | 58ab4a05b504a84f9d76a8b313bac813d5c050fc (diff) | |
download | openbmc-9ca070ccdba1a518c0f3a901c46c474bde67b50e.tar.xz |
classes-systemd: Add override variable
Add SYSTEMD_OVERRIDE variable for easy override file deployment.
Change-Id: I5114296254f118fb2b9883615a710c0329921fa7
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 | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass index 1881ec0ef..3d7d846a4 100644 --- a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass @@ -33,6 +33,15 @@ # the ${systemd_system_unitdir} namespace, where: # tgt: the link target # name: the link name, relative to ${systemd_system_unitdir} +# +# SYSTEMD_OVERRIDE_${PN} = "src:dest" +# A specification for installing unit overrides where: +# src: the override file template +# dest: the override install location, relative to ${systemd_system_unitdir} +# +# Typically SYSTEMD_SUBSTITUTIONS is used to deploy a range +# of overrides from a single template file. To simply install +# a single override use "foo.conf:my-service.d/foo.conf" inherit obmc-phosphor-utils @@ -179,6 +188,15 @@ python() { set_append(d, '_INSTALL_LINKS', spec) + def add_override(d, spec, pkg): + tmpl, dest = spec.split(':') + set_append(d, '_INSTALL_OVERRIDES', '%s' % spec) + unit_dir = d.getVar('systemd_system_unitdir', True) + set_append(d, 'FILES_%s' % pkg, '%s/%s' % (unit_dir, dest)) + add_default_subs(d, '%s' % dest) + add_sd_user(d, '%s' % dest, pkg) + + pn = d.getVar('PN', True) if d.getVar('SYSTEMD_SERVICE_%s' % pn, True) is None: d.setVar('SYSTEMD_SERVICE_%s' % pn, '%s.service' % pn) @@ -199,6 +217,8 @@ python() { add_env_file(d, name, pkg) for spec in listvar_to_list(d, 'SYSTEMD_LINK_%s' % pkg): install_link(d, spec, pkg) + for spec in listvar_to_list(d, 'SYSTEMD_OVERRIDE_%s' % pkg): + add_override(d, spec, pkg) } @@ -262,8 +282,32 @@ python systemd_do_postinst() { os.symlink(tgt, dest) + def install_overrides(d): + install_dir = d.getVar('D', True) + install_dir += d.getVar('systemd_system_unitdir', True) + searchpaths = d.getVar('FILESPATH', True) + + for spec in listvar_to_list(d, '_INSTALL_OVERRIDES'): + tmpl, dest = spec.split(':') + source = bb.utils.which(searchpaths, tmpl) + if not os.path.isfile(source): + bb.fatal('Did not find SYSTEMD_OVERRIDE ' + 'template: \'%s\'' % source) + + dest = os.path.join(install_dir, dest) + parent = os.path.dirname(dest) + if not os.path.exists(parent): + os.makedirs(parent) + + with open(source, 'r') as fd: + content = fd.read() + with open('%s' % dest, 'w+') as fd: + fd.write(content) + + install_links(d) install_envs(d) + install_overrides(d) make_subs(d) } |