diff options
Diffstat (limited to 'meta/classes/update-rc.d.bbclass')
-rw-r--r-- | meta/classes/update-rc.d.bbclass | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass deleted file mode 100644 index 1366fee653..0000000000 --- a/meta/classes/update-rc.d.bbclass +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | UPDATERCPN ?= "${PN}" | ||
2 | |||
3 | DEPENDS_append_class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', ' update-rc.d initscripts', '', d)}" | ||
4 | |||
5 | UPDATERCD = "update-rc.d" | ||
6 | UPDATERCD_class-cross = "" | ||
7 | UPDATERCD_class-native = "" | ||
8 | UPDATERCD_class-nativesdk = "" | ||
9 | |||
10 | INITSCRIPT_PARAMS ?= "defaults" | ||
11 | |||
12 | INIT_D_DIR = "${sysconfdir}/init.d" | ||
13 | |||
14 | def use_updatercd(d): | ||
15 | # If the distro supports both sysvinit and systemd, and the current recipe | ||
16 | # supports systemd, only call update-rc.d on rootfs creation or if systemd | ||
17 | # is not running. That's because systemctl enable/disable will already call | ||
18 | # update-rc.d if it detects initscripts. | ||
19 | if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and bb.data.inherits_class('systemd', d): | ||
20 | return '[ -n "$D" -o ! -d /run/systemd/system ]' | ||
21 | return 'true' | ||
22 | |||
23 | PACKAGE_WRITE_DEPS += "update-rc.d-native" | ||
24 | |||
25 | updatercd_postinst() { | ||
26 | if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then | ||
27 | if [ -n "$D" ]; then | ||
28 | OPT="-r $D" | ||
29 | else | ||
30 | OPT="-s" | ||
31 | fi | ||
32 | update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} | ||
33 | fi | ||
34 | } | ||
35 | |||
36 | updatercd_prerm() { | ||
37 | if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then | ||
38 | ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : | ||
39 | fi | ||
40 | } | ||
41 | |||
42 | updatercd_postrm() { | ||
43 | if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then | ||
44 | if [ -n "$D" ]; then | ||
45 | OPT="-f -r $D" | ||
46 | else | ||
47 | OPT="-f" | ||
48 | fi | ||
49 | update-rc.d $OPT ${INITSCRIPT_NAME} remove | ||
50 | fi | ||
51 | } | ||
52 | |||
53 | |||
54 | def update_rc_after_parse(d): | ||
55 | if d.getVar('INITSCRIPT_PACKAGES', False) == None: | ||
56 | if d.getVar('INITSCRIPT_NAME', False) == None: | ||
57 | bb.fatal("%s inherits update-rc.d but doesn't set INITSCRIPT_NAME" % d.getVar('FILE', False)) | ||
58 | if d.getVar('INITSCRIPT_PARAMS', False) == None: | ||
59 | bb.fatal("%s inherits update-rc.d but doesn't set INITSCRIPT_PARAMS" % d.getVar('FILE', False)) | ||
60 | |||
61 | python __anonymous() { | ||
62 | update_rc_after_parse(d) | ||
63 | } | ||
64 | |||
65 | PACKAGESPLITFUNCS_prepend = "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'populate_packages_updatercd ', '', d)}" | ||
66 | PACKAGESPLITFUNCS_remove_class-nativesdk = "populate_packages_updatercd " | ||
67 | |||
68 | populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst" | ||
69 | populate_packages_updatercd[vardepsexclude] += "OVERRIDES" | ||
70 | |||
71 | python populate_packages_updatercd () { | ||
72 | def update_rcd_auto_depend(pkg): | ||
73 | import subprocess | ||
74 | import os | ||
75 | path = d.expand("${D}${INIT_D_DIR}/${INITSCRIPT_NAME}") | ||
76 | if not os.path.exists(path): | ||
77 | return | ||
78 | statement = "grep -q -w '/etc/init.d/functions' %s" % path | ||
79 | if subprocess.call(statement, shell=True) == 0: | ||
80 | mlprefix = d.getVar('MLPREFIX') or "" | ||
81 | d.appendVar('RDEPENDS_' + pkg, ' %sinitd-functions' % (mlprefix)) | ||
82 | |||
83 | def update_rcd_package(pkg): | ||
84 | bb.debug(1, 'adding update-rc.d calls to postinst/prerm/postrm for %s' % pkg) | ||
85 | |||
86 | localdata = bb.data.createCopy(d) | ||
87 | overrides = localdata.getVar("OVERRIDES") | ||
88 | localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides)) | ||
89 | |||
90 | update_rcd_auto_depend(pkg) | ||
91 | |||
92 | postinst = d.getVar('pkg_postinst_%s' % pkg) | ||
93 | if not postinst: | ||
94 | postinst = '#!/bin/sh\n' | ||
95 | postinst += localdata.getVar('updatercd_postinst') | ||
96 | d.setVar('pkg_postinst_%s' % pkg, postinst) | ||
97 | |||
98 | prerm = d.getVar('pkg_prerm_%s' % pkg) | ||
99 | if not prerm: | ||
100 | prerm = '#!/bin/sh\n' | ||
101 | prerm += localdata.getVar('updatercd_prerm') | ||
102 | d.setVar('pkg_prerm_%s' % pkg, prerm) | ||
103 | |||
104 | postrm = d.getVar('pkg_postrm_%s' % pkg) | ||
105 | if not postrm: | ||
106 | postrm = '#!/bin/sh\n' | ||
107 | postrm += localdata.getVar('updatercd_postrm') | ||
108 | d.setVar('pkg_postrm_%s' % pkg, postrm) | ||
109 | |||
110 | d.appendVar('RRECOMMENDS_' + pkg, " ${MLPREFIX}${UPDATERCD}") | ||
111 | |||
112 | # Check that this class isn't being inhibited (generally, by | ||
113 | # systemd.bbclass) before doing any work. | ||
114 | if not d.getVar("INHIBIT_UPDATERCD_BBCLASS"): | ||
115 | pkgs = d.getVar('INITSCRIPT_PACKAGES') | ||
116 | if pkgs == None: | ||
117 | pkgs = d.getVar('UPDATERCPN') | ||
118 | packages = (d.getVar('PACKAGES') or "").split() | ||
119 | if not pkgs in packages and packages != []: | ||
120 | pkgs = packages[0] | ||
121 | for pkg in pkgs.split(): | ||
122 | update_rcd_package(pkg) | ||
123 | } | ||