From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by mail.openembedded.org (Postfix) with ESMTP id 02124772E1 for ; Tue, 20 Dec 2016 09:48:39 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id a20so23325550wme.2 for ; Tue, 20 Dec 2016 01:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/pfpCooJrz9IGnJA5hENqrBYCdQrrocSIaDql+5YkRo=; b=kze5bWTQRD847r1o08KSAdRyaqr+v5eV7U91Krn0meokg2x2xJwQlXxELtduva7hvF 0+h4nYFMbw5JKlXxcLk+a4oDXPGKXsUnKaCR4mNG0oUlZmTGNgZ/1G3rymcX1yC8u1gw Ena7Xh86qDSOm9c/vNFuZn5NURpy9rTo/+cKZ8uVdKDv+ZSQnTvdxe1eagWy1wP7E0Vm Ff1TuFOE+hBKPkOgXePhK6wIqZAp0Rxiki7vVTla8O/82oIHHmzG1NHTVJt7NKgzbtdL 8ibzfmUUMYZMGf5Tm6Bu2Rn25It/UX7bOw22oeOcIkBJsDCwgzKR0EAUZQbBGkQmwT1B M+og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/pfpCooJrz9IGnJA5hENqrBYCdQrrocSIaDql+5YkRo=; b=DA1C4lfDNN27cfXT+oBMxVpS5aR0vUPs90XWPt2FUwtdshD2r3tgEaBCUTBSW8nIB4 4u8vjwRWKrJ0zUssqq/9bT0u3GhMIrwAwoX3c19twpetqW43xjZ9L7m7jKYdH/PHSDxw Q/NKxFoUYlRE6tnMeF8k9Z9NylHIYpJhskc72HIKUbizSstfcdqF2fr2npbXREzeG5po qsuuNZ0WovDt6ftSCnJhJ0lCioc8OtnAzTewqszVPGVXYkkpX/nSXGrFuAnCIOkk/YE7 mRQ8GyW3H6/UL/A5DQBX1kwVfe7UCVWBCPkFm1OabGPFoibrzEp/xUK/LcItlCdMzhoU 6omw== X-Gm-Message-State: AIkVDXICGNmSHTruJf0v8trHRjjAIzQJ8yuFpsN8aIdpEmFPhWf+MGcz+SR4UV/RJFIUAA== X-Received: by 10.28.60.5 with SMTP id j5mr1127751wma.119.1482227320704; Tue, 20 Dec 2016 01:48:40 -0800 (PST) Received: from localhost.localdomain ([185.47.80.46]) by smtp.gmail.com with ESMTPSA id y4sm24705707wjp.0.2016.12.20.01.48.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Dec 2016 01:48:40 -0800 (PST) From: David Vincent To: openembedded-core@lists.openembedded.org, haris.okanovic@ni.com, markus.lehtonen@linux.intel.com Date: Tue, 20 Dec 2016 10:47:45 +0100 Message-Id: <20161220094745.11485-1-freesilicon@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161212160148.9248-1-freesilicon@gmail.com> References: <20161212160148.9248-1-freesilicon@gmail.com> Subject: [PATCH v6] classes: Fix alternatives and rc.d ordering X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2016 09:48:40 -0000 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 --- meta/classes/update-alternatives.bbclass | 29 ++++++++++++++++++++++------- meta/classes/update-rc.d.bbclass | 20 ++++++++++++++++++-- 2 files changed, 40 insertions(+), 9 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) } 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 } updatercd_postinst() { +# Begin section update-rc.d if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then if [ -n "$D" ]; then OPT="-r $D" @@ -43,12 +44,15 @@ if ${@use_updatercd(d)} && 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 ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : fi +# End section update-rc.d } updatercd_postrm() { @@ -111,13 +115,25 @@ python populate_packages_updatercd () { postinst = d.getVar('pkg_postinst_%s' % pkg) if not postinst: postinst = '#!/bin/sh\n' - postinst += localdata.getVar('updatercd_postinst') + postinst = postinst.splitlines(True) + try: + index = postinst.index('# End section update-alternatives\n') + postinst.insert(index + 1, localdata.getVar('updatercd_postinst')) + except ValueError: + postinst.append(localdata.getVar('updatercd_postinst')) + postinst = ''.join(postinst) d.setVar('pkg_postinst_%s' % pkg, postinst) prerm = d.getVar('pkg_prerm_%s' % pkg) if not prerm: prerm = '#!/bin/sh\n' - prerm += localdata.getVar('updatercd_prerm') + prerm = prerm.splitlines(True) + try: + index = prerm.index('# Begin section update-alternatives\n') + prerm.insert(index, localdata.getVar('updatercd_prerm')) + except ValueError: + prerm.append(localdata.getVar('updatercd_prerm')) + prerm = ''.join(prerm) d.setVar('pkg_prerm_%s' % pkg, prerm) postrm = d.getVar('pkg_postrm_%s' % pkg) -- 2.11.0