summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2018-01-29 14:01:31 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-01-30 11:50:12 +0000
commit6ca669105ff7f405e85142d1aa5375a8430c9606 (patch)
tree6b63559fee22c94da95c81043d42a519245bbd98
parent32c500b8ea2c8c76edf35a860477be34af72c499 (diff)
downloadpoky-6ca669105ff7f405e85142d1aa5375a8430c9606.tar.gz
package.bbclass: add support for pkg_postinst_ontarget()
This function is a convenient and more readable shortcut for situations when the postinst code always needs to run on target. All commands that cannot be executed during cross-install and can only be run on target should go into this function. They will only be executed on first boot (if package was cross-installed) or immediately during package installation on target. Plain pkg_postinst() works as before: it is run during cross-install time, it can contain a request to defer to first boot, and it is also run during package installation on target. Also fix the oeqa test for this functionality to use the new function where appropriate. (From OE-Core rev: 229f4e975fb6957f44b5c56735fd6d58564098d7) Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/recipes-test/postinst/postinst_1.0.bb14
-rw-r--r--meta/classes/package.bbclass20
2 files changed, 22 insertions, 12 deletions
diff --git a/meta-selftest/recipes-test/postinst/postinst_1.0.bb b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
index 112aa08c80..d4bab6dcc2 100644
--- a/meta-selftest/recipes-test/postinst/postinst_1.0.bb
+++ b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
@@ -35,14 +35,9 @@ pkg_postinst_${PN}-rootfs () {
35 35
36# Depends on rootfs, delays until first boot, verifies that the rootfs file was 36# Depends on rootfs, delays until first boot, verifies that the rootfs file was
37# written. 37# written.
38pkg_postinst_${PN}-delayed-a () { 38pkg_postinst_ontarget_${PN}-delayed-a () {
39 set -e 39 set -e
40 40
41 if [ -n "$D" ]; then
42 echo "Delaying ${PN}-delayed-a until first boot"
43 exit 1
44 fi
45
46 if [ ! -e ${TESTDIR}/rootfs ]; then 41 if [ ! -e ${TESTDIR}/rootfs ]; then
47 echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found" 42 echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found"
48 exit 1 43 exit 1
@@ -53,14 +48,9 @@ pkg_postinst_${PN}-delayed-a () {
53 48
54# Depends on delayed-a, delays until first boot, verifies that the delayed-a file was 49# Depends on delayed-a, delays until first boot, verifies that the delayed-a file was
55# written. This verifies the ordering between delayed postinsts. 50# written. This verifies the ordering between delayed postinsts.
56pkg_postinst_${PN}-delayed-b () { 51pkg_postinst_ontarget_${PN}-delayed-b () {
57 set -e 52 set -e
58 53
59 if [ -n "$D" ]; then
60 echo "Delaying ${PN}-delayed-b until first boot"
61 exit 1
62 fi
63
64 if [ ! -e ${TESTDIR}/delayed-a ]; then 54 if [ ! -e ${TESTDIR}/delayed-a ]; then
65 echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found" 55 echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found"
66 exit 1 56 exit 1
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 7dc759699f..6a7f35a3e7 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1320,6 +1320,25 @@ python emit_pkgdata() {
1320 from glob import glob 1320 from glob import glob
1321 import json 1321 import json
1322 1322
1323 def process_postinst_on_target(pkg, mlprefix):
1324 defer_fragment = """
1325if [ -n "$D" ]; then
1326 $INTERCEPT_DIR/postinst_intercept delay_to_first_boot %s mlprefix=%s
1327 exit 0
1328fi
1329""" % (pkg, mlprefix)
1330
1331 postinst = d.getVar('pkg_postinst_%s' % pkg)
1332 postinst_ontarget = d.getVar('pkg_postinst_ontarget_%s' % pkg)
1333
1334 if postinst_ontarget:
1335 bb.debug(1, 'adding deferred pkg_postinst_ontarget() to pkg_postinst() for %s' % pkg)
1336 if not postinst:
1337 postinst = '#!/bin/sh\n'
1338 postinst += defer_fragment
1339 postinst += postinst_ontarget
1340 d.setVar('pkg_postinst_%s' % pkg, postinst)
1341
1323 def write_if_exists(f, pkg, var): 1342 def write_if_exists(f, pkg, var):
1324 def encode(str): 1343 def encode(str):
1325 import codecs 1344 import codecs
@@ -1415,6 +1434,7 @@ python emit_pkgdata() {
1415 write_if_exists(sf, pkg, 'ALLOW_EMPTY') 1434 write_if_exists(sf, pkg, 'ALLOW_EMPTY')
1416 write_if_exists(sf, pkg, 'FILES') 1435 write_if_exists(sf, pkg, 'FILES')
1417 write_if_exists(sf, pkg, 'CONFFILES') 1436 write_if_exists(sf, pkg, 'CONFFILES')
1437 process_postinst_on_target(pkg, d.getVar("MLPREFIX"))
1418 write_if_exists(sf, pkg, 'pkg_postinst') 1438 write_if_exists(sf, pkg, 'pkg_postinst')
1419 write_if_exists(sf, pkg, 'pkg_postrm') 1439 write_if_exists(sf, pkg, 'pkg_postrm')
1420 write_if_exists(sf, pkg, 'pkg_preinst') 1440 write_if_exists(sf, pkg, 'pkg_preinst')