Skip to contentSkip to conversation

update-rc.d.bbclass: remove preinst and remove -f for postinst

PATCH In review [email protected] 1 participant 3 messages Nov 9, 2018 – Feb 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 config by default 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.

---
 meta/classes/update-rc.d.bbclass | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)
meta/classes/update-rc.d.bbclass +4 -24
index 265c4be..1366fee 100644
@@ -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
#1 lore raw

ping

Quoted 92 lines · On 11/9/18 5:42 PM, [email protected] wrote:

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 config by default 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.

---
  meta/classes/update-rc.d.bbclass | 28 ++++------------------------
  1 file changed, 4 insertions(+), 24 deletions(-)
meta/classes/update-rc.d.bbclass +4 -24
index 265c4be..1366fee 100644
@@ -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)
#2 lore raw

ping

Quoted 93 lines · Changqing Li

ping

Quoted 89 lines · On 11/9/18 5:42 PM, [email protected] wrote:

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 config by default 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.

---
  meta/classes/update-rc.d.bbclass | 28 ++++------------------------

  1 file changed, 4 insertions(+), 24 deletions(-)
meta/classes/update-rc.d.bbclass +0 -0
index 265c4be..1366fee 100644
@@ -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 || :

meta/classes/update-rc.d.bbclass +0 -2
-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

meta/classes/update-rc.d.bbclass +0 -3
-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

meta/classes/update-rc.d.bbclass +0 -0
@@ -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 () {

meta/classes/update-rc.d.bbclass +0 -0
@@ -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")

meta/classes/update-rc.d.bbclass +0 -5
@@ -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)