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.

287 lines
7.9 KiB

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