[oe-commits] [openembedded-core] 25/39: update-rc.d: ignore initscript in prerm and preinst when systemd is active

git at git.openembedded.org git at git.openembedded.org
Thu Dec 8 10:33:23 UTC 2016


rpurdie pushed a commit to branch master
in repository openembedded-core.

commit f2cc0fdfd97b097145e40bc52674e17378cec863
Author: Andreas Oberritter <obi at opendreambox.org>
AuthorDate: Wed Nov 30 13:27:28 2016 +0100

    update-rc.d: ignore initscript in prerm and preinst when systemd is active
    
    In hybrid systemd/sysvinit builds, if the recipe inherits systemd and systemd
    is installed, we can safely assume that the service gets stopped by the prerm
    script fragment from systemd.bbclass. This fixes deinstallation of packages
    with initscripts returning errors when no running service was found. The preinst
    shouldn't run the initscript either, because postinst will call systemctl restart.
    
    Signed-off-by: Andreas Oberritter <obi at opendreambox.org>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/classes/update-rc.d.bbclass | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 321924b..2c3ef9e 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -11,11 +11,20 @@ INITSCRIPT_PARAMS ?= "defaults"
 
 INIT_D_DIR = "${sysconfdir}/init.d"
 
+def use_updatercd(d):
+    # If the distro supports both sysvinit and systemd, and the current recipe
+    # supports systemd, only call update-rc.d on rootfs creation or if systemd
+    # is not running. That's because systemctl enable/disable will already call
+    # update-rc.d if it detects initscripts.
+    if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and bb.data.inherits_class('systemd', d):
+        return '[ -n "$D" -o ! -d /run/systemd/system ]'
+    return 'true'
+
 updatercd_preinst() {
-if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
+if ${@use_updatercd(d)} && [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
 	${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
-if type update-rc.d >/dev/null 2>/dev/null; then
+if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
 	if [ -n "$D" ]; then
 		OPT="-f -r $D"
 	else
@@ -26,7 +35,7 @@ fi
 }
 
 updatercd_postinst() {
-if type update-rc.d >/dev/null 2>/dev/null; then
+if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
 	if [ -n "$D" ]; then
 		OPT="-r $D"
 	else
@@ -37,13 +46,13 @@ fi
 }
 
 updatercd_prerm() {
-if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
+if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
 	${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
 }
 
 updatercd_postrm() {
-if type update-rc.d >/dev/null 2>/dev/null; then
+if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
 	if [ -n "$D" ]; then
 		OPT="-f -r $D"
 	else

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list