summaryrefslogtreecommitdiffstats
path: root/meta/classes/update-rc.d.bbclass
diff options
context:
space:
mode:
authorJacob Kroon <jacob.kroon@gmail.com>2013-10-30 01:57:11 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-11-01 11:09:04 +0000
commit717c1ed719a7744ad2f073786cf1d91ca0ce111b (patch)
tree04c2d8a17e668dae997dd3219041b0c747b9a6a3 /meta/classes/update-rc.d.bbclass
parent452b23a3bbe44e835f4bed87f61920323b303734 (diff)
downloadast2050-yocto-poky-717c1ed719a7744ad2f073786cf1d91ca0ce111b.zip
ast2050-yocto-poky-717c1ed719a7744ad2f073786cf1d91ca0ce111b.tar.gz
update-rc.d.bbclass: Cleanup package scripts
* Add proper preinst script * Use -n "$D"/-z "$D" checks throughout the scripts * Only set OPT in cases where its used * Don't pass unnecessary -f to update-rc.d in postrm script * Remove outdated comment (From OE-Core rev: 2d9114aaf130179cb13c20c8b045c2694eca6fd9) Signed-off-by: Jacob Kroon <jacob.kroon@mikrodidakt.se> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/update-rc.d.bbclass')
-rw-r--r--meta/classes/update-rc.d.bbclass49
1 files changed, 25 insertions, 24 deletions
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 9437e9c..29b5a8e 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -12,13 +12,11 @@ INITSCRIPT_PARAMS ?= "defaults"
INIT_D_DIR = "${sysconfdir}/init.d"
-updatercd_postinst() {
-# test if there is a previous init script there, ie, we are updating the package
-# if so, we stop the service and remove it before we install from the new package
+updatercd_preinst() {
+if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
+ ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
+fi
if type update-rc.d >/dev/null 2>/dev/null; then
- if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
- ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
- fi
if [ -n "$D" ]; then
OPT="-f -r $D"
else
@@ -26,30 +24,32 @@ if type update-rc.d >/dev/null 2>/dev/null; then
fi
update-rc.d $OPT ${INITSCRIPT_NAME} remove
fi
+}
-if [ -n "$D" ]; then
- OPT="-r $D"
-else
- OPT="-s"
-fi
+updatercd_postinst() {
if type update-rc.d >/dev/null 2>/dev/null; then
+ if [ -n "$D" ]; then
+ OPT="-r $D"
+ else
+ OPT="-s"
+ fi
update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
fi
}
updatercd_prerm() {
-if test "x$D" = "x"; then
+if [ -z "$D" ]; then
${INIT_D_DIR}/${INITSCRIPT_NAME} stop
fi
}
updatercd_postrm() {
-if test "$D" != ""; then
- OPT="-f -r $D"
-else
- OPT=""
-fi
if type update-rc.d >/dev/null 2>/dev/null; then
+ if [ -n "$D" ]; then
+ OPT="-r $D"
+ else
+ OPT=""
+ fi
update-rc.d $OPT ${INITSCRIPT_NAME} remove
fi
}
@@ -68,22 +68,23 @@ python __anonymous() {
PACKAGESPLITFUNCS_prepend = "populate_packages_updatercd "
-populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst"
+populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst"
python populate_packages_updatercd () {
def update_rcd_package(pkg):
- bb.debug(1, 'adding update-rc.d calls to postinst/postrm for %s' % pkg)
- """
- update_rc.d postinst is appended here because pkg_postinst may require to
- execute on the target. Not doing so may cause update_rc.d postinst invoked
- twice to cause unwanted warnings.
- """
+ bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg)
localdata = bb.data.createCopy(d)
overrides = localdata.getVar("OVERRIDES", True)
localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides))
bb.data.update_data(localdata)
+ preinst = d.getVar('pkg_preinst_%s' % pkg, True)
+ if not preinst:
+ preinst = '#!/bin/sh\n'
+ preinst += localdata.getVar('updatercd_preinst', True)
+ d.setVar('pkg_preinst_%s' % pkg, preinst)
+
postinst = d.getVar('pkg_postinst_%s' % pkg, True)
if not postinst:
postinst = '#!/bin/sh\n'
OpenPOWER on IntegriCloud