From: Adrian Freihofer <adrian.freihofer@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Adrian Freihofer <adrian.freihofer@siemens.com>
Subject: [PATCH 3/5] systemd.bbclass: refactor adding files
Date: Wed, 11 Dec 2024 22:58:39 +0100 [thread overview]
Message-ID: <20241211215859.2187259-4-adrian.freihofer@gmail.com> (raw)
In-Reply-To: <20241211215859.2187259-1-adrian.freihofer@gmail.com>
From: Adrian Freihofer <adrian.freihofer@siemens.com>
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.
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
meta/classes-recipe/systemd.bbclass | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 7324af8555d..be77da48125 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -124,29 +124,26 @@ python systemd_populate_packages() {
return appended
# 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
if systemd_append_file(pkg_systemd, oe.path.join(path, service)):
fullpath = oe.path.join(d.getVar("D"), path, service)
if service.find('.service') != -1:
# for *.service add *@.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:
# for *.socket add *.service and *@.service
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', keys)
- for key in keys.split():
- # recurse all dependencies found in keys ('Also';'Conflicts';..) and add to files
- cmd = "grep %s %s | sed 's,%s=,,g' | tr ',' '\\n'" % (key, shlex.quote(fullpath), key)
- pipe = os.popen(cmd, 'r')
- line = pipe.readline()
- while line:
- line = line.replace('\n', '')
- systemd_add_files_and_parse(pkg_systemd, path, line, keys)
- line = pipe.readline()
- pipe.close()
+ systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service')
+ systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service')
+ # Add all units which have an Also= referring a unit in this package to this package as well.
+ with open(fullpath, 'r') as unit_f:
+ for line in unit_f:
+ if line.startswith('Also'):
+ also_unit = line.split('=', 1)[1].strip()
+ bb.warn("also: %s" % also_unit)
+ systemd_add_files_and_parse(pkg_systemd, path, also_unit)
# Check service-files and call systemd_add_files_and_parse for each entry
def systemd_check_services():
@@ -155,7 +152,6 @@ python systemd_populate_packages() {
searchpaths.append(d.getVar("systemd_user_unitdir"))
systemd_packages = d.getVar('SYSTEMD_PACKAGES')
- keys = 'Also'
# scan for all in SYSTEMD_SERVICE[]
for pkg_systemd in systemd_packages.split():
for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split():
@@ -179,7 +175,7 @@ python systemd_populate_packages() {
break
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:
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 ""))
--
2.47.0
next prev parent reply other threads:[~2024-12-11 21:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 21:58 [PATCH 0/5] systemd split networkd package Adrian Freihofer
2024-12-11 21:58 ` [PATCH 1/5] busybox: add klogd service to FILES Adrian Freihofer
2024-12-11 21:58 ` [PATCH 2/5] dropbear: add dropbearkey.service " Adrian Freihofer
2024-12-11 21:58 ` Adrian Freihofer [this message]
2024-12-11 21:58 ` [PATCH 4/5] systemd.bbclass: do not automatically add Also services Adrian Freihofer
2024-12-11 21:58 ` [PATCH 5/5] systemd: split networkd into its own package Adrian Freihofer
2024-12-12 12:02 ` [OE-core] " Mathieu Dubois-Briand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241211215859.2187259-4-adrian.freihofer@gmail.com \
--to=adrian.freihofer@gmail.com \
--cc=adrian.freihofer@siemens.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.