summaryrefslogtreecommitdiffstats
path: root/meta
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
parent452b23a3bbe44e835f4bed87f61920323b303734 (diff)
downloadpoky-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')
-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 9437e9cc31..29b5a8ea27 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -12,13 +12,11 @@ INITSCRIPT_PARAMS ?= "defaults"
12 12
13INIT_D_DIR = "${sysconfdir}/init.d" 13INIT_D_DIR = "${sysconfdir}/init.d"
14 14
15updatercd_postinst() { 15updatercd_preinst() {
16# test if there is a previous init script there, ie, we are updating the package 16if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
17# if so, we stop the service and remove it before we install from the new package 17 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
18fi
18if type update-rc.d >/dev/null 2>/dev/null; then 19if type update-rc.d >/dev/null 2>/dev/null; then
19 if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
20 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
21 fi
22 if [ -n "$D" ]; then 20 if [ -n "$D" ]; then
23 OPT="-f -r $D" 21 OPT="-f -r $D"
24 else 22 else
@@ -26,30 +24,32 @@ if type update-rc.d >/dev/null 2>/dev/null; then
26 fi 24 fi
27 update-rc.d $OPT ${INITSCRIPT_NAME} remove 25 update-rc.d $OPT ${INITSCRIPT_NAME} remove
28fi 26fi
27}
29 28
30if [ -n "$D" ]; then 29updatercd_postinst() {
31 OPT="-r $D"
32else
33 OPT="-s"
34fi
35if type update-rc.d >/dev/null 2>/dev/null; then 30if type update-rc.d >/dev/null 2>/dev/null; then
31 if [ -n "$D" ]; then
32 OPT="-r $D"
33 else
34 OPT="-s"
35 fi
36 update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} 36 update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
37fi 37fi
38} 38}
39 39
40updatercd_prerm() { 40updatercd_prerm() {
41if test "x$D" = "x"; then 41if [ -z "$D" ]; then
42 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop 42 ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
43fi 43fi
44} 44}
45 45
46updatercd_postrm() { 46updatercd_postrm() {
47if test "$D" != ""; then
48 OPT="-f -r $D"
49else
50 OPT=""
51fi
52if type update-rc.d >/dev/null 2>/dev/null; then 47if type update-rc.d >/dev/null 2>/dev/null; then
48 if [ -n "$D" ]; then
49 OPT="-r $D"
50 else
51 OPT=""
52 fi
53 update-rc.d $OPT ${INITSCRIPT_NAME} remove 53 update-rc.d $OPT ${INITSCRIPT_NAME} remove
54fi 54fi
55} 55}
@@ -68,22 +68,23 @@ python __anonymous() {
68 68
69PACKAGESPLITFUNCS_prepend = "populate_packages_updatercd " 69PACKAGESPLITFUNCS_prepend = "populate_packages_updatercd "
70 70
71populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst" 71populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst"
72 72
73python populate_packages_updatercd () { 73python populate_packages_updatercd () {
74 def update_rcd_package(pkg): 74 def update_rcd_package(pkg):
75 bb.debug(1, 'adding update-rc.d calls to postinst/postrm for %s' % pkg) 75 bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg)
76 """
77 update_rc.d postinst is appended here because pkg_postinst may require to
78 execute on the target. Not doing so may cause update_rc.d postinst invoked
79 twice to cause unwanted warnings.
80 """
81 76
82 localdata = bb.data.createCopy(d) 77 localdata = bb.data.createCopy(d)
83 overrides = localdata.getVar("OVERRIDES", True) 78 overrides = localdata.getVar("OVERRIDES", True)
84 localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides)) 79 localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides))
85 bb.data.update_data(localdata) 80 bb.data.update_data(localdata)
86 81
82 preinst = d.getVar('pkg_preinst_%s' % pkg, True)
83 if not preinst:
84 preinst = '#!/bin/sh\n'
85 preinst += localdata.getVar('updatercd_preinst', True)
86 d.setVar('pkg_preinst_%s' % pkg, preinst)
87
87 postinst = d.getVar('pkg_postinst_%s' % pkg, True) 88 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
88 if not postinst: 89 if not postinst:
89 postinst = '#!/bin/sh\n' 90 postinst = '#!/bin/sh\n'