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.

742 lines
21 KiB

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