summaryrefslogtreecommitdiffstats
path: root/meta/classes/update-rc.d.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/update-rc.d.bbclass')
-rw-r--r--meta/classes/update-rc.d.bbclass90
1 files changed, 1 insertions, 89 deletions
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 83816d6ad6..34f9838084 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -1,89 +1 @@
1UPDATERCPN ?= "${PN}" inherit ${@base_contains('DISTRO_FEATURES','sysvinit','update-rc.d_real','',d)}
2
3DEPENDS_append = " update-rc.d-native"
4UPDATERCD = "update-rc.d"
5UPDATERCD_virtclass-cross = ""
6UPDATERCD_class-native = ""
7UPDATERCD_class-nativesdk = ""
8
9RDEPENDS_${UPDATERCPN}_append = " ${UPDATERCD}"
10
11INITSCRIPT_PARAMS ?= "defaults"
12
13INIT_D_DIR = "${sysconfdir}/init.d"
14
15updatercd_postinst() {
16if test "x$D" != "x"; then
17 OPT="-r $D"
18else
19 OPT="-s"
20fi
21update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
22}
23
24updatercd_prerm() {
25if test "x$D" = "x"; then
26 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
27fi
28}
29
30updatercd_postrm() {
31if [ "$D" != "" ]; then
32 update-rc.d -f -r $D ${INITSCRIPT_NAME} remove
33else
34 update-rc.d ${INITSCRIPT_NAME} remove
35fi
36}
37
38
39def update_rc_after_parse(d):
40 if d.getVar('INITSCRIPT_PACKAGES') == None:
41 if d.getVar('INITSCRIPT_NAME') == None:
42 raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_NAME" % d.getVar('FILE')
43 if d.getVar('INITSCRIPT_PARAMS') == None:
44 raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_PARAMS" % d.getVar('FILE')
45
46python __anonymous() {
47 update_rc_after_parse(d)
48}
49
50python populate_packages_prepend () {
51 def update_rcd_package(pkg):
52 bb.debug(1, 'adding update-rc.d calls to postinst/postrm for %s' % pkg)
53 localdata = bb.data.createCopy(d)
54 overrides = localdata.getVar("OVERRIDES", True)
55 localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides))
56 bb.data.update_data(localdata)
57
58 """
59 update_rc.d postinst is appended here because pkg_postinst may require to
60 execute on the target. Not doing so may cause update_rc.d postinst invoked
61 twice to cause unwanted warnings.
62 """
63 postinst = localdata.getVar('pkg_postinst', True)
64 if not postinst:
65 postinst = '#!/bin/sh\n'
66 postinst += localdata.getVar('updatercd_postinst', True)
67 d.setVar('pkg_postinst_%s' % pkg, postinst)
68
69 prerm = localdata.getVar('pkg_prerm', True)
70 if not prerm:
71 prerm = '#!/bin/sh\n'
72 prerm += localdata.getVar('updatercd_prerm', True)
73 d.setVar('pkg_prerm_%s' % pkg, prerm)
74
75 postrm = localdata.getVar('pkg_postrm', True)
76 if not postrm:
77 postrm = '#!/bin/sh\n'
78 postrm += localdata.getVar('updatercd_postrm', True)
79 d.setVar('pkg_postrm_%s' % pkg, postrm)
80
81 pkgs = d.getVar('INITSCRIPT_PACKAGES', True)
82 if pkgs == None:
83 pkgs = d.getVar('UPDATERCPN', True)
84 packages = (d.getVar('PACKAGES', True) or "").split()
85 if not pkgs in packages and packages != []:
86 pkgs = packages[0]
87 for pkg in pkgs.split():
88 update_rcd_package(pkg)
89}