All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Make systemd.bbclass work without SYSTEMD_AUTO_ENABLE.
@ 2013-06-26 17:33 Randy Witt
  2013-06-26 17:33 ` [PATCH 1/2] systemd: Don't enable systemd services when native Randy Witt
  2013-06-26 17:33 ` [PATCH 2/2] systemd: Move functions that only affect metadata to parse time Randy Witt
  0 siblings, 2 replies; 4+ messages in thread
From: Randy Witt @ 2013-06-26 17:33 UTC (permalink / raw)
  To: openembedded-core

Currently when using systemd.bbclass, the package will always get a
postinst function that either enables or disables on install, based
on the value of the SYSTEMD_AUTO_ENABLE variable.

There are instances where automatic disabling or enabling on package
install is not desired so this set of patches allows for a package
to override the systemd_postinst routine to be empty.

The moving of the functions in the second patch is mostly to make sure
that changes to systemd_postinst in a recipe actually cause the package
tasks to rerun.

Randy Witt (2):
  systemd: Don't enable systemd services when native.
  systemd: Move functions that only affect metadata to parse time.

 meta/classes/systemd.bbclass | 72 ++++++++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 33 deletions(-)

-- 
1.8.1.4



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] systemd: Don't enable systemd services when native.
  2013-06-26 17:33 [PATCH 0/2] Make systemd.bbclass work without SYSTEMD_AUTO_ENABLE Randy Witt
@ 2013-06-26 17:33 ` Randy Witt
  2013-06-26 17:33 ` [PATCH 2/2] systemd: Move functions that only affect metadata to parse time Randy Witt
  1 sibling, 0 replies; 4+ messages in thread
From: Randy Witt @ 2013-06-26 17:33 UTC (permalink / raw)
  To: openembedded-core

From: Randy Witt <rewitt@lpdev.prtdev.lexmark.com>

It shouldn't be desired that systemd enable services when using
class native. Blanking out the SYSTEMD_PACKAGES when native seems
like the most straightforward way to fix this problem.

Signed-off-by: Randy Witt <rewitt@declaratino.com>
---
 meta/classes/systemd.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index 86d9a9a..0447e53 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -2,6 +2,8 @@
 # each entry, optionally have a SYSTEMD_SERVICE_[package] that lists the service
 # files in this package.  If this variable isn't set, [package].service is used.
 SYSTEMD_PACKAGES ?= "${PN}"
