diff options
-rw-r--r-- | meta/classes/update-rc.d.bbclass | 19 |
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 | ||
12 | INIT_D_DIR = "${sysconfdir}/init.d" | 12 | INIT_D_DIR = "${sysconfdir}/init.d" |
13 | 13 | ||
14 | def 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 | |||
14 | updatercd_preinst() { | 23 | updatercd_preinst() { |
15 | if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then | 24 | if ${@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 || : |
17 | fi | 26 | fi |
18 | if type update-rc.d >/dev/null 2>/dev/null; then | 27 | if ${@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 | ||
28 | updatercd_postinst() { | 37 | updatercd_postinst() { |
29 | if type update-rc.d >/dev/null 2>/dev/null; then | 38 | if ${@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 | ||
39 | updatercd_prerm() { | 48 | updatercd_prerm() { |
40 | if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then | 49 | if ${@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 || : |
42 | fi | 51 | fi |
43 | } | 52 | } |
44 | 53 | ||
45 | updatercd_postrm() { | 54 | updatercd_postrm() { |
46 | if type update-rc.d >/dev/null 2>/dev/null; then | 55 | if ${@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 |