diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-08-17 21:46:41 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-09-06 04:58:26 +0300 |
commit | 0161aff3820ba2fa9a83afe0e9f2a65dd6d1d9b1 (patch) | |
tree | 56241064b7dfb9255dbe48bbc3a04c1ca11a57bb /meta-phosphor/classes/obmc-phosphor-systemd.bbclass | |
parent | afb2e1bf275145d915bd3308d65af59ecc94ec71 (diff) | |
download | openbmc-0161aff3820ba2fa9a83afe0e9f2a65dd6d1d9b1.tar.xz |
classes-systemd: Add link variable
Add new variable SYSTEMD_LINK for arbitrary link installation
in the ${systemd_system_unitdir} namespace.
For example, assume a template foo@.target exists and an instance of
this template is desired. To describe this:
SYSTEMD_LINK_${PN} +=
"foo@.target:foo@instance.service"
Change-Id: I8bb443e71d8eed44d4704c58167e1ff19bdfe2f5
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 | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass index 3b707378c..6e350552f 100644 --- a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass @@ -28,6 +28,12 @@ # # SYSTEMD_ENVIRONMENT_FILE_${PN} = "foo" # One or more environment files to be installed. +# +# SYSTEMD_LINK_${PN} = "tgt:name" +# A specification for installing arbitrary links in +# the ${systemd_system_unitdir} namespace, where: +# tgt: the link target +# name: the link name, relative to ${systemd_system_unitdir} inherit obmc-phosphor-utils @@ -168,6 +174,14 @@ python() { set_append(d, '_INSTALL_ENV_FILES', name) + def install_link(d, spec, pkg): + tgt, dest = spec.split(':') + + set_append(d, 'FILES_%s' % pkg, '%s/%s' \ + % (d.getVar('systemd_system_unitdir', True), dest)) + set_append(d, '_INSTALL_LINKS', spec) + + pn = d.getVar('PN', True) if d.getVar('SYSTEMD_SERVICE_%s' % pn, True) is None: d.setVar('SYSTEMD_SERVICE_%s' % pn, '%s.service' % pn) @@ -186,6 +200,8 @@ python() { 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) + for spec in listvar_to_list(d, 'SYSTEMD_LINK_%s' % pkg): + install_link(d, spec, pkg) } @@ -232,6 +248,20 @@ python systemd_do_postinst() { fd.write(content) + def install_links(d): + install_dir = d.getVar('D', True) + install_dir += d.getVar('systemd_system_unitdir', True) + + for spec in listvar_to_list(d, '_INSTALL_LINKS'): + tgt, dest = spec.split(':') + dest = os.path.join(install_dir, dest) + parent = os.path.dirname(dest) + if not os.path.exists(parent): + os.makedirs(parent) + os.symlink(tgt, dest) + + + install_links(d) install_envs(d) make_subs(d) } |