post-image.sh 1.3 KB

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