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.

309 lines
8.5 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
  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. # Should we freeze Git versions of these packages?
  33. # This is handy in some cases, if breakages occur
  34. # (although we actually compile an older version of a package)
  35. #
  36. # Define a commit hash to freeze to
  37. # Use keyword 'HEAD' if you want to use the latest git
  38. # version available
  39. # Do NOT leave these variable empty!
  40. git_commithash_dxvk=1af96347e1c6f1f2eb11aeb11009f380fd5761ec
  41. git_commithash_wine=HEAD
  42. # These apply only on Debian/Ubuntu/Mint
  43. git_commithash_meson=5d6dcf8850fcc5d552f55943b6aa3582754dedf8
  44. git_commithash_glslang=HEAD
  45. ###########################################################
  46. # Allow interruption of the script at any time (Ctrl + C)
  47. trap "exit" INT
  48. ###########################################################
  49. COMMANDS=(
  50. date
  51. df
  52. find
  53. git
  54. grep
  55. groups
  56. nproc
  57. patch
  58. readlink
  59. sudo
  60. tar
  61. uname
  62. wc
  63. wget
  64. )
  65. function checkCommands() {
  66. if [[ $(which --help 2>/dev/null) ]] && [[ $(echo --help 2>/dev/null) ]]; then
  67. local a=0
  68. for command in ${@}; do
  69. if [[ ! $(which $command 2>/dev/null) ]]; then
  70. local COMMANDS_NOTFOUND[$a]=${command}
  71. let a++
  72. fi
  73. done
  74. if [[ -n $COMMANDS_NOTFOUND ]]; then
  75. echo -e "\nError! The following commands could not be found: ${COMMANDS_NOTFOUND[*]}\nAborting\n"
  76. exit 1
  77. fi
  78. else
  79. exit 1
  80. fi
  81. }
  82. checkCommands "${COMMANDS[*]}"
  83. ###########################################################
  84. # http://wiki.bash-hackers.org/snipplets/print_horizontal_line#a_line_across_the_entire_width_of_the_terminal
  85. function INFO_SEP() { printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - ; }
  86. ###########################################################
  87. if [[ $(uname -a | grep -c x86_64) -eq 0 ]]; then
  88. echo "This script supports 64-bit architectures only."
  89. exit 1
  90. fi
  91. if [[ $(groups | grep -c sudo) -eq 0 ]]; then
  92. echo "You must belong to sudo group."
  93. exit 1
  94. fi
  95. if [[ $UID -eq 0 ]]; then
  96. echo "Run as a regular user."
  97. exit 1
  98. fi
  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. i=0
  104. for arg in ${@}; do
  105. case ${arg} in
  106. --no-staging)
  107. # Do not build Wine staging version, just Wine
  108. ;;
  109. --no-install)
  110. # Just build, do not install DXVK or Wine-Staging
  111. # Note that some version of Wine is required for DXVK compilation, though!
  112. ;;
  113. --no-wine)
  114. # Skip Wine build & installation process all together
  115. NO_WINE=
  116. ;;
  117. --no-dxvk)
  118. # Skip DXVK build & installation process all together
  119. NO_DXVK=
  120. ;;
  121. --no-pol)
  122. # Skip PlayOnLinux Wine prefixes update process
  123. ;;
  124. --no-winetricks)
  125. # Do not build Winetricks, do not install DXVK
  126. # Debian only
  127. ;;
  128. *)
  129. echo -e "\n\
  130. \
  131. ${SCRIPT_TITLE} by ${SCRIPT_AUTHOR}\n\n\
  132. Usage:\n\nbash updatewine.sh\n\nArguments:\n\n\
  133. --no-install\tDo not install Wine, Winetricks or DXVK, just compile them. Wine, meson & glslang must be installed for DXVK compilation.\n\
  134. --no-dxvk\tDo not compile or install DXVK\n\
  135. --no-pol\tDo not update PlayOnLinux Wine prefixes\n\n\
  136. --no-staging\tCompile Wine instead of Wine Staging\n\
  137. --no-wine\tDo not compile or install Wine/Wine Staging\n\
  138. --no-winetricks\t[Debian only] Do not compile or install Winetricks.\n\
  139. \t\tNo DXVK installation unless Winetricks already installed.\n\n\
  140. Compiled packages are installed by default, unless '--no-install' argument is given.\n\
  141. If '--no-install' argument is given, the script doesn't check or update your PlayOnLinux Wine prefixes.\n"
  142. exit 0
  143. ;;
  144. esac
  145. args[$i]="${arg}"
  146. let i++
  147. done
  148. ###########################################################
  149. # Date timestamp and random number identifier for compiled
  150. # DXVK & Wine Staging builds
  151. # This variable is known as 'datedir' in other script files
  152. datesuffix=$(echo $(date '+%Y-%m-%d-%H%M%S'))
  153. ###########################################################
  154. # Add git commit hash overrides to argument list
  155. # Pass them to subscripts, as well.
  156. githash_overrides=(
  157. "${git_commithash_dxvk}"
  158. "${git_commithash_glslang}"
  159. "${git_commithash_meson}"
  160. "${git_commithash_wine}"
  161. )
  162. #############################
  163. # Commit syntax validity check
  164. for githash in ${githash_overrides[@]}; do
  165. if [[ ! $(printf ${githash} | wc -c) -eq 40 ]] && \
  166. [[ ! ${githash} == HEAD ]]; then
  167. echo -e "\nError: badly formatted commit hash '${githash}' in the script file 'updatewine.sh'. Aborting\n"
  168. exit 1
  169. fi
  170. done
  171. #############################
  172. params=(${datesuffix} ${githash_overrides[@]} ${args[@]})
  173. ###########################################################
  174. function sudoQuestion() {
  175. sudo -k
  176. 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"
  177. sudo -v
  178. if [[ $? -ne 0 ]]; then
  179. echo -e "Invalid sudo password.\n"
  180. exit 1
  181. fi
  182. # PID of the current main process
  183. PIDOF=$$
  184. # Run sudo timestamp update on the background and continue the script execution
  185. # Refresh sudo timestamp while the main process is running
  186. function sudo_refresh() {
  187. while [[ $(printf $(ps ax -o pid --no-headers | grep -o ${PIDOF} &> /dev/null)$?) -eq 0 ]]; do
  188. sudo -nv && sleep 2
  189. done
  190. }
  191. sudo_refresh &
  192. }
  193. ###########################################################
  194. function checkInternet() {
  195. if [[ $(echo $(wget --delete-after -q -T 5 github.com -o -)$?) -ne 0 ]]; then
  196. echo -e "\nInternet connection failed (GitHub). Please check your connection and try again.\n"
  197. exit 1
  198. fi
  199. rm -f ./index.html.tmp
  200. }
  201. checkInternet
  202. ###########################################################
  203. # Only Debian & Arch based Linux distributions are currently supported
  204. function determineDistroFamily() {
  205. # These are default package managers used by the supported Linux distributions
  206. pkgmgrs=('dpkg' 'pacman')
  207. for pkgmgr in ${pkgmgrs[@]}; do
  208. if [[ $(printf $(which ${pkgmgr} &> /dev/null)$?) -eq 0 ]]; then
  209. pkgmgr_valid=${pkgmgr}
  210. fi
  211. done
  212. case ${pkgmgr_valid} in
  213. dpkg)
  214. distro="debian"
  215. ;;
  216. pacman)
  217. distro="arch"
  218. ;;
  219. default|*)
  220. echo -e "Your Linux distribution is not supported. Aborting.\n"
  221. exit 1
  222. ;;
  223. esac
  224. }
  225. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]]; then
  226. echo -e "\n${SCRIPT_TITLE}\n\nBuild identifier:\t${datesuffix}\n"
  227. else
  228. echo ""
  229. fi
  230. if [[ -n ${args[*]} ]]; then
  231. echo -e "Using arguments:\t${args[*]}\n"
  232. fi
  233. determineDistroFamily
  234. INFO_SEP
  235. 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\
  236. This script comes with GPU driver installation scripts for Debian-based Linux distributions.\n"
  237. INFO_SEP
  238. if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]]; then
  239. sudoQuestion
  240. echo ""
  241. fi
  242. bash -c "cd ${distro} && bash ./updatewine_${distro}.sh ${params[*]}"