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.

278 lines
7.8 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. # TODO: remove duplicate functionality. This function is defined in updatewine.sh
  27. function INFO_SEP() { printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - ; }
  28. ########################################################
  29. # Divide input args into array indexes
  30. # These are passed to the subscripts (array b)
  31. i=0
  32. for p in ${@:2}; do
  33. params[$i]=${p}
  34. let i++
  35. done
  36. ########################################################
  37. # Parse input arguments, filter user parameters
  38. # The range is defined in ../updatewine.sh
  39. # All input arguments are:
  40. # <datedir> 4*<githash_override> 4*<gitbranch_override> <args>
  41. # 0 1 2 3 4 5 6 7 8 9...
  42. # Filter all but <args>, i.e. the first 0-8 arguments
  43. i=0
  44. for arg in ${params[@]:8}; do
  45. args[$i]="${arg}"
  46. let i++
  47. done
  48. # All valid arguments given in ../updatewine.sh are handled...
  49. # All valid arguments are passed to subscripts...
  50. # ...but these are specifically used in this script
  51. #
  52. for check in ${args[@]}; do
  53. case ${check} in
  54. --no-wine)
  55. NO_WINE=
  56. ;;
  57. --no-staging)
  58. NO_STAGING=
  59. ;;
  60. --no-dxvk)
  61. NO_DXVK=
  62. ;;
  63. --no-d9vk)
  64. NO_D9VK=
  65. ;;
  66. --no-pol)
  67. NO_POL=
  68. ;;
  69. --no-install)
  70. NO_INSTALL=
  71. # If this option is given, do not check PoL wineprefixes
  72. NO_POL=
  73. ;;
  74. esac
  75. done
  76. ########################################################
  77. # Create identifiable directory for this build
  78. mkdir -p ${ROOTDIR}/compiled_deb/${datedir}
  79. ########################################################
  80. # If the script is interrupted (Ctrl+C/SIGINT), do the following
  81. function Deb_intCleanup() {
  82. cd ${ROOTDIR}
  83. rm -rf compiled_deb/${datedir}
  84. exit 0
  85. }
  86. # Allow interruption of the script at any time (Ctrl + C)
  87. trap "Deb_intCleanup" INT
  88. ########################################################
  89. # Check existence of ccache package
  90. function ccacheCheck() {
  91. if [[ $(echo $(dpkg -s ccache &>/dev/null)$?) -ne 0 ]]; then
  92. 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"
  93. fi
  94. }
  95. ccacheCheck
  96. ########################################################
  97. # Call Wine compilation & installation subscript in the following function
  98. function wine_install_main() {
  99. echo -e "Starting compilation & installation of Wine$(if [[ ! -v NO_STAGING ]]; then printf " Staging"; fi)\n\n\
  100. This can take up to 0.5-2 hours depending on the available CPU cores.\n\n\
  101. Using $(nproc --ignore 1) of $(nproc) available CPU cores for Wine source code compilation.
  102. "
  103. bash -c "cd ${ROOTDIR}/wineroot/ && bash ./winebuild.sh \"${datedir}\" \"${params[*]}\""
  104. }
  105. ########################################################
  106. # Call DXVK compilation & installation subscript in the following function
  107. function dxvk_install_main() {
  108. echo -e "Starting compilation & installation of DXVK/D9VK\n\n\
  109. This can take up to 10-20 minutes depending on how many dependencies we need to build for it.\n"
  110. bash -c "cd ${ROOTDIR}/dxvkroot && bash dxvkbuild.sh \"${datedir}\" \"${params[*]}\""
  111. }
  112. ########################################################
  113. function mainQuestions() {
  114. # General function for question responses
  115. # TODO: remove duplicate functionality. This function is defined in updatewine.sh
  116. function questionresponse() {
  117. local response=${1}
  118. read -r -p "" response
  119. if [[ $(echo $response | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  120. echo ""
  121. return 0
  122. else
  123. return 1
  124. fi
  125. }
  126. ##################################
  127. INFO_SEP
  128. echo -e "\e[1mINFO:\e[0m About installation\n\nThe installation may take long time because many development dependencies may be \
  129. installed and the following packages may be compiled from source (depending on your choises):\n\n\
  130. \t- Wine/Wine Staging (latest git version)\n\
  131. \t- DXVK (latest git version)\n\
  132. \t- D9VK (latest git version)\n\
  133. \t- meson & glslang (latest git versions; these are build time dependencies for DXVK & D9VK)\n\n\
  134. Do you want to continue? [Y/n]"
  135. questionresponse
  136. if [[ $? -ne 0 ]]; then
  137. echo -e "Cancelling.\n"
  138. exit 1
  139. fi
  140. ####################
  141. INFO_SEP
  142. echo -e "\e[1mQUESTION:\e[0m Do you want to remove unneeded build time dependencies after package build process? [Y/n]"
  143. questionresponse
  144. if [[ $? -eq 0 ]]; then
  145. params+=('--buildpkg-rm')
  146. fi
  147. ####################
  148. # This question is relevant only if DXVK or D9VK stuff is compiled
  149. if [[ ! -v NO_DXVK ]] || [[ ! -v NO_D9VK ]]; then
  150. INFO_SEP
  151. 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\
  152. If you answer 'yes', then those dependencies are updated if needed. Otherwise, already installed\n\
  153. build time dependencies are not updated. If you don't have 'meson' or 'glslang' installed on your system, they will be compiled, anyway.\n\
  154. Be aware, that updating these packages may increase total run time used by this script.\n\n\
  155. Update dependency packages & other system packages? [Y/n]"
  156. questionresponse
  157. if [[ $? -eq 0 ]]; then
  158. params+=('--updateoverride')
  159. fi
  160. INFO_SEP
  161. fi
  162. }
  163. ########################################################
  164. function coredeps_check() {
  165. # Universal core dependencies for package compilation
  166. _coredeps=('dh-make' 'make' 'gcc' 'build-essential' 'fakeroot')
  167. for coredep in ${_coredeps[@]}; do
  168. if [[ $(echo $(dpkg -s ${coredep} &>/dev/null)$?) -ne 0 ]]; then
  169. echo -e "Installing core dependency ${coredep}.\n"
  170. sudo apt install -y ${coredep}
  171. if [[ $? -ne 0 ]]; then
  172. echo -e "Could not install ${coredep}. Aborting.\n"
  173. exit 1
  174. fi
  175. fi
  176. done
  177. }
  178. ########################################################
  179. # If either Wine, DXVK or D9VK is to be compiled
  180. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]] || [[ ! -v NO_D9VK ]]; then
  181. mainQuestions
  182. coredeps_check
  183. fi
  184. ####################
  185. # If Wine is going to be compiled, then
  186. if [[ ! -v NO_WINE ]]; then
  187. wine_install_main
  188. else
  189. echo -e "Skipping Wine build$(if [[ ! -v NO_INSTALL ]]; then printf " & installation"; fi) process.\n"
  190. fi
  191. ####################
  192. # If DXVK or D9VK is going to be installed, then
  193. if [[ ! -v NO_DXVK ]] || [[ ! -v NO_D9VK ]]; then
  194. dxvk_install_main
  195. else
  196. echo -e "Skipping DXVK/D9VK build$(if [[ ! -v NO_INSTALL ]]; then printf " & installation"; fi) process.\n"
  197. fi
  198. ####################
  199. # If PlayOnLinux Wine prefixes are going to be updated, then
  200. if [[ ! -v NO_POL ]]; then
  201. echo -e "\e[1mINFO:\e[0m Updating your PlayOnLinux Wine prefixes.\n"
  202. bash -c "cd ${ROOTDIR} && bash playonlinux_prefixupdate.sh"
  203. fi