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.

201 lines
4.4 KiB

  1. #!/usr/bin/env bash
  2. # NOTE: This is a modified version of script file
  3. # https://github.com/HansKristian-Work/vkd3d-proton/blob/master/setup_vkd3d_proton.sh
  4. #
  5. # default directories
  6. dxvk_nvapi_lib32=${dxvk_nvapi_lib32:-"x32"}
  7. dxvk_nvapi_lib64=${dxvk_nvapi_lib64:-"x64"}
  8. # figure out where we are
  9. basedir=$(dirname "$(readlink -f "$0")")
  10. # figure out which action to perform
  11. action="$1"
  12. case "$action" in
  13. install)
  14. ;;
  15. uninstall)
  16. ;;
  17. *)
  18. echo "Unrecognized action: $action"
  19. echo "Usage: $0 [install|uninstall] [--symlink]"
  20. exit 1
  21. esac
  22. # process arguments
  23. shift
  24. file_cmd="cp -v"
  25. while (($# > 0)); do
  26. case "$1" in
  27. "--symlink")
  28. file_cmd="ln -s -v"
  29. ;;
  30. esac
  31. shift
  32. done
  33. # check wine prefix before invoking wine, so that we
  34. # don't accidentally create one if the user screws up
  35. if [ -n "$WINEPREFIX" ] && ! [ -f "$WINEPREFIX/system.reg" ]; then
  36. echo "$WINEPREFIX:"' Not a valid wine prefix.' >&2
  37. exit 1
  38. fi
  39. # find wine executable
  40. export WINEDEBUG=-all
  41. # disable mscoree and mshtml to avoid downloading
  42. # wine gecko and mono
  43. export WINEDLLOVERRIDES="mscoree,mshtml="
  44. wine="wine"
  45. wine64="wine64"
  46. wineboot="wineboot"
  47. # $PATH is the way for user to control where wine is located (including custom Wine versions).
  48. # Pure 64-bit Wine (non Wow64) requries skipping 32-bit steps.
  49. # In such case, wine64 and winebooot will be present, but wine binary will be missing,
  50. # however it can be present in other PATHs, so it shouldn't be used, to avoid versions mixing.
  51. wine_path=$(dirname "$(which $wineboot)")
  52. wow64=true
  53. if ! [ -f "$wine_path/$wine" ]; then
  54. wine=$wine64
  55. wow64=false
  56. fi
  57. # resolve 32-bit and 64-bit system32 path
  58. winever=$($wine --version | grep wine)
  59. if [ -z "$winever" ]; then
  60. echo "$wine: Not a wine executable. Check your $wine." >&2
  61. exit 1
  62. fi
  63. # ensure wine placeholder dlls are recreated
  64. # if they are missing
  65. $wineboot -u
  66. win64_sys_path=$($wine64 winepath -u 'C:\windows\system32' 2> /dev/null)
  67. win64_sys_path="${win64_sys_path/$'\r'/}"
  68. if $wow64; then
  69. win32_sys_path=$($wine winepath -u 'C:\windows\system32' 2> /dev/null)
  70. win32_sys_path="${win32_sys_path/$'\r'/}"
  71. fi
  72. if [ -z "$win32_sys_path" ] && [ -z "$win64_sys_path" ]; then
  73. echo 'Failed to resolve C:\windows\system32.' >&2
  74. exit 1
  75. fi
  76. # create native dll override
  77. overrideDll() {
  78. if ! $wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /d native /f >/dev/null 2>&1
  79. then
  80. echo -e "Failed to add override for $1"
  81. exit 1
  82. fi
  83. }
  84. # remove dll override
  85. restoreDll() {
  86. if ! $wine reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /f > /dev/null 2>&1
  87. then
  88. echo "Failed to remove override for $1"
  89. fi
  90. }
  91. # copy or link nvapi dll, back up original file
  92. installFile() {
  93. dstfile="${1}/${3}.dll"
  94. srcfile="${basedir}/${2}/${3}.dll"
  95. if ! [ -f "${srcfile}" ]; then
  96. echo "${srcfile}: File not found. Skipping." >&2
  97. return 1
  98. fi
  99. if [ -n "$1" ]; then
  100. if [ -f "${dstfile}" ] || [ -h "${dstfile}" ]; then
  101. if ! [ -f "${dstfile}.old" ]; then
  102. mv -v "${dstfile}" "${dstfile}.old"
  103. else
  104. rm -v "${dstfile}"
  105. fi
  106. else
  107. touch "${dstfile}.old_none"
  108. fi
  109. $file_cmd "${srcfile}" "${dstfile}"
  110. fi
  111. return 0
  112. }
  113. # remove nvapi dll, restore original file
  114. uninstallFile() {
  115. dstfile="${1}/${3}.dll"
  116. srcfile="${basedir}/${2}/${3}.dll"
  117. if ! [ -f "${srcfile}" ]; then
  118. echo "${srcfile}: File not found. Skipping." >&2
  119. return 1
  120. fi
  121. if ! [ -f "${dstfile}" ] && ! [ -h "${dstfile}" ]; then
  122. echo "${dstfile}: File not found. Skipping." >&2
  123. return 1
  124. fi
  125. if [ -f "${dstfile}.old" ]; then
  126. rm -v "${dstfile}"
  127. mv -v "${dstfile}.old" "${dstfile}"
  128. return 0
  129. elif [ -f "${dstfile}.old_none" ]; then
  130. rm -v "${dstfile}.old_none"
  131. rm -v "${dstfile}"
  132. return 0
  133. else
  134. return 1
  135. fi
  136. }
  137. install() {
  138. installFile "$win64_sys_path" "$dxvk_nvapi_lib64" "${1}64"
  139. inst64_ret="$?"
  140. inst32_ret=-1
  141. if $wow64; then
  142. installFile "$win32_sys_path" "$dxvk_nvapi_lib32" "$1"
  143. inst32_ret="$?"
  144. fi
  145. if (( (inst32_ret == 0) )); then
  146. overrideDll "$1"
  147. fi
  148. if (( (inst64_ret == 0) )); then
  149. overrideDll "${1}64"
  150. fi
  151. }
  152. uninstall() {
  153. uninstallFile "$win64_sys_path" "$dxvk_nvapi_lib64" "${1}64"
  154. uninst64_ret="$?"
  155. uninst32_ret=-1
  156. if $wow64; then
  157. uninstallFile "$win32_sys_path" "$dxvk_nvapi_lib32" "$1"
  158. uninst32_ret="$?"
  159. fi
  160. if (( (uninst32_ret == 0) )); then
  161. restoreDll "$1"
  162. fi
  163. if (( (uninst64_ret == 0) )); then
  164. restoreDll "${1}64"
  165. fi
  166. }
  167. $action nvapi