postinst_1.0.bb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. SUMMARY = "Packages to exercise postinstall functions"
  2. LICENSE = "MIT"
  3. inherit allarch
  4. PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-rootfs-failing"
  5. ALLOW_EMPTY_${PN}-rootfs = "1"
  6. ALLOW_EMPTY_${PN}-delayed-a = "1"
  7. ALLOW_EMPTY_${PN}-delayed-b = "1"
  8. ALLOW_EMPTY_${PN}-rootfs-failing = "1"
  9. RDEPENDS_${PN}-delayed-a = "${PN}-rootfs"
  10. RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a"
  11. TESTDIR = "${sysconfdir}/postinst-test"
  12. # At rootfs time touch $TESTDIR/rootfs. Errors if the file already exists, or
  13. # if the function runs on first boot.
  14. pkg_postinst_${PN}-rootfs () {
  15. set -e
  16. if [ -z "$D" ]; then
  17. echo "${PN}-rootfs should have finished at rootfs time"
  18. exit 1
  19. fi
  20. if [ -e $D${TESTDIR}/rootfs ]; then
  21. echo "$D${TESTDIR}/rootfs exists, but should not"
  22. exit 1
  23. fi
  24. mkdir -p $D${TESTDIR}
  25. touch $D${TESTDIR}/rootfs
  26. }
  27. # Depends on rootfs, delays until first boot, verifies that the rootfs file was
  28. # written.
  29. pkg_postinst_ontarget_${PN}-delayed-a () {
  30. set -e
  31. if [ ! -e ${TESTDIR}/rootfs ]; then
  32. echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found"
  33. exit 1
  34. fi
  35. touch ${TESTDIR}/delayed-a
  36. }
  37. # Depends on delayed-a, delays until first boot, verifies that the delayed-a file was
  38. # written. This verifies the ordering between delayed postinsts.
  39. pkg_postinst_ontarget_${PN}-delayed-b () {
  40. set -e
  41. if [ ! -e ${TESTDIR}/delayed-a ]; then
  42. echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found"
  43. exit 1
  44. fi
  45. touch ${TESTDIR}/delayed-b
  46. }
  47. # This scriptlet intentionally includes a bogus command in the middle to test
  48. # that we catch and report such errors properly.
  49. pkg_postinst_${PN}-rootfs-failing () {
  50. mkdir -p $D${TESTDIR}
  51. touch $D${TESTDIR}/rootfs-before-failure
  52. run_a_really_broken_command
  53. # Scriptlet execution should stop here; the following commands are NOT supposed to run.
  54. # (oe-selftest checks for it).
  55. touch $D${TESTDIR}/rootfs-after-failure
  56. }