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.

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