summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Oberritter <obi@opendreambox.org>2016-11-30 13:27:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-08 10:31:30 +0000
commitb4da2b0040543f55cd9a2908d77d9d79a387a539 (patch)
tree1c434df04af06355ce6519cae80ed51c83a1ed8a
parent0dffc090580bca54960018d04ba3376ea3e440ae (diff)
downloadpoky-b4da2b0040543f55cd9a2908d77d9d79a387a539.tar.gz
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. (From OE-Core rev: f2cc0fdfd97b097145e40bc52674e17378cec863) Signed-off-by: Andreas Oberritter <obi@opendreambox.org> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/update-rc.d.bbclass19
1 files changed, 14 insertions, 5 deletions
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 321924bb3e..2c3ef9edd1 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -11,11 +11,20 @@ INITSCRIPT_PARAMS ?= "defaults"
11 11
12INIT_D_DIR = "${sysconfdir}/init.d" 12INIT_D_DIR = "${sysconfdir}/init.d"
13 13
14def use_updatercd(d):
15 # If the distro supports both sysvinit and systemd, and the current recipe
16 # supports systemd, only call update-rc.d on rootfs creation or if systemd
17 # is not running. That's because systemctl enable/disable will already call
18 # update-rc.d if it detects initscripts.
19 if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and bb.data.inherits_class('systemd', d):
20 return '[ -n "$D" -o ! -d /run/systemd/system ]'
21 return 'true'
22
14updatercd_preinst() { 23updatercd_preinst() {
15if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then 24if ${@use_updatercd(d)} && [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
16 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : 25 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
17fi 26fi
18if type update-rc.d >/dev/null 2>/dev/null; then 27if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
19 if [ -n "$D" ]; then 28 if [ -n "$D" ]; then
20 OPT="-f -r $D" 29 OPT="-f -r $D"
21 else 30 else
@@ -26,7 +35,7 @@ fi
26} 35}
27 36
28updatercd_postinst() { 37updatercd_postinst() {
29if type update-rc.d >/dev/null 2>/dev/null; then 38if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
30 if [ -n "$D" ]; then 39 if [ -n "$D" ]; then
31 OPT="-r $D" 40 OPT="-r $D"
32 else 41 else
@@ -37,13 +46,13 @@ fi
37} 46}
38 47
39updatercd_prerm() { 48updatercd_prerm() {
40if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then 49if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
41 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : 50 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
42fi 51fi
43} 52}
44 53
45updatercd_postrm() { 54updatercd_postrm() {
46if type update-rc.d >/dev/null 2>/dev/null; then 55if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
47 if [ -n "$D" ]; then 56 if [ -n "$D" ]; then
48 OPT="-f -r $D" 57 OPT="-f -r $D"
49 else 58 else