1 DEPENDS_append = " update-rc.d update-rc.d-native"
2 RDEPENDS_${PN}_append = " ${@base_conditional("ONLINE_PACKAGE_MANAGEMENT", "none", "", "update-rc.d", d)}"
3 RDEPENDS_${PN}_virtclass-native = ""
5 INITSCRIPT_PARAMS ?= "defaults"
7 INIT_D_DIR = "${sysconfdir}/init.d"
10 if test "x$D" != "x"; then
15 update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
19 if test "x$D" = "x"; then
20 if test "$1" = "upgrade" -o "$1" = "remove"; then
21 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
26 # Note: to be Debian compliant, we should only invoke update-rc.d remove
27 # at the "purge" step, but opkg does not support it. So instead we also
28 # run it at the "remove" step if the init script no longer exists.
31 if test "x$D" != "x"; then
36 if test "$1" = "remove" -o "$1" = "purge"; then
37 if ! test -e "${INIT_D_DIR}/${INITSCRIPT_NAME}"; then
38 update-rc.d $OPT ${INITSCRIPT_NAME} remove
44 def update_rc_after_parse(d):
45 if bb.data.getVar('INITSCRIPT_PACKAGES', d) == None:
46 if bb.data.getVar('INITSCRIPT_NAME', d) == None:
47 raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_NAME" % bb.data.getVar('FILE', d)
48 if bb.data.getVar('INITSCRIPT_PARAMS', d) == None:
49 raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_PARAMS" % bb.data.getVar('FILE', d)
51 python __anonymous() {
52 update_rc_after_parse(d)
55 python populate_packages_prepend () {
56 def update_rcd_package(pkg):
57 bb.debug(1, 'adding update-rc.d calls to postinst/postrm for %s' % pkg)
58 localdata = bb.data.createCopy(d)
59 overrides = bb.data.getVar("OVERRIDES", localdata, 1)
60 bb.data.setVar("OVERRIDES", "%s:%s" % (pkg, overrides), localdata)
61 bb.data.update_data(localdata)
63 postinst = '#!/bin/sh\n'
65 postinst += bb.data.getVar('pkg_postinst', localdata, 1)
68 postinst += bb.data.getVar('updatercd_postinst', localdata, 1)
69 bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
70 prerm = bb.data.getVar('pkg_prerm', localdata, 1)
73 prerm += bb.data.getVar('updatercd_prerm', localdata, 1)
74 bb.data.setVar('pkg_prerm_%s' % pkg, prerm, d)
75 postrm = bb.data.getVar('pkg_postrm', localdata, 1)
77 postrm = '#!/bin/sh\n'
78 postrm += bb.data.getVar('updatercd_postrm', localdata, 1)
79 bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d)
81 pkgs = bb.data.getVar('INITSCRIPT_PACKAGES', d, 1)
83 pkgs = bb.data.getVar('PN', d, 1)
84 packages = (bb.data.getVar('PACKAGES', d, 1) or "").split()
85 if not pkgs in packages and packages != []:
87 for pkg in pkgs.split():
88 update_rcd_package(pkg)