From 7cf454e23cdead13dd0041b626045e19d4889bf5 Mon Sep 17 00:00:00 2001 From: David Vincent Date: Wed, 25 Jan 2017 15:03:06 +0200 Subject: 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 Signed-off-by: Ross Burton (cherry picked from commit aa87b1a4dcc14e4dfe719b6c55045c5662bc59c2) Signed-off-by: Richard Purdie --- meta/classes/update-rc.d.bbclass | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'meta/classes/update-rc.d.bbclass') 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 } updatercd_postinst() { +# Begin section update-rc.d if type update-rc.d >/dev/null 2>/dev/null; then if [ -n "$D" ]; then OPT="-r $D" @@ -34,12 +35,15 @@ if type update-rc.d >/dev/null 2>/dev/null; then fi update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} fi +# End section update-rc.d } updatercd_prerm() { +# Begin section update-rc.d if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : fi +# End section update-rc.d } updatercd_postrm() { @@ -102,13 +106,25 @@ python populate_packages_updatercd () { postinst = d.getVar('pkg_postinst_%s' % pkg, True) if not postinst: postinst = '#!/bin/sh\n' - postinst += localdata.getVar('updatercd_postinst', True) + postinst = postinst.splitlines(True) + try: + index = postinst.index('# End section update-alternatives\n') + postinst.insert(index + 1, localdata.getVar('updatercd_postinst', True)) + except ValueError: + postinst.append(localdata.getVar('updatercd_postinst', True)) + postinst = ''.join(postinst) d.setVar('pkg_postinst_%s' % pkg, postinst) prerm = d.getVar('pkg_prerm_%s' % pkg, True) if not prerm: prerm = '#!/bin/sh\n' - prerm += localdata.getVar('updatercd_prerm', True) + prerm = prerm.splitlines(True) + try: + index = prerm.index('# Begin section update-alternatives\n') + prerm.insert(index, localdata.getVar('updatercd_prerm', True)) + except ValueError: + prerm.append(localdata.getVar('updatercd_prerm', True)) + prerm = ''.join(prerm) d.setVar('pkg_prerm_%s' % pkg, prerm) postrm = d.getVar('pkg_postrm_%s' % pkg, True) -- cgit v1.2.3-54-g00ecf