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.

307 lines
8.4 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
  1. #!/bin/bash
  2. # getsource - Simple script to set up Wine Staging + DXVK for PoL wineprefixes
  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. # Your system username (who has PoL profile // existing Wine prefixes)
  19. # Get it by running 'whoami'
  20. USER=fincer
  21. ###########################################################
  22. # REQUIREMENTS:
  23. # - Arch Linux or equivalent (uses pacman)
  24. #
  25. # - Existing PlayonLinux package installation and $HOME/.PlayOnLinux folder
  26. # with all relevant subfolders
  27. #
  28. # - git, sudo, pwd...etc.
  29. #
  30. # - dxvk-git and wine-staging-git package dependencies installed
  31. # (see PKGBUILD files ./PKGBUILD and ./0-dxvk-git/PKGBUILD for details)
  32. #
  33. # - Internet connection
  34. #
  35. # - GPU Vulkan support and the most recent Nvidia/AMD drivers
  36. ###########################################################
  37. # Usage
  38. # Run with sudo
  39. #
  40. # # sudo bash ./updatewine.sh
  41. #
  42. # NOTE: All commands are executed as user (defined above).
  43. # Only commands which require root permissions are ones
  44. # which install packages wine-staging-git and dxvk into
  45. # your system
  46. # All regular user commands have prefix 'cmd' below
  47. # Switches:
  48. #
  49. # --refresh
  50. #
  51. # Check for new Staging/DXVK releases, update PoL Wine prefixes if needed
  52. # Does a comparison between local & remote git repos
  53. #
  54. # --check
  55. #
  56. # Check for new Staging/DXVK releases
  57. # Does a comparison between local & remote git repos
  58. #
  59. # --force
  60. #
  61. # Force Wine Staging & DXVK installation
  62. #
  63. ###########################################################
  64. # Get current date
  65. CURDATE=$(date "+%d-%m-%Y %H:%M:%S")
  66. # This variable value is automatically generated. DO NOT CHANGE.
  67. LASTUPDATE=
  68. # This variable value is automatically generated. DO NOT CHANGE.
  69. WINE_VERSION=
  70. ###########################################################
  71. # Switches
  72. if [[ "${1}" == "--refresh" ]]; then
  73. WINE_INSTALL=
  74. CHECK=
  75. fi
  76. if [[ "${1}" == "--check" ]]; then
  77. CHECK=
  78. fi
  79. if [[ "${1}" == "--force" ]] || [[ $WINE_VERSION == "" ]] || [[ $LASTUPDATE == "" ]]; then
  80. WINE_INSTALL=
  81. FORCE_INSTALL=
  82. fi
  83. ###########################################################
  84. if [[ $UID -ne 0 ]]; then
  85. echo "Run as root or sudo"
  86. exit 1
  87. fi
  88. echo -e "\nLast update: $LASTUPDATE\n"
  89. ORG_CURDIR=$(pwd)
  90. cmd() {
  91. sudo -u $USER bash -c "${*}"
  92. }
  93. ###########################################################
  94. # Check for existing PoL user folder
  95. if [[ ! -d /home/$USER/.PlayOnLinux ]]; then
  96. echo "No existing PlayonLinux profiles in $USER's home folder. Aborting"
  97. exit 1
  98. fi
  99. ###########################################################
  100. # Check internet connection
  101. function netCheck() {
  102. if [[ $(echo $(wget --delete-after -q -T 5 github.com -o -)$?) -ne 0 ]]; then
  103. echo -e "\nInternet connection failed (GitHub). Please check your connection and try again.\n"
  104. exit 1
  105. fi
  106. }
  107. ###########################################################
  108. # Local/Remote git comparisons
  109. function gitCheck() {
  110. netCheck
  111. if [[ -v $FORCE_INSTALL ]]; then
  112. NEEDSBUILD=1
  113. return 0
  114. fi
  115. if [[ ! -d "${1}" ]]; then
  116. NEEDSBUILD=1
  117. return 1
  118. fi
  119. echo -e "=> Checking ${2} GIT for changes\n"
  120. local CURDIR="${PWD}"
  121. cd "${1}"
  122. local LOCAL_GIT=$(git rev-parse @)
  123. local REMOTE_GIT=$(git ls-remote origin -h refs/heads/master | awk '{print $1}')
  124. echo -e "\t${2}:\n\tlocal git: $LOCAL_GIT\n\tremote git: $REMOTE_GIT"
  125. if [[ $LOCAL_GIT != $REMOTE_GIT ]]; then
  126. # true
  127. echo -e "\e[91m\n\t${2} needs to be updated\e[0m\n"
  128. NEEDSBUILD=1
  129. else
  130. # false
  131. echo -e "\e[92m\n\t${2} is updated\e[0m\n"
  132. NEEDSBUILD=0
  133. fi
  134. cd "${CURDIR}"
  135. }
  136. ###########################################################
  137. # Remove any existing pkg,src or tar.xz packages left by previous pacman commands
  138. cmd "rm -rf ./*/{pkg,src,*.tar.xz}"
  139. cmd "rm -f ./0-wine-staging-git/*.patch"
  140. if [[ $? -ne 0 ]]; then
  141. echo "Could not remove previous pacman-generated Wine source folders"
  142. exit 1
  143. fi
  144. ###########################################################
  145. # Do git check for Wine Staging
  146. gitCheck ./wine-staging-git Wine
  147. # If needs build and --check switch is not used
  148. if [[ $NEEDSBUILD -eq 1 ]] && [[ ! -v CHECK ]]; then
  149. # Create wine-staging-git package and install it to the system
  150. cd "${ORG_CURDIR}"/0-wine-staging-git
  151. cmd "updpkgsums && makepkg ;"
  152. if [[ $(find . -mindepth 1 -maxdepth 1 -type f -iname "wine-*tar.xz" | wc -l) -ne 0 ]]; then
  153. pacman -U --noconfirm wine-*.tar.xz
  154. else
  155. cmd "rm -rf ./{*.patch,pkg,src}"
  156. exit 1
  157. fi
  158. if [[ $? -eq 0 ]]; then
  159. cmd "rm -rf ./{*.patch,pkg,src,*.tar.xz}"
  160. WINE_INSTALL=
  161. WINE_VERSION_UPDATE=$(pacman -Qi wine-staging-git | grep 'Version' | awk '{print $NF}')
  162. else
  163. exit 1
  164. fi
  165. cd ..
  166. fi
  167. #############################
  168. # Create dxvk-git package and install it to the system
  169. gitCheck ./0-dxvk-git/dxvk-git DXVK
  170. # If needs build and --check switch is not used
  171. if [[ $NEEDSBUILD -eq 1 ]] && [[ ! -v CHECK ]]; then
  172. # Create dxvk-git package and install it to the system
  173. cd "${ORG_CURDIR}"/0-dxvk-git
  174. cmd "updpkgsums && makepkg ;"
  175. if [[ $(find . -mindepth 1 -maxdepth 1 -type f -iname "dxvk-git-*tar.xz" | wc -l) -ne 0 ]]; then
  176. pacman -U --noconfirm dxvk-git*.tar.xz
  177. else
  178. cmd "rm -rf ./{pkg,src}"
  179. exit 1
  180. fi
  181. if [[ $? -eq 0 ]]; then
  182. cmd "rm -rf ./{pkg,src,dxvk-git*.tar.xz}"
  183. else
  184. exit 1
  185. fi
  186. fi
  187. cd ..
  188. # If a new Wine Staging version was installed and 'System' version of Wine has been used in
  189. # PoL wineprefix configurations, update those existing PoL wineprefixes
  190. if [[ -v WINE_INSTALL ]]; then
  191. for wineprefix in $(find /home/$USER/.PlayOnLinux/wineprefix -mindepth 1 -maxdepth 1 -type d); do
  192. if [[ -d ${wineprefix}/dosdevices ]]; then
  193. # If VERSION string exists, skip updating that prefix.
  194. if [[ $(printf $(grep -ril "VERSION" ${wineprefix}/playonlinux.cfg &> /dev/null)$?) -ne 0 ]]; then
  195. # If currently installed Wine version is not same than we just built.
  196. if [[ -v WINE_VERSION_UPDATE ]]; then
  197. if [[ "${WINE_VERSION}" != "${WINE_VERSION_UPDATE}" ]]; then
  198. cmd "WINEPREFIX=${wineprefix} wineboot -u"
  199. fi
  200. fi
  201. fi
  202. fi
  203. done
  204. # If a new Wine Staging version was installed, update WINE_VERSION string variable in this script file
  205. if [[ -v WINE_VERSION_UPDATE ]]; then
  206. cmd "sed -i 's/^WINE_VERSION=.*/WINE_VERSION=\"${WINE_VERSION_UPDATE}\"/' $ORG_CURDIR/updatewine.sh"
  207. fi
  208. fi
  209. # Install dxvk-git to every PlayOnLinux wineprefix
  210. if [[ $? -eq 0 ]]; then
  211. for wineprefix in $(find /home/$USER/.PlayOnLinux/wineprefix -mindepth 1 -maxdepth 1 -type d); do
  212. if [[ -d ${wineprefix}/dosdevices ]]; then
  213. if [[ $(printf $(grep -ril "\"d3d11\"=\"native\"" ${wineprefix}/user.reg &> /dev/null)$?) -ne 0 ]]; then
  214. cmd "WINEPREFIX=${wineprefix} setup_dxvk32"
  215. cmd "WINEPREFIX=${wineprefix} setup_dxvk64"
  216. fi
  217. # For D3D10 DXVK support
  218. if [[ $(printf $(grep -ril "\"\*d3dcompiler_43\"=\"native\"" ${wineprefix}/user.reg &> /dev/null)$?) -ne 0 ]]; then
  219. cmd "WINEPREFIX=${wineprefix} winetricks d3dcompiler_43"
  220. fi
  221. fi
  222. done
  223. fi
  224. # Update LASTUPDATE variable string, if --check switch is not used + a new Wine Staging version is used or NEEDSBUILD variable is set to 1
  225. if [[ ! -v CHECK ]]; then
  226. if [[ -v WINE_INSTALL ]] || [[ $NEEDSBUILD -eq 1 ]]; then
  227. cmd "sed -i 's/^LASTUPDATE=.*/LASTUPDATE=\"$CURDATE\"/' $ORG_CURDIR/updatewine.sh"
  228. fi
  229. fi
  230. # Unset various env vars
  231. unset CHECK
  232. unset WINE_INSTALL
  233. unset FORCE_INSTALL