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.

755 lines
22 KiB

6 years ago
6 years ago
  1. #!/bin/env bash
  2. # Compile DXVK & D9VK git on Debian/Ubuntu/Mint and variants
  3. # Copyright (C) 2019 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. # Divide input args into array indexes
  26. i=0
  27. for p in ${@:2}; do
  28. params[$i]=${p}
  29. let i++
  30. done
  31. ########################################################
  32. # Parse input git override hashes
  33. # This order is mandatory!
  34. # If you change the order or contents of 'githash_overrides'
  35. # array in ../updatewine.sh, make sure to update these
  36. # variables!
  37. #
  38. git_commithash_dxvk=${params[0]}
  39. git_commithash_d9vk=${params[1]}
  40. git_commithash_glslang=${params[2]}
  41. git_commithash_meson=${params[3]}
  42. git_branch_dxvk=${params[5]}
  43. git_branch_d9vk=${params[6]}
  44. git_branch_glslang=${params[7]}
  45. git_branch_meson=${params[8]}
  46. ########################################################
  47. # Parse input arguments, filter user parameters
  48. # The range is defined in ../updatewine.sh
  49. # All input arguments are:
  50. # <datedir> 4*<githash_override> 4*<gitbranch_override> <args>
  51. # 0 1 2 3 4 5 6 7 8 9...
  52. # Filter all but <args>, i.e. the first 0-8 arguments
  53. i=0
  54. for arg in ${params[@]:8}; do
  55. args[$i]="${arg}"
  56. let i++
  57. done
  58. for check in ${args[@]}; do
  59. case ${check} in
  60. --no-install)
  61. NO_INSTALL=
  62. ;;
  63. --updateoverride)
  64. UPDATE_OVERRIDE=
  65. ;;
  66. --buildpkg-rm)
  67. BUILDPKG_RM=
  68. ;;
  69. --no-dxvk)
  70. NO_DXVK=
  71. ;;
  72. --no-d9vk)
  73. NO_D9VK=
  74. ;;
  75. esac
  76. done
  77. ########################################################
  78. # Check presence of Wine. Some version of Wine should
  79. # be found in the system in order to install DXVK.
  80. known_wines=(
  81. 'wine'
  82. 'wine-stable'
  83. 'wine32'
  84. 'wine64'
  85. 'libwine:amd64'
  86. 'libwine:i386'
  87. 'wine-git'
  88. 'wine-staging-git'
  89. )
  90. # Alternative remote dependency packages for Debian distributions which offer too old packages for DXVK/D9VK
  91. #
  92. # Left side: <package name in repositories>,<version_number>
  93. # Right side: package alternative source URL
  94. #
  95. # NOTE: Determine these packages in corresponding debdata files as runtime or buildtime dependencies
  96. #
  97. typeset -A remotePackagesAlt
  98. remotePackagesAlt=(
  99. [gcc-mingw-w64-base,830]="http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-mingw-w64/gcc-mingw-w64-base_8.3.0-6ubuntu1+21.1build2_amd64.deb"
  100. [mingw-w64-common,600]="http://mirrors.kernel.org/ubuntu/pool/universe/m/mingw-w64/mingw-w64-common_6.0.0-3_all.deb"
  101. # [binutils-common,232]="http://mirrors.kernel.org/ubuntu/pool/main/b/binutils/binutils-common_2.32-7ubuntu4_amd64.deb"
  102. [binutils-mingw-w64-x86-64,232]="http://mirrors.kernel.org/ubuntu/pool/universe/b/binutils-mingw-w64/binutils-mingw-w64-x86-64_2.32-7ubuntu4+8.3ubuntu2_amd64.deb"
  103. [binutils-mingw-w64-i686,232]="http://mirrors.kernel.org/ubuntu/pool/universe/b/binutils-mingw-w64/binutils-mingw-w64-i686_2.32-7ubuntu4+8.3ubuntu2_amd64.deb"
  104. [mingw-w64-x86-64-dev,600]="http://mirrors.kernel.org/ubuntu/pool/universe/m/mingw-w64/mingw-w64-x86-64-dev_6.0.0-3_all.deb"
  105. [gcc-mingw-w64-x86-64,830]="http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-mingw-w64/gcc-mingw-w64-x86-64_8.3.0-6ubuntu1+21.1build2_amd64.deb"
  106. [g++-mingw-w64-x86-64,830]="http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-mingw-w64/g++-mingw-w64-x86-64_8.3.0-6ubuntu1+21.1build2_amd64.deb"
  107. [mingw-w64-i686-dev,600]="http://mirrors.kernel.org/ubuntu/pool/universe/m/mingw-w64/mingw-w64-i686-dev_6.0.0-3_all.deb"
  108. [gcc-mingw-w64-i686,830]="http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-mingw-w64/gcc-mingw-w64-i686_8.3.0-6ubuntu1+21.1build2_amd64.deb"
  109. [g++-mingw-w64-i686,830]="http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-mingw-w64/g++-mingw-w64-i686_8.3.0-6ubuntu1+21.1build2_amd64.deb"
  110. )
  111. # Posix-compliant MingW alternative executables
  112. #
  113. typeset -A alternatives
  114. alternatives=(
  115. [x86_64-w64-mingw32-gcc]="x86_64-w64-mingw32-gcc-posix"
  116. [x86_64-w64-mingw32-g++]="x86_64-w64-mingw32-g++-posix"
  117. [i686-w64-mingw32-gcc]="i686-w64-mingw32-gcc-posix"
  118. [i686-w64-mingw32-g++]="i686-w64-mingw32-g++-posix"
  119. )
  120. # Temporary symbolic links for DXVK & D9VK compilation
  121. #
  122. typeset -A tempLinks
  123. tempLinks=(
  124. ['/usr/bin/i686-w64-mingw32-gcc']='/usr/bin/i686-w64-mingw32-gcc-posix'
  125. ['/usr/bin/i686-w64-mingw32-g++']='/usr/bin/i686-w64-mingw32-g++-posix'
  126. ['/usr/bin/x86_64-w64-mingw32-gcc']='x86_64-w64-mingw32-gcc-posix'
  127. ['/usr/bin/x86_64-w64-mingw32-g++']='x86_64-w64-mingw32-g++-posix'
  128. )
  129. ########################################################
  130. function runtimeCheck() {
  131. # Friendly name for this package
  132. local pkgreq_name=${1}
  133. # Known package names to check on Debian
  134. local known_pkgs=${2}
  135. # Check if any of these Wine packages are present on the system
  136. i=0
  137. for pkg in ${known_pkgs[@]}; do
  138. if [[ $(echo $(dpkg -s ${pkg} &>/dev/null)$?) -eq 0 ]]; then
  139. local pkglist[$i]=${pkg}
  140. let i++
  141. fi
  142. done
  143. if [[ -z ${pkglist[*]} ]]; then
  144. echo -e "\e[1mWARNING:\e[0m Not installing DXVK/D9VK because \e[1m${pkgreq_name}\e[0m is missing on your system.\n\
  145. ${pkgreq_name} should be installed in order to use DXVK/D9VK. Just compiling DXVK/D9VK for later use.\n"
  146. # Do this check separately so we can warn about all missing runtime dependencies above
  147. if [[ ! -v NO_INSTALL ]]; then
  148. # Force --no-install switch
  149. NO_INSTALL=
  150. fi
  151. fi
  152. }
  153. ########################################################
  154. # If the script is interrupted (Ctrl+C/SIGINT), do the following
  155. function DXVK_intCleanup() {
  156. rm -rf ${DXVKROOT}/{dxvk-git,d9vk-git,meson,glslang,*.deb}
  157. rm -rf ${DXVKROOT}/../compiled_deb/"${datedir}"
  158. exit 0
  159. }
  160. # Allow interruption of the script at any time (Ctrl + C)
  161. trap "DXVK_intCleanup" INT
  162. # Error event
  163. #trap "DXVK_intCleanup" ERR
  164. ########################################################
  165. # http://wiki.bash-hackers.org/snipplets/print_horizontal_line#a_line_across_the_entire_width_of_the_terminal
  166. function INFO_SEP() { printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - ; }
  167. ########################################################
  168. # Update all packages if UPDATE_OVERRIDE given
  169. if [[ -v UPDATE_OVERRIDE ]]; then
  170. echo -en "Updating all packages" && \
  171. if [[ $(printf $(sudo -n uptime &>/dev/null)$?) -ne 0 ]]; then printf " Please provide your sudo password.\n"; else printf "\n\n"; fi
  172. sudo apt update && sudo apt upgrade -y
  173. fi
  174. ########################################################
  175. # Check do we need to compile the package
  176. # given as input for this function
  177. function pkgcompilecheck() {
  178. local install_function=${1}
  179. local pkg=${2}
  180. local pkg_data=${3}
  181. if [[ $(echo $(dpkg -s ${pkg} &>/dev/null)$?) -ne 0 ]] || [[ -v UPDATE_OVERRIDE ]]; then
  182. ${install_function} ${pkg_data}
  183. fi
  184. }
  185. ########################################################
  186. # DXVK CUSTOM INSTALLATION HOOKS
  187. # These are custom installation instructions for DXVK
  188. # They are not used independently.
  189. function dxvk_install_custom() {
  190. local PATCHDIR="${1}"
  191. # Use posix alternates for MinGW binaries
  192. function dxvk_posixpkgs() {
  193. for alt in ${!alternatives[@]}; do
  194. echo "Linking MingW executable ${alt} to ${alternatives[$alt]}"
  195. sudo rm -rf /etc/alternatives/"${alt}" 2>/dev/null
  196. sudo ln -sf /usr/bin/"${alternatives[$alt]}" /etc/alternatives/"${alt}"
  197. if [[ $? -ne 0 ]]; then
  198. echo -e "\e[1mERROR:\e[0m Error occured while linking executable ${alt} to ${alternatives[$alt]}. Aborting\n"
  199. exit 1
  200. fi
  201. done
  202. for link in ${!tempLinks[@]}; do
  203. if [[ ! -f ${link} ]]; then
  204. echo "Creating temporary links for MingW executable ${link}"
  205. sudo ln -sf ${tempLinks["${link}"]} "${link}"
  206. if [[ $? -ne 0 ]]; then
  207. echo -e "\e[1mERROR:\e[0m Error occured while linking executable ${link}. Aborting\n"
  208. exit 1
  209. fi
  210. fi
  211. done
  212. }
  213. ############################
  214. # DXVK - CUSTOM PATCHES
  215. # Add and apply custom DXVK patches
  216. function dxvk_custompatches() {
  217. # Get our current directory, since we will change it during patching process below
  218. # We want to go back here after having applied the patches
  219. local CURDIR="${PWD}"
  220. # Check if the following folder exists, and proceed.
  221. if [[ -d "${DXVKROOT}/../../${PATCHDIR}" ]]; then
  222. cp -r "${DXVKROOT}/../../${PATCHDIR}/"*.{patch,diff} "${DXVKROOT}/${pkg_name}/" 2>/dev/null
  223. local dxvk_builddir_name=$(ls -l "${DXVKROOT}/${pkg_name}" | grep ^d | awk '{print $NF}')
  224. # TODO Expecting just one folder here. This method doesn't work with multiple dirs present
  225. if [[ $(echo ${dxvk_builddir_name} | wc -l) -gt 1 ]]; then
  226. echo -e "\e[1mERROR:\e[0m Multiple entries in dxvk build directory detected. Can't decide which one to use. Aborting\n"
  227. exit 1
  228. fi
  229. local dxvk_builddir_path="${DXVKROOT}/${pkg_name}/${dxvk_builddir_name}"
  230. cd "${dxvk_builddir_path}"
  231. for pfile in ../*.{patch,diff}; do
  232. if [[ -f ${pfile} ]]; then
  233. echo -e "Applying DXVK patch: ${pfile}\n"
  234. patch -Np1 < ${pfile}
  235. fi
  236. if [[ $? -ne 0 ]]; then
  237. echo -e "\e[1mERROR:\e[0m Error occured while applying DXVK patch '${pfile}'. Aborting\n"
  238. cd ${CURDIR}
  239. exit 1
  240. fi
  241. done
  242. cd "${CURDIR}"
  243. fi
  244. }
  245. ############################
  246. # DXVK - CUSTOM HOOKS EXECUTION
  247. dxvk_custompatches && \
  248. dxvk_posixpkgs
  249. }
  250. ########################################################
  251. # COMMON - COMPILE AND INSTALL DEB PACKAGE
  252. # Instructions to compile and install a deb package
  253. # on Debian system
  254. # Global variable to track buildtime dependencies
  255. z=0
  256. function compile_and_install_deb() {
  257. ############################
  258. # Set local variables
  259. local _pkg_name="${1}"
  260. local _pkg_license="${2}"
  261. local _pkg_giturl="${3}"
  262. local _pkg_gitbranch="${4}"
  263. local _git_commithash="${5}"
  264. local _pkg_gitver="${6}"
  265. local _pkg_debinstall="${7}"
  266. local _pkg_debcontrol="${8}"
  267. local _pkg_debrules="${9}"
  268. local _pkg_installfile="${10}"
  269. local _pkg_controlfile="${11}"
  270. local _pkg_rulesfile="${12}"
  271. local _pkg_deps_build="${13}"
  272. local _pkg_deps_runtime="${14}"
  273. local _pkg_debbuilder="${15}"
  274. ############################
  275. # COMMON - ARRAY PARAMETER FIX
  276. # Separate array indexes correctly
  277. # We have streamed all array indexes, separated
  278. # by | symbol. We reconstruct the arrays here.
  279. function arrayparser_reverse() {
  280. local arrays=(
  281. '_pkg_deps_build'
  282. '_pkg_deps_runtime'
  283. )
  284. for w in ${arrays[@]}; do
  285. local s=\${${w}}
  286. local IFS='|'
  287. local y=0
  288. for t in $(eval printf '%s\|' ${s}); do
  289. eval ${w}[$y]=\"${t}\"
  290. let y++
  291. done
  292. unset IFS
  293. done
  294. }
  295. arrayparser_reverse
  296. ############################
  297. function pkg_installcheck() {
  298. RETURNVALUE=$(echo $(dpkg -s "${1}" &>/dev/null)$?)
  299. return $RETURNVALUE
  300. }
  301. ############################
  302. echo -e "Starting compilation$(if [[ ! -v NO_INSTALL ]] || [[ ${_pkg_name} =~ ^meson|glslang$ ]]; then printf " & installation"; fi) of ${_pkg_name}\n"
  303. ############################
  304. # COMMON - PACKAGE DEPENDENCIES CHECK
  305. # Check and install package related dependencies if they are missing
  306. function pkg_dependencies() {
  307. local _pkg_list="${1}"
  308. local _pkg_type="${2}"
  309. local IFS=$'\n'
  310. _pkg_list=$(echo "${_pkg_list}" | sed 's/([^)]*)//g')
  311. unset IFS
  312. case ${_pkg_type} in
  313. buildtime)
  314. local _pkg_type_str="build time"
  315. ;;
  316. runtime)
  317. local _pkg_type_str="runtime"
  318. ;;
  319. esac
  320. if [[ ${_pkg_list[0]} == "empty" ]]; then
  321. return 0
  322. fi
  323. # Generate a list of missing dependencies
  324. local a=0
  325. for p in ${_pkg_list[@]}; do
  326. if [[ $(pkg_installcheck ${p}) -eq 0 ]]; then
  327. local _validlist[$a]=${p}
  328. let a++
  329. # Global array to track installed build dependencies
  330. if [[ ${_pkg_type} == "buildtime" ]]; then
  331. _buildpkglist[$z]="${p}"
  332. let z++
  333. fi
  334. fi
  335. done
  336. function pkg_remoteinstall() {
  337. sudo apt install -y ${1} &> /dev/null
  338. }
  339. function pkg_localinstall() {
  340. wget ${1} -O ${DXVKROOT}/"${2}".deb
  341. sudo dpkg -i --force-all ${DXVKROOT}/"${2}".deb
  342. }
  343. function pkg_configure() {
  344. if [[ $(sudo dpkg-reconfigure ${1} | grep "is broken or not fully installed") ]]; then
  345. if [[ -v ${2} ]]; then
  346. pkg_localinstall ${2} ${1}
  347. else
  348. pkg_remoteinstall ${1}
  349. fi
  350. fi
  351. }
  352. # Install missing dependencies, be informative
  353. local b=0
  354. for _pkg_dep in ${_validlist[@]}; do
  355. echo -e "$(( $b + 1 ))/$(( ${#_validlist[*]} )) - Installing ${_pkg_name} ${_pkg_type_str} dependency ${_pkg_dep}"
  356. if [[ ${#remotePackagesAlt[@]} -gt 0 ]]; then
  357. for altRemote in ${!remotePackagesAlt[@]}; do
  358. altRemotepkg=$(echo ${altRemote} | awk -F ',' '{print $1}')
  359. altRemotever=$(echo ${altRemote} | awk -F ',' '{print $2}')
  360. if [[ "${_pkg_dep}" == "${altRemotepkg}" ]]; then
  361. if [[ $(pkg_installcheck ${altRemotepkg}) -ne 0 ]]; then
  362. # TODO remove duplicate functionality
  363. if [[ $(apt-cache show "${altRemotepkg}" | grep -m1 -oP "(?<=^Version: )[0-9|\.]*" | sed 's/\.//g') < ${altRemotever} ]]; then
  364. pkg_localinstall ${remotePackagesAlt["${altRemote}"]} "${altRemotepkg}"
  365. pkg_configure "${altRemotepkg}" ${remotePackagesAlt["${altRemote}"]}
  366. else
  367. pkg_remoteinstall "${altRemotepkg}"
  368. pkg_configure "${altRemotepkg}"
  369. fi
  370. else
  371. if [[ $(dpkg -s "${altRemotepkg}" | grep -m1 -oP "(?<=^Version: )[0-9|\.]*" | sed 's/\.//g') < ${altRemotever} ]]; then
  372. pkg_localinstall ${remotePackagesAlt["${altRemote}"]} "${altRemotepkg}"
  373. pkg_configure "${altRemotepkg}" ${remotePackagesAlt["${altRemote}"]}
  374. else
  375. pkg_remoteinstall "${altRemotepkg}"
  376. pkg_configure "${altRemotepkg}"
  377. fi
  378. fi
  379. fi
  380. done
  381. fi
  382. if [[ $(pkg_installcheck ${_pkg_dep}) -ne 0 ]]; then
  383. pkg_remoteinstall "${_pkg_dep}"
  384. pkg_configure "${_pkg_dep}"
  385. fi
  386. if [[ $? -eq 0 ]]; then
  387. let b++
  388. else
  389. echo -e "\n\e[1mERROR:\e[0m Error occured while installing ${_pkg_dep}. Aborting.\n"
  390. exit 1
  391. fi
  392. done
  393. if [[ -n ${_validlist[*]} ]]; then
  394. # Add empty newline
  395. echo ""
  396. fi
  397. }
  398. ############################
  399. # COMMON - RETRIEVE PACKAGE
  400. # GIT VERSION TAG
  401. # Get git-based version in order to rename the package main folder
  402. # This is required by deb builder. It retrieves the version number
  403. # from that folder name
  404. function pkg_gitversion() {
  405. if [[ -n "${_pkg_gitver}" ]] && [[ "${_pkg_gitver}" =~ ^git ]]; then
  406. cd ${_pkg_name}
  407. git checkout ${_pkg_gitbranch}
  408. git reset --hard ${_git_commithash}
  409. if [[ $? -ne 0 ]]; then
  410. echo -e "\e[1mERROR:\e[0m Couldn't find commit ${_git_commithash} for ${_pkg_name}. Aborting\n"
  411. exit 1
  412. fi
  413. _pkg_gitver=$(eval "${_pkg_gitver}")
  414. cd ..
  415. fi
  416. }
  417. ############################
  418. # COMMON - OVERWRITE
  419. # DEBIAN BUILD ENV FILES
  420. # Overwrite a file which is given as user input
  421. # The contents are supplied as input, too.
  422. function pkg_override_debianfile() {
  423. local contents=${1}
  424. local targetfile=${2}
  425. if [[ ${contents} != "empty" ]]; then
  426. echo "${contents}" > "${targetfile}"
  427. if [[ $? -ne 0 ]]; then
  428. echo -e "\e[1mERROR:\e[0m Couldn't create Debian file '${targetfile}' for ${_pkg_name}. Aborting\n"
  429. exit 1
  430. fi
  431. fi
  432. }
  433. ############################
  434. # COMMON - GET SOURCE AND
  435. # PREPARE SOURCE FOLDER
  436. function pkg_folderprepare() {
  437. # Remove old build directory, if present
  438. rm -rf ${_pkg_name}
  439. # Create a new build directory, access it and download git sources there
  440. mkdir ${_pkg_name}
  441. cd ${_pkg_name}
  442. echo -e "Retrieving source code of ${_pkg_name} from $(printf ${_pkg_giturl} | sed 's/^.*\/\///; s/\/.*//')\n"
  443. git clone ${_pkg_giturl} ${_pkg_name}
  444. # If sources could be downloaded, rename the folder properly for deb builder
  445. # Access the folder after which package specific debianbuild function will be run
  446. # That function is defined inside package specific install_main function below
  447. if [[ $? -eq 0 ]]; then
  448. pkg_gitversion && \
  449. mv ${_pkg_name} ${_pkg_name}-${_pkg_gitver}
  450. cd ${_pkg_name}-${_pkg_gitver}
  451. dh_make --createorig -s -y -c ${_pkg_license} && \
  452. pkg_override_debianfile "${_pkg_debinstall}" "${_pkg_installfile}"
  453. pkg_override_debianfile "${_pkg_debcontrol}" "${_pkg_controlfile}"
  454. pkg_override_debianfile "${_pkg_debrules}" "${_pkg_rulesfile}"
  455. else
  456. echo -e "\e[1mERROR:\e[0m Error while downloading source of ${_pkg_name} package. Aborting\n"
  457. exit 1
  458. fi
  459. }
  460. ############################
  461. # COMMON - COMPILE, INSTALL
  462. # AND STORE DEB PACKAGE
  463. function pkg_debianbuild() {
  464. # Start deb builder
  465. bash -c "${_pkg_debbuilder}"
  466. # Once our deb package is compiled, install and store it
  467. # We do not make installation optional because this is a core dependency for DXVK
  468. if [[ $? -eq 0 ]]; then
  469. rm -rf ../*.{changes,buildinfo,tar.xz} && \
  470. sudo dpkg -i ../${_pkg_name}*.deb && \
  471. mv ../${_pkg_name}*.deb ../../../compiled_deb/"${datedir}" && \
  472. echo -e "Compiled ${_pkg_name} is stored at '$(readlink -f ../../../compiled_deb/"${datedir}")/'\n"
  473. cd ../..
  474. rm -rf {${_pkg_name},*.deb}
  475. else
  476. buildpkg_removal
  477. exit 1
  478. fi
  479. }
  480. ############################
  481. # COMMON - EXECUTION HOOKS
  482. pkg_dependencies "${_pkg_deps_build[*]}" buildtime
  483. if [[ ${_pkg_deps_runtime[0]} != "empty" ]] && [[ ! -v NO_INSTALL ]]; then
  484. pkg_dependencies "${_pkg_deps_runtime[*]}" runtime
  485. fi
  486. pkg_folderprepare
  487. # TODO use package name or separate override switch here?
  488. if [[ "${_pkg_name}" == *"dxvk"* ]]; then
  489. dxvk_install_custom "dxvk_custom_patches"
  490. fi
  491. if [[ "${_pkg_name}" == *"d9vk"* ]]; then
  492. dxvk_install_custom "d9vk_custom_patches"
  493. fi
  494. pkg_debianbuild
  495. unset _pkg_gitver
  496. }
  497. ########################################################
  498. # BUILD DEPENDENCIES REMOVAL
  499. function buildpkg_removal() {
  500. _buildpkglist=($(echo ${_buildpkglist[@]} | tr ' ' '\n' |sort -u | tr '\n' ' '))
  501. for link in ${!tempLinks[@]}; do
  502. if [[ $(file ${link}) == *"symbolic link"* ]]; then
  503. sudo rm -f "${link}"
  504. fi
  505. done
  506. # Build time dependencies which were installed but no longer needed
  507. if [[ -v _buildpkglist ]]; then
  508. if [[ -v BUILDPKG_RM ]]; then
  509. sudo apt purge --remove -y ${_buildpkglist[*]}
  510. # In some cases, glslang or meson may still be present on the system. Remove them
  511. for _extrapkg in glslang meson; do
  512. if [[ $(echo $(dpkg -s ${_extrapkg} &>/dev/null)$?) -eq 0 ]]; then
  513. sudo dpkg --remove --force-remove-reinstreq ${_extrapkg}
  514. fi
  515. done
  516. # Manually obtained deb packages are expected to break system configuration, thus we need to fix it.
  517. sudo apt --fix-broken -y install
  518. else
  519. echo -e "The following build time dependencies were installed and no longer needed:\n\n$(for l in ${_buildpkglist[*]}; do echo -e ${l}; done)\n"
  520. fi
  521. fi
  522. }
  523. ########################################################
  524. # Package installation instructions
  525. function pkg_install_main() {
  526. # Read necessary variables from debdata file
  527. local pkg_datafile=${1}
  528. if [[ -f ${pkg_datafile} ]]; then
  529. source ${pkg_datafile}
  530. else
  531. echo -e "\e[1mERROR:\e[0m Couldn't read datafile '${pkg_datafile}'. Check the file path and try again.\n"
  532. exit 1
  533. fi
  534. ############################
  535. # Prepare these arrays for 'compile_and_install_deb' input
  536. # Separate each array index with | in these arrays
  537. function pkg_arrayparser() {
  538. local pkg_arrays=(
  539. 'pkg_deps_build'
  540. 'pkg_deps_runtime'
  541. )
  542. local IFS=$'\n'
  543. for w in ${pkg_arrays[@]}; do
  544. local s=\${${w}[@]}
  545. local t=$(eval printf '%s\|' ${s})
  546. unset ${w}
  547. eval ${w}=\"${t}\"
  548. done
  549. }
  550. ############################
  551. # Execute package installation procedure
  552. pkg_arrayparser && \
  553. compile_and_install_deb \
  554. "${pkg_name}" \
  555. "${pkg_license}" \
  556. "${pkg_giturl}" \
  557. "${pkg_gitbranch}" \
  558. "${git_commithash}" \
  559. "${pkg_gitver}" \
  560. "${pkg_debinstall}" \
  561. "${pkg_debcontrol}" \
  562. "${pkg_debrules}" \
  563. "${pkg_installfile}" \
  564. "${pkg_controlfile}" \
  565. "${pkg_rulesfile}" \
  566. "${pkg_deps_build}" \
  567. "${pkg_deps_runtime}" \
  568. "${pkg_debbuilder}"
  569. }
  570. ########################################################
  571. # Check existence of known Wine packages
  572. runtimeCheck Wine "${known_wines[*]}"
  573. # Meson - compile (& install)
  574. pkgcompilecheck pkg_install_main meson "${DXVKROOT}/meson.debdata"
  575. # Glslang - compile (& install)
  576. pkgcompilecheck pkg_install_main glslang "${DXVKROOT}/glslang.debdata"
  577. if [[ ! -v NO_DXVK ]]; then
  578. # DXVK - compile (& install)
  579. pkg_install_main "${DXVKROOT}/dxvk.debdata"
  580. fi
  581. if [[ ! -v NO_D9VK ]]; then
  582. # D9VK - compile (& install)
  583. pkg_install_main "${DXVKROOT}/d9vk.debdata"
  584. fi
  585. # Clean buildtime dependencies
  586. buildpkg_removal