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.

842 lines
21 KiB

6 years ago
  1. #!/bin/env bash
  2. # Wine/Wine Staging build script for Debian & variants (amd64)
  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 variable supplied by ../updatewine_debian.sh script file
  21. datedir="${1}"
  22. ########################################################
  23. # Staging patchsets. Default: all patchsets.
  24. # Applies only if Wine Staging is set to be compiled
  25. # Please see Wine Staging patchinstall.sh file for individual patchset names.
  26. staging_patchsets=(--all)
  27. ########################################################
  28. # Wine build dependency lists on Debian
  29. wine_deps_build_common=(
  30. 'make'
  31. 'gcc-multilib'
  32. 'g++-multilib'
  33. 'libxml-simple-perl'
  34. 'libxml-parser-perl'
  35. 'libxml-libxml-perl'
  36. 'lzma'
  37. 'flex'
  38. 'bison'
  39. 'quilt'
  40. 'gettext'
  41. # 'oss4-dev' # Not available on Debian
  42. 'sharutils'
  43. 'pkg-config'
  44. 'dctrl-tools'
  45. 'khronos-api'
  46. 'unicode-data'
  47. 'freebsd-glue'
  48. 'icoutils'
  49. 'librsvg2-bin'
  50. 'imagemagick'
  51. 'fontforge'
  52. )
  53. wine_deps_build_amd64=(
  54. 'libxi-dev:amd64'
  55. 'libxt-dev:amd64'
  56. 'libxmu-dev:amd64'
  57. 'libx11-dev:amd64'
  58. 'libxext-dev:amd64'
  59. 'libxfixes-dev:amd64'
  60. 'libxrandr-dev:amd64'
  61. 'libxcursor-dev:amd64'
  62. 'libxrender-dev:amd64'
  63. 'libxkbfile-dev:amd64'
  64. 'libxxf86vm-dev:amd64'
  65. 'libxxf86dga-dev:amd64'
  66. 'libxinerama-dev:amd64'
  67. 'libgl1-mesa-dev:amd64'
  68. 'libglu1-mesa-dev:amd64'
  69. 'libxcomposite-dev:amd64'
  70. 'libpng-dev:amd64'
  71. 'libssl-dev:amd64'
  72. 'libv4l-dev:amd64'
  73. 'libxml2-dev:amd64'
  74. 'libgsm1-dev:amd64'
  75. 'libjpeg-dev:amd64'
  76. 'libkrb5-dev:amd64'
  77. 'libtiff-dev:amd64'
  78. 'libsane-dev:amd64'
  79. 'libudev-dev:amd64'
  80. 'libpulse-dev:amd64'
  81. 'liblcms2-dev:amd64'
  82. 'libldap2-dev:amd64'
  83. 'libxslt1-dev:amd64'
  84. 'unixodbc-dev:amd64'
  85. 'libcups2-dev:amd64'
  86. 'libcapi20-dev:amd64'
  87. 'libopenal-dev:amd64'
  88. 'libdbus-1-dev:amd64'
  89. 'freeglut3-dev:amd64'
  90. 'libmpg123-dev:amd64'
  91. 'libasound2-dev:amd64'
  92. 'libgphoto2-dev:amd64'
  93. 'libosmesa6-dev:amd64'
  94. 'libpcap0.8-dev:amd64'
  95. 'libgnutls28-dev:amd64'
  96. 'libncurses5-dev:amd64'
  97. 'libgettextpo-dev:amd64'
  98. 'libfreetype6-dev:amd64'
  99. 'libfontconfig1-dev:amd64'
  100. 'libgstreamer-plugins-base1.0-dev:amd64'
  101. 'ocl-icd-opencl-dev:amd64'
  102. 'libvulkan-dev:amd64'
  103. )
  104. wine_deps_build_i386=(
  105. 'libxi-dev:i386'
  106. 'libxt-dev:i386'
  107. 'libxmu-dev:i386'
  108. 'libx11-dev:i386'
  109. 'libxext-dev:i386'
  110. 'libxfixes-dev:i386'
  111. 'libxrandr-dev:i386'
  112. 'libxcursor-dev:i386'
  113. 'libxrender-dev:i386'
  114. 'libxkbfile-dev:i386'
  115. 'libxxf86vm-dev:i386'
  116. 'libxxf86dga-dev:i386'
  117. 'libxinerama-dev:i386'
  118. 'libgl1-mesa-dev:i386'
  119. 'libglu1-mesa-dev:i386'
  120. 'libxcomposite-dev:i386'
  121. 'libpng-dev:i386'
  122. 'libssl-dev:i386'
  123. 'libv4l-dev:i386'
  124. 'libgsm1-dev:i386'
  125. 'libjpeg-dev:i386'
  126. 'libkrb5-dev:i386'
  127. 'libsane-dev:i386'
  128. 'libudev-dev:i386'
  129. 'libpulse-dev:i386'
  130. 'liblcms2-dev:i386'
  131. 'libldap2-dev:i386'
  132. 'unixodbc-dev:i386'
  133. 'libcapi20-dev:i386'
  134. 'libopenal-dev:i386'
  135. 'libdbus-1-dev:i386'
  136. 'freeglut3-dev:i386'
  137. 'libmpg123-dev:i386'
  138. 'libasound2-dev:i386'
  139. 'libgphoto2-dev:i386'
  140. 'libosmesa6-dev:i386'
  141. 'libpcap0.8-dev:i386'
  142. 'libncurses5-dev:i386'
  143. 'libgettextpo-dev:i386'
  144. 'libfreetype6-dev:i386'
  145. 'libfontconfig1-dev:i386'
  146. 'ocl-icd-opencl-dev:i386'
  147. 'libvulkan-dev:i386'
  148. 'libicu-dev:i386'
  149. 'libxml2-dev:i386'
  150. 'libxslt1-dev:i386'
  151. 'libtiff-dev:i386'
  152. 'libcups2-dev:i386'
  153. 'libgnutls28-dev:i386'
  154. 'gir1.2-gstreamer-1.0:i386' #required by libgstreamer1.0-dev:i386 (Mint)
  155. 'libgstreamer1.0-dev:i386'
  156. 'libgstreamer-plugins-base1.0-dev:i386'
  157. )
  158. ########################################################
  159. # Wine runtime dependency lists on Debian
  160. wine_deps_runtime_common=(
  161. 'desktop-file-utils'
  162. )
  163. wine_deps_runtime_i386=(
  164. 'libxcursor1:i386'
  165. 'libxrandr2:i386'
  166. 'libxi6:i386'
  167. # 'gettext:i386' # Conflicts with amd64 version on multiple distros
  168. 'libsm6:i386'
  169. 'libvulkan1:i386'
  170. 'libasound2:i386'
  171. 'libc6:i386'
  172. 'libfontconfig1:i386'
  173. 'libfreetype6:i386'
  174. 'libgcc1:i386'
  175. 'libglib2.0-0:i386'
  176. 'libgphoto2-6:i386'
  177. 'libgphoto2-port12:i386'
  178. 'liblcms2-2:i386'
  179. 'libldap-2.4-2:i386'
  180. 'libmpg123-0:i386'
  181. 'libncurses5:i386'
  182. 'libopenal1:i386'
  183. 'libpcap0.8:i386'
  184. 'libpulse0:i386'
  185. 'libtinfo5:i386'
  186. 'libudev1:i386'
  187. 'libx11-6:i386'
  188. 'libxext6:i386'
  189. 'libxml2:i386'
  190. 'ocl-icd-libopencl1:i386'
  191. 'zlib1g:i386'
  192. 'libgstreamer-plugins-base1.0-0:i386'
  193. 'libgstreamer1.0-0:i386'
  194. )
  195. wine_deps_runtime_amd64=(
  196. 'fontconfig:amd64'
  197. 'libxcursor1:amd64'
  198. 'libxrandr2:amd64'
  199. 'libxi6:amd64'
  200. 'gettext:amd64'
  201. 'libsm6:amd64'
  202. 'libvulkan1:amd64'
  203. 'libasound2:amd64'
  204. 'libc6:amd64'
  205. 'libfontconfig1:amd64'
  206. 'libfreetype6:amd64'
  207. 'libgcc1:amd64'
  208. 'libglib2.0-0:amd64'
  209. 'libgphoto2-6:amd64'
  210. 'libgphoto2-port12:amd64'
  211. 'liblcms2-2:amd64'
  212. 'libldap-2.4-2:amd64'
  213. 'libmpg123-0:amd64'
  214. 'libncurses5:amd64'
  215. 'libopenal1:amd64'
  216. 'libpcap0.8:amd64'
  217. 'libpulse0:amd64'
  218. 'libtinfo5:amd64'
  219. 'libudev1:amd64'
  220. 'libx11-6:amd64'
  221. 'libxext6:amd64'
  222. 'libxml2:amd64'
  223. 'ocl-icd-libopencl1:amd64'
  224. 'zlib1g:amd64'
  225. 'libgstreamer-plugins-base1.0-0:amd64'
  226. 'libgstreamer1.0-0:amd64'
  227. )
  228. ########################################################
  229. # Wine staging override list
  230. # Wine Staging replaces and conflicts with these packages
  231. # Applies to debian/control file
  232. wine_overr_pkgs=(
  233. 'wine'
  234. 'wine-development'
  235. 'wine64-development'
  236. 'wine1.6'
  237. 'wine1.6-i386'
  238. 'wine1.6-amd64'
  239. 'libwine:amd64'
  240. 'libwine:i386'
  241. 'wine-stable'
  242. 'wine32'
  243. 'wine64'
  244. 'fonts-wine'
  245. )
  246. ############################
  247. # Suggest section in debian/control file
  248. wine_suggested_pkgs=(
  249. 'winbind'
  250. 'winetricks'
  251. 'playonlinux'
  252. 'wine-binfmt'
  253. 'dosbox'
  254. )
  255. ########################################################
  256. # Architecture check. We do not support independent
  257. # i386 environments
  258. if [[ $(uname -a | grep -c x86_64) -eq 0 ]]; then
  259. echo "This script supports 64-bit architectures only."
  260. exit 1
  261. fi
  262. ########################################################
  263. # Parse input arguments
  264. i=0
  265. for arg in ${@:2}; do
  266. args[$i]="${arg}"
  267. let i++
  268. done
  269. # Must be a true array as defined above, not a single index list!
  270. #args="${@:2}"
  271. for check in ${args[@]}; do
  272. case ${check} in
  273. --no-staging)
  274. NO_STAGING=
  275. ;;
  276. --no-install)
  277. NO_INSTALL=
  278. ;;
  279. --buildpkg-rm)
  280. BUILDPKG_RM=
  281. ;;
  282. esac
  283. done
  284. ########################################################
  285. # If the script is interrupted (Ctrl+C/SIGINT), do the following
  286. function Wine_intCleanup() {
  287. cd ..
  288. rm -rf winebuild_${datedir}
  289. exit 0
  290. }
  291. # Allow interruption of the script at any time (Ctrl + C)
  292. trap "Wine_intCleanup" INT
  293. ########################################################
  294. # This is specifically for Debian
  295. # Must be done in order to install Wine i386 buildtime dependencies on amd64 environment
  296. #
  297. if [[ $(dpkg --print-foreign-architectures | grep i386 | wc -w) -eq 0 ]]; then
  298. sudo dpkg --add-architecture i386
  299. sudo apt update
  300. fi
  301. ########################################################
  302. # If user has gstreamer girl (amd64) package installed on the system
  303. # before Wine compilation, then reinstall it after the compilation process
  304. #
  305. function girl_check() {
  306. girlpkg="gir1.2-gstreamer-1.0:amd64"
  307. if [[ $(echo $(dpkg -s ${girlpkg} &>/dev/null)$?) -eq 0 ]]; then
  308. GIRL_CHECK=
  309. fi
  310. }
  311. ########################################################
  312. function getWine() {
  313. local wine_url="git://source.winehq.org/git/wine.git"
  314. local winestaging_url="git://github.com/wine-staging/wine-staging.git"
  315. function cleanOldBuilds() {
  316. if [[ $(find . -type d -name "winebuild_*" | wc -l) -ne 0 ]]; then
  317. echo -e "Removing old Wine build folders. This can take a while.\n"
  318. rm -rf ./winebuild_*
  319. fi
  320. }
  321. cleanOldBuilds
  322. mkdir winebuild_${datedir}
  323. cd winebuild_${datedir}
  324. WINEROOT="${PWD}"
  325. echo -e "Retrieving source code of Wine$(if [[ ! -v NO_STAGING ]]; then echo ' & Wine Staging' ; fi)\n"
  326. git clone ${wine_url}
  327. if [[ ! -v NO_STAGING ]]; then
  328. git clone ${winestaging_url}
  329. WINEDIR_STAGING="${WINEROOT}/wine-staging"
  330. PKGNAME="wine-staging-git"
  331. else
  332. PKGNAME="wine-git"
  333. fi
  334. mkdir wine-{patches,32-build,32-install,64-build,64-install,package}
  335. cp -r ../../../wine_custom_patches/*.{patch,diff} wine-patches/ 2>/dev/null
  336. WINEDIR="${WINEROOT}/wine"
  337. WINEDIR_PATCHES="${WINEROOT}/wine-patches"
  338. WINEDIR_BUILD_32="${WINEROOT}/wine-32-build"
  339. WINEDIR_BUILD_64="${WINEROOT}/wine-64-build"
  340. WINEDIR_INSTALL_32="${WINEROOT}/wine-32-install"
  341. WINEDIR_INSTALL_64="${WINEROOT}/wine-64-install"
  342. WINEDIR_PACKAGE="${WINEROOT}/wine-package"
  343. }
  344. function getDebianFiles() {
  345. local debian_archive=wine_3.0-1ubuntu1.debian.tar.xz
  346. cd "${WINEDIR}"
  347. wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wine/${debian_archive}
  348. tar xvf ${debian_archive}
  349. rm ${debian_archive}
  350. }
  351. ########################################################
  352. # Wine dependencies removal/installation
  353. # Global variable to track buildtime dependencies
  354. z=0
  355. function WineDeps() {
  356. local method=${1}
  357. local deps="${2}"
  358. local depsname=${3}
  359. local pkgtype=${4}
  360. case ${method} in
  361. install)
  362. local str="Installing"
  363. local mgrcmd="sudo apt install -y"
  364. ;;
  365. remove)
  366. local str="Removing"
  367. local mgrcmd="sudo apt purge --remove -y"
  368. ;;
  369. *)
  370. echo -e "Error: Unknown package management input method. Aborting\n"
  371. exit 1
  372. esac
  373. echo -e "${str} Wine dependencies (${depsname}).\n"
  374. # Check and install/remove package related dependencies if they are missing/installed
  375. function pkgdependencies() {
  376. local deplist="${1}"
  377. # Get a valid logic for generating 'list' array below
  378. case ${method} in
  379. install)
  380. # Package is not installed, install it
  381. local checkstatus=0
  382. ;;
  383. remove)
  384. # Package is installed, remove it
  385. local checkstatus=1
  386. ;;
  387. esac
  388. # Generate a list of missing/removable dependencies, depending on the logic
  389. local a=0
  390. for p in ${deplist[@]}; do
  391. if [[ $(echo $(dpkg -s ${p} &>/dev/null)$?) -ne ${checkstatus} ]]; then
  392. local validlist[$a]=${p}
  393. let a++
  394. # Global array to track installed build dependencies
  395. if [[ ${method} == "install" ]] && [[ ${pkgtype} == "buildtime" ]]; then
  396. buildpkglist[$z]=${p}
  397. let z++
  398. fi
  399. fi
  400. done
  401. # Install missing/Remove existing dependencies, be informative
  402. local b=0
  403. for pkgdep in ${validlist[@]}; do
  404. echo -e "$(( $b + 1 ))/$(( ${#validlist[*]} )) - ${str} ${depsname} dependency ${pkgdep}"
  405. eval ${mgrcmd} ${pkgdep} &> /dev/null
  406. if [[ $? -eq 0 ]]; then
  407. let b++
  408. else
  409. echo -e "\nError occured while processing ${pkgdep}. Aborting.\n"
  410. exit 1
  411. fi
  412. done
  413. if [[ -n ${validlist[*]} ]]; then
  414. # Add empty newline
  415. echo ""
  416. fi
  417. }
  418. pkgdependencies "${deps[*]}"
  419. }
  420. ########################################################
  421. # Feed the following data to Wine debian/control file
  422. # If we separate i386 build to be an independent one, this function
  423. # must be improved, if built with amd64 package together
  424. # If we just bundle them together, single package description for
  425. # debian/control file is enough
  426. function feedControlfile() {
  427. local MAINTAINER="$USER"
  428. sed -ie "s/^Build-Depends:.*$/Build-Depends: debhelper (>=10), $(echo ${wine_deps_build[*]} | sed 's/\s/, /g')/g" debian/control
  429. sed -ie "s/^Depends:.*$/Depends: $(echo ${wine_deps_runtime[*]} | sed 's/\s/, /g')/g" debian/control
  430. sed -ie "s/^Suggests:.*$/Suggests: $(echo ${wine_suggested_pkgs[*]} | sed 's/\s/, /g')/g" debian/control
  431. sed -ie "s/^Maintainer:.*$/Maintainer: ${MAINTAINER}/g" debian/control
  432. sed -ie "s/^Source:.*$/Source: ${PKGNAME}/g" debian/control
  433. sed -ie "s/^Package:.*$/Package: ${PKGNAME}/g" debian/control
  434. for ctrl_section in Conflicts Breaks Replaces Provides; do
  435. sed -ie "s/^${ctrl_section}:.*$/${ctrl_section}: $(echo ${wine_overr_pkgs[*]} | sed 's/\s/, /g')/g" debian/control
  436. done
  437. }
  438. ########################################################
  439. # Refresh Wine GIT
  440. function refreshWineGIT() {
  441. # Restore the wine tree to its git origin state, without wine-staging patches
  442. # (necessary for reapllying wine-staging patches in succedent builds,
  443. # otherwise the patches will fail to be reapplied)
  444. cd "${WINEDIR}"
  445. git reset --hard HEAD # Restore tracked files
  446. git clean -d -x -f # Delete untracked files
  447. if [[ ! -v NO_STAGING ]]; then
  448. # Change back to the wine upstream commit that this version of wine-staging is based on
  449. git checkout $(bash "${WINEDIR_STAGING}"/patches/patchinstall.sh --upstream-commit)
  450. fi
  451. }
  452. ########################################################
  453. # Get Wine version tag
  454. function getWineVersion() {
  455. cd "${WINEDIR}"
  456. wine_version=$(git describe | sed 's/^[a-z]*-//; s/-[0-9]*-[a-z0-9]*$//')
  457. }
  458. ########################################################
  459. # Apply patches
  460. function patchWineSource() {
  461. if [[ ! -v NO_STAGING ]]; then
  462. cd "${WINEDIR_STAGING}/patches"
  463. bash ./patchinstall.sh DESTDIR="${WINEDIR}" ${staging_patchsets[*]}
  464. fi
  465. cp -r ${WINEROOT}/../../../wine_custom_patches/* "${WINEDIR_PATCHES}/"
  466. if [[ $(find "${WINEDIR_PATCHES}" -mindepth 1 -maxdepth 1 -regex ".*\.\(patch\|diff\)$") ]]; then
  467. cd "${WINEDIR}"
  468. for i in "${WINEDIR_PATCHES}"/*.patch; do
  469. patch -Np1 < $i
  470. done
  471. fi
  472. }
  473. ########################################################
  474. # 64-bit build
  475. function wine64Build() {
  476. cd "${WINEDIR_BUILD_64}"
  477. "${WINEDIR}"/configure \
  478. --with-x \
  479. --with-gstreamer \
  480. --enable-win64 \
  481. --with-xattr \
  482. --disable-mscoree \
  483. --with-vulkan \
  484. --prefix=/usr \
  485. --libdir=/usr/lib/x86_64-linux-gnu/
  486. make -j$(nproc --ignore 1)
  487. make -j$(nproc --ignore 1) prefix="${WINEDIR_INSTALL_64}/usr" \
  488. libdir="${WINEDIR_INSTALL_64}/usr/lib/x86_64-linux-gnu/" \
  489. dlldir="${WINEDIR_INSTALL_64}/usr/lib/x86_64-linux-gnu/wine" install
  490. }
  491. # 32-bit build
  492. function wine32Build() {
  493. # Gstreamer amd64 & i386 dev packages conflict on Ubuntu
  494. cd "${WINEDIR_BUILD_32}"
  495. "${WINEDIR}"/configure \
  496. --with-x \
  497. --with-gstreamer \
  498. --with-xattr \
  499. --disable-mscoree \
  500. --with-vulkan \
  501. --without-gstreamer \
  502. --libdir=/usr/lib/i386-linux-gnu/ \
  503. --with-wine64="${WINEDIR_BUILD_64}" \
  504. --prefix=/usr
  505. make -j$(nproc --ignore 1)
  506. make -j$(nproc --ignore 1) prefix="${WINEDIR_INSTALL_32}/usr" \
  507. libdir="${WINEDIR_INSTALL_32}/usr/lib/i386-linux-gnu/" \
  508. dlldir="${WINEDIR_INSTALL_32}/usr/lib/i386-linux-gnu/wine" install
  509. }
  510. ########################################################
  511. # Merge compiled files, build Debian archive
  512. function mergeWineBuilds() {
  513. cp -r "${WINEDIR_INSTALL_64}"/* "${WINEDIR_PACKAGE}"/
  514. cp -r "${WINEDIR_INSTALL_32}"/usr/bin/{wine,wine-preloader} "${WINEDIR_PACKAGE}"/usr/bin/
  515. cp -r "${WINEDIR_INSTALL_32}"/usr/lib/* "${WINEDIR_PACKAGE}"/usr/lib/
  516. }
  517. function buildDebianArchive() {
  518. cd "${WINEROOT}"
  519. mv "${WINEDIR_PACKAGE}" "${WINEROOT}/${PKGNAME}-${wine_version}"
  520. cd "${WINEROOT}/${PKGNAME}-${wine_version}"
  521. dh_make --createorig -s -y -c lgpl
  522. rm debian/*.{ex,EX}
  523. printf "usr/* /usr" > debian/install
  524. cat << 'DEBIANCONTROL' > debian/control
  525. Source:
  526. Section: otherosfs
  527. Priority: optional
  528. Maintainer:
  529. Build-Depends:
  530. Standards-Version: 4.1.2
  531. Homepage: https://www.winehq.org
  532. Package:
  533. Architecture: any
  534. Depends:
  535. Suggests:
  536. Conflicts:
  537. Breaks:
  538. Replaces:
  539. Provides:
  540. Description: A compatibility layer for running Windows programs.
  541. Wine is an open source Microsoft Windows API implementation for
  542. POSIX-compliant operating systems, including Linux.
  543. Git version includes the latest updates available for Wine.
  544. DEBIANCONTROL
  545. feedControlfile
  546. # Start compilation process
  547. DEB_BUILD_OPTIONS="strip nodocs noddebs" dpkg-buildpackage -b -us -uc
  548. }
  549. function installDebianArchive() {
  550. cd "${WINEROOT}"
  551. # TODO Although the package name ends with 'amd64', this contains both 32 and 64 bit Wine versions
  552. echo -e "\nInstalling Wine$(if [[ -v ! NO_STAGING ]]; then printf " Staging"; fi).\n"
  553. sudo dpkg -i ${PKGNAME}_${wine_version}-1_amd64.deb
  554. }
  555. function storeDebianArchive() {
  556. cd "${WINEROOT}"
  557. mv ${PKGNAME}_${wine_version}-1_amd64.deb ../../compiled_deb/"${datedir}" && \
  558. echo -e "Compiled ${PKGNAME} is stored at '$(readlink -f ../../compiled_deb/"${datedir}")/'\n"
  559. rm -rf winebuild_${datedir}
  560. }
  561. function cleanTree() {
  562. rm -rf "${WINEROOT}"
  563. }
  564. ###########################################################
  565. # Check presence of Wine if compiled deb is going to be installed
  566. # This function is not relevant if --no-install switch is used
  567. function wineCheck() {
  568. # Known Wine package names to check on Debian
  569. local known_wines=(
  570. 'wine'
  571. 'wine32'
  572. 'wine64'
  573. 'wine-git'
  574. 'wine-staging-git'
  575. 'libwine:amd64'
  576. 'libwine:i386'
  577. 'fonts-wine'
  578. )
  579. # Check if any of these Wine packages are present on the system
  580. for winepkg in ${known_wines[@]}; do
  581. if [[ $(echo $(dpkg -s ${winepkg} &>/dev/null)$?) -eq 0 ]]; then
  582. sudo apt purge --remove -y ${winepkg}
  583. fi
  584. done
  585. }
  586. ########################################################
  587. # Check existence of gstreamer girl package before further operations
  588. girl_check
  589. ##########################
  590. # Get Wine (& Wine-Staging) sources
  591. getWine
  592. ##########################
  593. # Refresh & sync Wine (+ Wine Staging) git sources
  594. refreshWineGIT
  595. # Update Wine source files
  596. patchWineSource
  597. # Get Wine/Wine Staging version
  598. getWineVersion
  599. ########################################################
  600. # Compile 64 & 32 bit Wine/Wine Staging
  601. # WE MUST BUILD 64-BIT FIRST, THEN 32-BIT. THIS ORDER IS MANDATORY!
  602. # We split 64-bit & 32-bit compilation due to two major reasons:
  603. # - pure Debian has major conflicts between 32/64 bit dev packages
  604. # - on Mint/Ubuntu, some 32-bit dev packages must be excluded due to conflicts, too
  605. ##########################
  606. # Install Wine common buildtime dependencies
  607. WineDeps install "${wine_deps_build_common[*]}" "Wine common build time" buildtime
  608. ##########################
  609. # TODO If we do architecture separation in the future, add if check for amd64 here
  610. # Condition would be: if amd64, then
  611. #
  612. # Purge i386 buildtime dependencies
  613. # On Debian, we can't have them with i386 at the same time
  614. #
  615. echo -e "Preparing system environment for 64-bit Wine compilation.\n"
  616. WineDeps remove "${wine_deps_build_i386[*]}" "Wine build time (32-bit)" buildtime
  617. WineDeps install "${wine_deps_build_amd64[*]}" "Wine build time (64-bit)" buildtime
  618. wine64Build && \
  619. echo -e "\nWine 64-bit build process finished.\n"
  620. ##########################
  621. # TODO If we do architecture separation in the future, add if check for i386 here
  622. # Condition would be: if i386 or amd64, then
  623. #
  624. # Purge amd64 buildtime dependencies
  625. # On Debian, we can't have them with i386 at the same time
  626. #
  627. echo -e "Preparing system environment for 32-bit Wine compilation.\n"
  628. WineDeps remove "${wine_deps_build_amd64[*]}" "Wine build time (64-bit)" buildtime
  629. WineDeps install "${wine_deps_build_i386[*]}" "Wine build time (32-bit)" buildtime
  630. wine32Build &&
  631. echo -e "\nWine 32-bit build process finished.\n"
  632. ##########################
  633. # Remove i386 buildtime dependencies after successful compilation process
  634. WineDeps remove "${wine_deps_build_i386[*]}" "Wine build time (32-bit)" buildtime
  635. ##########################
  636. # i386/amd64 runtime dependencies have been tested and they are able to co-exist on Debian system
  637. if [[ ! -v NO_INSTALL ]]; then
  638. # Install Wine common runtime dependencies
  639. WineDeps install "${wine_deps_runtime_common[*]}" "Wine common runtime" runtime
  640. # Install architecture-dependent Wine runtime dependencies
  641. WineDeps install "${wine_deps_runtime_amd64[*]}" "Wine runtime (64-bit)" runtime
  642. WineDeps install "${wine_deps_runtime_i386[*]}" "Wine runtime (32-bit)" runtime
  643. # Check presence of already installed Wine packages and remove them
  644. wineCheck
  645. fi
  646. ##########################
  647. # Build time dependencies which were installed but no longer needed
  648. if [[ -v buildpkglist ]]; then
  649. if [[ -v BUILDPKG_RM ]]; then
  650. sudo apt purge --remove -y "${buildpkglist[*]}"
  651. else
  652. 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"
  653. fi
  654. fi
  655. ##########################
  656. if [[ -v GIRL_CHECK ]]; then
  657. sudo apt install -y ${girlpkg}
  658. fi
  659. ########################################################
  660. # Bundle compiled Wine/Wine-Staging files
  661. mergeWineBuilds
  662. # Bundle and install Debian deb archive
  663. buildDebianArchive
  664. if [[ ! -v NO_INSTALL ]]; then
  665. installDebianArchive
  666. fi
  667. storeDebianArchive
  668. # Clean all temporary files
  669. cleanTree