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.

277 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=${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] \n\n
  139. WARNING: The check is not perfect. Answering [y] MAY DAMAGE YOUR SYSTEM!\n \
  140. Safer approach is to answer [n] and get the list of installed packages, thus you can manually decide which packages to uninstall.
  141. "
  142. questionresponse
  143. if [[ $? -eq 0 ]]; then
  144. params+=('--buildpkg-rm')
  145. fi
  146. ####################
  147. # This question is relevant only if DXVK stuff is compiled
  148. if [[ ! -v NO_DXVK ]]; then
  149. INFO_SEP
  150. 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\
  151. If you answer 'yes', then those dependencies are updated if needed. Otherwise, already installed\n\
  152. build time dependencies are not updated. If you don't have 'meson' or 'glslang' installed on your system, they will be compiled, anyway.\n\
  153. Be aware, that updating these packages may increase total run time used by this script.\n\n\
  154. Update dependency packages & other system packages? [Y/n]"
  155. questionresponse
  156. if [[ $? -eq 0 ]]; then
  157. params+=('--updateoverride')
  158. fi
  159. INFO_SEP
  160. fi
  161. }
  162. ########################################################
  163. function coredeps_check() {
  164. # Universal core dependencies for package compilation
  165. _coredeps=('dh-make' 'make' 'gcc' 'build-essential' 'fakeroot')
  166. for coredep in ${_coredeps[@]}; do
  167. if [[ $(echo $(dpkg -s ${coredep} &>/dev/null)$?) -ne 0 ]]; then
  168. echo -e "Installing core dependency ${coredep}.\n"
  169. sudo apt install -y ${coredep}
  170. if [[ $? -ne 0 ]]; then
  171. echo -e "Could not install ${coredep}. Aborting.\n"
  172. exit 1
  173. fi
  174. fi
  175. done
  176. }
  177. ########################################################
  178. # If either Wine, DXVK is to be compiled
  179. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]]; then
  180. mainQuestions
  181. coredeps_check
  182. fi
  183. ####################
  184. # If Wine is going to be compiled, then
  185. if [[ ! -v NO_WINE ]]; then
  186. wine_install_main
  187. else
  188. echo -e "Skipping Wine build$(if [[ ! -v NO_INSTALL ]]; then printf " & installation"; fi) process.\n"
  189. fi
  190. ####################
  191. # If DXVK is going to be installed, then
  192. if [[ ! -v NO_DXVK ]]; then
  193. dxvk_install_main
  194. else
  195. echo -e "Skipping DXVK build$(if [[ ! -v NO_INSTALL ]]; then printf " & installation"; fi) process.\n"
  196. fi
  197. ####################
  198. # If PlayOnLinux Wine prefixes are going to be updated, then
  199. if [[ ! -v NO_POL ]]; then
  200. echo -e "\e[1mINFO:\e[0m Updating your PlayOnLinux Wine prefixes.\n"
  201. bash -c "cd ${ROOTDIR} && bash playonlinux_prefixupdate.sh"
  202. fi