Automate installation of DXVK, D9VK + Wine/Wine Staging & update GPU drivers + PlayonLinux wineprefixes (Debian/Ubuntu/Mint/Arch Linux/Manjaro)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

300 lines
8.5 KiB

6 years ago
6 years ago
  1. #!/bin/env bash
  2. # Wrapper for DXVK & Wine compilation scripts
  3. # Copyright (C) 2019 Pekka Helenius
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. ########################################################
  18. # DO NOT RUN INDIVIDUALLY, ONLY VIA ../updatewine.sh PARENT SCRIPT!
  19. ########################################################
  20. # Root directory of this script file
  21. ROOTDIR="${PWD}"
  22. # datedir variable supplied by ../updatewine.sh script file
  23. datedir="${1}"
  24. ########################################################
  25. # http://wiki.bash-hackers.org/snipplets/print_horizontal_line#a_line_across_the_entire_width_of_the_terminal
  26. function INFO_SEP() { printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - ; }
  27. ########################################################
  28. # Divide input args into array indexes
  29. # These are passed to the subscripts (array b)
  30. i=0
  31. for p in ${@:2}; do
  32. params[$i]=${p}
  33. let i++
  34. done
  35. ########################################################
  36. # Parse input arguments, filter user parameters
  37. # The range is defined in ../updatewine.sh
  38. # All input arguments are:
  39. # <datedir> 4*<githash_override> 4*<gitbranch_override> <args>
  40. # 0 1 2 3 4 5 6 7 8 9...
  41. # Filter all but <args>, i.e. the first 0-8 arguments
  42. i=0
  43. for arg in ${params[@]:8}; do
  44. args[$i]="${arg}"
  45. let i++
  46. done
  47. # All valid arguments given in ../updatewine.sh are handled...
  48. # All valid arguments are passed to subscripts...
  49. # ...but these are specifically used in this script
  50. #
  51. for check in ${args[@]}; do
  52. case ${check} in
  53. --no-wine)
  54. NO_WINE=
  55. ;;
  56. --no-staging)
  57. NO_STAGING=
  58. ;;
  59. --no-dxvk)
  60. NO_DXVK=
  61. ;;
  62. --no-d9vk)
  63. NO_D9VK=
  64. ;;
  65. --no-pol)
  66. NO_POL=
  67. ;;
  68. --no-install)
  69. NO_INSTALL=
  70. # If this option is given, do not check PoL wineprefixes
  71. NO_POL=
  72. ;;
  73. esac
  74. done
  75. ########################################################
  76. # Create identifiable directory for this build
  77. mkdir -p ${ROOTDIR}/compiled_deb/${datedir}
  78. ########################################################
  79. # If the script is interrupted (Ctrl+C/SIGINT), do the following
  80. function Deb_intCleanup() {
  81. cd ${ROOTDIR}
  82. rm -rf compiled_deb/${datedir}
  83. exit 0
  84. }
  85. # Allow interruption of the script at any time (Ctrl + C)
  86. trap "Deb_intCleanup" INT
  87. ########################################################
  88. # Check existence of ccache package
  89. function ccacheCheck() {
  90. if [[ $(echo $(dpkg -s ccache &>/dev/null)$?) -ne 0 ]]; then
  91. echo -e "\e[1mNOTE:\e[0m Please consider installation of 'ccache' for faster compilation times if you compile repetitively.\nInstall it by typing 'sudo apt install ccache'\n"
  92. fi
  93. }
  94. ccacheCheck
  95. ########################################################
  96. # Call Wine compilation & installation subscript in the following function
  97. function wine_install_main() {
  98. echo -e "Starting compilation & installation of Wine$(if [[ ! -v NO_STAGING ]]; then printf " Staging"; fi)\n\n\
  99. This can take up to 0.5-2 hours depending on the available CPU cores.\n\n\
  100. Using $(nproc --ignore 1) of $(nproc) available CPU cores for Wine source code compilation.
  101. "
  102. bash -c "cd ${ROOTDIR}/wineroot/ && bash ./winebuild.sh \"${datedir}\" \"${params[*]}\""
  103. }
  104. ########################################################
  105. # Call DXVK compilation & installation subscript in the following function
  106. function dxvk_install_main() {
  107. echo -e "Starting compilation & installation of DXVK/D9VK\n\n\
  108. This can take up to 10-20 minutes depending on how many dependencies we need to build for it.\n"
  109. bash -c "cd ${ROOTDIR}/dxvkroot && bash dxvkbuild.sh \"${datedir}\" \"${params[*]}\""
  110. }
  111. ########################################################
  112. function mainQuestions() {
  113. # General function for question responses
  114. function questionresponse() {
  115. local response=${1}
  116. read -r -p "" response
  117. if [[ $(echo $response | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  118. echo ""
  119. return 0
  120. else
  121. return 1
  122. fi
  123. }
  124. ##################################
  125. INFO_SEP
  126. echo -e "\e[1mINFO:\e[0m About installation\n\nThe installation may take long time because many development dependencies may be \
  127. installed and the following packages may be compiled from source (depending on your choises):\n\n\
  128. \t- Wine/Wine Staging (latest git version)\n\
  129. \t- DXVK (latest git version)\n\
  130. \t- D9VK (latest git version)\n\
  131. \t- meson & glslang (latest git versions; these are build time dependencies for DXVK)\n\n\
  132. Do you want to continue? [Y/n]"
  133. questionresponse
  134. if [[ $? -ne 0 ]]; then
  135. echo -e "Cancelling.\n"
  136. exit 1
  137. fi
  138. ####################
  139. INFO_SEP
  140. echo -e "\e[1mQUESTION:\e[0m Do you want to remove unneeded build time dependencies after package build process? [Y/n]"
  141. questionresponse
  142. if [[ $? -eq 0 ]]; then
  143. params+=('--buildpkg-rm')
  144. fi
  145. ####################
  146. AVAIL_SPACE=$(df -h -B MB --output=avail . | sed '1d; s/[A-Z]*//g')
  147. REC_SPACE=8000
  148. if [[ ${AVAIL_SPACE} -lt ${REC_SPACE} ]] && [[ ! -v NO_WINE ]]; then
  149. INFO_SEP
  150. echo -e "\e[1mWARNING:\e[0m Not sufficient storage space\n\nYou will possibly run out of space while compiling software.\n\
  151. The script strongly recommends ~\e[1m$((${REC_SPACE} / 1000)) GB\e[0m at least to compile software successfully but you have only\n\
  152. \e[1m${AVAIL_SPACE} MB\e[0m left on the filesystem the script is currently placed at.\n\n\
  153. Be aware that the script process may fail because of this, especially while compiling Wine Staging.\n\n\
  154. Do you really want to continue? [Y/n]"
  155. questionresponse
  156. if [[ $? -ne 0 ]]; then
  157. echo -e "Cancelling.\n"
  158. exit 1
  159. fi
  160. unset AVAIL_SPACE REC_SPACE
  161. fi
  162. ####################
  163. # This question is relevant only if DXVK or D9VK stuff is compiled
  164. if [[ ! -v NO_DXVK ]] || [[ ! -v NO_D9VK ]]; then
  165. INFO_SEP
  166. echo -e "\e[1mQUESTION:\e[0m Update existing dependencies?\n\nIn a case you have old build time dependencies on your system, do you want to update them?\n\
  167. If you answer 'yes', then those dependencies are updated if needed. Otherwise, already installed\n\
  168. build time dependencies are not updated. If you don't have 'meson' or 'glslang' installed on your system, they will be compiled, anyway.\n\
  169. Be aware, that updating these packages may increase total run time used by this script.\n\n\
  170. Update dependency packages & other system packages? [Y/n]"
  171. questionresponse
  172. if [[ $? -eq 0 ]]; then
  173. params+=('--updateoverride')
  174. fi
  175. INFO_SEP
  176. fi
  177. }
  178. ########################################################
  179. function coredeps_check() {
  180. # Universal core dependencies for package compilation
  181. _coredeps=('dh-make' 'make' 'gcc' 'build-essential' 'fakeroot')
  182. for coredep in ${_coredeps[@]}; do
  183. if [[ $(echo $(dpkg -s ${coredep} &>/dev/null)$?) -ne 0 ]]; then
  184. echo -e "Installing core dependency ${coredep}.\n"
  185. sudo apt install -y ${coredep}
  186. if [[ $? -ne 0 ]]; then
  187. echo -e "Could not install ${coredep}. Aborting.\n"
  188. exit 1
  189. fi
  190. fi
  191. done
  192. }
  193. ########################################################
  194. # If either Wine, DXVK or D9VK is to be compiled
  195. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]] || [[ ! -v NO_D9VK ]]; then
  196. mainQuestions
  197. coredeps_check
  198. fi
  199. ####################
  200. # If Wine is going to be compiled, then
  201. if [[ ! -v NO_WINE ]]; then
  202. wine_install_main
  203. else
  204. echo -e "Skipping Wine build$(if [[ ! -v NO_INSTALL ]]; then printf " & installation"; fi) process.\n"
  205. fi
  206. ####################
  207. # If DXVK or D9VK is going to be installed, then
  208. if [[ ! -v NO_DXVK ]] || [[ ! -v NO_D9VK ]]; then
  209. dxvk_install_main
  210. else
  211. echo -e "Skipping DXVK/D9VK build$(if [[ ! -v NO_INSTALL ]]; then printf " & installation"; fi) process.\n"
  212. fi
  213. ####################
  214. # If PlayOnLinux Wine prefixes are going to be updated, then
  215. if [[ ! -v NO_POL ]]; then
  216. echo -e "\e[1mINFO:\e[0m Updating your PlayOnLinux Wine prefixes.\n"
  217. bash -c "cd ${ROOTDIR} && bash playonlinux_prefixupdate.sh"
  218. fi