gentoo.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/libuv
  25. app-arch/lz4
  26. dev-libs/openssl
  27. virtual/libelf
  28. dev-lang/python
  29. dev-libs/libuv
  30. "
  31. usage() {
  32. cat << EOF
  33. OPTIONS:
  34. [--dont-wait] [--non-interactive] [ ]
  35. EOF
  36. }
  37. check_flags() {
  38. while [ -n "${1}" ]; do
  39. case "${1}" in
  40. dont-wait | --dont-wait | -n)
  41. DONT_WAIT=1
  42. ;;
  43. non-interactive | --non-interactive | -y)
  44. NON_INTERACTIVE=1
  45. ;;
  46. help | -h | --help)
  47. usage
  48. exit 1
  49. ;;
  50. *)
  51. echo >&2 "ERROR: Cannot understand option '${1}'"
  52. echo >&2
  53. usage
  54. exit 1
  55. ;;
  56. esac
  57. shift
  58. done
  59. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  60. read -r -p "Press ENTER to run it > " || exit 1
  61. fi
  62. }
  63. # shellcheck disable=SC2068
  64. check_flags ${@}
  65. packages_to_install=
  66. # shellcheck disable=SC2068
  67. for package in $package_tree; do
  68. if qlist -IRv "$package" &> /dev/null; then
  69. echo "Package '${package}' is installed"
  70. else
  71. echo "Package '${package}' is NOT installed"
  72. packages_to_install="$packages_to_install $package"
  73. fi
  74. done
  75. if [[ -z "$packages_to_install" ]]; then
  76. echo "All required packages are already installed. Skipping .."
  77. else
  78. echo "packages_to_install:" "$packages_to_install"
  79. opts="--ask"
  80. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  81. echo >&2 "Running in non-interactive mode"
  82. opts=""
  83. fi
  84. # shellcheck disable=SC2086
  85. emerge ${opts} $packages_to_install
  86. fi