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.

270 lines
7.6 KiB

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