gentoo.sh 1.8 KB

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