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.

274 lines
7.6 KiB

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