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.

477 lines
12 KiB

5 years ago
5 years ago
  1. #!/bin/env bash
  2. # Compile DXVK git on Debian/Ubuntu/Mint and variants
  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. # DO NOT RUN INDIVIDUALLY, ONLY VIA ../../updatewine.sh PARENT SCRIPT!
  19. ########################################################
  20. # Root directory of this script file
  21. DXVKROOT="${PWD}"
  22. # datedir variable supplied by ../updatewine_debian.sh script file
  23. datedir="${1}"
  24. ###########################################################
  25. # Parse input arguments
  26. i=0
  27. for arg in ${@:2}; do
  28. args[$i]="${arg}"
  29. let i++
  30. done
  31. # Must be a true array as defined above, not a single index list!
  32. #args="${@:2}"
  33. for check in ${args[@]}; do
  34. case ${check} in
  35. --no-install)
  36. NO_INSTALL=
  37. ;;
  38. --updateoverride)
  39. updateoverride=
  40. ;;
  41. esac
  42. done
  43. ###########################################################
  44. # Some version of Wine must be found in the system
  45. # Warn the user
  46. function wineCheck() {
  47. if [[ ! $(which wine 2>/dev/null) ]]; then
  48. echo -e "Warning: You must have Wine installed before DXVK can be compiled.\n"
  49. fi
  50. }
  51. wineCheck
  52. ###########################################################
  53. function DXVK_intCleanup() {
  54. rm -rf ${DXVKROOT}/{dxvk-git,meson,glslang}
  55. rm -rf ${DXVKROOT}/../compiled_deb/"${datedir}"
  56. exit 0
  57. }
  58. # Allow interruption of the script at any time (Ctrl + C)
  59. trap "DXVK_intCleanup" INT
  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. # Universal core dependencies
  65. _coredeps=('dh-make' 'make' 'gcc' 'build-essential' 'fakeroot')
  66. ##################################
  67. function customReqs() {
  68. if [[ -v updateoverride ]]; then
  69. echo -en "Updating package databases." && \
  70. if [[ $(printf $(sudo -n uptime &>/dev/null)$?) -ne 0 ]]; then printf " Please provide your sudo password.\n"; else printf "\n\n"; fi
  71. sudo apt update
  72. fi
  73. for cmd in git tar wget; do
  74. if [[ $(printf $(which ${cmd} &> /dev/null)$?) -ne 0 ]]; then
  75. echo -e "Missing ${cmd}. Installing...\n"
  76. sudo apt update && sudo apt install -y ${cmd}
  77. fi
  78. done
  79. for coredep in ${_coredeps[@]}; do
  80. local coredep=$(printf ${coredep} | sed 's/\+/\\\+/g')
  81. if [[ $(apt version ${coredep} | wc -w) -eq 0 ]]; then
  82. echo -e "Installing core dependency $(printf ${coredep} | sed 's/\\//g').\n"
  83. sudo apt install -y ${coredep}
  84. if [[ $? -ne 0 ]]; then
  85. echo -e "Could not install ${coredep}. Aborting.\n"
  86. exit 1
  87. fi
  88. fi
  89. done
  90. }
  91. customReqs
  92. ##################################
  93. function pkgcompilecheck() {
  94. local pkg=$(printf ${1} | sed 's/\+/\\\+/g')
  95. if [[ $(dpkg --get-selections | awk '{print $1}' | grep -wE "^${pkg}$" | wc -l) -eq 0 ]] || [[ -v updateoverride ]]; then
  96. ${2}
  97. fi
  98. }
  99. ###################################################
  100. function preparepackage() {
  101. echo -e "Starting compilation (& installation) of ${1}\n"
  102. local a=0
  103. local _pkgname=${1}
  104. local _pkgdeps=${2}
  105. local _pkgurl=${3}
  106. local _pkgver=${4}
  107. if [[ -n ${5} ]]; then local _pkgdeps_runtime=${5}; fi
  108. function pkgdependencies() {
  109. for pkgdep in ${@}; do
  110. if [[ $(apt version ${pkgdep} | wc -w) -eq 0 ]]; then
  111. echo -e "Installing ${_pkgname} dependency ${pkgdep} ($(($a + 1 )) / $((${#*} + 1)))\n."
  112. sudo apt install -y ${pkgdep} &> /dev/null
  113. if [[ $? -eq 0 ]]; then
  114. let a++
  115. else
  116. echo -e "\nError occured while installing ${pkgdep}. Aborting.\n"
  117. exit 1
  118. fi
  119. fi
  120. done
  121. }
  122. function pkgversion() {
  123. if [[ -n "${_pkgver}" ]] && [[ "${_pkgver}" =~ ^git ]]; then
  124. cd ${_pkgname}
  125. _pkgver=$(eval "${_pkgver}")
  126. cd ..
  127. fi
  128. }
  129. function pkgfoldername() {
  130. rm -rf ${_pkgname}
  131. mkdir ${_pkgname}
  132. cd ${_pkgname}
  133. echo -e "Retrieving source code of ${_pkgname} from $(printf ${_pkgurl} | sed 's/^.*\/\///; s/\/.*//')\n"
  134. git clone ${_pkgurl} ${_pkgname}
  135. pkgversion && \
  136. mv ${_pkgname} ${_pkgname}-${_pkgver}
  137. cd ${_pkgname}-${_pkgver}
  138. }
  139. pkgdependencies "${_pkgdeps[*]}" && \
  140. if [[ -v _pkgdeps_runtime ]]; then pkgdependencies "${_pkgdeps_runtime[*]}"; fi
  141. pkgfoldername
  142. unset _pkgver
  143. }
  144. ###################################################
  145. function meson_install_main() {
  146. local pkgname="meson"
  147. local pkgdeps_build=(
  148. 'python3'
  149. 'dh-python'
  150. 'python3-setuptools'
  151. 'ninja-build'
  152. )
  153. <<DISABLED
  154. 'zlib1g-dev'
  155. 'libboost-dev'
  156. 'libboost-thread-dev'
  157. 'libboost-test-dev'
  158. 'libboost-log-dev'
  159. 'gobjc'
  160. 'gobjc++'
  161. 'gnustep-make'
  162. 'libgnustep-base-dev'
  163. 'libgtest-dev'
  164. 'google-mock'
  165. 'qtbase5-dev'
  166. 'qtbase5-dev-tools'
  167. 'qttools5-dev-tools'
  168. 'protobuf-compiler'
  169. 'libprotobuf-dev'
  170. 'default-jdk-headless'
  171. 'valac'
  172. 'gobject-introspection'
  173. 'libgirepository1.0-dev'
  174. 'gfortran'
  175. 'flex'
  176. 'bison'
  177. 'mono-mcs'
  178. 'mono-devel'
  179. 'libwxgtk3.0-dev'
  180. 'gtk-doc-tools'
  181. 'rustc'
  182. 'bash-doc'
  183. 'python3-dev'
  184. 'cython3'
  185. 'gdc'
  186. 'itstool'
  187. 'libgtk-3-dev'
  188. 'g++-arm-linux-gnueabihf'
  189. 'bash-doc'
  190. 'valgrind'
  191. 'llvm-dev'
  192. 'libsdl2-dev'
  193. 'openmpi-bin'
  194. 'libopenmpi-dev'
  195. 'libvulkan-dev'
  196. 'libpcap-dev'
  197. 'libcups2-dev'
  198. 'gtk-sharp2'
  199. 'gtk-sharp2-gapi'
  200. 'libglib2.0-cil-dev'
  201. 'libwmf-dev'
  202. 'mercurial'
  203. 'gcovr'
  204. 'lcov'
  205. 'fpga-icestorm'
  206. 'arachne-pnr'
  207. 'yosys'
  208. 'qtbase5-private-dev'
  209. DISABLED
  210. local pkgver_git="git describe --long | sed 's/\-[a-z].*//; s/\-/\./; s/[a-z]//g'"
  211. local pkgurl="https://github.com/mesonbuild/meson"
  212. local pkgurl_debian="http://archive.ubuntu.com/ubuntu/pool/universe/m/meson/meson_0.45.1-2.debian.tar.xz"
  213. function meson_debianbuild() {
  214. wget ${pkgurl_debian} -O debian.tar.xz
  215. tar xf debian.tar.xz && rm debian.tar.xz
  216. local sedversion=$(printf '%s' $(pwd | sed -e 's/.*\-//' -e 's/\./\\\./g'))
  217. # Do not perform checks
  218. sed -ir '/nocheck/d' debian/control
  219. sed -ir '/\.\/run_tests\.py/d' debian/rules
  220. # Downgrade debhelper version requirement for Debian compatilibity
  221. sed -ir 's/debhelper (>= 11)/debhelper (>= 10)/' debian/control
  222. sed -ir "s/0\.45\.1-2/${sedversion}/" debian/changelog
  223. sed -ir '/rm \$\$(pwd)\/debian\/meson\/usr\/bin\/mesontest/d' debian/rules
  224. sed -ir '/rm \$\$(pwd)\/debian\/meson\/usr\/bin\/mesonconf/d' debian/rules
  225. sed -ir '/rm \$\$(pwd)\/debian\/meson\/usr\/bin\/mesonintrospect/d' debian/rules
  226. sed -ir '/rm \$\$(pwd)\/debian\/meson\/usr\/bin\/wraptool/d' debian/rules
  227. sed -ir '/rm \-rf \$\$(pwd)\/debian\/meson\/usr\/lib\/python3/d' debian/rules
  228. #sed -ir "s/0\.45\.1-2/${sedversion}/" debian/files
  229. #sed -ir "s/0\.45\.1-2/${sedversion}/" debian/meson/DEBIAN/control
  230. rm -r debian/patches
  231. # Compile the package and actually install it. It is required by DXVK
  232. DEB_BUILD_OPTIONS="strip nodocs noddebs" dpkg-buildpackage -rfakeroot -b -us -uc
  233. if [[ $? -eq 0 ]]; then
  234. rm -rf ../*.{changes,buildinfo,tar.xz} && \
  235. sudo dpkg -i ../${pkgname}*.deb && \
  236. mv ../${pkgname}*.deb ../../../compiled_deb/"${datedir}" && \
  237. echo -e "Compiled ${pkgname} is stored at '$(readlink -f ../../../compiled_deb/"${datedir}")/'\n"
  238. cd ../..
  239. rm -rf ${pkgname}
  240. else
  241. exit 1
  242. fi
  243. }
  244. preparepackage "${pkgname}" "${pkgdeps_build[*]}" "${pkgurl}" "${pkgver_git}" && \
  245. meson_debianbuild
  246. }
  247. ###################################################
  248. function glslang_install_main() {
  249. local pkgname="glslang"
  250. local pkgdeps_build=('cmake' 'python2.7')
  251. local pkgurl="https://github.com/KhronosGroup/glslang"
  252. local pkgver_git="git describe --long | sed 's/\-[a-z].*//; s/\-/\./; s/[a-z]//g'"
  253. function glslang_debianbuild() {
  254. # Compile the package and actually install it. It is required by DXVK
  255. dh_make --createorig -s -y
  256. sed -ie "s/^Build-Depends:.*$/Build-Depends: debhelper (>=10), $(echo ${_coredeps[*]} | sed 's/\s/, /g'), $(echo ${pkgdeps_build[*]} | sed 's/\s/, /g')/g" debian/control
  257. printf 'override_dh_usrlocal:' | tee -a debian/rules
  258. DEB_BUILD_OPTIONS="strip nodocs noddebs" dpkg-buildpackage -rfakeroot -b -us -uc
  259. if [[ $? -eq 0 ]]; then
  260. rm -rf ../*.{changes,buildinfo,tar.xz} && \
  261. sudo dpkg -i ../${pkgname}*.deb && \
  262. mv ../${pkgname}*.deb ../../../compiled_deb/"${datedir}" && \
  263. echo -e "Compiled ${pkgname} is stored at '$(readlink -f ../../../compiled_deb/"${datedir}")/'\n"
  264. cd ../..
  265. rm -rf ${pkgname}
  266. else
  267. exit 1
  268. fi
  269. }
  270. preparepackage "${pkgname}" "${pkgdeps_build[*]}" "${pkgurl}" "${pkgver_git}" && \
  271. glslang_debianbuild
  272. }
  273. ###################################################
  274. function dxvk_install_main() {
  275. local pkgname="dxvk-git"
  276. local pkgdeps_build=(
  277. 'meson'
  278. 'glslang'
  279. 'gcc-mingw-w64-x86-64'
  280. 'gcc-mingw-w64-i686'
  281. 'g++-mingw-w64-x86-64'
  282. 'g++-mingw-w64-i686'
  283. 'mingw-w64-x86-64-dev'
  284. 'mingw-w64-i686-dev'
  285. )
  286. local pkgdeps_runtime=('wine' 'winetricks')
  287. local pkgver_git="git describe --long | sed 's/\-[a-z].*//; s/\-/\./; s/[a-z]//g'"
  288. local pkgurl="https://github.com/doitsujin/dxvk"
  289. function dxvk_posixpkgs() {
  290. local packages=(
  291. 'i686-w64-mingw32-g++'
  292. 'i686-w64-mingw32-gcc'
  293. 'x86_64-w64-mingw32-g++'
  294. 'x86_64-w64-mingw32-gcc'
  295. )
  296. for package in "${packages[@]}"; do
  297. local option=$(echo "" | sudo update-alternatives --config "${package}" | grep posix | sed 's@^[^0-9]*\([0-9]\+\).*@\1@')
  298. echo "${option}" | sudo update-alternatives --config "${package}" &> /dev/null
  299. done
  300. }
  301. function dxvk_debianbuild() {
  302. local dxvx_relative_builddir="debian/source/dxvk-master"
  303. dh_make --createorig -s -y
  304. sed -ie "s/^Build-Depends:.*$/Build-Depends: debhelper (>=10), $(echo ${_coredeps[*]} | sed 's/\s/, /g'), $(echo ${pkgdeps_build[*]} | sed 's/\s/, /g')/g" debian/control
  305. sed -ie "s/^Depends:.*$/Depends: $(echo ${pkgdeps_runtime} | sed 's/\s/, /g')/g" debian/control
  306. printf "${dxvx_relative_builddir}/setup_dxvk.verb usr/share/dxvk/" > debian/install
  307. printf "\n${dxvx_relative_builddir}/bin/* usr/bin/" >> debian/install
  308. rm debian/*.{ex,EX}
  309. cat << 'DXVK-DEBIANRULES' > debian/rules
  310. #!/usr/bin/make -f
  311. %:
  312. dh $@
  313. override_dh_auto_configure:
  314. override_dh_usrlocal:
  315. DXVK-DEBIANRULES
  316. bash ./package-release.sh master debian/source/ --no-package
  317. if [[ $? -ne 0 ]]; then
  318. echo "Error while compiling ${pkgname}. Check messages above. Aborting\n"
  319. exit 1
  320. fi
  321. sed -ir '/dxvk64_dir/d' ${dxvx_relative_builddir}/setup_dxvk.verb
  322. mkdir -p ${dxvx_relative_builddir}/bin
  323. echo -e "#!/bin/sh\nwinetricks --force /usr/share/dxvk/setup_dxvk.verb" \
  324. > "${dxvx_relative_builddir}/bin/setup_dxvk"
  325. chmod +x "${dxvx_relative_builddir}/bin/setup_dxvk"
  326. for arch in 64 32; do
  327. mkdir -p ${dxvx_relative_builddir}/x${arch}
  328. printf "\n${dxvx_relative_builddir}/x${arch}/* usr/share/dxvk/x${arch}/" >> debian/install
  329. done
  330. DEB_BUILD_OPTIONS="strip nodocs noddebs" dpkg-buildpackage -us -uc -b --source-option=--include-binaries
  331. if [[ $? -eq 0 ]]; then
  332. if [[ ! -v NO_INSTALL ]]; then
  333. sudo dpkg -i ../${pkgname}*.deb
  334. fi
  335. rm -rf ../*.{changes,buildinfo,tar.xz}
  336. mv ../${pkgname}*.deb ../../../compiled_deb/"${datedir}" && \
  337. echo -e "Compiled ${pkgname} is stored at '$(readlink -f ../../../compiled_deb/"${datedir}")/'\n"
  338. cd ../..
  339. rm -rf ${pkgname}
  340. else
  341. exit 1
  342. fi
  343. }
  344. preparepackage "${pkgname}" "${pkgdeps_build[*]}" "${pkgurl}" "${pkgver_git}" "${pkgdeps_runtime[*]}" && \
  345. dxvk_posixpkgs && \
  346. dxvk_debianbuild
  347. }
  348. ####################################################################
  349. pkgcompilecheck meson meson_install_main
  350. pkgcompilecheck glslang glslang_install_main
  351. dxvk_install_main