gentoo.sh 1.9 KB

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