# Maintainer: Oscar Wallberg <oscar.wallberg@outlook.com>
pkgname=proton-ge-custom
pkgver=11.1
pkgrel=1
pkgdesc='Compatibility tool for Steam Play based on Wine and additional components'
arch=('x86_64')
url='https://github.com/GloriousEggroll/proton-ge-custom'
license=(
  'BSD-2-Clause'
  'BSD-3-Clause'
  'LGPL-2.1-or-later'
  'MIT'
  'MPL-2.0'
  'OFL-1.1'
  'LicenseRef-AOM-Patent-License-1.0'
  'LicenseRef-Ume-Fonts'
  'zlib'
  'custom'
)
depends=('python')
optdepends=(
  'steam: use Proton-GE through Steam'
  'vulkan-driver: Vulkan driver for DXVK and vkd3d-proton'
  'lib32-vulkan-driver: 32-bit Vulkan driver for DXVK and vkd3d-proton'
  'vulkan-icd-loader: Vulkan loader'
  'lib32-vulkan-icd-loader: 32-bit Vulkan loader'
  'openxr: VR support through wineopenxr'
  'lib32-openal: OpenAL audio support for 32-bit games'
  'lib32-libpulse: PulseAudio audio support for 32-bit games'
  'gst-plugins-base-libs: GStreamer media support'
  'gst-plugins-bad-libs: additional GStreamer media support'
  'lib32-libva: VA-API media support for 32-bit games'
  'lib32-libvdpau: VDPAU media support for 32-bit games'
  'lib32-mpg123: MPEG audio support for 32-bit games'
  'lib32-libtheora: Theora video support for 32-bit games'
  'lib32-speex: Speex audio support for 32-bit games'
  'lib32-libjpeg-turbo: JPEG support for 32-bit games'
  'lib32-libgudev: device discovery support for 32-bit games'
  'lib32-libusb: USB device support for 32-bit games'
  'lib32-libpcap: packet capture support for 32-bit games'
  'lib32-libxkbcommon: Wayland keyboard handling for 32-bit games'
  'lib32-openssl: TLS support for 32-bit games'
  'lib32-libsoup3: HTTP support for 32-bit media components'
  'blas: speech recognition through vosk'
  'lapack: speech recognition through vosk'
  'winetricks: protonfixes support'
  'kdialog: KDE dialog support'
  'zenity: GTK dialog support'
)
conflicts=('proton-ge-custom-bin')
options=('!strip' '!debug' 'emptydirs')

_release="GE-Proton${pkgver/./-}"
_toolname='Proton-GE'
source=("${_release}.tar.gz::${url}/releases/download/${_release}/${_release}.tar.gz")
sha512sums=('d5792f4ac81d3832f5fe40467090c67d561b780c6a4236e76f8b59cb1d4ca25c82df91018e79d156bb267a67224a41f0d621a1e6cbbeec79040cc60275dc9e5a')

package() {
  local toolroot="${pkgdir}/usr/share/steam/compatibilitytools.d/${pkgname}"
  local licensedir="${pkgdir}/usr/share/licenses/${pkgname}"

  install -d "${toolroot}"
  cp -a --no-preserve=ownership "${srcdir}/${_release}/." "${toolroot}/"
  sed -i "s|\"${_release}\"|\"${_toolname}\"|g" "${toolroot}/compatibilitytool.vdf"

  install -Dm644 "${srcdir}/${_release}/LICENSE" "${licensedir}/LICENSE"
  install -Dm644 "${srcdir}/${_release}/LICENSE.OFL" "${licensedir}/LICENSE.OFL"
  install -Dm644 "${srcdir}/${_release}/PATENTS.AV1" "${licensedir}/PATENTS.AV1"
}
