summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-recipe/systemd.bbclass28
1 files changed, 12 insertions, 16 deletions
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 7324af8555..be77da4812 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -124,29 +124,26 @@ python systemd_populate_packages() {
124 return appended 124 return appended
125 125
126 # Add systemd files to FILES:*-systemd, parse for Also= and follow recursive 126 # Add systemd files to FILES:*-systemd, parse for Also= and follow recursive
127 def systemd_add_files_and_parse(pkg_systemd, path, service, keys): 127 def systemd_add_files_and_parse(pkg_systemd, path, service):
128 # avoid infinite recursion 128 # avoid infinite recursion
129 if systemd_append_file(pkg_systemd, oe.path.join(path, service)): 129 if systemd_append_file(pkg_systemd, oe.path.join(path, service)):
130 fullpath = oe.path.join(d.getVar("D"), path, service) 130 fullpath = oe.path.join(d.getVar("D"), path, service)
131 if service.find('.service') != -1: 131 if service.find('.service') != -1:
132 # for *.service add *@.service 132 # for *.service add *@.service
133 service_base = service.replace('.service', '') 133 service_base = service.replace('.service', '')
134 systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) 134 systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service')
135 if service.find('.socket') != -1: 135 if service.find('.socket') != -1:
136 # for *.socket add *.service and *@.service 136 # for *.socket add *.service and *@.service
137 service_base = service.replace('.socket', '') 137 service_base = service.replace('.socket', '')
138 systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service', keys) 138 systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service')
139 systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) 139 systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service')
140 for key in keys.split(): 140 # Add all units which have an Also= referring a unit in this package to this package as well.
141 # recurse all dependencies found in keys ('Also';'Conflicts';..) and add to files 141 with open(fullpath, 'r') as unit_f:
142 cmd = "grep %s %s | sed 's,%s=,,g' | tr ',' '\\n'" % (key, shlex.quote(fullpath), key) 142 for line in unit_f:
143 pipe = os.popen(cmd, 'r') 143 if line.startswith('Also'):
144 line = pipe.readline() 144 also_unit = line.split('=', 1)[1].strip()
145 while line: 145 bb.warn("also: %s" % also_unit)
146 line = line.replace('\n', '') 146 systemd_add_files_and_parse(pkg_systemd, path, also_unit)
147 systemd_add_files_and_parse(pkg_systemd, path, line, keys)
148 line = pipe.readline()
149 pipe.close()
150 147
151 # Check service-files and call systemd_add_files_and_parse for each entry 148 # Check service-files and call systemd_add_files_and_parse for each entry
152 def systemd_check_services(): 149 def systemd_check_services():
@@ -155,7 +152,6 @@ python systemd_populate_packages() {
155 searchpaths.append(d.getVar("systemd_user_unitdir")) 152 searchpaths.append(d.getVar("systemd_user_unitdir"))
156 systemd_packages = d.getVar('SYSTEMD_PACKAGES') 153 systemd_packages = d.getVar('SYSTEMD_PACKAGES')
157 154
158 keys = 'Also'
159 # scan for all in SYSTEMD_SERVICE[] 155 # scan for all in SYSTEMD_SERVICE[]
160 for pkg_systemd in systemd_packages.split(): 156 for pkg_systemd in systemd_packages.split():
161 for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): 157 for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split():
@@ -179,7 +175,7 @@ python systemd_populate_packages() {
179 break 175 break
180 176
181 if path_found != '': 177 if path_found != '':
182 systemd_add_files_and_parse(pkg_systemd, path_found, service, keys) 178 systemd_add_files_and_parse(pkg_systemd, path_found, service)
183 else: 179 else:
184 bb.fatal("Didn't find service unit '{0}', specified in SYSTEMD_SERVICE:{1}. {2}".format( 180 bb.fatal("Didn't find service unit '{0}', specified in SYSTEMD_SERVICE:{1}. {2}".format(
185 service, pkg_systemd, "Also looked for service unit '{0}'.".format(base) if base is not None else "")) 181 service, pkg_systemd, "Also looked for service unit '{0}'.".format(base) if base is not None else ""))