Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | SUMMARY = "Packages to exercise postinstall functions" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2 | LICENSE = "MIT" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3 | |
| 4 | inherit allarch |
| 5 | |
| 6 | PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-rootfs-failing" |
| 7 | |
| 8 | ALLOW_EMPTY_${PN}-rootfs = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9 | ALLOW_EMPTY_${PN}-delayed-a = "1" |
| 10 | ALLOW_EMPTY_${PN}-delayed-b = "1" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | ALLOW_EMPTY_${PN}-rootfs-failing = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13 | RDEPENDS_${PN}-delayed-a = "${PN}-rootfs" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 14 | RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 15 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 16 | TESTDIR = "${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. |
| 20 | pkg_postinst_${PN}-rootfs () { |
| 21 | set -e |
| 22 | |
| 23 | if [ -z "$D" ]; then |
| 24 | echo "${PN}-rootfs should have finished at rootfs time" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | exit 1 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 26 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 27 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 28 | if [ -e $D${TESTDIR}/rootfs ]; then |
| 29 | echo "$D${TESTDIR}/rootfs exists, but should not" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 30 | exit 1 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | fi |
| 32 | |
| 33 | mkdir -p $D${TESTDIR} |
| 34 | touch $D${TESTDIR}/rootfs |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 35 | } |
| 36 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | # Depends on rootfs, delays until first boot, verifies that the rootfs file was |
| 38 | # written. |
| 39 | pkg_postinst_ontarget_${PN}-delayed-a () { |
| 40 | set -e |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 41 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 42 | if [ ! -e ${TESTDIR}/rootfs ]; then |
| 43 | echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 44 | exit 1 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 45 | fi |
| 46 | |
| 47 | touch ${TESTDIR}/delayed-a |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 48 | } |
| 49 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 50 | # Depends on delayed-a, delays until first boot, verifies that the delayed-a file was |
| 51 | # written. This verifies the ordering between delayed postinsts. |
| 52 | pkg_postinst_ontarget_${PN}-delayed-b () { |
| 53 | set -e |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 54 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 55 | if [ ! -e ${TESTDIR}/delayed-a ]; then |
| 56 | echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 57 | exit 1 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 58 | fi |
| 59 | |
| 60 | touch ${TESTDIR}/delayed-b |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 61 | } |
| 62 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 63 | # This scriptlet intentionally includes a bogus command in the middle to test |
| 64 | # that we catch and report such errors properly. |
| 65 | pkg_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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 72 | } |