2
1

genimage.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. die() {
  3. cat <<EOF >&2
  4. Error: $@
  5. Usage: ${0} -c GENIMAGE_CONFIG_FILE
  6. EOF
  7. exit 1
  8. }
  9. # Parse arguments and put into argument list of the script
  10. opts="$(getopt -n "${0##*/}" -o c: -- "$@")" || exit $?
  11. eval set -- "$opts"
  12. GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
  13. while true ; do
  14. case "$1" in
  15. -c)
  16. GENIMAGE_CFG="${2}";
  17. shift 2 ;;
  18. --) # Discard all non-option parameters
  19. shift 1;
  20. break ;;
  21. *)
  22. die "unknown option '${1}'" ;;
  23. esac
  24. done
  25. [ -n "${GENIMAGE_CFG}" ] || die "Missing argument"
  26. # Pass an empty rootpath. genimage makes a full copy of the given rootpath to
  27. # ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
  28. # space. We don't rely on genimage to build the rootfs image, just to insert a
  29. # pre-built one in the disk image.
  30. trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
  31. ROOTPATH_TMP="$(mktemp -d)"
  32. rm -rf "${GENIMAGE_TMP}"
  33. genimage \
  34. --rootpath "${ROOTPATH_TMP}" \
  35. --tmppath "${GENIMAGE_TMP}" \
  36. --inputpath "${BINARIES_DIR}" \
  37. --outputpath "${BINARIES_DIR}" \
  38. --config "${GENIMAGE_CFG}"
  39. if grep -Eq "^BR2_PACKAGE_HOST_BMAP_TOOLS=y$" "${BR2_CONFIG}"; then
  40. while IFS= read -r image; do
  41. image_path="${BINARIES_DIR}/${image}"
  42. if ! test -f "${image_path}"; then
  43. continue
  44. fi
  45. bmaptool create "${image_path}" -o "${image_path}.bmap"
  46. done < <(grep '^image ' "${GENIMAGE_CFG}" | cut -d ' ' -f 2)
  47. fi