blob: 913bfabf89e3a22f59600fffab1bdccbab401e7b [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001SUMMARY = "Packages to exercise postinstall functions"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002LICENSE = "MIT"
Brad Bishop316dfdd2018-06-25 12:45:53 -04003
4inherit allarch
5
6PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-rootfs-failing"
7
8ALLOW_EMPTY_${PN}-rootfs = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009ALLOW_EMPTY_${PN}-delayed-a = "1"
10ALLOW_EMPTY_${PN}-delayed-b = "1"
Brad Bishop316dfdd2018-06-25 12:45:53 -040011ALLOW_EMPTY_${PN}-rootfs-failing = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012
Brad Bishop316dfdd2018-06-25 12:45:53 -040013RDEPENDS_${PN}-delayed-a = "${PN}-rootfs"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015
Brad Bishop316dfdd2018-06-25 12:45:53 -040016TESTDIR = "${sysconfdir}/postinst-test"
17
18# At rootfs time touch $TESTDIR/rootfs. Errors if the file already exists, or
19# if the function runs on first boot.
20pkg_postinst_${PN}-rootfs () {
21 set -e
22
23 if [ -z "$D" ]; then
24 echo "${PN}-rootfs should have finished at rootfs time"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 exit 1
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -050027
Brad Bishop316dfdd2018-06-25 12:45:53 -040028 if [ -e $D${TESTDIR}/rootfs ]; then
29 echo "$D${TESTDIR}/rootfs exists, but should not"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030 exit 1
Brad Bishop316dfdd2018-06-25 12:45:53 -040031 fi
32
33 mkdir -p $D${TESTDIR}
34 touch $D${TESTDIR}/rootfs
Brad Bishop6e60e8b2018-02-01 10:27:11 -050035}
36
Brad Bishop316dfdd2018-06-25 12:45:53 -040037# Depends on rootfs, delays until first boot, verifies that the rootfs file was
38# written.
39pkg_postinst_ontarget_${PN}-delayed-a () {
40 set -e
Brad Bishop6e60e8b2018-02-01 10:27:11 -050041
Brad Bishop316dfdd2018-06-25 12:45:53 -040042 if [ ! -e ${TESTDIR}/rootfs ]; then
43 echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050044 exit 1
Brad Bishop316dfdd2018-06-25 12:45:53 -040045 fi
46
47 touch ${TESTDIR}/delayed-a
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048}
49
Brad Bishop316dfdd2018-06-25 12:45:53 -040050# Depends on delayed-a, delays until first boot, verifies that the delayed-a file was
51# written. This verifies the ordering between delayed postinsts.
52pkg_postinst_ontarget_${PN}-delayed-b () {
53 set -e
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054
Brad Bishop316dfdd2018-06-25 12:45:53 -040055 if [ ! -e ${TESTDIR}/delayed-a ]; then
56 echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057 exit 1
Brad Bishop316dfdd2018-06-25 12:45:53 -040058 fi
59
60 touch ${TESTDIR}/delayed-b
Brad Bishop6e60e8b2018-02-01 10:27:11 -050061}
62
Brad Bishop316dfdd2018-06-25 12:45:53 -040063# This scriptlet intentionally includes a bogus command in the middle to test
64# that we catch and report such errors properly.
65pkg_postinst_${PN}-rootfs-failing () {
66 mkdir -p $D${TESTDIR}
67 touch $D${TESTDIR}/rootfs-before-failure
68 run_a_really_broken_command
69 # Scriptlet execution should stop here; the following commands are NOT supposed to run.
70 # (oe-selftest checks for it).
71 touch $D${TESTDIR}/rootfs-after-failure
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072}