post-image.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. main()
  28. {
  29. local FILES="$(dtb_list) $(linux_image)"
  30. local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)"
  31. local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
  32. sed -e "s/%FILES%/${FILES}/" \
  33. board/freescale/common/imx/genimage.cfg.template > ${GENIMAGE_CFG}
  34. rm -rf "${GENIMAGE_TMP}"
  35. genimage \
  36. --rootpath "${TARGET_DIR}" \
  37. --tmppath "${GENIMAGE_TMP}" \
  38. --inputpath "${BINARIES_DIR}" \
  39. --outputpath "${BINARIES_DIR}" \
  40. --config "${GENIMAGE_CFG}"
  41. rm -f ${GENIMAGE_CFG}
  42. exit $?
  43. }
  44. main $@