ext-tools.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env bash
  2. TOOLS_TAR=""
  3. HOST_BUILD_DIR=$(pwd)/"build_dir/host"
  4. HOST_STAGING_DIR_STAMP=$(pwd)/"staging_dir/host/stamp"
  5. refresh_timestamps() {
  6. find -H "$1" -not -type l -print0 | xargs -0 touch
  7. }
  8. extract_prebuilt_tar() {
  9. tar -xf "$1"
  10. }
  11. install_prebuilt_tools() {
  12. extract_prebuilt_tar "$TOOLS_TAR"
  13. if [ ! -d "$HOST_BUILD_DIR" ]; then
  14. echo "Can't find Host Build Dir "$HOST_BUILD_DIR"" >&2
  15. exit 1
  16. fi
  17. refresh_timestamps "$HOST_BUILD_DIR"
  18. sleep 1
  19. if [ ! -d "$HOST_STAGING_DIR_STAMP" ]; then
  20. echo "Can't find Host Staging Dir Stamp "$HOST_STAGING_DIR_STAMP"" >&2
  21. exit 1
  22. fi
  23. refresh_timestamps "$HOST_STAGING_DIR_STAMP"
  24. return 0
  25. }
  26. while [ -n "$1" ]; do
  27. arg="$1"; shift
  28. case "$arg" in
  29. --host-build-dir)
  30. [ -d "$1" ] || {
  31. echo "Directory '$1' does not exist." >&2
  32. exit 1
  33. }
  34. HOST_BUILD_DIR="$(cd "$1"; pwd)"; shift
  35. ;;
  36. --host-staging-dir-stamp)
  37. [ -d "$1" ] || {
  38. echo "Directory '$1' does not exist." >&2
  39. exit 1
  40. }
  41. HOST_STAGING_DIR_STAMP="$(cd "$1"; pwd)"; shift
  42. ;;
  43. --tools)
  44. [ -f "$1" ] || {
  45. echo "Tools tar file '$1' does not exist." >&2
  46. exit 1
  47. }
  48. TOOLS_TAR="$1"; shift
  49. install_prebuilt_tools
  50. exit $?
  51. ;;
  52. -h|--help)
  53. me="$(basename "$0")"
  54. echo -e "\nUsage:\n" >&2
  55. echo -e " $me --host-build-dir {directory}" >&2
  56. echo -e " Set to refresh timestamp of this build directory" >&2
  57. echo -e " with --tools." >&2
  58. echo -e " THIS OPTION MUST BE SET BEFORE --tools." >&2
  59. echo -e " If not provided the default directory is:" >&2
  60. echo -e " $(pwd)/build_dir/host\n" >&2
  61. echo -e " $me --host-staging-dir-stamp {directory}" >&2
  62. echo -e " Set to refresh staging timestamp present in this" >&2
  63. echo -e " directory with --tools." >&2
  64. echo -e " THIS OPTION MUST BE SET BEFORE --tools." >&2
  65. echo -e " If not provided the default directory is:" >&2
  66. echo -e " $(pwd)/staging_dir/host/stamp\n" >&2
  67. echo -e " $me --tools {tar}" >&2
  68. echo -e " Install the prebuilt tools present in the passed" >&2
  69. echo -e " tar and prepare them." >&2
  70. echo -e " To correctly use them it's needed to update the." >&2
  71. echo -e " timestamp of each tools to skip recompilation.\n" >&2
  72. echo -e " $me --help" >&2
  73. echo -e " Display this help text and exit.\n\n" >&2
  74. exit 1
  75. ;;
  76. *)
  77. echo "Unknown argument '$arg'" >&2
  78. exec $0 --help
  79. ;;
  80. esac
  81. done
  82. exec $0 --help