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.

279 lines
7.9 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-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
  115. 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- meson & glslang (latest git versions; these are build time dependencies for DXVK)\n\n\
  131. Do you want to continue? [Y/n]"
  132. questionresponse
  133. if [[ $? -ne 0 ]]; then
  134. echo -e "Cancelling.\n"
  135. exit 1
  136. fi
  137. ####################
  138. INFO_SEP
  139. echo -e "\e[1mQUESTION:\e[0m Do you want to remove unneeded build time dependencies after package build process? [Y/n] \n\n
  140. WARNING: The check is not perfect. Answering [y] MAY DAMAGE YOUR SYSTEM!\n \
  141. Safer approach is to answer [n] and get the list of installed packages, thus you can manually decide which packages to uninstall.
  142. "
  143. questionresponse
  144. if [[ $? -eq 0 ]]; then
  145. params+=('--buildpkg-rm')
  146. fi
  147. ####################
  148. # This question is relevant only if DXVK stuff is compiled
  149. if [[ ! -v NO_DXVK ]]; 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 is to be compiled
  180. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]]; 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 is going to be installed, then
  193. if [[ ! -v NO_DXVK ]]; then
  194. dxvk_install_main
  195. else
  196. echo -e "Skipping DXVK 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