simple_make.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #!/usr/bin/env bash
  2. set -eu -o pipefail
  3. apt_install() {
  4. local apt_packages=(
  5. automake
  6. autotools-dev
  7. build-essential
  8. check
  9. checkinstall
  10. cmake
  11. git
  12. libavdevice-dev
  13. libgdk-pixbuf2.0-dev
  14. libglib2.0-dev
  15. libgtk2.0-dev
  16. libopenal-dev
  17. libopus-dev
  18. libqrencode-dev
  19. libqt5opengl5-dev
  20. libqt5svg5-dev
  21. libsodium-dev
  22. libsqlcipher-dev
  23. libtool
  24. libvpx-dev
  25. libxss-dev
  26. qrencode
  27. qt5-default
  28. qt5-qmake
  29. qttools5-dev
  30. qttools5-dev-tools
  31. )
  32. local codename=$(lsb_release -c -s)
  33. # Enable Debian Jessie backports repository for libsqlcipher-dev (if not yet enabled)
  34. if [ ${codename} == jessie ] && [ $(apt-cache policy | fgrep jessie-backports -c) == 0 ]
  35. then
  36. echo "deb http://httpredir.debian.org/debian jessie-backports main" | sudo tee /etc/apt/sources.list.d/qtox-backports.list
  37. sudo apt-get update
  38. fi
  39. sudo apt-get install "${apt_packages[@]}"
  40. }
  41. pacman_install() {
  42. local pacman_packages=(
  43. base-devel
  44. git
  45. libsodium
  46. libvpx
  47. libxss
  48. openal
  49. opus
  50. qrencode
  51. qt5
  52. )
  53. sudo pacman -S --needed "${pacman_packages[@]}"
  54. }
  55. dnf_install() {
  56. local dnf_group_packages=(
  57. 'Development Tools'
  58. 'C Development Tools and Libraries'
  59. )
  60. sudo dnf group install "${dnf_group_packages[@]}"
  61. # pure Fedora doesn't have what it takes to compile qTox (ffmpeg)
  62. local fedora_version=$(rpm -E %fedora)
  63. local dnf_rpmfusion_package=(
  64. http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$fedora_version.noarch.rpm
  65. )
  66. sudo dnf install "$dnf_rpmfusion_package"
  67. local dnf_packages=(
  68. ffmpeg-devel
  69. gdk-pixbuf2-devel
  70. git
  71. glib2-devel
  72. gtk2-devel
  73. libsodium-devel
  74. libtool
  75. libvpx-devel
  76. libXScrnSaver-devel
  77. openal-soft-devel
  78. openssl-devel
  79. opus-devel
  80. qrencode-devel
  81. qt5-qtsvg
  82. qt5-qtsvg-devel
  83. qt5-qttools-devel
  84. qt-creator
  85. qt-devel
  86. qt-doc
  87. )
  88. sudo dnf install "${dnf_packages[@]}"
  89. }
  90. # Fedora by default doesn't include libs in /usr/local/lib so add it
  91. fedora_locallib() {
  92. local llib_file="/etc/ld.so.conf.d/locallib.conf"
  93. local llib_line="/usr/local/lib/"
  94. # check whether needed line already exists
  95. is_locallib() {
  96. grep -q "^$llib_line\$" "$llib_file"
  97. }
  98. # proceed only if line doesn't exist
  99. is_locallib \
  100. || echo "$llib_line" \
  101. | sudo tee -a "$llib_file"
  102. }
  103. zypper_install() {
  104. local zypper_packages=(
  105. automake
  106. cmake
  107. git
  108. libavcodec-devel
  109. libavdevice-devel
  110. libopus-devel
  111. libQt5Concurrent-devel
  112. libqt5-linguist
  113. libqt5-linguist-devel
  114. libQt5Network-devel
  115. libQt5OpenGL-devel
  116. libqt5-qtbase-common-devel
  117. libqt5-qtsvg-devel
  118. libQt5Test-devel
  119. libQt5Xml-devel
  120. libsodium-devel
  121. libvpx-devel
  122. libXScrnSaver-devel
  123. openal-soft-devel
  124. patterns-openSUSE-devel_basis
  125. qrencode-devel
  126. sqlcipher-devel
  127. )
  128. # if not sudo is installed, e.g. in docker image, install it
  129. command -v sudo || zypper in sudo
  130. sudo zypper in "${zypper_packages[@]}"
  131. }
  132. main() {
  133. if command -v zypper && [ -f /etc/products.d/openSUSE.prod ]
  134. then
  135. zypper_install
  136. elif command -v apt-get
  137. then
  138. apt_install
  139. elif command -v pacman
  140. then
  141. pacman_install
  142. elif command -v dnf
  143. then
  144. dnf_install
  145. fedora_locallib
  146. else
  147. echo "Unknown package manager, attempting to compile anyways"
  148. fi
  149. ./bootstrap.sh
  150. mkdir -p _build
  151. cd _build
  152. cmake ../
  153. make -j$(nproc)
  154. }
  155. main