prepare-build-deps.sh 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. AUTO_INSTALL_BUILD_DEPS="${AUTO_INSTALL_BUILD_DEPS:-0}"
  4. required_packages_mac_osx="freetds unixodbc coreutils"
  5. required_cmds_mac_osx="curl zip unzip autoconf automake cmake openssl"
  6. dependency_missing() {
  7. echo "error: $1 is not found in the system"
  8. if [ "${AUTO_INSTALL_BUILD_DEPS}" = "1" ]; then
  9. echo "brew install $1"
  10. brew install "$1"
  11. else
  12. echo "You can install it by running:"
  13. echo " brew install $1"
  14. exit 1
  15. fi
  16. }
  17. prepare_mac_osx() {
  18. current_packages=$(brew list)
  19. for package in ${required_packages_mac_osx}
  20. do
  21. if ! echo "${current_packages}" | grep -q "${package}"; then
  22. dependency_missing "${package}"
  23. fi
  24. done
  25. for cmd in ${required_cmds_mac_osx}
  26. do
  27. if ! command -v "${cmd}" &> /dev/null; then
  28. dependency_missing "${cmd}"
  29. fi
  30. done
  31. }
  32. case $(uname) in
  33. *Darwin*) prepare_mac_osx;;
  34. *) exit 0;;
  35. esac