gentoo.sh 1.9 KB

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