dependency_setup.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #!/bin/sh
  2. set -e
  3. if [ "$(id -u)" != 0 ]; then
  4. SUDO="${SUDO:-$(command -v sudo)}"
  5. else
  6. SUDO="${SUDO:-}"
  7. fi
  8. brew_sh="https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"
  9. setup_mac() {
  10. if ! command -v brew >/dev/null; then
  11. echo "brew not found, installing..." >&2
  12. bash -c "$(curl -fL "${brew_sh}")" || return 1
  13. fi
  14. for i in cmake gcc pkgconf llvm@13; do
  15. echo "Installing $i with brew..." >&2
  16. brew install "$i" || return 1
  17. done
  18. }
  19. setup_apt() {
  20. apt_deps="git make gcc pkg-config libasound2-dev"
  21. $1 install $apt_deps || return 1
  22. }
  23. setup_pacman() {
  24. pacman_deps="git make gcc pkgconf alsa-lib"
  25. $1 -Sy $pacman_deps || return 1
  26. }
  27. setup_xbps() {
  28. xbps_deps="git make gcc pkg-config alsa-lib-devel"
  29. $1 -S $xbps_deps || return 1
  30. }
  31. setup_dnf() {
  32. dnf_deps="git make gcc pkg-config findutils lato-fonts"
  33. $1 install -y $dnf_deps || return 1
  34. }
  35. setup_apk() {
  36. apk_deps="git make gcc musl-dev pkgconfig alsa-lib-dev"
  37. $1 add $apk_deps || return 1
  38. }
  39. setup_zypper() {
  40. zypper_deps="git make gcc pkg-config findutils"
  41. $1 install -y $zypper_deps || return 1
  42. }
  43. setup_emerge() {
  44. emerge_deps="dev-vcs/git media-libs/alsa-lib"
  45. $1 $emerge_deps || return 1
  46. }
  47. setup_pkg() {
  48. pkg_deps="git bash gcc findutils cantarell-fonts gmake devel/automake"
  49. $1 install -y $pkg_deps || return 1
  50. }
  51. setup_pkg_add() {
  52. pkg_add_deps="git bash gcc-11.2.0p6 findutils cantarell-fonts gmake automake-1.15.1"
  53. $1 -I $pkg_add_deps || return 1
  54. }
  55. setup_pkgin() {
  56. pkgin_deps="git bash gcc12 findutils cantarell-fonts pkgconf gmake automake"
  57. $1 -y install $pkgin_deps || return 1
  58. }
  59. case "$(uname -s)" in
  60. Linux)
  61. if command -v apt >/dev/null; then
  62. echo "Setting up for apt" >&2
  63. setup_apt "$SUDO $(command -v apt)" || exit 1
  64. echo "Dependencies installed!" >&2
  65. exit 0
  66. fi
  67. if command -v apt-get >/dev/null; then
  68. echo "Setting up for apt-get" >&2
  69. setup_apt "$SUDO $(command -v apt-get)" || exit 1
  70. echo "Dependencies installed!" >&2
  71. exit 0
  72. fi
  73. if command -v pacman; then
  74. echo "Setting up for pacman" >&2
  75. setup_pacman "$SUDO $(command -v pacman)" || exit 1
  76. echo "Dependencies installed!" >&2
  77. exit 0
  78. fi
  79. if command -v xbps-install; then
  80. echo "Setting up for xbps" >&2
  81. setup_xbps "$SUDO $(command -v xbps-install)" || exit 1
  82. echo "Dependencies installed!" >&2
  83. exit 0
  84. fi
  85. if command -v dnf; then
  86. echo "Setting up for dnf" >&2
  87. setup_dnf "$SUDO $(command -v dnf)" || exit 1
  88. echo "Dependencies installed!" >&2
  89. exit 0
  90. fi
  91. if command -v apk; then
  92. echo "Setting up for apk" >&2
  93. setup_apk "$SUDO $(command -v apk)" || exit 1
  94. echo "Dependencies installed!" >&2
  95. exit 0
  96. fi
  97. if command -v zypper; then
  98. echo "Setting up for zypper" >&2
  99. setup_zypper "$SUDO $(command -v zypper)" || exit 1
  100. echo "Dependencies installed!" >&2
  101. exit 0
  102. fi
  103. if command -v emerge; then
  104. echo "Setting up for emerge" >&2
  105. setup_emerge "$SUDO $(command -v emerge)" || exit 1
  106. echo "Dependencies installed!" >&2
  107. exit 0
  108. fi
  109. echo "Error: Could not recognize your package manager." >&2
  110. exit 1
  111. ;;
  112. *BSD*)
  113. if command -v pkgin; then
  114. echo "Setting up for pkgin/NetBSD" >&2
  115. setup_pkgin "$SUDO $(command -v pkgin)" || exit 1
  116. elif command -v pkg; then
  117. echo "Setting up for pkg/FreeBSD" >&2
  118. setup_pkg "$SUDO $(command -v pkg)" || exit 1
  119. elif command -v pkg_add; then
  120. echo "Setting up for pkg_add/OpenBSD" >&2
  121. setup_pkg_add "$SUDO $(command -v pkg_add)" || exit 1
  122. echo "Rust support is not yet ready for OpenBSD, see https://github.com/rust-lang/rustup/issues/2168#issuecomment-1505185711"
  123. echo "You may try to compile rustc and cargo yourself or get the latest with:"
  124. echo "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain nightly --default-host x86_64-unknown-openbsd"
  125. fi
  126. echo "Error: Could not recognize your package manager." >&2
  127. exit 1
  128. ;;
  129. Darwin)
  130. echo "Setting up for OSX" >&2
  131. setup_mac || exit 1
  132. echo "Dependencies installed!" >&2
  133. exit 0
  134. ;;
  135. ""|*)
  136. echo "Unsupported OS, sorry." >&2
  137. exit 1
  138. ;;
  139. esac