summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@siemens.com>2024-12-12 16:55:24 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-12-17 11:41:52 +0000
commit0324f6974964b9bc32726e9cbb5b718d90c78503 (patch)
treebeb166eefbabd2926f1a5194e5c404f0de818208 /meta/classes-recipe
parent86a1b62e2f042a0433ee1ce77e8fab741a698d08 (diff)
downloadpoky-0324f6974964b9bc32726e9cbb5b718d90c78503.tar.gz
systemd.bbclass: refactor adding files
The keys variable was intended as an array of keys. But it looks like this has not been used for more than 10 years now. Adding files automatically to packages needs probably anyway very specific code rather than a generic loop. Lets simplify this a bit. Using python code should also not be slower for these usually small files. (From OE-Core rev: 0eda7131bf743719d6586ccd36d99cbe11c88262) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
-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 ""))