post-image.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. set -e
  3. #
  4. # dtb_list extracts the list of DTB files from BR2_LINUX_KERNEL_INTREE_DTS_NAME
  5. # in ${BR_CONFIG}, then prints the corresponding list of file names for the
  6. # genimage configuration file
  7. #
  8. dtb_list()
  9. {
  10. local DTB_LIST
  11. DTB_LIST="$(sed -n 's/^BR2_LINUX_KERNEL_INTREE_DTS_NAME="\([\/a-z0-9 \-]*\)"$/\1/p' "${BR2_CONFIG}")"
  12. for dt in $DTB_LIST; do
  13. echo -n "\"$(basename "${dt}").dtb\", "
  14. done
  15. }
  16. #
  17. # linux_image extracts the Linux image format from BR2_LINUX_KERNEL_UIMAGE in
  18. # ${BR_CONFIG}, then prints the corresponding file name for the genimage
  19. # configuration file
  20. #
  21. linux_image()
  22. {
  23. if grep -Eq "^BR2_LINUX_KERNEL_UIMAGE=y$" ${BR2_CONFIG}; then
  24. echo "\"uImage\""
  25. else
  26. echo "\"zImage\""
  27. fi
  28. }
  29. main()
  30. {
  31. local FILES="$(dtb_list) $(linux_image)"
  32. local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)"
  33. local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
  34. sed -e "s/%FILES%/${FILES}/" \
  35. board/freescale/common/mxs/genimage.cfg.template > ${GENIMAGE_CFG}
  36. rm -rf "${GENIMAGE_TMP}"
  37. genimage \
  38. --rootpath "${TARGET_DIR}" \
  39. --tmppath "${GENIMAGE_TMP}" \
  40. --inputpath "${BINARIES_DIR}" \
  41. --outputpath "${BINARIES_DIR}" \
  42. --config "${GENIMAGE_CFG}"
  43. rm -f ${GENIMAGE_CFG}
  44. exit $?
  45. }
  46. main $@