# Description: Digital distribution client bootstrap package.
# URL: https://store.steampowered.com/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: dbus-32 desktop-file-utils gtk-32 libgcrypt-32 mesa-32 nss-32 openal-32 zenity
# Optional: pulseaudio-32

name=steam
version=1.0.0.78
release=1
source=(https://repo.steampowered.com/$name/pool/$name/s/$name/${name}_$version.tar.gz
  steam-runtime.sh)

build() {
  cd steam-launcher

  # apply roundups for udev rules
  sed -r 's|("0666")|"0660", TAG+="uaccess"|g' -i subprojects/steam-devices/60-steam-input.rules
  sed -r 's|("misc")|\1, OPTIONS+="static_node=uinput"|g' -i subprojects/steam-devices/60-steam-input.rules
  sed -r 's|(, TAG\+="uaccess")|, MODE="0660"\1|g' -i subprojects/steam-devices/60-steam-vr.rules

  # separated runtime/native desktop files
  sed -r 's|(Name=Steam)|\1 (Runtime)|' -i steam.desktop
  sed -r 's|(/usr/bin/steam)|\1-runtime|' -i steam.desktop

  make DESTDIR=$PKG install

  mv $PKG/usr/bin/steam $PKG/usr/lib/steam/steam
  install -Dm 755 $SRC/steam-runtime.sh $PKG/usr/bin/steam-runtime

  # blank steamdeps because apt-get
  ln -sf /bin/true $PKG/usr/bin/steamdeps

  install -d $PKG/etc/ssl/certs

  install -Dm 644 subprojects/steam-devices/60-steam-input.rules \
    $PKG/usr/lib/udev/rules.d/70-steam-input.rules

  install -Dm 644 subprojects/steam-devices/60-steam-vr.rules \
    $PKG/usr/lib/udev/rules.d/70-steam-vr.rules

  rm -r $PKG/usr/share/doc
}
