Patchwork [2/4] update-rc.d: automatically rdepend on initscripts-funtions

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Jan. 23, 2014, 12:12 p.m.
Message ID <f1cf5165fbbb4f3d90a6d8f35b26b8ad706e672a.1390479069.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/65611/
State Accepted
Commit 021129ab0bef2d0a5d3c0377ab1c89a934dec86f
Headers show

Comments

Qi.Chen@windriver.com - Jan. 23, 2014, 12:12 p.m.
Automatically add 'initscripts-functions' to packages when needed.

This extra dependency is added only when the package's init script
would be used at system start-up. In other words, in a systemd based
image, if the package has already got its service files, it will not
have this extra dependency.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/update-rc.d.bbclass |   12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch

diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index c9bf04c..ad803c2 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -71,6 +71,16 @@  PACKAGESPLITFUNCS_prepend = "populate_packages_updatercd "
 populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst"
 
 python populate_packages_updatercd () {
+    def update_rcd_auto_depend(pkg):
+        import subprocess
+        import os
+        path = d.expand("${D}${INIT_D_DIR}/${INITSCRIPT_NAME}")
+        if not os.path.exists(path):
+            return
+        statement = "grep -q -w '/etc/init.d/functions' %s" % path
+        if subprocess.call(statement, shell=True) == 0:
+            d.appendVar('RDEPENDS_' + pkg, ' initscripts-functions')
+
     def update_rcd_package(pkg):
         bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg)
 
@@ -79,6 +89,8 @@  python populate_packages_updatercd () {
         localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides))
         bb.data.update_data(localdata)
 
+        update_rcd_auto_depend(pkg)
+
         preinst = d.getVar('pkg_preinst_%s' % pkg, True)
         if not preinst:
             preinst = '#!/bin/sh\n'