+SYSTEMD_PACKAGES_class-native ?= ""
+SYSTEMD_PACKAGES_class-nativesdk ?= ""
 
 # Whether to enable or disable the services on installation.
 SYSTEMD_AUTO_ENABLE ??= "enable"
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] systemd: Move functions that only affect metadata to parse time.
  2013-06-26 17:33 [PATCH 0/2] Make systemd.bbclass work without SYSTEMD_AUTO_ENABLE Randy Witt
  2013-06-26 17:33 ` [PATCH 1/2] systemd: Don't enable systemd services when native Randy Witt
@ 2013-06-26 17:33 ` Randy Witt
  2013-07-04 10:14   ` Burton, Ross
  1 sibling, 1 reply; 4+ messages in thread
From: Randy Witt @ 2013-06-26 17:33 UTC (permalink / raw)
  To: openembedded-core

From: Randy Witt <rewitt@lpdev.prtdev.lexmark.com>

The functions that don't have dependencies on the data in ${D} should
run at parse time. This way overrides behave correctly and the
python functions can actually be replaced/redefined in individual
recipes.

i.e:
systemd_postinst_${PN} () {
}

This is useful for times when you don't want to enable or disable a
service automatically on install, but still want the rest of the
functionality of the systemd.bbclass.

Signed-off-by: Randy Witt <rewitt@declaratino.com>
---
 meta/classes/systemd.bbclass | 70 +++++++++++++++++++++++---------------------
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index 0447e53..b997f32 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -12,6 +12,37 @@ SYSTEMD_AUTO_ENABLE ??= "enable"
 # even if the systemd DISTRO_FEATURE isn't enabled.  As such don't make any
 # changes directly but check the DISTRO_FEATURES first.
 python __anonymous() {
+    # Check if systemd-packages already included in PACKAGES
+    def systemd_check_package(pkg_systemd):
+        packages = d.getVar('PACKAGES', True)
+        if not pkg_systemd in packages.split():
+            bb.error('%s does not appear in package list, please add it' % pkg_systemd)
+
+
+    def systemd_generate_package_scripts(pkg):
+        bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg)
+
+        # Add pkg to the overrides so that it finds the SYSTEMD_SERVICE_pkg
+        # variable.
+        localdata = d.createCopy()
+        localdata.prependVar("OVERRIDES", pkg + ":")
+        bb.data.update_data(localdata)
+
+        shebang = '#!/bin/sh\n'
+        postinst = d.getVar('pkg_postinst_%s' % pkg, True)
+        if not postinst:
+            postinst = shebang
+        postinst += localdata.getVar('systemd_postinst', True)
+        if postinst != shebang:
+            d.setVar('pkg_postinst_%s' % pkg, postinst)
+
+        prerm = d.getVar('pkg_prerm_%s' % pkg, True)
+        if not prerm:
+            prerm = '#!/bin/sh\n'
+        prerm += localdata.getVar('systemd_prerm', True)
+        d.setVar('pkg_prerm_%s' % pkg, prerm)
+
+
     features = d.getVar("DISTRO_FEATURES", True).split()
     # If the distro features have systemd but not sysvinit, inhibit update-rcd
     # from doing any work so that pure-systemd images don't have redundant init
@@ -20,6 +51,12 @@ python __anonymous() {
         d.appendVar("DEPENDS", " systemd-systemctl-native")
         if "sysvinit" not in features:
             d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
+
+        for pkg in d.getVar('SYSTEMD_PACKAGES', True).split():
+            systemd_check_package(pkg)
+            if d.getVar('SYSTEMD_SERVICE_' + pkg, True):
+                systemd_generate_package_scripts(pkg)
+
 }
 
 systemd_postinst() {
@@ -58,35 +95,6 @@ python systemd_populate_packages() {
             val = (d.getVar(var, True) or "").strip()
         return val
 
-    # Check if systemd-packages already included in PACKAGES
-    def systemd_check_package(pkg_systemd):
-        packages = d.getVar('PACKAGES', True)
-        if not pkg_systemd in packages.split():
-            bb.error('%s does not appear in package list, please add it' % pkg_systemd)
-
-
-    def systemd_generate_package_scripts(pkg):
-        bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg)
-
-        # Add pkg to the overrides so that it finds the SYSTEMD_SERVICE_pkg
-        # variable.
-        localdata = d.createCopy()
-        localdata.prependVar("OVERRIDES", pkg + ":")
-        bb.data.update_data(localdata)
-
-        postinst = d.getVar('pkg_postinst_%s' % pkg, True)
-        if not postinst:
-            postinst = '#!/bin/sh\n'
-        postinst += localdata.getVar('systemd_postinst', True)
-        d.setVar('pkg_postinst_%s' % pkg, postinst)
-
-        prerm = d.getVar('pkg_prerm_%s' % pkg, True)
-        if not prerm:
-            prerm = '#!/bin/sh\n'
-        prerm += localdata.getVar('systemd_prerm', True)
-        d.setVar('pkg_prerm_%s' % pkg, prerm)
-
-
     # Add files to FILES_*-systemd if existent and not already done
     def systemd_append_file(pkg_systemd, file_append):
         appended = False
@@ -153,10 +161,6 @@ python systemd_populate_packages() {
 
     # 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_check_package(pkg)
-            if d.getVar('SYSTEMD_SERVICE_' + pkg, True):
-                systemd_generate_package_scripts(pkg)
         systemd_check_services()
 }
 
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] systemd: Move functions that only affect metadata to parse time.
  2013-06-26 17:33 ` [PATCH 2/2] systemd: Move functions that only affect metadata to parse time Randy Witt
@ 2013-07-04 10:14   ` Burton, Ross
  0 siblings, 0 replies; 4+ messages in thread
From: Burton, Ross @ 2013-07-04 10:14 UTC (permalink / raw)
  To: Randy Witt; +Cc: openembedded-core

On 26 June 2013 18:33, Randy Witt <rewitt@declaratino.com> wrote:
> This is useful for times when you don't want to enable or disable a
> service automatically on install, but still want the rest of the
> functionality of the systemd.bbclass.

This seems like a brute-force way of approaching the problem, which is
that you don't want a service explicitly enabled or disabled on
install.

Why not extend the usage of SYSTEMD_AUTO_ENABLE and support setting it
to ""?  i.e. "enable" means enable it, "disable" means disable it, and
"" means do nothing.

Ross


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-04 10:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26 17:33 [PATCH 0/2] Make systemd.bbclass work without SYSTEMD_AUTO_ENABLE Randy Witt
2013-06-26 17:33 ` [PATCH 1/2] systemd: Don't enable systemd services when native Randy Witt
2013-06-26 17:33 ` [PATCH 2/2] systemd: Move functions that only affect metadata to parse time Randy Witt
2013-07-04 10:14   ` Burton, Ross

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.