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.

213 lines
5.9 KiB

5 years ago
5 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-dxvk)
  46. NO_DXVK=
  47. ;;
  48. --no-pol)
  49. NO_POL=
  50. ;;
  51. --no-install)
  52. # If this option is given, do not check PoL wineprefixes
  53. NO_POL=
  54. ;;
  55. esac
  56. done
  57. ########################################################
  58. # Create identifiable directory for this build
  59. mkdir -p ${ROOTDIR}/compiled_deb/${datedir}
  60. ########################################################
  61. # If the script is interrupted (Ctrl+C/SIGINT), do the following
  62. function Deb_intCleanup() {
  63. cd ${ROOTDIR}
  64. rm -rf compiled_deb/${datedir}
  65. exit 0
  66. }
  67. # Allow interruption of the script at any time (Ctrl + C)
  68. trap "Deb_intCleanup" INT
  69. ########################################################
  70. # Check existence of ccache package
  71. function ccacheCheck() {
  72. if [[ $(apt version ccache | wc -w) -eq 0 ]]; then
  73. echo -e "NOTE: Please consider using 'ccache' for faster compilation times.\nInstall it by typing 'sudo apt install ccache'\n"
  74. fi
  75. }
  76. ccacheCheck
  77. ########################################################
  78. # Call Wine compilation & installation subscript in the following function
  79. function wine_install_main() {
  80. echo -e "Starting compilation & installation of Wine\n\n\
  81. This can take up to 0.5-2 hours depending on the available CPU cores.\n\n\
  82. Using $(nproc --ignore 1) of $(nproc) available CPU cores for Wine source code compilation.
  83. "
  84. bash -c "cd ${ROOTDIR}/wineroot/ && bash ./winebuild.sh \"${datedir}\" \"${args[*]}\""
  85. }
  86. ########################################################
  87. # General function for question responses
  88. function questionresponse() {
  89. local response=${1}
  90. read -r -p "" response
  91. if [[ $(echo $response | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  92. echo ""
  93. return 0
  94. else
  95. return 1
  96. fi
  97. }
  98. ##################################
  99. INFO_SEP
  100. echo -e "\e[1mINFO:\e[0m About installation\n\nThe installation may take long time because many development dependencies may be \
  101. installed and the following packages will be compiled from source (depending on your choise):\n\n\
  102. \t- Wine/Wine Staging (latest git version)\n\
  103. \t- DXVK (latest git version)\n\
  104. \t- meson & glslang (latest git versions; these are build time dependencies for DXVK)\n\n\
  105. Do you want to continue? [Y/n]"
  106. questionresponse
  107. if [[ $? -ne 0 ]]; then
  108. echo -e "Cancelling.\n"
  109. exit 2
  110. fi
  111. ####################
  112. AVAIL_SPACE=$(df -h -B MB --output=avail . | sed '1d; s/[A-Z]*//g')
  113. REC_SPACE=8000
  114. if [[ ${AVAIL_SPACE} -lt ${REC_SPACE} ]]; then
  115. INFO_SEP
  116. echo -e "\e[1mWARNING:\e[0m Not sufficient storage space\n\nYou will possibly run out of space while compiling software.\n\
  117. The script strongly recommends ~\e[1m$((${REC_SPACE} / 1000)) GB\e[0m at least to compile software successfully but you have only\n\
  118. \e[1m${AVAIL_SPACE} MB\e[0m left on the filesystem the script is currently placed at.\n\n\
  119. Be aware that the script process may fail because of this, especially while compiling Wine Staging.\n\n\
  120. Do you really want to continue? [Y/n]"
  121. questionresponse
  122. if [[ $? -ne 0 ]]; then
  123. echo -e "Cancelling.\n"
  124. exit 2
  125. fi
  126. unset AVAIL_SPACE REC_SPACE
  127. fi
  128. ####################
  129. INFO_SEP
  130. echo -e "\e[1mINFO:\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\
  131. If you answer 'yes', then those dependencies are updated if needed. Otherwise, already installed\n\
  132. build time dependencies are not updated. If you don't have 'meson' or 'glslang' installed on your system, they will be compiled, anyway.\n\
  133. Be aware, that updating these packages may increase total run time used by this script.\n\n\
  134. Update dependency packages & other system packages? [Y/n]"
  135. questionresponse
  136. if [[ $? -eq 0 ]]; then
  137. args+=('--updateoverride')
  138. fi
  139. INFO_SEP
  140. ########################################################
  141. if [[ ! -v NO_WINE ]]; then
  142. wine_install_main
  143. else
  144. echo -e "Skipping Wine build & installation process.\n"
  145. fi
  146. if [[ ! -v NO_DXVK ]]; then
  147. bash -c "cd ${ROOTDIR}/dxvkroot && bash dxvkbuild.sh \"${datedir}\" \"${args[*]}\""
  148. else
  149. echo -e "Skipping DXVK build & installation process.\n"
  150. fi
  151. if [[ ! -v NO_POL ]]; then
  152. bash -c "cd ${ROOTDIR} && bash playonlinux_prefixupdate.sh"
  153. fi