Skip to contentSkip to conversation

update-rc.d.bbclass vs dpkg issues

RFC PATCH In review Jeremy Lainé 2 participants 2 messages Oct 23, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 update-rc.d.bbclass vs dpkg issues

Having recently switch from opkg to dpkg, I encountered some problems when upgrading packages which use the update-rc.d class. The problem are that update-rc.d :

a/ unconditionally calls "${INIT_D_DIR}/${INITSCRIPT_NAME} stop" in the prerm script. This is wrong, it should only do so when the prerm script is called for the "upgrade" and "remove" steps.

b/ unconditionally calls "update-rc.d $OPT ${INITSCRIPT_NAME} remove" in the postrm script. This is wrong, it should only do so when the prerm script is called for the "purge" step. However, "opkg" does not seem to support the "purge" step so I suggest calling it both for the "remove" and "purge" steps, after checking that the init script no longer exists.

You can find a description of how maintainer scripts are called by dpkg at:

http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html

Attached is a patch which fixes both issues. I'd appreciate comments on this one as update-rc.d.bbclass is widely used.

Signature · 2 lines
Jeremy LAINE
Bolloré telecom | 11bis, rue Scribe | F-75009 Paris
classes/update-rc.d.bbclass +12 -2
index 91af859..4744806 100644
@@ -16,17 +16,27 @@ update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
 
 updatercd_prerm() {
 if test "x$D" = "x"; then
-	${INIT_D_DIR}/${INITSCRIPT_NAME} stop
+	if test "$1" = "upgrade" -o "$1" = "remove"; then
+		${INIT_D_DIR}/${INITSCRIPT_NAME} stop
+	fi
 fi
 }
 
+# Note: to be Debian compliant, we should only invoke update-rc.d remove
+# in the "purge" step, but opkg does not support it. So instead we also
+# run it at the "remove" step in the init script no longer exists.
+
 updatercd_postrm() {
 if test "x$D" != "x"; then
 	OPT="-r $D"
 else
 	OPT=""
 fi
-update-rc.d $OPT ${INITSCRIPT_NAME} remove
+if test "$1" = "remove" -o "$1" = "purge"; then
+	if ! test -e "${INIT_D_DIR}/${INITSCRIPT_NAME}"; then
+		update-rc.d $OPT ${INITSCRIPT_NAME} remove
+	fi
+fi
 }
 
 
#1 lore raw
Quoted 2 lines · Jeremy Lainé

Attached is a patch which fixes both issues. I'd appreciate comments on this one as update-rc.d.bbclass is widely used.

Looks good to me.

p.