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.

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