update-rc.d: support enable/disable function
v2 cover update-rc.d: support enable/disable function
These three patches are for support disable/enable function for update-rc.d
change in V2:
add some comments and fix commit message
change in V1:
* change of script update-rc.d is for support disable/enable of init script link
* update-rc.d.bbclass remove preinst to make disable/enable can work after upgrade
* fix the doc manual
Changqing Li (2):
update-rc.d.bbclass: remove preinst and remove -f for postinst ref-variables.xml: update manual page for update-rc.d
documentation/ref-manual/ref-variables.xml | 2 +- meta/classes/update-rc.d.bbclass | 28 ++++------------------------ 2 files changed, 5 insertions(+), 25 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/2 update-rc.d.bbclass: remove preinst and remove -f for postinst
From: Changqing Li <[email protected]>
*preinst use "-f remove" to remove any links in the /etc/rcrunlevel.d
but this will make user cannot keep previous init script link after upgrade
eg: user disable one service before upgrade, after upgrade, service could be started since during preinst, all link have been deleted, so postinst may create the link to start service.
remove preinst to keep previous links, so that after upgrade, if any link existed for the package, postinst will not create new start/stop links.
(note: patch of support enable/disable function of update-rc.d send to yocto mail list today)
*remove -f for postinst, previously, recipe keepalived use remove during
postinst, so need this -f, but remove in postinst is not proper, recipe keepalived have fixed this problem, so remove -f.
[Yocto #12955]
--- meta/classes/update-rc.d.bbclass | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-)
meta/classes/update-rc.d.bbclass +4 -24
@@ -20,28 +20,14 @@ def use_updatercd(d): return '[ -n "$D" -o ! -d /run/systemd/system ]' return 'true' -updatercd_preinst() { -if ${@use_updatercd(d)} && [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then - ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : -fi -if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then - if [ -n "$D" ]; then - OPT="-f -r $D" - else - OPT="-f" - fi - update-rc.d $OPT ${INITSCRIPT_NAME} remove -fi -} - PACKAGE_WRITE_DEPS += "update-rc.d-native" updatercd_postinst() { if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then if [ -n "$D" ]; then - OPT="-f -r $D" + OPT="-r $D" else - OPT="-f -s" + OPT="-s" fi update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} fi
@@ -79,7 +65,7 @@ python __anonymous() { PACKAGESPLITFUNCS_prepend = "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'populate_packages_updatercd ', '', d)}" PACKAGESPLITFUNCS_remove_class-nativesdk = "populate_packages_updatercd " -populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst" +populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst" populate_packages_updatercd[vardepsexclude] += "OVERRIDES" python populate_packages_updatercd () {
@@ -95,7 +81,7 @@ python populate_packages_updatercd () { d.appendVar('RDEPENDS_' + pkg, ' %sinitd-functions' % (mlprefix)) def update_rcd_package(pkg): - bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg) + bb.debug(1, 'adding update-rc.d calls to postinst/prerm/postrm for %s' % pkg) localdata = bb.data.createCopy(d) overrides = localdata.getVar("OVERRIDES")
@@ -103,12 +89,6 @@ python populate_packages_updatercd () { update_rcd_auto_depend(pkg) - preinst = d.getVar('pkg_preinst_%s' % pkg) - if not preinst: - preinst = '#!/bin/sh\n' - preinst += localdata.getVar('updatercd_preinst') - d.setVar('pkg_preinst_%s' % pkg, preinst) - postinst = d.getVar('pkg_postinst_%s' % pkg) if not postinst: postinst = '#!/bin/sh\n'
Signature · 1 line
2.7.4
PATCH v2 2/2 ref-variables.xml: update manual page for update-rc.d
In reply to [email protected]From: Changqing Li <[email protected]>
Currently, yocto doc refer link http://www.tin.org/bin/man.cgi?
section=8&topic=update-rc.d. as man page of update-rc.d, but lastest debian udpate-rc.d have big difference with yocto, they need insserv and all the initscripts support LSB comment header.
change to new link which is more similar to yocto
[Yocto #12955]
--- documentation/ref-manual/ref-variables.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
documentation/ref-manual/ref-variables.xml +1 -1
@@ -7198,7 +7198,7 @@ recipes-graphics/xorg-font/font-alias_1.0.3.bb:PR = "${INC_PR}.3" to the <filename>update-rc.d</filename> command. For more information on valid parameters, please see the <filename>update-rc.d</filename> manual page at - <ulink url='http://www.tin.org/bin/man.cgi?section=8&topic=update-rc.d'></ulink>. + <ulink url='https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.html'></ulink>. </para> </glossdef> </glossentry>
Signature · 1 line
2.7.4
PATCH v2 1/1 update-rc.d: support enable/disable function
In reply to [email protected]From: Changqing Li <[email protected]>
Add support of enable/disable function, so that user can keep previous config like disable one service even after upgrade package.
this patch need to work with oe-core patch [update-rc.d.bbclass: remove preinst and remove -f for postinst]
[Yocto 12955]
--- update-rc.d | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
update-rc.d +81 -0
@@ -27,6 +27,7 @@ usage() usage: update-rc.d [-n] [-f] [-r <root>] <basename> remove update-rc.d [-n] [-r <root>] [-s] <basename> defaults [NN | sNN kNN] update-rc.d [-n] [-r <root>] [-s] <basename> start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r <root>] [-s] <basename> enable|disable [S|2|3|4|5] -n: not really -f: force -v: verbose
@@ -101,6 +102,53 @@ makelinks() done } +# function to disable/enable init script link of one run level +# $1 should be K/S, means to disable/enable +# $2 means which run level to disable/enable +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + # modifies existing runlevel links for the script /etc/init.d/name by renaming start links to stop link + # or stop link to start link with a sequence number equal to the difference of 100 minus the original sequence number. + if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then + oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3` + newnn=$[100-$oldnn] + [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then + mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn} + fi + if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then + $fn start || true + fi + fi + +} + +# function to disable/enable init script link +# $1 should be K/S, means to disable/enable +# $2 run level [S|2|3|4|5], optional, If no start runlevel is +# specified after the disable or enable keywords +# the script will attempt to modify links in all start runlevels +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} + while [ $# -gt 0 ]; do case $1 in -n) notreally=1
@@ -221,6 +269,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi + while [ $# -gt 0 ]; do if [ $1 = "start" ]; then letter=S
@@ -251,6 +306,32 @@ case $1 in makelinks ;; + enable | disable) + if [ $1 = "enable" ]; then + letter=S + elif [ $1 = "disable" ]; then + letter=K + else + usage + exit 1 + fi + shift + # + if [ $# -gt 0 ] + then + case $1 in + S|2|3|4|5) + renamelinks $letter $1 + ;; + *) + usage + exit 1 + ;; + esac + else + renamelinks $letter + fi + ;; *) usage exit 1
Signature · 1 line
2.7.4
Ping
Quoted 18 lines · On 1/21/19 5:09 PM, [email protected] wrote:
These three patches are for support disable/enable function for update-rc.d
change in V2:
add some comments and fix commit messagechange in V1:
* change of script update-rc.d is for support disable/enable of init script link
* update-rc.d.bbclass remove preinst to make disable/enable can work after upgrade
* fix the doc manualChangqing Li (2):
update-rc.d.bbclass: remove preinst and remove -f for postinst ref-variables.xml: update manual page for update-rc.ddocumentation/ref-manual/ref-variables.xml | 2 +- meta/classes/update-rc.d.bbclass | 28 ++++------------------------ 2 files changed, 5 insertions(+), 25 deletions(-)
Signature · 3 lines
BRs Sandy(Li Changqing)
Add Ross and Phil who have been committers for update-rc.d.
The changes seem sensible to me but the commit logs need some polish to be more clear. I'll help Sandy with that later if needed.
../Randy
Quoted 18 lines · On 1/21/19 4:09 AM, [email protected] wrote:
These three patches are for support disable/enable function for update-rc.d
change in V2:
add some comments and fix commit messagechange in V1:
* change of script update-rc.d is for support disable/enable of init script link
* update-rc.d.bbclass remove preinst to make disable/enable can work after upgrade
* fix the doc manualChangqing Li (2):
update-rc.d.bbclass: remove preinst and remove -f for postinst ref-variables.xml: update manual page for update-rc.ddocumentation/ref-manual/ref-variables.xml | 2 +- meta/classes/update-rc.d.bbclass | 28 ++++------------------------ 2 files changed, 5 insertions(+), 25 deletions(-)
Signature · 2 lines
# Randy MacLeod # Wind River Linux
PATCH v3 1/1 update-rc.d: support enable/disable options
From: Changqing Li <[email protected]>
* 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]
--- documentation/ref-manual/ref-variables.xml | 2 +- meta/classes/update-rc.d.bbclass | 28 ++++------------------------ 2 files changed, 5 insertions(+), 25 deletions(-)
documentation/ref-manual/ref-variables.xml +1 -1
@@ -7243,7 +7243,7 @@ to the <filename>update-rc.d</filename> command. For more information on valid parameters, please see the <filename>update-rc.d</filename> manual page at - <ulink url='http://www.tin.org/bin/man.cgi?section=8&topic=update-rc.d'></ulink>. + <ulink url='https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.html'></ulink>. </para> </glossdef> </glossentry>
meta/classes/update-rc.d.bbclass +4 -24
@@ -20,28 +20,14 @@ def use_updatercd(d): return '[ -n "$D" -o ! -d /run/systemd/system ]' return 'true' -updatercd_preinst() { -if ${@use_updatercd(d)} && [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then - ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : -fi -if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then - if [ -n "$D" ]; then - OPT="-f -r $D" - else - OPT="-f" - fi - update-rc.d $OPT ${INITSCRIPT_NAME} remove -fi -} - PACKAGE_WRITE_DEPS += "update-rc.d-native" updatercd_postinst() { if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then if [ -n "$D" ]; then - OPT="-f -r $D" + OPT="-r $D" else - OPT="-f -s" + OPT="-s" fi update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} fi
@@ -79,7 +65,7 @@ python __anonymous() { PACKAGESPLITFUNCS_prepend = "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'populate_packages_updatercd ', '', d)}" PACKAGESPLITFUNCS_remove_class-nativesdk = "populate_packages_updatercd " -populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst" +populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst" populate_packages_updatercd[vardepsexclude] += "OVERRIDES" python populate_packages_updatercd () {
@@ -95,7 +81,7 @@ python populate_packages_updatercd () { d.appendVar('RDEPENDS_' + pkg, ' %sinitd-functions' % (mlprefix)) def update_rcd_package(pkg): - bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg) + bb.debug(1, 'adding update-rc.d calls to postinst/prerm/postrm for %s' % pkg) localdata = bb.data.createCopy(d) overrides = localdata.getVar("OVERRIDES")
@@ -103,12 +89,6 @@ python populate_packages_updatercd () { update_rcd_auto_depend(pkg) - preinst = d.getVar('pkg_preinst_%s' % pkg) - if not preinst: - preinst = '#!/bin/sh\n' - preinst += localdata.getVar('updatercd_preinst') - d.setVar('pkg_preinst_%s' % pkg, preinst) - postinst = d.getVar('pkg_postinst_%s' % pkg) if not postinst: postinst = '#!/bin/sh\n'
Signature · 1 line
2.7.4
PATCH v3 1/1 update-rc.d: support enable/disable options
From: Changqing Li <[email protected]>
Add support of enable/disable options, refer
https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.html
With support of these options, the usr can never change an existing configuration even after upgrading a package. The program will only install links if none are present, otherwise, it will keep the previous configuration.
preinst in update-rc.d.bbclass will delete all the links under rcrunlevel.d, this behavior now conflicts with enable/disable options. so remove preinst from the update-rc.d.bbclass
[Yocto 12955]
--- update-rc.d | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
update-rc.d +81 -0
@@ -27,6 +27,7 @@ usage() usage: update-rc.d [-n] [-f] [-r <root>] <basename> remove update-rc.d [-n] [-r <root>] [-s] <basename> defaults [NN | sNN kNN] update-rc.d [-n] [-r <root>] [-s] <basename> start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r <root>] [-s] <basename> enable|disable [S|2|3|4|5] -n: not really -f: force -v: verbose
@@ -101,6 +102,53 @@ makelinks() done } +# function to disable/enable init script link of one run level +# $1 should be K/S, means to disable/enable +# $2 means which run level to disable/enable +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + # modifies existing runlevel links for the script /etc/init.d/name by renaming start links to stop link + # or stop link to start link with a sequence number equal to the difference of 100 minus the original sequence number. + if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then + oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3` + newnn=$[100-$oldnn] + [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then + mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn} + fi + if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then + $fn start || true + fi + fi + +} + +# function to disable/enable init script link +# $1 should be K/S, means to disable/enable +# $2 run level [S|2|3|4|5], optional, If no start runlevel is +# specified after the disable or enable keywords +# the script will attempt to modify links in all start runlevels +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} + while [ $# -gt 0 ]; do case $1 in -n) notreally=1
@@ -221,6 +269,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi + while [ $# -gt 0 ]; do if [ $1 = "start" ]; then letter=S
@@ -251,6 +306,32 @@ case $1 in makelinks ;; + enable | disable) + if [ $1 = "enable" ]; then + letter=S + elif [ $1 = "disable" ]; then + letter=K + else + usage + exit 1 + fi + shift + # + if [ $# -gt 0 ] + then + case $1 in + S|2|3|4|5) + renamelinks $letter $1 + ;; + *) + usage + exit 1 + ;; + esac + else + renamelinks $letter + fi + ;; *) usage exit 1
Signature · 1 line
2.7.4
Re: [update-rc.d][PATCH V3] update-rc.d: support enable/disable options
ping
Quoted 134 lines · On 4/30/19 2:56 PM, [email protected] wrote:
From: Changqing Li <[email protected]>
Add support of enable/disable options, refer
https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.htmlWith support of these options, the usr can never change an existing configuration even after upgrading a package. The program will only install links if none are present, otherwise, it will keep the previous configuration.
preinst in update-rc.d.bbclass will delete all the links under rcrunlevel.d, this behavior now conflicts with enable/disable options. so remove preinst from the update-rc.d.bbclass
[Yocto 12955]
Signed-off-by Changqing Li <[email protected]>--- update-rc.d | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)update-rc.d +81
-0@@ -27,6 +27,7 @@ usage() usage: update-rc.d [-n] [-f] [-r <root>] <basename> remove update-rc.d [-n] [-r <root>] [-s] <basename> defaults [NN | sNN kNN] update-rc.d [-n] [-r <root>] [-s] <basename> start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r <root>] [-s] <basename> enable|disable [S|2|3|4|5] -n: not really -f: force -v: verbose@@ -101,6 +102,53 @@ makelinks() done } +# function to disable/enable init script link of one run level +# $1 should be K/S, means to disable/enable +# $2 means which run level to disable/enable +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + # modifies existing runlevel links for the script /etc/init.d/name by renaming start links to stop link + # or stop link to start link with a sequence number equal to the difference of 100 minus the original sequence number. + if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then + oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3` + newnn=$[100-$oldnn] + [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then + mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn} + fi + if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then + $fn start || true + fi + fi + +} + +# function to disable/enable init script link +# $1 should be K/S, means to disable/enable +# $2 run level [S|2|3|4|5], optional, If no start runlevel is +# specified after the disable or enable keywords +# the script will attempt to modify links in all start runlevels +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} + while [ $# -gt 0 ]; do case $1 in -n) notreally=1@@ -221,6 +269,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi + while [ $# -gt 0 ]; do if [ $1 = "start" ]; then letter=S@@ -251,6 +306,32 @@ case $1 in makelinks ;; + enable | disable) + if [ $1 = "enable" ]; then + letter=S + elif [ $1 = "disable" ]; then + letter=K + else + usage + exit 1 + fi + shift + # + if [ $# -gt 0 ] + then + case $1 in + S|2|3|4|5) + renamelinks $letter $1 + ;; + *) + usage + exit 1 + ;; + esac + else + renamelinks $letter + fi + ;; *) usage exit 1
Signature · 3 lines
BRs Sandy(Li Changqing)
Re: [update-rc.d][PATCH V3] update-rc.d: support enable/disable options
ping
Quoted 143 lines · Changqing Li
ping
Quoted 139 lines · On 4/30/19 2:56 PM, [email protected] wrote:
From: Changqing Li <[email protected]>
Add support of enable/disable options, refer
https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.htmlWith support of these options, the usr can never change an existing configuration even after upgrading a package. The program will only install links if none are present, otherwise, it will keep the previous configuration.
preinst in update-rc.d.bbclass will delete all the links under rcrunlevel.d, this behavior now conflicts with enable/disable options. so remove preinst from the update-rc.d.bbclass
[Yocto 12955]
Signed-off-by Changqing Li <[email protected]>---
update-rc.d | 81
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1 file changed, 81 insertions(+)update-rc.d +0
-0@@ -27,6 +27,7 @@ usage()usage: update-rc.d [-n] [-f] [-r <root>] <basename> remove
update-rc.d [-n] [-r <root>] [-s] <basename> defaults [NN | sNN kNN] update-rc.d [-n] [-r <root>] [-s] <basename> start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r <root>] [-s] <basename> enable|disable [S|2|3|4|5]
-n: not really
-f: force
-v: verboseupdate-rc.d +0
-0@@ -101,6 +102,53 @@ makelinks()done
}
+# function to disable/enable init script link of one run levelupdate-rc.d +15
-0+# $1 should be K/S, means to disable/enable +# $2 means which run level to disable/enable +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + # modifies existing runlevel links for the script
/etc/init.d/nameby renaming start links to stop link
+ # or stop link to start link with a sequence number equal to
the difference of 100 minus the original sequence number.
+ if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then
+ oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut
-c2-3`
+ newnn=$[100-$oldnn]
+ [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then
+ mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn}
+ fi
+ if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then
+ $fn start || true
+ fi
+ fiupdate-rc.d +19
-0+ +} + +# function to disable/enable init script link +# $1 should be K/S, means to disable/enable +# $2 run level [S|2|3|4|5], optional, If no start runlevel is +# specified after the disable or enable keywords +# the script will attempt to modify links in all start runlevels +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} +while [ $# -gt 0 ]; do
case $1 in
-n) notreally=1update-rc.d +7
-0@@ -221,6 +269,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi +while [ $# -gt 0 ]; do
if [ $1 = "start" ]; then
letter=Supdate-rc.d +0
-0@@ -251,6 +306,32 @@ case $1 inmakelinks
;;
+ enable | disable)
+ if [ $1 = "enable" ]; then
+ letter=S
+ elif [ $1 = "disable" ]; then
+ letter=K
+ else
+ usage
+ exit 1
+ fi
+ shift
+ #
+ if [ $# -gt 0 ]
+ then
+ case $1 in
+ S|2|3|4|5)
+ renamelinks $letter $1
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ else
+ renamelinks $letter
+ fi
+ ;;
*)
usage
exit 1
Signature · 3 lines
BRs Sandy(Li Changqing)
Richard Purdie
AppliedRe: [update-rc.d][PATCH V3] update-rc.d: support enable/disable options
In reply to [email protected]Quoted 10 lines · On Tue, 2019-04-30 at 14:56 +0800, [email protected] wrote:
From: Changqing Li <[email protected]>
Add support of enable/disable options, refer
https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.htmlWith support of these options, the usr can never change an existing configuration even after upgrading a package. The program will only install links if none are present, otherwise, it will keep the previous configuration.
Quoted 7 lines
preinst in update-rc.d.bbclass will delete all the links under rcrunlevel.d, this behavior now conflicts with enable/disable options. so remove preinst from the update-rc.d.bbclass
[Yocto 12955]
Signed-off-by Changqing Li <[email protected]>
Merged, thanks, sorry about the delay.
Richard
Re: [update-rc.d][PATCH V3] update-rc.d: support enable/disable options
Quoted 15 lines · Richard Purdie
Quoted 14 lines · On Tue, 2019-04-30 at 14:56 +0800, [email protected] wrote:
From: Changqing Li <[email protected]>
Add support of enable/disable options, refer
https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.htmlWith support of these options, the usr can never change an existing configuration even after upgrading a package. The program will only install links if none are present, otherwise, it will keep the previous configuration.
preinst in update-rc.d.bbclass will delete all the links under rcrunlevel.d, this behavior now conflicts with enable/disable options. so remove preinst from the update-rc.d.bbclass
Quoted 8 lines
Quoted 3 lines
[Yocto 12955]
Signed-off-by Changqing Li <[email protected]>Merged, thanks, sorry about the delay.
Richard
Thanks, Richard.
I see this patch have merged into repo update-rc.d. But in this patch series, there are
2 patches, please also help to review the other one. Maybe this patch series seems a little messy
in the mail. I will reply on the other patch for you to pick it out easily.
Signature · 3 lines
BRs Sandy(Li Changqing)
Re: [PATCH V3] update-rc.d: support enable/disable options
In reply to [email protected]Please also help to review this patch, Thanks.
Quoted 109 lines · On 4/30/19 2:56 PM, [email protected] wrote:
From: Changqing Li <[email protected]>
* 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.dwhich 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]
Signed-off-by Changqing Li <[email protected]>--- documentation/ref-manual/ref-variables.xml | 2 +- meta/classes/update-rc.d.bbclass | 28 ++++------------------------ 2 files changed, 5 insertions(+), 25 deletions(-)documentation/ref-manual/ref-variables.xml +1
-1@@ -7243,7 +7243,7 @@ to the <filename>update-rc.d</filename> command. For more information on valid parameters, please see the <filename>update-rc.d</filename> manual page at - <ulink url='http://www.tin.org/bin/man.cgi?section=8&topic=update-rc.d'></ulink>. + <ulink url='https://manpages.debian.org/wheezy/sysv-rc/update-rc.d.8.en.html'></ulink>. </para> </glossdef> </glossentry>meta/classes/update-rc.d.bbclass +4
-24@@ -20,28 +20,14 @@ def use_updatercd(d): return '[ -n "$D" -o ! -d /run/systemd/system ]' return 'true' -updatercd_preinst() { -if ${@use_updatercd(d)} && [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then - ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : -fi -if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then - if [ -n "$D" ]; then - OPT="-f -r $D" - else - OPT="-f" - fi - update-rc.d $OPT ${INITSCRIPT_NAME} remove -fi -} - PACKAGE_WRITE_DEPS += "update-rc.d-native" updatercd_postinst() { if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then if [ -n "$D" ]; then - OPT="-f -r $D" + OPT="-r $D" else - OPT="-f -s" + OPT="-s" fi update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} fi@@ -79,7 +65,7 @@ python __anonymous() { PACKAGESPLITFUNCS_prepend = "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'populate_packages_updatercd ', '', d)}" PACKAGESPLITFUNCS_remove_class-nativesdk = "populate_packages_updatercd " -populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst" +populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst" populate_packages_updatercd[vardepsexclude] += "OVERRIDES" python populate_packages_updatercd () {@@ -95,7 +81,7 @@ python populate_packages_updatercd () { d.appendVar('RDEPENDS_' + pkg, ' %sinitd-functions' % (mlprefix)) def update_rcd_package(pkg): - bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg) + bb.debug(1, 'adding update-rc.d calls to postinst/prerm/postrm for %s' % pkg) localdata = bb.data.createCopy(d) overrides = localdata.getVar("OVERRIDES")@@ -103,12 +89,6 @@ python populate_packages_updatercd () { update_rcd_auto_depend(pkg) - preinst = d.getVar('pkg_preinst_%s' % pkg) - if not preinst: - preinst = '#!/bin/sh\n' - preinst += localdata.getVar('updatercd_preinst') - d.setVar('pkg_preinst_%s' % pkg, preinst) - postinst = d.getVar('pkg_postinst_%s' % pkg) if not postinst: postinst = '#!/bin/sh\n'
Signature · 3 lines
BRs Sandy(Li Changqing)
Re: [PATCH V3] update-rc.d: support enable/disable options
Quoted 1 line · Changqing Li
Please also help to review this patch, Thanks.
This patch needs to go to OE-Core for the bbclass part. The documentation piece needs to be separated out as its a different repository. Also doesn't it depend on the change I just made to the update-rc.d repo so there will be a SRCREV that needs to be updated that this depends on?
Thanks,
Richard
Re: [PATCH V3] update-rc.d: support enable/disable options
Quoted 7 lines · On 6/20/19 3:28 PM, [email protected] wrote:
Quoted 1 line · Changqing Li
Please also help to review this patch, Thanks.
This patch needs to go to OE-Core for the bbclass part. The documentation piece needs to be separated out as its a different repository. Also doesn't it depend on the change I just made to the update-rc.d repo so there will be a SRCREV that needs to be updated that this depends on?
I will split the oe-core and document part.
without change in update-rc.d.bbclass, new function add in update-rc.d repo will not work.
since preinst in update-rc.d.bbclass will delete all the links under rcrunlevel.d, this behavior
conflicts with enable/disable options.
and you're right, I also need to update SRCREV of update-rc.d.bb in oe-core repo.
Thanks.
I will send it later.
Quoted 6 lines
Thanks,
Richard
Signature · 3 lines
BRs Sandy(Li Changqing)