diff options
-rw-r--r-- | meta/classes/update-rc.d.bbclass | 90 | ||||
-rw-r--r-- | meta/classes/update-rc.d_real.bbclass | 89 |
2 files changed, 90 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 @@ | |||
1 | UPDATERCPN ?= "${PN}" | inherit ${@base_contains('DISTRO_FEATURES','sysvinit','update-rc.d_real','',d)} | |
2 | |||
3 | DEPENDS_append = " update-rc.d-native" | ||
4 | UPDATERCD = "update-rc.d" | ||
5 | UPDATERCD_virtclass-cross = "" | ||
6 | UPDATERCD_class-native = "" | ||
7 | UPDATERCD_class-nativesdk = "" | ||
8 | |||
9 | RDEPENDS_${UPDATERCPN}_append = " ${UPDATERCD}" | ||
10 | |||
11 | INITSCRIPT_PARAMS ?= "defaults" | ||
12 | |||
13 | INIT_D_DIR = "${sysconfdir}/init.d" | ||
14 | |||
15 | updatercd_postinst() { | ||
16 | if test "x$D" != "x"; then | ||
17 | OPT="-r $D" | ||
18 | else | ||
19 | OPT="-s" | ||
20 | fi | ||
21 | update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} | ||
22 | } | ||
23 | |||
24 | updatercd_prerm() { | ||
25 | if test "x$D" = "x"; then | ||
26 | ${INIT_D_DIR}/${INITSCRIPT_NAME} stop | ||
27 | fi | ||
28 | } | ||
29 | |||
30 | updatercd_postrm() { | ||
31 | if [ "$D" != "" ]; then | ||
32 | update-rc.d -f -r $D ${INITSCRIPT_NAME} remove | ||
33 | else | ||
34 | update-rc.d ${INITSCRIPT_NAME} remove | ||
35 | fi | ||
36 | } | ||
37 | |||
38 | |||
39 | def 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 | |||
46 | python __anonymous() { | ||
47 | update_rc_after_parse(d) | ||
48 | } | ||
49 | |||
50 | python 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 | } | ||
diff --git a/meta/classes/update-rc.d_real.bbclass b/meta/classes/update-rc.d_real.bbclass new file mode 100644 index 0000000000..83816d6ad6 --- /dev/null +++ b/meta/classes/update-rc.d_real.bbclass | |||
@@ -0,0 +1,89 @@ | |||
1 | UPDATERCPN ?= "${PN}" | ||
2 | |||
3 | DEPENDS_append = " update-rc.d-native" | ||
4 | UPDATERCD = "update-rc.d" | ||
5 | UPDATERCD_virtclass-cross = "" | ||
6 | UPDATERCD_class-native = "" | ||
7 | UPDATERCD_class-nativesdk = "" | ||
8 | |||
9 | RDEPENDS_${UPDATERCPN}_append = " ${UPDATERCD}" | ||
10 | |||
11 | INITSCRIPT_PARAMS ?= "defaults" | ||
12 | |||
13 | INIT_D_DIR = "${sysconfdir}/init.d" | ||
14 | |||
15 | updatercd_postinst() { | ||
16 | if test "x$D" != "x"; then | ||
17 | OPT="-r $D" | ||
18 | else | ||
19 | OPT="-s" | ||
20 | fi | ||
21 | update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} | ||
22 | } | ||
23 | |||
24 | updatercd_prerm() { | ||
25 | if test "x$D" = "x"; then | ||
26 | ${INIT_D_DIR}/${INITSCRIPT_NAME} stop | ||
27 | fi | ||
28 | } | ||
29 | |||
30 | updatercd_postrm() { | ||
31 | if [ "$D" != "" ]; then | ||
32 | update-rc.d -f -r $D ${INITSCRIPT_NAME} remove | ||
33 | else | ||
34 | update-rc.d ${INITSCRIPT_NAME} remove | ||
35 | fi | ||
36 | } | ||
37 | |||
38 | |||
39 | def 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 | |||
46 | python __anonymous() { | ||
47 | update_rc_after_parse(d) | ||
48 | } | ||
49 | |||
50 | python 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 | } | ||