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.

639 lines
15 KiB

  1. #!/bin/env bash
  2. # Wine/Wine Staging build script for Ubuntu & 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. #
  21. # Staging patchsets. Default: all patchsets.
  22. # Applies only if Wine Staging is set to be compiled
  23. # Please see Wine Staging patchinstall.sh file for individual patchset names.
  24. staging_patchsets=(--all)
  25. ########################################################
  26. datedir="${1}"
  27. ########################################################
  28. # Parse input arguments
  29. i=0
  30. for arg in ${@:2}; do
  31. args[$i]="${arg}"
  32. let i++
  33. done
  34. # Must be a true array as defined above, not a single index list!
  35. #args="${@:2}"
  36. for check in ${args[@]}; do
  37. case ${check} in
  38. --no-staging)
  39. NO_STAGING=
  40. ;;
  41. --no-install)
  42. NO_INSTALL=
  43. ;;
  44. esac
  45. done
  46. ########################################################
  47. function Wine_intCleanup() {
  48. cd ..
  49. rm -rf winebuild_${datedir}
  50. exit 0
  51. }
  52. # Allow interruption of the script at any time (Ctrl + C)
  53. trap "Wine_intCleanup" INT
  54. ########################################################
  55. # This is specifically for Debian
  56. # Must be done to install Wine buildtime dependencies on amd64 environment
  57. #
  58. if [[ $(dpkg --print-foreign-architectures | grep i386 | wc -l) -eq 0 ]]; then
  59. sudo dpkg --add-architecture i386
  60. sudo apt update
  61. fi
  62. ########################################################
  63. function getWine() {
  64. function cleanOldBuilds() {
  65. if [[ $(find . -type d -name "winebuild_*" | wc -l) -ne 0 ]]; then
  66. echo -e "Removing old Wine build folders. This can take a while.\n"
  67. rm -rf ./winebuild_*
  68. fi
  69. }
  70. cleanOldBuilds
  71. mkdir winebuild_${datedir}
  72. cd winebuild_${datedir}
  73. WINEROOT="${PWD}"
  74. echo -e "Retrieving source code of Wine$(if [[ ! -v NO_STAGING ]]; then echo ' & Wine Staging' ; fi)\n"
  75. git clone git://source.winehq.org/git/wine.git
  76. if [[ ! -v NO_STAGING ]]; then
  77. git clone git://github.com/wine-staging/wine-staging.git
  78. WINEDIR_STAGING="${WINEROOT}/wine-staging"
  79. PKGNAME="wine-staging-git"
  80. else
  81. PKGNAME="wine-git"
  82. fi
  83. mkdir wine-{patches,32-build,32-install,64-build,64-install,package}
  84. cp -r ../../../wine_custom_patches/*.{patch,diff} wine-patches/ 2>/dev/null
  85. WINEDIR="${WINEROOT}/wine"
  86. WINEDIR_PATCHES="${WINEROOT}/wine-patches"
  87. WINEDIR_BUILD_32="${WINEROOT}/wine-32-build"
  88. WINEDIR_BUILD_64="${WINEROOT}/wine-64-build"
  89. WINEDIR_INSTALL_32="${WINEROOT}/wine-32-install"
  90. WINEDIR_INSTALL_64="${WINEROOT}/wine-64-install"
  91. WINEDIR_PACKAGE="${WINEROOT}/wine-package"
  92. }
  93. function getDebianFiles() {
  94. local debian_archive=wine_3.0-1ubuntu1.debian.tar.xz
  95. cd "${WINEDIR}"
  96. wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wine/${debian_archive}
  97. tar xvf ${debian_archive}
  98. rm ${debian_archive}
  99. }
  100. ########################################################
  101. # Wine build dependency list on Debian
  102. wine_deps_build=(
  103. 'make'
  104. 'gcc-multilib'
  105. 'g++-multilib'
  106. 'libxml-simple-perl'
  107. 'libxml-parser-perl'
  108. 'libxml-libxml-perl'
  109. 'lzma'
  110. 'flex'
  111. 'bison'
  112. 'quilt'
  113. 'gettext'
  114. 'oss4-dev'
  115. 'sharutils'
  116. 'pkg-config'
  117. 'dctrl-tools'
  118. 'khronos-api'
  119. 'unicode-data'
  120. 'freebsd-glue'
  121. 'icoutils'
  122. 'librsvg2-bin'
  123. 'imagemagick'
  124. 'fontforge'
  125. 'libxi-dev:amd64'
  126. 'libxt-dev:amd64'
  127. 'libxmu-dev:amd64'
  128. 'libx11-dev:amd64'
  129. 'libxext-dev:amd64'
  130. 'libxfixes-dev:amd64'
  131. 'libxrandr-dev:amd64'
  132. 'libxcursor-dev:amd64'
  133. 'libxrender-dev:amd64'
  134. 'libxkbfile-dev:amd64'
  135. 'libxxf86vm-dev:amd64'
  136. 'libxxf86dga-dev:amd64'
  137. 'libxinerama-dev:amd64'
  138. 'libgl1-mesa-dev:amd64'
  139. 'libglu1-mesa-dev:amd64'
  140. 'libxcomposite-dev:amd64'
  141. 'libpng-dev:amd64'
  142. 'libssl-dev:amd64'
  143. 'libv4l-dev:amd64'
  144. 'libxml2-dev:amd64'
  145. 'libgsm1-dev:amd64'
  146. 'libjpeg-dev:amd64'
  147. 'libkrb5-dev:amd64'
  148. 'libtiff-dev:amd64'
  149. 'libsane-dev:amd64'
  150. 'libudev-dev:amd64'
  151. 'libpulse-dev:amd64'
  152. 'liblcms2-dev:amd64'
  153. 'libldap2-dev:amd64'
  154. 'libxslt1-dev:amd64'
  155. 'unixodbc-dev:amd64'
  156. 'libcups2-dev:amd64'
  157. 'libcapi20-dev:amd64'
  158. 'libopenal-dev:amd64'
  159. 'libdbus-1-dev:amd64'
  160. 'freeglut3-dev:amd64'
  161. 'libmpg123-dev:amd64'
  162. 'libasound2-dev:amd64'
  163. 'libgphoto2-dev:amd64'
  164. 'libosmesa6-dev:amd64'
  165. 'libpcap0.8-dev:amd64'
  166. 'libgnutls28-dev:amd64'
  167. 'libncurses5-dev:amd64'
  168. 'libgettextpo-dev:amd64'
  169. 'libfreetype6-dev:amd64'
  170. 'libfontconfig1-dev:amd64'
  171. 'libgstreamer-plugins-base1.0-dev:amd64'
  172. 'ocl-icd-opencl-dev:amd64'
  173. 'libvulkan-dev:amd64'
  174. 'libxi-dev:i386'
  175. 'libxt-dev:i386'
  176. 'libxmu-dev:i386'
  177. 'libx11-dev:i386'
  178. 'libxext-dev:i386'
  179. 'libxfixes-dev:i386'
  180. 'libxrandr-dev:i386'
  181. 'libxcursor-dev:i386'
  182. 'libxrender-dev:i386'
  183. 'libxkbfile-dev:i386'
  184. 'libxxf86vm-dev:i386'
  185. 'libxxf86dga-dev:i386'
  186. 'libxinerama-dev:i386'
  187. 'libgl1-mesa-dev:i386'
  188. 'libglu1-mesa-dev:i386'
  189. 'libxcomposite-dev:i386'
  190. 'libpng-dev:i386'
  191. 'libssl-dev:i386'
  192. 'libv4l-dev:i386'
  193. 'libgsm1-dev:i386'
  194. 'libjpeg-dev:i386'
  195. 'libkrb5-dev:i386'
  196. 'libsane-dev:i386'
  197. 'libudev-dev:i386'
  198. 'libpulse-dev:i386'
  199. 'liblcms2-dev:i386'
  200. 'libldap2-dev:i386'
  201. 'unixodbc-dev:i386'
  202. 'libcapi20-dev:i386'
  203. 'libopenal-dev:i386'
  204. 'libdbus-1-dev:i386'
  205. 'freeglut3-dev:i386'
  206. 'libmpg123-dev:i386'
  207. 'libasound2-dev:i386'
  208. 'libgphoto2-dev:i386'
  209. 'libosmesa6-dev:i386'
  210. 'libpcap0.8-dev:i386'
  211. 'libncurses5-dev:i386'
  212. 'libgettextpo-dev:i386'
  213. 'libfreetype6-dev:i386'
  214. 'libfontconfig1-dev:i386'
  215. 'ocl-icd-opencl-dev:i386'
  216. 'libvulkan-dev:i386'
  217. )
  218. # Excluded x86 packages since they conflict with their amd64 counterparts:
  219. #
  220. # libxslt1-dev:i386
  221. # libxml2-dev:i386
  222. # libicu-dev:i386
  223. # libtiff-dev:i386
  224. # libcups2-dev:i386
  225. # libgnutls28-dev:i386
  226. # libgstreamer1.0-dev:i386
  227. # libgstreamer-plugins-base1.0-dev:i386
  228. ########################################################
  229. # Wine runtime dependency list on Debian
  230. wine_deps_runtime=(
  231. 'libxcursor1:i386'
  232. 'libxrandr2:i386'
  233. 'libxi6:i386'
  234. 'libsm6:i386'
  235. 'libvulkan1:i386'
  236. 'libasound2:i386'
  237. 'libc6:i386'
  238. 'libfontconfig1:i386'
  239. 'libfreetype6:i386'
  240. 'libgcc1:i386'
  241. 'libglib2.0-0:i386'
  242. 'libgphoto2-6:i386'
  243. 'libgphoto2-port12:i386'
  244. 'liblcms2-2:i386'
  245. 'libldap-2.4-2:i386'
  246. 'libmpg123-0:i386'
  247. 'libncurses5:i386'
  248. 'libopenal1:i386'
  249. 'libpcap0.8:i386'
  250. 'libpulse0:i386'
  251. 'libtinfo5:i386'
  252. 'libudev1:i386'
  253. 'libx11-6:i386'
  254. 'libxext6:i386'
  255. 'libxml2:i386'
  256. 'ocl-icd-libopencl1:i386'
  257. 'zlib1g:i386'
  258. 'fontconfig:amd64'
  259. 'libxcursor1:amd64'
  260. 'libxrandr2:amd64'
  261. 'libxi6:amd64'
  262. 'gettext:amd64'
  263. 'libsm6:amd64'
  264. 'libvulkan1:amd64'
  265. 'libasound2:amd64'
  266. 'libc6:amd64'
  267. 'libfontconfig1:amd64'
  268. 'libfreetype6:amd64'
  269. 'libgcc1:amd64'
  270. 'libglib2.0-0:amd64'
  271. 'libgphoto2-6:amd64'
  272. 'libgphoto2-port12:amd64'
  273. 'liblcms2-2:amd64'
  274. 'libldap-2.4-2:amd64'
  275. 'libmpg123-0:amd64'
  276. 'libncurses5:amd64'
  277. 'libopenal1:amd64'
  278. 'libpcap0.8:amd64'
  279. 'libpulse0:amd64'
  280. 'libtinfo5:amd64'
  281. 'libudev1:amd64'
  282. 'libx11-6:amd64'
  283. 'libxext6:amd64'
  284. 'libxml2:amd64'
  285. 'ocl-icd-libopencl1:amd64'
  286. 'zlib1g:amd64'
  287. 'desktop-file-utils'
  288. 'libgstreamer-plugins-base1.0-0:amd64'
  289. 'libgstreamer1.0-0:amd64'
  290. )
  291. # Exclude the following i386 runtime dependencies
  292. # because they conflict with their amd64 counterparts:
  293. # gettext:i386
  294. ########################################################
  295. # Wine dependencies:
  296. function WineDeps() {
  297. local a=0
  298. local deps="${1}"
  299. local depsname=${2}
  300. echo -e "Installing Wine dependencies.\n" # Sudo password may be required.\n"
  301. # TODO should we install all at once, or go iterating the list,
  302. # giving better output for user. Iterative method is slower, though.
  303. #
  304. # sudo apt install -y ${deps[*]}
  305. # if [[ $? -ne 0 ]]; then
  306. # echo -e "Error while installing Wine dependencies. Aborting\n"
  307. # exit 1
  308. # fi
  309. function pkgdependencies() {
  310. for pkgdep in ${@}; do
  311. if [[ $(apt version ${pkgdep} | wc -w) -eq 0 ]]; then
  312. echo -e "Installing ${depsname} dependency ${pkgdep} ($(($a + 1 )) / $((${#*} + 1)))\n."
  313. sudo apt install -y ${pkgdep} &> /dev/null
  314. if [[ $? -eq 0 ]]; then
  315. let a++
  316. else
  317. echo -e "\nError occured while installing ${pkgdep}. Aborting.\n"
  318. exit 1
  319. fi
  320. fi
  321. done
  322. }
  323. pkgdependencies ${deps[*]}
  324. }
  325. ########################################################
  326. # Wine staging override list
  327. # Wine Staging replaces and conflicts with these packages
  328. # Applies to debian/control file
  329. wine_over_pkgs=(
  330. 'wine'
  331. 'wine-development'
  332. 'wine64-development'
  333. 'wine1.6'
  334. 'wine1.6-i386'
  335. 'wine1.6-amd64'
  336. 'libwine:amd64'
  337. 'libwine:i386'
  338. 'wine-stable'
  339. 'wine32'
  340. 'wine64'
  341. )
  342. ############################
  343. # Suggest section in debian/control file
  344. wine_suggest_pkgs=(
  345. 'winbind'
  346. 'winetricks'
  347. 'fonts-wine'
  348. 'playonlinux'
  349. 'wine-binfmt'
  350. 'dosbox'
  351. )
  352. ########################################################
  353. # Feed the following data to Wine debian/control file
  354. function feedControlfile() {
  355. local MAINTAINER="$USER"
  356. sed -ie "s/^Build-Depends:.*$/Build-Depends: debhelper (>=11), $(echo ${wine_deps_build[*]} | sed 's/\s/, /g')/g" debian/control
  357. sed -ie "s/^Depends:.*$/Depends: $(echo ${wine_deps_runtime[*]} | sed 's/\s/, /g')/g" debian/control
  358. sed -ie "s/^Suggests:.*$/Suggests: $(echo ${wine_suggest_pkgs[*]} | sed 's/\s/, /g')/g" debian/control
  359. sed -ie "s/^Maintainer:.*$/Maintainer: ${MAINTAINER}/g" debian/control
  360. sed -ie "s/^Source:.*$/Source: ${PKGNAME}/g" debian/control
  361. sed -ie "s/^Package:.*$/Package: ${PKGNAME}/g" debian/control
  362. for ctrl_section in Conflicts Breaks Replaces Provides; do
  363. sed -ie "s/^${ctrl_section}:.*$/${ctrl_section}: $(echo ${wine_over_pkgs[*]} | sed 's/\s/, /g')/g" debian/control
  364. done
  365. }
  366. ########################################################
  367. # Refresh Wine GIT
  368. function refreshWineGIT() {
  369. # Restore the wine tree to its git origin state, without wine-staging patches
  370. # (necessary for reapllying wine-staging patches in succedent builds,
  371. # otherwise the patches will fail to be reapplied)
  372. cd "${WINEDIR}"
  373. git reset --hard HEAD # Restore tracked files
  374. git clean -d -x -f # Delete untracked files
  375. if [[ ! -v NO_STAGING ]]; then
  376. # Change back to the wine upstream commit that this version of wine-staging is based on
  377. git checkout $(bash "${WINEDIR_STAGING}"/patches/patchinstall.sh --upstream-commit)
  378. fi
  379. }
  380. ########################################################
  381. # Get Wine version tag
  382. function getWineVersion() {
  383. cd "${WINEDIR}"
  384. wine_version=$(git describe | sed 's/^[a-z]*-//; s/-[0-9]*-[a-z0-9]*$//')
  385. }
  386. ########################################################
  387. # Apply patches
  388. function patchWineSource() {
  389. if [[ ! -v NO_STAGING ]]; then
  390. cd "${WINEDIR_STAGING}/patches"
  391. bash ./patchinstall.sh DESTDIR="${WINEDIR}" ${staging_patchsets[*]}
  392. fi
  393. cp -r ${WINEROOT}/../../../wine_custom_patches/* "${WINEDIR_PATCHES}/"
  394. if [[ $(find "${WINEDIR_PATCHES}" -mindepth 1 -maxdepth 1 -regex ".*\.\(patch\|diff\)$") ]]; then
  395. cd "${WINEDIR}"
  396. for i in "${WINEDIR_PATCHES}"/*.patch; do
  397. patch -Np1 < $i
  398. done
  399. fi
  400. }
  401. ########################################################
  402. # 64-bit build
  403. function wine64Build() {
  404. cd "${WINEDIR_BUILD_64}"
  405. "${WINEDIR}"/configure \
  406. --with-x \
  407. --with-gstreamer \
  408. --enable-win64 \
  409. --with-xattr \
  410. --disable-mscoree \
  411. --with-vulkan \
  412. --prefix=/usr \
  413. --libdir=/usr/lib/x86_64-linux-gnu/
  414. make -j$(nproc --ignore 1)
  415. make -j$(nproc --ignore 1) prefix="${WINEDIR_INSTALL_64}/usr" \
  416. libdir="${WINEDIR_INSTALL_64}/usr/lib/x86_64-linux-gnu/" \
  417. dlldir="${WINEDIR_INSTALL_64}/usr/lib/x86_64-linux-gnu/wine" install
  418. }
  419. # 32-bit build
  420. function wine32Build() {
  421. # Gstreamer amd64 & i386 dev packages conflict on Ubuntu
  422. cd "${WINEDIR_BUILD_32}"
  423. "${WINEDIR}"/configure \
  424. --with-x \
  425. --with-gstreamer \
  426. --with-xattr \
  427. --disable-mscoree \
  428. --with-vulkan \
  429. --without-gstreamer \
  430. --libdir=/usr/lib/i386-linux-gnu/ \
  431. --with-wine64="${WINEDIR_BUILD_64}" \
  432. --prefix=/usr
  433. make -j$(nproc --ignore 1)
  434. make -j$(nproc --ignore 1) prefix="${WINEDIR_INSTALL_32}/usr" \
  435. libdir="${WINEDIR_INSTALL_32}/usr/lib/i386-linux-gnu/" \
  436. dlldir="${WINEDIR_INSTALL_32}/usr/lib/i386-linux-gnu/wine" install
  437. }
  438. ########################################################
  439. function mergeWineBuilds() {
  440. cp -r "${WINEDIR_INSTALL_64}"/* "${WINEDIR_PACKAGE}"/
  441. cp -r "${WINEDIR_INSTALL_32}"/usr/bin/{wine,wine-preloader} "${WINEDIR_PACKAGE}"/usr/bin/
  442. cp -r "${WINEDIR_INSTALL_32}"/usr/lib/* "${WINEDIR_PACKAGE}"/usr/lib/
  443. }
  444. function buildDebianArchive() {
  445. cd "${WINEROOT}"
  446. mv "${WINEDIR_PACKAGE}" "${WINEROOT}/${PKGNAME}-${wine_version}"
  447. cd "${WINEROOT}/${PKGNAME}-${wine_version}"
  448. dh_make --createorig -s -y
  449. rm debian/*.{ex,EX}
  450. printf "usr/* /usr" > debian/install
  451. cat << 'DEBIANCONTROL' > debian/control
  452. Source:
  453. Section: otherosfs
  454. Priority: optional
  455. Maintainer:
  456. Build-Depends:
  457. Standards-Version: 4.1.2
  458. Homepage: https://www.winehq.org
  459. Package:
  460. Architecture: any
  461. Depends:
  462. Suggests:
  463. Conflicts:
  464. Breaks:
  465. Replaces:
  466. Provides:
  467. Description: A compatibility layer for running Windows programs.
  468. Wine is an open source Microsoft Windows API implementation for
  469. POSIX-compliant operating systems, including Linux.
  470. Git version includes the latest updates available for Wine.
  471. DEBIANCONTROL
  472. feedControlfile
  473. DEB_BUILD_OPTIONS="strip nodocs noddebs" dpkg-buildpackage -b -us -uc
  474. }
  475. function installDebianArchive() {
  476. cd "${WINEROOT}"
  477. # TODO Although the package name ends with 'amd64', this contains both 32 and 64 bit Wine versions
  478. echo -e "\nInstalling Wine.\n" # Please provide your sudo password.
  479. sudo dpkg -i ${PKGNAME}_${wine_version}-1_amd64.deb
  480. }
  481. function storeDebianArchive() {
  482. cd "${WINEROOT}"
  483. mv ${PKGNAME}_${wine_version}-1_amd64.deb ../../compiled_deb/"${datedir}" && \
  484. echo -e "Compiled ${PKGNAME} is stored at '$(readlink -f ../../compiled_deb/"${datedir}")/'\n"
  485. rm -rf winebuild_${datedir}
  486. }
  487. function clearTree() {
  488. rm -rf "${WINEROOT}"
  489. }
  490. ########################################################
  491. # Get Wine (& Wine-Staging) sources
  492. getWine
  493. # Install Wine dependencies
  494. WineDeps "${wine_deps_build[*]}" "Wine build time"
  495. WineDeps "${wine_deps_runtime[*]}" "Wine runtime"
  496. # Refresh & sync Wine (+ Wine Staging) git sources
  497. refreshWineGIT
  498. # Update Wine source files
  499. patchWineSource
  500. # Get Wine/Wine Staging version
  501. getWineVersion
  502. # Compile 64 & 32 bit Wine/Wine Staging
  503. wine64Build
  504. wine32Build
  505. # Bundle compiled Wine-Staging files
  506. mergeWineBuilds
  507. # Bundle and install Debian deb archive
  508. buildDebianArchive
  509. if [[ ! -v NO_INSTALL ]]; then
  510. installDebianArchive
  511. fi
  512. storeDebianArchive
  513. # Clear all temporary files
  514. clearTree