summaryrefslogtreecommitdiffstats
path: root/meta-phosphor/classes/obmc-phosphor-systemd.bbclass
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2016-08-17 15:58:26 -0400
committerPatrick Williams <patrick@stwcx.xyz>2016-09-06 11:13:38 +0000
commit58ab4a05b504a84f9d76a8b313bac813d5c050fc (patch)
tree053bf5f0e306b03f3f52ecea343dfcf301c9c556 /meta-phosphor/classes/obmc-phosphor-systemd.bbclass
parente306073ce2b779de139b943ca2e77ba888f2596e (diff)
downloadtalos-openbmc-58ab4a05b504a84f9d76a8b313bac813d5c050fc.tar.gz
talos-openbmc-58ab4a05b504a84f9d76a8b313bac813d5c050fc.zip
classes-systemd: refactor substitutions
The exising mechanism for doing substitutions worked but was cumbersome for expressing more than a handful. Rework the interfaces such that expressing many substitutions at once is simpler. Change-Id: I9ffee7a623219a797797cc8f085e7a06eaf74b3c 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.bbclass33
1 files changed, 17 insertions, 16 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass
index 6e350552f..1881ec0ef 100644
--- a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass
@@ -14,13 +14,12 @@
# Inhibit the warning that is displayed if a service unit without a
# restart policy is detected.
#
-# SYSTEMD_SUBSTITUTIONS_${path-relative-to-system_unitdir}
-# Variables in this list will be substituted in the specified
-# file during install (if bitbake finds python {format} strings
-# in the file itself). List entries take the form:
-# VAR:VALUE
-# where {VAR} is the format string bitbake should look for in the
-# file and VALUE is the value to substitute.
+# SYSTEMD_SUBSTITUTIONS = "var:val:file"
+# A specification for making python style {format} string
+# substitutions where:
+# var: the format string to search for
+# val: the value to replace with
+# file: the file in which to make the substitution
#
# SYSTEMD_USER_${PN}.service = "foo"
# SYSTEMD_USER_${unit}.service = "foo"
@@ -115,16 +114,14 @@ python() {
def add_default_subs(d, file):
- set_append(d, '_MAKE_SUBS', '%s' % file)
-
for x in [
'base_bindir',
'bindir',
'sbindir',
'envfiledir',
'SYSTEMD_DEFAULT_TARGET' ]:
- set_append(d, 'SYSTEMD_SUBSTITUTIONS_%s' % file,
- '%s:%s' % (x, d.getVar(x, True)))
+ set_append(d, 'SYSTEMD_SUBSTITUTIONS',
+ '%s:%s:%s' % (x, d.getVar(x, True), file))
def add_sd_unit(d, unit, pkg):
@@ -155,8 +152,8 @@ python() {
bb.fatal('Too many users assigned to %s: \'%s\'' % (var, ' '.join(user)))
user = user[0]
- set_append(d, 'SYSTEMD_SUBSTITUTIONS_%s' % file,
- 'USER:%s' % user)
+ set_append(d, 'SYSTEMD_SUBSTITUTIONS',
+ 'USER:%s:%s' % (user, file))
if user not in d.getVar('USERADD_PARAM_%s' % pkg, True):
set_append(
d,
@@ -207,9 +204,13 @@ python() {
python systemd_do_postinst() {
def make_subs(d):
- for f in listvar_to_list(d, '_MAKE_SUBS'):
- subs = dict([ x.split(':') for x in
- listvar_to_list(d, 'SYSTEMD_SUBSTITUTIONS_%s' % f)])
+ all_subs = {}
+ for spec in listvar_to_list(d, 'SYSTEMD_SUBSTITUTIONS'):
+ spec, file = spec.rsplit(':', 1)
+ all_subs.setdefault(file, []).append(spec)
+
+ for f, v in all_subs.iteritems():
+ subs = dict([ x.split(':') for x in v])
if not subs:
continue
OpenPOWER on IntegriCloud