arch.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/usr/bin/env bash
  2. # Package tree used for installing netdata on distribution:
  3. # << ArchLinux: [base] [base-devel] >> | << Manjaro >>
  4. set -e
  5. NON_INTERACTIVE=0
  6. DONT_WAIT=0
  7. declare -a package_tree=(
  8. gcc
  9. make
  10. autoconf
  11. autoconf-archive
  12. autogen
  13. automake
  14. libtool
  15. cmake
  16. zlib
  17. util-linux
  18. libmnl
  19. json-c
  20. libyaml
  21. libuv
  22. lz4
  23. openssl
  24. libelf
  25. git
  26. pkgconfig
  27. tar
  28. curl
  29. gzip
  30. python3
  31. binutils
  32. bison
  33. flex
  34. )
  35. usage() {
  36. cat << EOF
  37. OPTIONS:
  38. [--dont-wait] [--non-interactive] [ ]
  39. EOF
  40. }
  41. check_flags() {
  42. while [ -n "${1}" ]; do
  43. case "${1}" in
  44. dont-wait | --dont-wait | -n)
  45. DONT_WAIT=1
  46. ;;
  47. non-interactive | --non-interactive | -y)
  48. NON_INTERACTIVE=1
  49. ;;
  50. help | -h | --help)
  51. usage
  52. exit 1
  53. ;;
  54. *)
  55. echo >&2 "ERROR: Cannot understand option '${1}'"
  56. echo >&2
  57. usage
  58. exit 1
  59. ;;
  60. esac
  61. shift
  62. done
  63. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  64. read -r -p "Press ENTER to run it > " || exit 1
  65. fi
  66. }
  67. # shellcheck disable=SC2068
  68. check_flags ${@}
  69. packages_to_install=
  70. # shellcheck disable=SC2068
  71. for package in ${package_tree[@]}; do
  72. if pacman -Qn "$package" &> /dev/null; then
  73. echo "Package '${package}' is installed"
  74. else
  75. echo "Package '$package' is NOT installed"
  76. packages_to_install="$packages_to_install $package"
  77. fi
  78. done
  79. if [[ -z $packages_to_install ]]; then
  80. echo "All required packages are already installed. Skipping .."
  81. else
  82. echo "packages_to_install: " "${packages_to_install[@]}"
  83. opts=
  84. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  85. echo >&2 "Running in non-interactive mode"
  86. opts="--noconfirm"
  87. fi
  88. # shellcheck disable=SC2068
  89. pacman -Sy ${opts} ${packages_to_install[@]}
  90. fi