summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChangqing Li <changqing.li@windriver.com>2019-06-21 10:08:14 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-21 15:32:36 +0100
commited2a19f87e6e2d2a20d922f53c54632631fdcdc4 (patch)
treeeda9769ad7fa3e49e57c1d7fa4968eab6edd5143
parent239b7ffe207c8e2982e26647163efdc2bba62600 (diff)
downloadpoky-ed2a19f87e6e2d2a20d922f53c54632631fdcdc4.tar.gz
update-rc.d: support enable/disable options
* update-rc.d has added support of enable/disable options, which are expected to keep the previous configuration even after upgrade the packages. With support for these options, it will only create start/stop link when there are none, or it will keep the previous configuration. Our preinst uses "-f remove" to remove any links under the /etc/rcrunlevel.d which is conflicting behavior with disable/enable options, so remove it. For example, if a user disabled one service before upgrade, then after upgrade the service could be started. This happens because during preinst, all links have been deleted, then postinst may create the link to start service. With this change, we remove preinst and therefore keep the previous links so that after upgrade, if a link existed for the package, then the postinst will not create new start/stop links. * remove '-f' for postinst. Previously, the keepalived recipe used 'remove' during postinst, so we needed the -f, but now the keepalived recipe has fixed this problem, so it's safe to remove '-f'. [Yocto #12955] (From OE-Core rev: 7981d5261429cfb06030280460086f9af91876d9) Signed-off-by: Changqing Li <changqing.li@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/update-rc.d.bbclass28
1 files changed, 4 insertions, 24 deletions
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 265c4be9d1..1366fee653 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -20,28 +20,14 @@ def use_updatercd(d):
20 return '[ -n "$D" -o ! -d /run/systemd/system ]' 20 return '[ -n "$D" -o ! -d /run/systemd/system ]'
21 return 'true' 21 return 'true'
22 22
23updatercd_preinst() {
24if ${@use_updatercd(d)} && [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
25 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
26fi
27if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
28 if [ -n "$D" ]; then
29 OPT="-f -r $D"
30 else
31 OPT="-f"
32 fi
33 update-rc.d $OPT ${INITSCRIPT_NAME} remove
34fi
35}
36
37PACKAGE_WRITE_DEPS += "update-rc.d-native" 23PACKAGE_WRITE_DEPS += "update-rc.d-native"
38 24
39updatercd_postinst() { 25updatercd_postinst() {
40if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then 26if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
41 if [ -n "$D" ]; then 27 if [ -n "$D" ]; then
42 OPT="-f -r $D" 28 OPT="-r $D"
43 else 29 else
44 OPT="-f -s" 30 OPT="-s"
45 fi 31 fi
46 update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} 32 update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
47fi 33fi
@@ -79,7 +65,7 @@ python __anonymous() {
79PACKAGESPLITFUNCS_prepend = "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'populate_packages_updatercd ', '', d)}" 65PACKAGESPLITFUNCS_prepend = "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'populate_packages_updatercd ', '', d)}"
80PACKAGESPLITFUNCS_remove_class-nativesdk = "populate_packages_updatercd " 66PACKAGESPLITFUNCS_remove_class-nativesdk = "populate_packages_updatercd "
81 67
82populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst" 68populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst"
83populate_packages_updatercd[vardepsexclude] += "OVERRIDES" 69populate_packages_updatercd[vardepsexclude] += "OVERRIDES"
84 70
85python populate_packages_updatercd () { 71python populate_packages_updatercd () {
@@ -95,7 +81,7 @@ python populate_packages_updatercd () {
95 d.appendVar('RDEPENDS_' + pkg, ' %sinitd-functions' % (mlprefix)) 81 d.appendVar('RDEPENDS_' + pkg, ' %sinitd-functions' % (mlprefix))
96 82
97 def update_rcd_package(pkg): 83 def update_rcd_package(pkg):
98 bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg) 84 bb.debug(1, 'adding update-rc.d calls to postinst/prerm/postrm for %s' % pkg)
99 85
100 localdata = bb.data.createCopy(d) 86 localdata = bb.data.createCopy(d)
101 overrides = localdata.getVar("OVERRIDES") 87 overrides = localdata.getVar("OVERRIDES")
@@ -103,12 +89,6 @@ python populate_packages_updatercd () {
103 89
104 update_rcd_auto_depend(pkg) 90 update_rcd_auto_depend(pkg)
105 91
106 preinst = d.getVar('pkg_preinst_%s' % pkg)
107 if not preinst:
108 preinst = '#!/bin/sh\n'
109 preinst += localdata.getVar('updatercd_preinst')
110 d.setVar('pkg_preinst_%s' % pkg, preinst)
111
112 postinst = d.getVar('pkg_postinst_%s' % pkg) 92 postinst = d.getVar('pkg_postinst_%s' % pkg)
113 if not postinst: 93 if not postinst:
114 postinst = '#!/bin/sh\n' 94 postinst = '#!/bin/sh\n'