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.

474 lines
12 KiB

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