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.

254 lines
7.0 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. #!/bin/env bash
  2. # DXVK/Wine-Staging scripts dispatcher for various Linux distributions
  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. # Check if we're using bash or sh to run the script. If bash, OK.
  19. # If another one, ask user to run the script with bash.
  20. BASH_CHECK=$(ps | grep `echo $$` | awk '{ print $4 }')
  21. if [ $BASH_CHECK != "bash" ]; then
  22. echo "
  23. Please run this script using bash (/usr/bin/bash).
  24. "
  25. exit 1
  26. fi
  27. ###########################################################
  28. # Just a title & author for this script, used in initialization and help page
  29. SCRIPT_TITLE="\e[1mWine/Wine Staging & DXVK package builder & auto-installer\e[0m"
  30. SCRIPT_AUTHOR="Pekka Helenius (~Fincer), 2018"
  31. ###########################################################
  32. # Allow interruption of the script at any time (Ctrl + C)
  33. trap "exit" INT
  34. ###########################################################
  35. COMMANDS=(
  36. date
  37. df
  38. find
  39. git
  40. grep
  41. groups
  42. nproc
  43. patch
  44. readlink
  45. sudo
  46. tar
  47. uname
  48. wc
  49. wget
  50. )
  51. function checkCommands() {
  52. if [[ $(which --help 2>/dev/null) ]] && [[ $(echo --help 2>/dev/null) ]]; then
  53. local a=0
  54. for command in ${@}; do
  55. if [[ ! $(which $command 2>/dev/null) ]]; then
  56. local COMMANDS_NOTFOUND[$a]=${command}
  57. let a++
  58. fi
  59. done
  60. if [[ -n $COMMANDS_NOTFOUND ]]; then
  61. echo -e "\nError! The following commands could not be found: ${COMMANDS_NOTFOUND[*]}\nAborting\n"
  62. exit 1
  63. fi
  64. else
  65. exit 1
  66. fi
  67. }
  68. checkCommands "${COMMANDS[*]}"
  69. ###########################################################
  70. # http://wiki.bash-hackers.org/snipplets/print_horizontal_line#a_line_across_the_entire_width_of_the_terminal
  71. function INFO_SEP() { printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - ; }
  72. ###########################################################
  73. if [[ $(uname -a | grep -c x86_64) -eq 0 ]]; then
  74. echo "This script supports 64-bit architectures only."
  75. exit 1
  76. fi
  77. if [[ $(groups | grep -c sudo) -eq 0 ]]; then
  78. echo "You must belong to sudo group."
  79. exit 1
  80. fi
  81. if [[ $UID -eq 0 ]]; then
  82. echo "Run as a regular user."
  83. exit 1
  84. fi
  85. ###########################################################
  86. # User-passed arguments for the script
  87. # We check the values of this array
  88. # and pass them to the subscripts if supported
  89. i=0
  90. for arch_arg in ${@}; do
  91. case ${arch_arg} in
  92. --no-staging)
  93. # Do not build Wine staging version, just Wine
  94. ;;
  95. --no-install)
  96. # Just build, do not install DXVK or Wine-Staging
  97. # Note that some version of Wine is required for DXVK compilation, though!
  98. ;;
  99. --no-wine)
  100. # Skip Wine build & installation process all together
  101. NO_WINE=
  102. ;;
  103. --no-dxvk)
  104. # Skip DXVK build & installation process all together
  105. NO_DXVK=
  106. ;;
  107. --no-pol)
  108. # Skip PlayOnLinux Wine prefixes update process
  109. ;;
  110. *)
  111. echo -e "\n\
  112. \
  113. ${SCRIPT_TITLE} by ${SCRIPT_AUTHOR}\n\n\
  114. Usage:\n\nbash updatewine.sh\n\nArguments:\n\n\
  115. --no-staging\tCompile Wine instead of Wine Staging\n\
  116. --no-install\tDo not install Wine or DXVK, just compile them. Wine, meson & glslang must be installed for DXVK compilation.\n\
  117. --no-wine\tDo not compile or install Wine/Wine Staging\n\
  118. --no-dxvk\tDo not compile or install DXVK\n\
  119. --no-pol\tDo not update PlayOnLinux Wine prefixes\n\n\
  120. Compiled packages are installed by default, unless '--no-install' argument is given.\n\
  121. If '--no-install' argument is given, the script doesn't check or update your PlayOnLinux Wine prefixes.\n"
  122. exit 0
  123. ;;
  124. esac
  125. args[$i]="${arch_arg}"
  126. let i++
  127. done
  128. ###########################################################
  129. function sudoQuestion() {
  130. sudo -k
  131. echo -e "\e[1mINFO:\e[0m sudo password required\n\nThis script requires elevated permissions for package updates & installations. Please provide your sudo password for these script commands. Sudo permissions are not used for any other purposes.\n"
  132. sudo -v
  133. if [[ $? -ne 0 ]]; then
  134. echo -e "Invalid sudo password.\n"
  135. exit 1
  136. fi
  137. # PID of the current main process
  138. PIDOF=$$
  139. # Run sudo timestamp update on the background and continue the script execution
  140. # Refresh sudo timestamp while the main process is running
  141. function sudo_refresh() {
  142. while [[ $(printf $(ps ax -o pid --no-headers | grep -o ${PIDOF} &> /dev/null)$?) -eq 0 ]]; do
  143. sudo -nv && sleep 2
  144. done
  145. }
  146. sudo_refresh &
  147. }
  148. ###########################################################
  149. function checkInternet() {
  150. if [[ $(echo $(wget --delete-after -q -T 5 github.com -o -)$?) -ne 0 ]]; then
  151. echo -e "\nInternet connection failed (GitHub). Please check your connection and try again.\n"
  152. exit 1
  153. fi
  154. rm -f ./index.html.tmp
  155. }
  156. checkInternet
  157. ###########################################################
  158. # Date timestamp and random number identifier for compiled
  159. # DXVK & Wine Staging builds
  160. # This variable is known as 'datedir' in other script files
  161. datesuffix=$(echo $(date '+%Y-%m-%d-%H%M%S'))
  162. ###########################################################
  163. # Only Debian & Arch based Linux distributions are currently supported
  164. function determineDistroFamily() {
  165. # These are default package managers used by the supported Linux distributions
  166. pkgmgrs=('dpkg' 'pacman')
  167. for pkgmgr in ${pkgmgrs[@]}; do
  168. if [[ $(printf $(which ${pkgmgr} &> /dev/null)$?) -eq 0 ]]; then
  169. pkgmgr_valid=${pkgmgr}
  170. fi
  171. done
  172. case ${pkgmgr_valid} in
  173. dpkg)
  174. distro="debian"
  175. ;;
  176. pacman)
  177. distro="arch"
  178. ;;
  179. default|*)
  180. echo -e "Your Linux distribution is not supported. Aborting.\n"
  181. exit 1
  182. ;;
  183. esac
  184. }
  185. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]]; then
  186. echo -e "\n${SCRIPT_TITLE}\n\nBuild identifier:\t${datesuffix}\n"
  187. else
  188. echo ""
  189. fi
  190. if [[ -n ${args[*]} ]]; then
  191. echo -e "Using arguments:\t${args[*]}\n"
  192. fi
  193. determineDistroFamily
  194. INFO_SEP
  195. echo -e "\e[1mNOTE: \e[0mDXVK requires very latest Nvidia/AMD drivers to work.\nMake sure these drivers are available on your Linux distribution.\n\
  196. This script comes with GPU driver installation scripts for Debian-based Linux distributions.\n"
  197. INFO_SEP
  198. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]]; then
  199. sudoQuestion
  200. echo ""
  201. fi
  202. bash -c "cd ${distro} && bash ./updatewine_${distro}.sh \"${datesuffix}\" ${args[*]}"