Skip to contentSkip to conversation

systemd: Add systemd package to PACKAGE var

PATCH In review Khem Raj 3 participants 8 messages Feb 12, 2013

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 systemd: Add systemd package to PACKAGE var

If someone defines SYSTEMD_PACKAGES to be different then ${PN} then we need to make sure that they get added to PACKAGES variable

---
 meta/classes/systemd.bbclass |    7 +++++++
 1 file changed, 7 insertions(+)
meta/classes/systemd.bbclass +7 -0
index 32cc5c2..672f304 100644
@@ -46,6 +46,12 @@ def systemd_populate_packages(d):
             val = (d.getVar(var, True) or "").strip()
         return val
 
+    # prepend systemd-packages not already included
+    def systemd_create_package(pkg_systemd):
+        packages = d.getVar('PACKAGES', True)
+        if not pkg_systemd in packages:
+            d.appendVar('PACKAGES', " " + pkg_systemd)
+
 
     # Add a runtime dependency on systemd to pkg
     def systemd_add_rdepends(pkg):
@@ -144,6 +150,7 @@ def systemd_populate_packages(d):
     # Run all modifications once when creating package
     if os.path.exists(d.getVar("D", True)):
         for pkg in d.getVar('SYSTEMD_PACKAGES', True).split():
+            systemd_create_package(pkg)
             if d.getVar('SYSTEMD_SERVICE_' + pkg, True):
                 systemd_generate_package_scripts(pkg)
                 systemd_add_rdepends(pkg)
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 3 lines · Khem Raj

If someone defines SYSTEMD_PACKAGES to be different then ${PN} then we need to make sure that they get added to PACKAGES variable

The only case it won't already be in PACKAGES is if you're creating a package which contains just the service file, which as I've said before isn't recommended - package the service files along with the binaries that they are executing.

Or is there another use-case I'm missing?

Ross

#2 lore raw
Quoted 8 lines · Ross Burton
Quoted 3 lines · Khem Raj

If someone defines SYSTEMD_PACKAGES to be different then ${PN} then we need to make sure that they get added to PACKAGES variable

The only case it won't already be in PACKAGES is if you're creating a package which contains just the service file, which as I've said before isn't recommended - package the service files along with the binaries that they are executing.

Or is there another use-case I'm missing?

Well, there is always the possibillity that the install is split into multiple packages, with binaries also in some sub-packages. I can't recall right now if we have such packages, where the binaries in the sub-packages should be started by init, though.

Still, I'd say that it might be a valid use case for some applications.

Cheers,
Anders

Signature · 2 lines
Anders Darander
ChargeStorm AB / eStorm AB
#3 lore raw
Quoted 6 lines · Anders Darander
Quoted 1 line

Or is there another use-case I'm missing?

Well, there is always the possibillity that the install is split into multiple packages, with binaries also in some sub-packages. I can't recall right now if we have such packages, where the binaries in the sub-packages should be started by init, though.

And those sub-packages are obviously already in PACKAGES, so this isn't required again. I'm just trying to keep the amount of magic in the class to a minimum unless it's required.

Ross

#4 lore raw
Quoted 11 lines · Ross Burton
Quoted 6 lines · Anders Darander
Quoted 1 line

Or is there another use-case I'm missing?

Well, there is always the possibillity that the install is split into multiple packages, with binaries also in some sub-packages. I can't recall right now if we have such packages, where the binaries in the sub-packages should be started by init, though.

And those sub-packages are obviously already in PACKAGES, so this isn't required again. I'm just trying to keep the amount of magic in the class to a minimum unless it's required.

Ah, of course they are...

I completely mis-read the patch... As the patch only was concerned with adding packages to PACKAGES, I completely agree with you. Lets get rid of that extra magic.

Cheers,
Anders

Signature · 2 lines
Anders Darander
ChargeStorm AB / eStorm AB
author
#5 lore raw
In reply to Ross Burton
Quoted 8 lines · Ross Burton
Quoted 3 lines · Khem Raj

If someone defines SYSTEMD_PACKAGES to be different then ${PN} then we need to make sure that they get added to PACKAGES variable

The only case it won't already be in PACKAGES is if you're creating a package which contains just the service file, which as I've said before isn't recommended - package the service files along with the binaries that they are executing.

Or is there another use-case I'm missing?

Thinking about it from different perspective, I agree that probably adding an extra package is not right and having unitfiles as part of package proper is fine. but we should definitely have a check where if SYSTEMD_PACKAGES dont exist in PACKAGES then it should error out or warn about it.

Quoted 2 lines

Ross

#6 lore raw
Quoted 5 lines · Khem Raj

Thinking about it from different perspective, I agree that probably adding an extra package is not right and having unitfiles as part of package proper is fine. but we should definitely have a check where if SYSTEMD_PACKAGES dont exist in PACKAGES then it should error out or warn about it.

Yes, throwing an error/warning does make sense, as the alternative would be files mysteriously disappearing. Can you send a patch for that?

Ross

author
#7 lore raw
Quoted 4 lines · Ross

Yes, throwing an error/warning does make sense, as the alternative would be files mysteriously disappearing. Can you send a patch for that?

I have something for test.