Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Adrian Freihofer <adrian.freihofer@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Adrian Freihofer <adrian.freihofer@siemens.com>
Subject: [PATCHv2 4/5] systemd.bbclass: do not automatically add Also services
Date: Thu, 12 Dec 2024 16:55:25 +0100	[thread overview]
Message-ID: <20241212164407.2904755-5-adrian.freihofer@gmail.com> (raw)
In-Reply-To: <20241212164407.2904755-1-adrian.freihofer@gmail.com>

From: Adrian Freihofer <adrian.freihofer@siemens.com>

Starting a systemd service “Also” does not mean that both services
must be in the same package. However, the systemd.bbclass enforces
this.

Example:
  a.service:
    [Install]
    Also=b.service
If a.service is packed in package A, b.service is automatically packed
into package A as well. This happens even if b.service is explicitly
added to package B using FILES and SYSTEMD_SERVICE variables.

The automatic packing of socket files with the corresponding service
files is probably a widely used feature of systemd.bbclass. This bahavior
does not change.

Adding regular service files to a package just because it is another
service in the same package that "Also" uses the service is a bug that
this commit fixes.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/classes-recipe/systemd.bbclass | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index be77da48125..4b4470b7b34 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -132,18 +132,18 @@ python systemd_populate_packages() {
                 # for *.service add *@.service
                 service_base = service.replace('.service', '')
                 systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service')
+                # Add the socket unit which is referred by the Also= in this service file to the same package.
+                with open(fullpath, 'r') as unit_f:
+                    for line in unit_f:
+                        if line.startswith('Also'):
+                            also_unit = line.split('=', 1)[1].strip()
+                            if also_unit.find('.socket') != -1:
+                                systemd_add_files_and_parse(pkg_systemd, path, also_unit)
             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')
                 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():
-- 
2.47.0



  parent reply	other threads:[~2024-12-12 16:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12 15:55 [PATCHv2 0/5] systemd split networkd package Adrian Freihofer
2024-12-12 15:55 ` [PATCHv2 1/5] busybox: add klogd service to FILES Adrian Freihofer
2024-12-12 15:55 ` [PATCHv2 2/5] dropbear: add dropbearkey.service " Adrian Freihofer
2024-12-12 15:55 ` [PATCHv2 3/5] systemd.bbclass: refactor adding files Adrian Freihofer
2024-12-12 15:55 ` Adrian Freihofer [this message]
2024-12-12 15:55 ` [PATCHv2 5/5] systemd: split networkd into its own package Adrian Freihofer
2024-12-13 13:53   ` [OE-core] " Bruce Ashfield
2024-12-13 21:48     ` Adrian Freihofer
2024-12-16  4:41       ` Bruce Ashfield
2024-12-16 16:08         ` Freihofer, Adrian
2024-12-16 16:13           ` Bruce Ashfield
2024-12-13 11:18 ` [OE-core] [PATCHv2 0/5] systemd split networkd package Richard Purdie
2024-12-13 21:27   ` Adrian Freihofer

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=20241212164407.2904755-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox