diff options
| author | David Vincent <freesilicon@gmail.com> | 2017-01-25 15:03:06 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-08 12:00:21 +0000 |
| commit | 7cf454e23cdead13dd0041b626045e19d4889bf5 (patch) | |
| tree | f18de8ef09dc5f8e8a1b5af7a55fd775bfea5dab /meta/classes/update-alternatives.bbclass | |
| parent | 5bdf7c980b509330a35fef1dcf28d0d359c7bd6e (diff) | |
| download | poky-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-alternatives.bbclass')
| -rw-r--r-- | meta/classes/update-alternatives.bbclass | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass index 1fdd681315..65929e5555 100644 --- a/meta/classes/update-alternatives.bbclass +++ b/meta/classes/update-alternatives.bbclass | |||
| @@ -195,8 +195,8 @@ python populate_packages_updatealternatives () { | |||
| 195 | pkgdest = d.getVar('PKGD', True) | 195 | pkgdest = d.getVar('PKGD', True) |
| 196 | for pkg in (d.getVar('PACKAGES', True) or "").split(): | 196 | for pkg in (d.getVar('PACKAGES', True) or "").split(): |
| 197 | # Create post install/removal scripts | 197 | # Create post install/removal scripts |
| 198 | alt_setup_links = "" | 198 | alt_setup_links = "# Begin section update-alternatives\n" |
| 199 | alt_remove_links = "" | 199 | alt_remove_links = "# Begin section update-alternatives\n" |
| 200 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): | 200 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): |
| 201 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) | 201 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) |
| 202 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) | 202 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) |
| @@ -219,10 +219,13 @@ python populate_packages_updatealternatives () { | |||
| 219 | # Default to generate shell script.. eventually we may want to change this... | 219 | # Default to generate shell script.. eventually we may want to change this... |
| 220 | alt_target = os.path.normpath(alt_target) | 220 | alt_target = os.path.normpath(alt_target) |
| 221 | 221 | ||
| 222 | alt_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) | 222 | alt_setup_links += 'update-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) |
| 223 | alt_remove_links += '\tupdate-alternatives --remove %s %s\n' % (alt_name, alt_target) | 223 | alt_remove_links += 'update-alternatives --remove %s %s\n' % (alt_name, alt_target) |
| 224 | 224 | ||
| 225 | if alt_setup_links: | 225 | alt_setup_links += "# End section update-alternatives\n" |
| 226 | alt_remove_links += "# End section update-alternatives\n" | ||
| 227 | |||
| 228 | if len(alt_setup_links.splitlines()) > 2: | ||
| 226 | # RDEPENDS setup | 229 | # RDEPENDS setup |
| 227 | provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives', True) | 230 | provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives', True) |
| 228 | if provider: | 231 | if provider: |
| @@ -232,12 +235,24 @@ python populate_packages_updatealternatives () { | |||
| 232 | bb.note('adding update-alternatives calls to postinst/prerm for %s' % pkg) | 235 | bb.note('adding update-alternatives calls to postinst/prerm for %s' % pkg) |
| 233 | bb.note('%s' % alt_setup_links) | 236 | bb.note('%s' % alt_setup_links) |
| 234 | postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n' | 237 | postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n' |
| 235 | postinst += alt_setup_links | 238 | postinst = postinst.splitlines(True) |
| 239 | try: | ||
| 240 | index = postinst.index('# Begin section update-rc.d\n') | ||
| 241 | postinst.insert(index, alt_setup_links) | ||
| 242 | except ValueError: | ||
| 243 | postinst.append(alt_setup_links) | ||
| 244 | postinst = ''.join(postinst) | ||
| 236 | d.setVar('pkg_postinst_%s' % pkg, postinst) | 245 | d.setVar('pkg_postinst_%s' % pkg, postinst) |
| 237 | 246 | ||
| 238 | bb.note('%s' % alt_remove_links) | 247 | bb.note('%s' % alt_remove_links) |
| 239 | prerm = d.getVar('pkg_prerm_%s' % pkg, True) or '#!/bin/sh\n' | 248 | prerm = d.getVar('pkg_prerm_%s' % pkg, True) or '#!/bin/sh\n' |
| 240 | prerm += alt_remove_links | 249 | prerm = prerm.splitlines(True) |
| 250 | try: | ||
| 251 | index = prerm.index('# End section update-rc.d\n') | ||
| 252 | prerm.insert(index + 1, alt_remove_links) | ||
| 253 | except ValueError: | ||
| 254 | prerm.append(alt_remove_links) | ||
| 255 | prerm = ''.join(prerm) | ||
| 241 | d.setVar('pkg_prerm_%s' % pkg, prerm) | 256 | d.setVar('pkg_prerm_%s' % pkg, prerm) |
| 242 | } | 257 | } |
| 243 | 258 | ||
