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:27:01 +0000 |
commit | aa87b1a4dcc14e4dfe719b6c55045c5662bc59c2 (patch) | |
tree | 48b528d02d3397e215bf655b09b5c20e3a09233b /meta/classes/update-alternatives.bbclass | |
parent | 9ddcfb51e637acba82089da6430ac77e29f0f1ef (diff) | |
download | openembedded-core-aa87b1a4dcc14e4dfe719b6c55045c5662bc59c2.tar.gz openembedded-core-aa87b1a4dcc14e4dfe719b6c55045c5662bc59c2.tar.bz2 openembedded-core-aa87b1a4dcc14e4dfe719b6c55045c5662bc59c2.zip |
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
Signed-off-by: David Vincent <freesilicon@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
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 0460bf0241..a90ef19e45 100644 --- a/meta/classes/update-alternatives.bbclass +++ b/meta/classes/update-alternatives.bbclass @@ -195,8 +195,8 @@ python populate_packages_updatealternatives () { pkgdest = d.getVar('PKGD') for pkg in (d.getVar('PACKAGES') or "").split(): # Create post install/removal scripts - alt_setup_links = "" - alt_remove_links = "" + alt_setup_links = "# Begin section update-alternatives\n" + alt_remove_links = "# Begin section update-alternatives\n" for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split(): alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name) alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name) @@ -219,10 +219,13 @@ python populate_packages_updatealternatives () { # Default to generate shell script.. eventually we may want to change this... alt_target = os.path.normpath(alt_target) - alt_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) - alt_remove_links += '\tupdate-alternatives --remove %s %s\n' % (alt_name, alt_target) + alt_setup_links += 'update-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) + alt_remove_links += 'update-alternatives --remove %s %s\n' % (alt_name, alt_target) - if alt_setup_links: + alt_setup_links += "# End section update-alternatives\n" + alt_remove_links += "# End section update-alternatives\n" + + if len(alt_setup_links.splitlines()) > 2: # RDEPENDS setup provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives') if provider: @@ -232,12 +235,24 @@ python populate_packages_updatealternatives () { bb.note('adding update-alternatives calls to postinst/prerm for %s' % pkg) bb.note('%s' % alt_setup_links) postinst = d.getVar('pkg_postinst_%s' % pkg) or '#!/bin/sh\n' - postinst += alt_setup_links + postinst = postinst.splitlines(True) + try: + index = postinst.index('# Begin section update-rc.d\n') + postinst.insert(index, alt_setup_links) + except ValueError: + postinst.append(alt_setup_links) + postinst = ''.join(postinst) d.setVar('pkg_postinst_%s' % pkg, postinst) bb.note('%s' % alt_remove_links) prerm = d.getVar('pkg_prerm_%s' % pkg) or '#!/bin/sh\n' - prerm += alt_remove_links + prerm = prerm.splitlines(True) + try: + index = prerm.index('# End section update-rc.d\n') + prerm.insert(index + 1, alt_remove_links) + except ValueError: + prerm.append(alt_remove_links) + prerm = ''.join(prerm) d.setVar('pkg_prerm_%s' % pkg, prerm) } |