mirror of
https://git.yoctoproject.org/poky
synced 2026-09-24 22:36:21 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
86a1b62e2f
commit
0324f69749
@@ -124,29 +124,26 @@ python systemd_populate_packages() {
|
|||||||
return appended
|
return appended
|
||||||
|
|
||||||
# Add systemd files to FILES:*-systemd, parse for Also= and follow recursive
|
# Add systemd files to FILES:*-systemd, parse for Also= and follow recursive
|
||||||
def systemd_add_files_and_parse(pkg_systemd, path, service, keys):
|
def systemd_add_files_and_parse(pkg_systemd, path, service):
|
||||||
# avoid infinite recursion
|
# avoid infinite recursion
|
||||||
if systemd_append_file(pkg_systemd, oe.path.join(path, service)):
|
if systemd_append_file(pkg_systemd, oe.path.join(path, service)):
|
||||||
fullpath = oe.path.join(d.getVar("D"), path, service)
|
fullpath = oe.path.join(d.getVar("D"), path, service)
|
||||||
if service.find('.service') != -1:
|
if service.find('.service') != -1:
|
||||||
# for *.service add *@.service
|
# for *.service add *@.service
|
||||||
service_base = service.replace('.service', '')
|
service_base = service.replace('.service', '')
|
||||||
systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys)
|
systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service')
|
||||||
if service.find('.socket') != -1:
|
if service.find('.socket') != -1:
|
||||||
# for *.socket add *.service and *@.service
|
# for *.socket add *.service and *@.service
|
||||||
service_base = service.replace('.socket', '')
|
service_base = service.replace('.socket', '')
|
||||||
systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service', keys)
|
systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service')
|
||||||
systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys)
|
systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service')
|
||||||
for key in keys.split():
|
# Add all units which have an Also= referring a unit in this package to this package as well.
|
||||||
# recurse all dependencies found in keys ('Also';'Conflicts';..) and add to files
|
with open(fullpath, 'r') as unit_f:
|
||||||
cmd = "grep %s %s | sed 's,%s=,,g' | tr ',' '\\n'" % (key, shlex.quote(fullpath), key)
|
for line in unit_f:
|
||||||
pipe = os.popen(cmd, 'r')
|
if line.startswith('Also'):
|
||||||
line = pipe.readline()
|
also_unit = line.split('=', 1)[1].strip()
|
||||||
while line:
|
bb.warn("also: %s" % also_unit)
|
||||||
line = line.replace('\n', '')
|
systemd_add_files_and_parse(pkg_systemd, path, also_unit)
|
||||||
systemd_add_files_and_parse(pkg_systemd, path, line, keys)
|
|
||||||
line = pipe.readline()
|
|
||||||
pipe.close()
|
|
||||||
|
|
||||||
# Check service-files and call systemd_add_files_and_parse for each entry
|
# Check service-files and call systemd_add_files_and_parse for each entry
|
||||||
def systemd_check_services():
|
def systemd_check_services():
|
||||||
@@ -155,7 +152,6 @@ python systemd_populate_packages() {
|
|||||||
searchpaths.append(d.getVar("systemd_user_unitdir"))
|
searchpaths.append(d.getVar("systemd_user_unitdir"))
|
||||||
systemd_packages = d.getVar('SYSTEMD_PACKAGES')
|
systemd_packages = d.getVar('SYSTEMD_PACKAGES')
|
||||||
|
|
||||||
keys = 'Also'
|
|
||||||
# scan for all in SYSTEMD_SERVICE[]
|
# scan for all in SYSTEMD_SERVICE[]
|
||||||
for pkg_systemd in systemd_packages.split():
|
for pkg_systemd in systemd_packages.split():
|
||||||
for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split():
|
for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split():
|
||||||
@@ -179,7 +175,7 @@ python systemd_populate_packages() {
|
|||||||
break
|
break
|
||||||
|
|
||||||
if path_found != '':
|
if path_found != '':
|
||||||
systemd_add_files_and_parse(pkg_systemd, path_found, service, keys)
|
systemd_add_files_and_parse(pkg_systemd, path_found, service)
|
||||||
else:
|
else:
|
||||||
bb.fatal("Didn't find service unit '{0}', specified in SYSTEMD_SERVICE:{1}. {2}".format(
|
bb.fatal("Didn't find service unit '{0}', specified in SYSTEMD_SERVICE:{1}. {2}".format(
|
||||||
service, pkg_systemd, "Also looked for service unit '{0}'.".format(base) if base is not None else ""))
|
service, pkg_systemd, "Also looked for service unit '{0}'.".format(base) if base is not None else ""))
|
||||||
|
|||||||
Reference in New Issue
Block a user