diff options
author | David Vincent <freesilicon@gmail.com> | 2016-12-20 10:47:45 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-09 13:39:11 +0000 |
commit | fc89a3f739ff25306ea91d9bdb424fc8389bdf72 (patch) | |
tree | 12087cd9fa77f658058e7dd42eb5fc860123cf8c /meta/classes/update-rc.d.bbclass | |
parent | 02f89167a394d3a64ac0699f8ecae18563e560ab (diff) | |
download | poky-fc89a3f739ff25306ea91d9bdb424fc8389bdf72.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]
Changes since v5:
- Remove boolean in d.getVar() calls
(From OE-Core rev: aa87b1a4dcc14e4dfe719b6c55045c5662bc59c2)
Signed-off-by: David Vincent <freesilicon@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
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.bbclass | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass index 2746c360fe..9d3a7bc0c7 100644 --- a/meta/classes/update-rc.d.bbclass +++ b/meta/classes/update-rc.d.bbclass | |||
@@ -35,6 +35,7 @@ fi | |||
35 | } | 35 | } |
36 | 36 | ||
37 | updatercd_postinst() { | 37 | updatercd_postinst() { |
38 | # Begin section update-rc.d | ||
38 | if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then | 39 | if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then |
39 | if [ -n "$D" ]; then | 40 | if [ -n "$D" ]; then |
40 | OPT="-r $D" | 41 | OPT="-r $D" |
@@ -43,12 +44,15 @@ if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then | |||
43 | fi | 44 | fi |
44 | update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} | 45 | update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} |
45 | fi | 46 | fi |
47 | # End section update-rc.d | ||
46 | } | 48 | } |
47 | 49 | ||
48 | updatercd_prerm() { | 50 | updatercd_prerm() { |
51 | # Begin section update-rc.d | ||
49 | if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then | 52 | if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then |
50 | ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : | 53 | ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : |
51 | fi | 54 | fi |
55 | # End section update-rc.d | ||
52 | } | 56 | } |
53 | 57 | ||
54 | updatercd_postrm() { | 58 | updatercd_postrm() { |
@@ -111,13 +115,25 @@ python populate_packages_updatercd () { | |||
111 | postinst = d.getVar('pkg_postinst_%s' % pkg) | 115 | postinst = d.getVar('pkg_postinst_%s' % pkg) |
112 | if not postinst: | 116 | if not postinst: |
113 | postinst = '#!/bin/sh\n' | 117 | postinst = '#!/bin/sh\n' |
114 | postinst += localdata.getVar('updatercd_postinst') | 118 | postinst = postinst.splitlines(True) |
119 | try: | ||
120 | index = postinst.index('# End section update-alternatives\n') | ||
121 | postinst.insert(index + 1, localdata.getVar('updatercd_postinst')) | ||
122 | except ValueError: | ||
123 | postinst.append(localdata.getVar('updatercd_postinst')) | ||
124 | postinst = ''.join(postinst) | ||
115 | d.setVar('pkg_postinst_%s' % pkg, postinst) | 125 | d.setVar('pkg_postinst_%s' % pkg, postinst) |
116 | 126 | ||
117 | prerm = d.getVar('pkg_prerm_%s' % pkg) | 127 | prerm = d.getVar('pkg_prerm_%s' % pkg) |
118 | if not prerm: | 128 | if not prerm: |
119 | prerm = '#!/bin/sh\n' | 129 | prerm = '#!/bin/sh\n' |
120 | prerm += localdata.getVar('updatercd_prerm') | 130 | prerm = prerm.splitlines(True) |
131 | try: | ||
132 | index = prerm.index('# Begin section update-alternatives\n') | ||
133 | prerm.insert(index, localdata.getVar('updatercd_prerm')) | ||
134 | except ValueError: | ||
135 | prerm.append(localdata.getVar('updatercd_prerm')) | ||
136 | prerm = ''.join(prerm) | ||
121 | d.setVar('pkg_prerm_%s' % pkg, prerm) | 137 | d.setVar('pkg_prerm_%s' % pkg, prerm) |
122 | 138 | ||
123 | postrm = d.getVar('pkg_postrm_%s' % pkg) | 139 | postrm = d.getVar('pkg_postrm_%s' % pkg) |