summaryrefslogtreecommitdiffstats
path: root/meta/classes/update-rc.d.bbclass
diff options
context:
space:
mode:
authorDavid Vincent <freesilicon@gmail.com>2017-01-25 15:03:06 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-08 12:00:21 +0000
commit7cf454e23cdead13dd0041b626045e19d4889bf5 (patch)
treef18de8ef09dc5f8e8a1b5af7a55fd775bfea5dab /meta/classes/update-rc.d.bbclass
parent5bdf7c980b509330a35fef1dcf28d0d359c7bd6e (diff)
downloadpoky-7cf454e23cdead13dd0041b626045e19d4889bf5.tar.gz
classes: Fix alternatives and rc.d ordering
When using an alternative as an initscript, the ordering between update-rc.d and update-alternatives tasks during prerm and postinst tasks must always be the following in order to work: * prerm: - stop daemon - remove alternative * postinst: - add alternative - start daemon This patchset adds comments to the scripts generated by both classes and organize the generated sections based on those comments. [YOCTO #10433] (From OE-Core rev: b0c70bef015f1b2a30556a5db5e255592d5bf316) Signed-off-by: David Vincent <freesilicon@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> (cherry picked from commit aa87b1a4dcc14e4dfe719b6c55045c5662bc59c2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/update-rc.d.bbclass')
-rw-r--r--meta/classes/update-rc.d.bbclass20
1 files changed, 18 insertions, 2 deletions
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 321924bb3e..18df2dc3f2 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -26,6 +26,7 @@ fi
26} 26}
27 27
28updatercd_postinst() { 28updatercd_postinst() {
29# Begin section update-rc.d
29if type update-rc.d >/dev/null 2>/dev/null; then 30if type update-rc.d >/dev/null 2>/dev/null; then
30 if [ -n "$D" ]; then 31 if [ -n "$D" ]; then
31 OPT="-r $D" 32 OPT="-r $D"
@@ -34,12 +35,15 @@ if type update-rc.d >/dev/null 2>/dev/null; then
34 fi 35 fi
35 update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} 36 update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
36fi 37fi
38# End section update-rc.d
37} 39}
38 40
39updatercd_prerm() { 41updatercd_prerm() {
42# Begin section update-rc.d
40if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then 43if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
41 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : 44 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
42fi 45fi
46# End section update-rc.d
43} 47}
44 48
45updatercd_postrm() { 49updatercd_postrm() {
@@ -102,13 +106,25 @@ python populate_packages_updatercd () {
102 postinst = d.getVar('pkg_postinst_%s' % pkg, True) 106 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
103 if not postinst: 107 if not postinst:
104 postinst = '#!/bin/sh\n' 108 postinst = '#!/bin/sh\n'
105 postinst += localdata.getVar('updatercd_postinst', True) 109 postinst = postinst.splitlines(True)
110 try:
111 index = postinst.index('# End section update-alternatives\n')
112 postinst.insert(index + 1, localdata.getVar('updatercd_postinst', True))
113 except ValueError:
114 postinst.append(localdata.getVar('updatercd_postinst', True))
115 postinst = ''.join(postinst)
106 d.setVar('pkg_postinst_%s' % pkg, postinst) 116 d.setVar('pkg_postinst_%s' % pkg, postinst)
107 117
108 prerm = d.getVar('pkg_prerm_%s' % pkg, True) 118 prerm = d.getVar('pkg_prerm_%s' % pkg, True)
109 if not prerm: 119 if not prerm:
110 prerm = '#!/bin/sh\n' 120 prerm = '#!/bin/sh\n'
111 prerm += localdata.getVar('updatercd_prerm', True) 121 prerm = prerm.splitlines(True)
122 try:
123 index = prerm.index('# Begin section update-alternatives\n')
124 prerm.insert(index, localdata.getVar('updatercd_prerm', True))
125 except ValueError:
126 prerm.append(localdata.getVar('updatercd_prerm', True))
127 prerm = ''.join(prerm)
112 d.setVar('pkg_prerm_%s' % pkg, prerm) 128 d.setVar('pkg_prerm_%s' % pkg, prerm)
113 129
114 postrm = d.getVar('pkg_postrm_%s' % pkg, True) 130 postrm = d.getVar('pkg_postrm_%s' % pkg, True)