genimage.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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}"