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