# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
# Maintainer: Christian Heusel <gromit@archlinux.org>
# Contributor: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: K900 <k0009000@gmail.com>

pkgbase=steam
pkgname=(steam steam-devices)
pkgver=1.0.0.85
pkgrel=5
pkgdesc="Valve's digital software delivery system"
url='https://steampowered.com/'
arch=('aarch64' 'x86_64')
license=('LicenseRef-steam-subscriber-agreement')
# the beta directory is a superset of stable and also contains the stable releases
source=(
  https://repo.steampowered.com/${pkgbase}/archive/stable/${pkgbase}_${pkgver}{.tar.gz,.dsc}
  steam.sh
  bin_steam.sh
  git+https://github.com/ValveSoftware/steam-devices#commit=39e7bd00f7a322e5165fd8f416b31d23daf6d385
)
makedepends=(git)
sha512sums=('81d404fcbd516fa1d984a991be3530855c0ded826ea8aca68c8cb5492e95d3d430cd7c556a9997a7c0780055a810239322181b1785e78f8d8fabe01c39fee2f7'
            'e3722d006485249fc91113feee0df018d341dc8d7327199a9161022c84b04ca5faa2be36268d50ae0bc29b6fd6063fe2b69a29a354adb32dd6b75d78dc7f9702'
            '5e75c019e9fe8c67d686c4e3343dac1180a69a4bdb7d39b333415c63201eef9b98da5619dbf6fd8daa6884e65bc7f8afc9e52778682425e5a75987d527eae6f0'
            'ca6e1e1482ba55b02f99f0d8553644fb683b30bbbe06bcb0d315976ee5186c26a2189cfef468cd61f73dac54ff9d7c48a446e41c8c25be6b6637462757792df7'
            'b9e2da2992801c71ee47780338f2102668248a4c3260a595c4ff9b51c8da18b79f8d2b875fbe4e6979011ff1f455fce4db3955d8061176dd149bb0dd3e0dd0cf')
b2sums=('6cc699e7b740693529845ef76d39570a977716735da46e21b681629aebf3e5ee80b09a3b47b1c84debb066ca43456f1c78509de7ddfe8e35df21903cceebde4f'
        '833edc4b6b8aa32861fb6caccdc4f7441a0462600315b68eae0bbbebf7c94cc64a8be61ce2e30842ea2f354ac0630898b7829d0d9eafd97eb7b621a72befb897'
        'c6bac99336b7c30fec7cdbaf9e949555c687dd9dff50bcae136134d6314f4b841f5fc66ddb2caac1b003690b926fd4afbdc11da143b4674db4b75f27709fdd23'
        '903f1357ad92111511a7c83e01d26bf2cc91f6f0d3d605f6654e2da0be3535cf3dd511e8f1c1b279bfe9fa85b1c5bb4a1a23dd045882e836fb72dcd1e0ff5f79'
        'ab8f5572d7b990bae8b1da7525f7d22c67041b4e6d10473d1239135615d79bde5a22bbb720dac8cf0e0ac0d4e82328e3b84bc0be21250c6b760a6322d3ad0987')
validpgpkeys=('BA1816EF8E75005FCF5E27A1F24AEA9FB05498B7') # linux@steampowered.com

package_steam() {
  depends=(
    bash
    coreutils
    curl
    dbus
    desktop-file-utils
    diffutils
    freetype2
    gdk-pixbuf2
    glibc
    hicolor-icon-theme
    libxcrypt
    libxcrypt-compat
    libxkbcommon-x11
    lsb-release
    lsof
    nss
    python
    ttf-font
    usbutils
    vulkan-icd-loader
    xdg-user-dirs
    xorg-xrandr
    xz
    zenity
  )
 
  optdepends=(
    'polkit: to setup SteamVR without root access'
    'xdg-desktop-portal-impl: file & folder picker'
    'xorg-fonts-misc: for non-latin locales'
  )
  depends+=(steam-devices)

  tmpdir=$(pwd)/tmpdir
  mkdir -p $tmpdir
  cd ${pkgname}-launcher
  make DESTDIR="${tmpdir}" install

  install -d "${pkgdir}/usr/share/"
  cp -a "${tmpdir}/usr/share" "${pkgdir}/usr/"

  install -d "${pkgdir}/usr/lib/steam"

  #install -Dm 755 "steam.desktop" "${pkgdir}/usr/share/applications/steam.desktop"
  ln -s "/usr/share/application/steam.desktop" "${pkgdir}/usr/lib/steam/steam.desktop"

  install -Dm 755 "com.valvesoftware.Steam.metainfo.xml" "${pkgdir}/usr/share/metainfo/com.valvesoftware.Steam.metainfo.xml"

  install -Dm 755 "${srcdir}/steam.sh" "${pkgdir}/usr/bin/steam"
  install -Dm 755 "${srcdir}/bin_steam.sh" "${pkgdir}/usr/lib/steam/bin_steam.sh"
  ln -s "/usr/lib/steam/bin_steam.sh" "${pkgdir}/usr/lib/steam/steam"

  install -d "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 755 "steam_subscriber_agreement.txt" "${pkgdir}/usr/share/licenses/${pkgname}/"
  install -Dm 644 debian/changelog -t "${pkgdir}/usr/share/doc/${pkgname}"

}

package_steam-devices() {
  pkgdesc="List of devices Steam and SteamVR will want read/write permissions on"
  license=(MIT)
  depends=(udev)

  cd "$srcdir/steam-devices"

  install -Dm 644 LICENSE \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  install -Dm 644 60-steam-input.rules \
    "${pkgdir}/usr/lib/udev/rules.d/60-steam-input.rules"
  #install -Dm 644 60-steam-vr.rules \
  #  "${pkgdir}/usr/lib/udev/rules.d/60-steam-vr.rules"
}

# vim: ts=2 sw=2 et:
