diff options
author | Jacob Kroon <jacob.kroon@gmail.com> | 2013-10-30 01:57:11 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-11-01 11:09:04 +0000 |
commit | 717c1ed719a7744ad2f073786cf1d91ca0ce111b (patch) | |
tree | 04c2d8a17e668dae997dd3219041b0c747b9a6a3 /meta/classes/update-rc.d.bbclass | |
parent | 452b23a3bbe44e835f4bed87f61920323b303734 (diff) | |
download | 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.bbclass | 49 |
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 | ||
13 | INIT_D_DIR = "${sysconfdir}/init.d" | 13 | INIT_D_DIR = "${sysconfdir}/init.d" |
14 | 14 | ||
15 | updatercd_postinst() { | 15 | updatercd_preinst() { |
16 | # test if there is a previous init script there, ie, we are updating the package | 16 | if [ -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 |
18 | fi | ||
18 | if type update-rc.d >/dev/null 2>/dev/null; then | 19 | if 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 |
28 | fi | 26 | fi |
27 | } | ||
29 | 28 | ||
30 | if [ -n "$D" ]; then | 29 | updatercd_postinst() { |
31 | OPT="-r $D" | ||
32 | else | ||
33 | OPT="-s" | ||
34 | fi | ||
35 | if type update-rc.d >/dev/null 2>/dev/null; then | 30 | if 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} |
37 | fi | 37 | fi |
38 | } | 38 | } |
39 | 39 | ||
40 | updatercd_prerm() { | 40 | updatercd_prerm() { |
41 | if test "x$D" = "x"; then | 41 | if [ -z "$D" ]; then |
42 | ${INIT_D_DIR}/${INITSCRIPT_NAME} stop | 42 | ${INIT_D_DIR}/${INITSCRIPT_NAME} stop |
43 | fi | 43 | fi |
44 | } | 44 | } |
45 | 45 | ||
46 | updatercd_postrm() { | 46 | updatercd_postrm() { |
47 | if test "$D" != ""; then | ||
48 | OPT="-f -r $D" | ||
49 | else | ||
50 | OPT="" | ||
51 | fi | ||
52 | if type update-rc.d >/dev/null 2>/dev/null; then | 47 | if 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 |
54 | fi | 54 | fi |
55 | } | 55 | } |
@@ -68,22 +68,23 @@ python __anonymous() { | |||
68 | 68 | ||
69 | PACKAGESPLITFUNCS_prepend = "populate_packages_updatercd " | 69 | PACKAGESPLITFUNCS_prepend = "populate_packages_updatercd " |
70 | 70 | ||
71 | populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_postinst" | 71 | populate_packages_updatercd[vardeps] += "updatercd_prerm updatercd_postrm updatercd_preinst updatercd_postinst" |
72 | 72 | ||
73 | python populate_packages_updatercd () { | 73 | python 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' |