post-build.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env bash
  2. set -e
  3. DEVICE_TYPE="buildroot-x86_64"
  4. ARTIFACT_NAME="1.0"
  5. function parse_args {
  6. local o O opts
  7. o='a:o:d:'
  8. O='artifact-name:,data-part-size:,device-type:'
  9. opts="$(getopt -o "${o}" -l "${O}" -- "${@}")"
  10. eval set -- "${opts}"
  11. while [ ${#} -gt 0 ]; do
  12. case "${1}" in
  13. (-o|--data-part-size)
  14. # Ignored to have same options as other scripts
  15. shift 2
  16. ;;
  17. (-d|--device-type)
  18. DEVICE_TYPE="${2}"; shift 2
  19. ;;
  20. (-a|--artifact-name)
  21. ARTIFACT_NAME="${2}"; shift 2
  22. ;;
  23. (--)
  24. shift; break
  25. ;;
  26. esac
  27. done
  28. }
  29. # Create a persistent directory to mount the data partition at.
  30. function mender_fixup {
  31. pushd "${TARGET_DIR}"
  32. if [[ -L var/lib/mender ]]; then
  33. rm var/lib/mender
  34. mkdir -p var/lib/mender
  35. fi
  36. # The common paradigm is to have the persistent data volume at /data for mender.
  37. if [[ ! -L data ]]; then
  38. ln -s var/lib/mender data
  39. fi
  40. popd
  41. }
  42. function main {
  43. parse_args "${@}"
  44. mender_fixup
  45. echo "device_type=${DEVICE_TYPE}" > "${TARGET_DIR}/etc/mender/device_type"
  46. echo "artifact_name=${ARTIFACT_NAME}" > "${TARGET_DIR}/etc/mender/artifact_info"
  47. }
  48. main "${@}"