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.

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