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.

752 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) 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. # 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. ########################################################
  163. # http://wiki.bash-hackers.org/snipplets/print_horizontal_line#a_line_across_the_entire_width_of_the_terminal
  164. function INFO_SEP() { printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - ; }
  165. ########################################################
  166. # Update all packages if UPDATE_OVERRIDE given
  167. if [[ -v UPDATE_OVERRIDE ]]; then
  168. echo -en "Updating all packages" && \
  169. if [[ $(printf $(sudo -n uptime &>/dev/null)$?) -ne 0 ]]; then printf " Please provide your sudo password.\n"; else printf "\n\n"; fi
  170. sudo apt update && sudo apt upgrade -y
  171. fi
  172. ########################################################
  173. # Check do we need to compile the package
  174. # given as input for this function
  175. function pkgcompilecheck() {
  176. local install_function=${1}
  177. local pkg=${2}
  178. local pkg_data=${3}
  179. if [[ $(echo $(dpkg -s ${pkg} &>/dev/null)$?) -ne 0 ]] || [[ -v UPDATE_OVERRIDE ]]; then
  180. ${install_function} ${pkg_data}
  181. fi
  182. }
  183. ########################################################
  184. # DXVK CUSTOM INSTALLATION HOOKS
  185. # These are custom installation instructions for DXVK
  186. # They are not used independently.
  187. function dxvk_install_custom() {
  188. local PATCHDIR="${1}"
  189. # Use posix alternates for MinGW binaries
  190. function dxvk_posixpkgs() {
  191. for alt in ${!alternatives[@]}; do
  192. echo "Linking MingW executable ${alt} to ${alternatives[$alt]}"
  193. sudo rm -rf /etc/alternatives/"${alt}" 2>/dev/null
  194. sudo ln -sf /usr/bin/"${alternatives[$alt]}" /etc/alternatives/"${alt}"
  195. if [[ $? -ne 0 ]]; then
  196. echo -e "\e[1mERROR:\e[0m Error occured while linking executable ${alt} to ${alternatives[$alt]}. Aborting\n"
  197. exit 1
  198. fi
  199. done
  200. for link in ${!tempLinks[@]}; do
  201. if [[ ! -f ${link} ]]; then
  202. echo "Creating temporary links for MingW executable ${link}"
  203. sudo ln -sf ${tempLinks["${link}"]} "${link}"
  204. if [[ $? -ne 0 ]]; then
  205. echo -e "\e[1mERROR:\e[0m Error occured while linking executable ${link}. Aborting\n"
  206. exit 1
  207. fi
  208. fi
  209. done
  210. }
  211. ############################
  212. # DXVK - CUSTOM PATCHES
  213. # Add and apply custom DXVK patches
  214. function dxvk_custompatches() {
  215. # Get our current directory, since we will change it during patching process below
  216. # We want to go back here after having applied the patches
  217. local CURDIR="${PWD}"
  218. # Check if the following folder exists, and proceed.
  219. if [[ -d "${DXVKROOT}/../../${PATCHDIR}" ]]; then
  220. cp -r "${DXVKROOT}/../../${PATCHDIR}/"*.{patch,diff} "${DXVKROOT}/${pkg_name}/" 2>/dev/null
  221. local dxvk_builddir_name=$(ls -l "${DXVKROOT}/${pkg_name}" | grep ^d | awk '{print $NF}')
  222. # TODO Expecting just one folder here. This method doesn't work with multiple dirs present
  223. if [[ $(echo ${dxvk_builddir_name} | wc -l) -gt 1 ]]; then
  224. echo -e "\e[1mERROR:\e[0m Multiple entries in dxvk build directory detected. Can't decide which one to use. Aborting\n"
  225. exit 1
  226. fi
  227. local dxvk_builddir_path="${DXVKROOT}/${pkg_name}/${dxvk_builddir_name}"
  228. cd "${dxvk_builddir_path}"
  229. for pfile in ../*.{patch,diff}; do
  230. if [[ -f ${pfile} ]]; then
  231. echo -e "Applying DXVK patch: ${pfile}\n"
  232. patch -Np1 < ${pfile}
  233. fi
  234. if [[ $? -ne 0 ]]; then
  235. echo -e "\e[1mERROR:\e[0m Error occured while applying DXVK patch '${pfile}'. Aborting\n"
  236. cd ${CURDIR}
  237. exit 1
  238. fi
  239. done
  240. cd "${CURDIR}"
  241. fi
  242. }
  243. ############################
  244. # DXVK - CUSTOM HOOKS EXECUTION
  245. dxvk_custompatches && \
  246. dxvk_posixpkgs
  247. }
  248. ########################################################
  249. # COMMON - COMPILE AND INSTALL DEB PACKAGE
  250. # Instructions to compile and install a deb package
  251. # on Debian system
  252. # Global variable to track buildtime dependencies
  253. z=0
  254. function compile_and_install_deb() {
  255. ############################
  256. # Set local variables
  257. local _pkg_name="${1}"
  258. local _pkg_license="${2}"
  259. local _pkg_giturl="${3}"
  260. local _pkg_gitbranch="${4}"
  261. local _git_commithash="${5}"
  262. local _pkg_gitver="${6}"
  263. local _pkg_debinstall="${7}"
  264. local _pkg_debcontrol="${8}"
  265. local _pkg_debrules="${9}"
  266. local _pkg_installfile="${10}"
  267. local _pkg_controlfile="${11}"
  268. local _pkg_rulesfile="${12}"
  269. local _pkg_deps_build="${13}"
  270. local _pkg_deps_runtime="${14}"
  271. local _pkg_debbuilder="${15}"
  272. ############################
  273. # COMMON - ARRAY PARAMETER FIX
  274. # Separate array indexes correctly
  275. # We have streamed all array indexes, separated
  276. # by | symbol. We reconstruct the arrays here.
  277. function arrayparser_reverse() {
  278. local arrays=(
  279. '_pkg_deps_build'
  280. '_pkg_deps_runtime'
  281. )
  282. for w in ${arrays[@]}; do
  283. local s=\${${w}}
  284. local IFS='|'
  285. local y=0
  286. for t in $(eval printf '%s\|' ${s}); do
  287. eval ${w}[$y]=\"${t}\"
  288. let y++
  289. done
  290. unset IFS
  291. done
  292. }
  293. arrayparser_reverse
  294. ############################
  295. function pkg_installcheck() {
  296. RETURNVALUE=$(echo $(dpkg -s "${1}" &>/dev/null)$?)
  297. return $RETURNVALUE
  298. }
  299. ############################
  300. echo -e "Starting compilation$(if [[ ! -v NO_INSTALL ]] || [[ ${_pkg_name} =~ ^meson|glslang$ ]]; then printf " & installation"; fi) of ${_pkg_name}\n"
  301. ############################
  302. # COMMON - PACKAGE DEPENDENCIES CHECK
  303. # Check and install package related dependencies if they are missing
  304. function pkg_dependencies() {
  305. local _pkg_list="${1}"
  306. local _pkg_type="${2}"
  307. local IFS=$'\n'
  308. _pkg_list=$(echo "${_pkg_list}" | sed 's/([^)]*)//g')
  309. unset IFS
  310. case ${_pkg_type} in
  311. buildtime)
  312. local _pkg_type_str="build time"
  313. ;;
  314. runtime)
  315. local _pkg_type_str="runtime"
  316. ;;
  317. esac
  318. if [[ ${_pkg_list[0]} == "empty" ]]; then
  319. return 0
  320. fi
  321. # Generate a list of missing dependencies
  322. local a=0
  323. for p in ${_pkg_list[@]}; do
  324. if [[ $(pkg_installcheck ${p}) -eq 0 ]]; then
  325. local _validlist[$a]=${p}
  326. let a++
  327. # Global array to track installed build dependencies
  328. if [[ ${_pkg_type} == "buildtime" ]]; then
  329. _buildpkglist[$z]="${p}"
  330. let z++
  331. fi
  332. fi
  333. done
  334. function pkg_remoteinstall() {
  335. sudo apt install -y ${1} &> /dev/null
  336. }
  337. function pkg_localinstall() {
  338. wget ${1} -O ${DXVKROOT}/"${2}".deb
  339. sudo dpkg -i --force-all ${DXVKROOT}/"${2}".deb
  340. }
  341. function pkg_configure() {
  342. if [[ $(sudo dpkg-reconfigure ${1} | grep "is broken or not fully installed") ]]; then
  343. if [[ -v ${2} ]]; then
  344. pkg_localinstall ${2} ${1}
  345. else
  346. pkg_remoteinstall ${1}
  347. fi
  348. fi
  349. }
  350. # Install missing dependencies, be informative
  351. local b=0
  352. for _pkg_dep in ${_validlist[@]}; do
  353. echo -e "$(( $b + 1 ))/$(( ${#_validlist[*]} )) - Installing ${_pkg_name} ${_pkg_type_str} dependency ${_pkg_dep}"
  354. if [[ ${#remotePackagesAlt[@]} -gt 0 ]]; then
  355. for altRemote in ${!remotePackagesAlt[@]}; do
  356. altRemotepkg=$(echo ${altRemote} | awk -F ',' '{print $1}')
  357. altRemotever=$(echo ${altRemote} | awk -F ',' '{print $2}')
  358. if [[ "${_pkg_dep}" == "${altRemotepkg}" ]]; then
  359. if [[ $(pkg_installcheck ${altRemotepkg}) -ne 0 ]]; then
  360. # TODO remove duplicate functionality
  361. if [[ $(apt-cache show "${altRemotepkg}" | grep -m1 -oP "(?<=^Version: )[0-9|\.]*" | sed 's/\.//g') < ${altRemotever} ]]; then
  362. pkg_localinstall ${remotePackagesAlt["${altRemote}"]} "${altRemotepkg}"
  363. pkg_configure "${altRemotepkg}" ${remotePackagesAlt["${altRemote}"]}
  364. else
  365. pkg_remoteinstall "${altRemotepkg}"
  366. pkg_configure "${altRemotepkg}"
  367. fi
  368. else
  369. if [[ $(dpkg -s "${altRemotepkg}" | grep -m1 -oP "(?<=^Version: )[0-9|\.]*" | sed 's/\.//g') < ${altRemotever} ]]; then
  370. pkg_localinstall ${remotePackagesAlt["${altRemote}"]} "${altRemotepkg}"
  371. pkg_configure "${altRemotepkg}" ${remotePackagesAlt["${altRemote}"]}
  372. else
  373. pkg_remoteinstall "${altRemotepkg}"
  374. pkg_configure "${altRemotepkg}"
  375. fi
  376. fi
  377. fi
  378. done
  379. fi
  380. if [[ $(pkg_installcheck ${_pkg_dep}) -ne 0 ]]; then
  381. pkg_remoteinstall "${_pkg_dep}"
  382. pkg_configure "${_pkg_dep}"
  383. fi
  384. if [[ $? -eq 0 ]]; then
  385. let b++
  386. else
  387. echo -e "\n\e[1mERROR:\e[0m Error occured while installing ${_pkg_dep}. Aborting.\n"
  388. exit 1
  389. fi
  390. done
  391. if [[ -n ${_validlist[*]} ]]; then
  392. # Add empty newline
  393. echo ""
  394. fi
  395. }
  396. ############################
  397. # COMMON - RETRIEVE PACKAGE
  398. # GIT VERSION TAG
  399. # Get git-based version in order to rename the package main folder
  400. # This is required by deb builder. It retrieves the version number
  401. # from that folder name
  402. function pkg_gitversion() {
  403. if [[ -n "${_pkg_gitver}" ]] && [[ "${_pkg_gitver}" =~ ^git ]]; then
  404. cd ${_pkg_name}
  405. git checkout ${_pkg_gitbranch}
  406. git reset --hard ${_git_commithash}
  407. if [[ $? -ne 0 ]]; then
  408. echo -e "\e[1mERROR:\e[0m Couldn't find commit ${_git_commithash} for ${_pkg_name}. Aborting\n"
  409. exit 1
  410. fi
  411. _pkg_gitver=$(eval "${_pkg_gitver}")
  412. cd ..
  413. fi
  414. }
  415. ############################
  416. # COMMON - OVERWRITE
  417. # DEBIAN BUILD ENV FILES
  418. # Overwrite a file which is given as user input
  419. # The contents are supplied as input, too.
  420. function pkg_override_debianfile() {
  421. local contents=${1}
  422. local targetfile=${2}
  423. if [[ ${contents} != "empty" ]]; then
  424. echo "${contents}" > "${targetfile}"
  425. if [[ $? -ne 0 ]]; then
  426. echo -e "\e[1mERROR:\e[0m Couldn't create Debian file '${targetfile}' for ${_pkg_name}. Aborting\n"
  427. exit 1
  428. fi
  429. fi
  430. }
  431. ############################
  432. # COMMON - GET SOURCE AND
  433. # PREPARE SOURCE FOLDER
  434. function pkg_folderprepare() {
  435. # Remove old build directory, if present
  436. rm -rf ${_pkg_name}
  437. # Create a new build directory, access it and download git sources there
  438. mkdir ${_pkg_name}
  439. cd ${_pkg_name}
  440. echo -e "Retrieving source code of ${_pkg_name} from $(printf ${_pkg_giturl} | sed 's/^.*\/\///; s/\/.*//')\n"
  441. git clone ${_pkg_giturl} ${_pkg_name}
  442. # If sources could be downloaded, rename the folder properly for deb builder
  443. # Access the folder after which package specific debianbuild function will be run
  444. # That function is defined inside package specific install_main function below
  445. if [[ $? -eq 0 ]]; then
  446. pkg_gitversion && \
  447. mv ${_pkg_name} ${_pkg_name}-${_pkg_gitver}
  448. cd ${_pkg_name}-${_pkg_gitver}
  449. dh_make --createorig -s -y -c ${_pkg_license} && \
  450. pkg_override_debianfile "${_pkg_debinstall}" "${_pkg_installfile}"
  451. pkg_override_debianfile "${_pkg_debcontrol}" "${_pkg_controlfile}"
  452. pkg_override_debianfile "${_pkg_debrules}" "${_pkg_rulesfile}"
  453. else
  454. echo -e "\e[1mERROR:\e[0m Error while downloading source of ${_pkg_name} package. Aborting\n"
  455. exit 1
  456. fi
  457. }
  458. ############################
  459. # COMMON - COMPILE, INSTALL
  460. # AND STORE DEB PACKAGE
  461. function pkg_debianbuild() {
  462. # Start deb builder
  463. bash -c "${_pkg_debbuilder}"
  464. # Once our deb package is compiled, install and store it
  465. # We do not make installation optional because this is a core dependency for DXVK
  466. if [[ $? -eq 0 ]]; then
  467. rm -rf ../*.{changes,buildinfo,tar.xz} && \
  468. sudo dpkg -i ../${_pkg_name}*.deb && \
  469. mv ../${_pkg_name}*.deb ../../../compiled_deb/"${datedir}" && \
  470. echo -e "Compiled ${_pkg_name} is stored at '$(readlink -f ../../../compiled_deb/"${datedir}")/'\n"
  471. cd ../..
  472. rm -rf {${_pkg_name},*.deb}
  473. else
  474. buildpkg_removal
  475. exit 1
  476. fi
  477. }
  478. ############################
  479. # COMMON - EXECUTION HOOKS
  480. pkg_dependencies "${_pkg_deps_build[*]}" buildtime
  481. if [[ ${_pkg_deps_runtime[0]} != "empty" ]] && [[ ! -v NO_INSTALL ]]; then
  482. pkg_dependencies "${_pkg_deps_runtime[*]}" runtime
  483. fi
  484. pkg_folderprepare
  485. # TODO use package name or separate override switch here?
  486. if [[ "${_pkg_name}" == *"dxvk"* ]]; then
  487. dxvk_install_custom "dxvk_custom_patches"
  488. fi
  489. if [[ "${_pkg_name}" == *"d9vk"* ]]; then
  490. dxvk_install_custom "d9vk_custom_patches"
  491. fi
  492. pkg_debianbuild
  493. unset _pkg_gitver
  494. }
  495. ########################################################
  496. # BUILD DEPENDENCIES REMOVAL
  497. function buildpkg_removal() {
  498. _buildpkglist=($(echo ${_buildpkglist[@]} | tr ' ' '\n' |sort -u | tr '\n' ' '))
  499. for link in ${!tempLinks[@]}; do
  500. if [[ $(file ${link}) == *"symbolic link"* ]]; then
  501. sudo rm -f "${link}"
  502. fi
  503. done
  504. # Build time dependencies which were installed but no longer needed
  505. if [[ -v _buildpkglist ]]; then
  506. if [[ -v BUILDPKG_RM ]]; then
  507. sudo apt purge --remove -y ${_buildpkglist[*]}
  508. # In some cases, glslang or meson may still be present on the system. Remove them
  509. for _extrapkg in glslang meson; do
  510. if [[ $(echo $(dpkg -s ${_extrapkg} &>/dev/null)$?) -eq 0 ]]; then
  511. sudo dpkg --remove --force-remove-reinstreq ${_extrapkg}
  512. fi
  513. done
  514. # Manually obtained deb packages are expected to break system configuration, thus we need to fix it.
  515. sudo apt --fix-broken -y install
  516. else
  517. 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"
  518. fi
  519. fi
  520. }
  521. ########################################################
  522. # Package installation instructions
  523. function pkg_install_main() {
  524. # Read necessary variables from debdata file
  525. local pkg_datafile=${1}
  526. if [[ -f ${pkg_datafile} ]]; then
  527. source ${pkg_datafile}
  528. else
  529. echo -e "\e[1mERROR:\e[0m Couldn't read datafile '${pkg_datafile}'. Check the file path and try again.\n"
  530. exit 1
  531. fi
  532. ############################
  533. # Prepare these arrays for 'compile_and_install_deb' input
  534. # Separate each array index with | in these arrays
  535. function pkg_arrayparser() {
  536. local pkg_arrays=(
  537. 'pkg_deps_build'
  538. 'pkg_deps_runtime'
  539. )
  540. local IFS=$'\n'
  541. for w in ${pkg_arrays[@]}; do
  542. local s=\${${w}[@]}
  543. local t=$(eval printf '%s\|' ${s})
  544. unset ${w}
  545. eval ${w}=\"${t}\"
  546. done
  547. }
  548. ############################
  549. # Execute package installation procedure
  550. pkg_arrayparser && \
  551. compile_and_install_deb \
  552. "${pkg_name}" \
  553. "${pkg_license}" \
  554. "${pkg_giturl}" \
  555. "${pkg_gitbranch}" \
  556. "${git_commithash}" \
  557. "${pkg_gitver}" \
  558. "${pkg_debinstall}" \
  559. "${pkg_debcontrol}" \
  560. "${pkg_debrules}" \
  561. "${pkg_installfile}" \
  562. "${pkg_controlfile}" \
  563. "${pkg_rulesfile}" \
  564. "${pkg_deps_build}" \
  565. "${pkg_deps_runtime}" \
  566. "${pkg_debbuilder}"
  567. }
  568. ########################################################
  569. # Check existence of known Wine packages
  570. runtimeCheck Wine "${known_wines[*]}"
  571. # Meson - compile (& install)
  572. pkgcompilecheck pkg_install_main meson "${DXVKROOT}/meson.debdata"
  573. # Glslang - compile (& install)
  574. pkgcompilecheck pkg_install_main glslang "${DXVKROOT}/glslang.debdata"
  575. if [[ ! -v NO_DXVK ]]; then
  576. # DXVK - compile (& install)
  577. pkg_install_main "${DXVKROOT}/dxvk.debdata"
  578. fi
  579. if [[ ! -v NO_D9VK ]]; then
  580. # D9VK - compile (& install)
  581. pkg_install_main "${DXVKROOT}/d9vk.debdata"
  582. fi
  583. # Clean buildtime dependencies
  584. buildpkg_removal