---
# Copyright © 2013-2016 Valve Corporation
# Copyright © 2017-2019 Collabora Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of these scripts and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

id_prefix: com.valvesoftware.SteamRuntime

add_packages_multiarch:
  - steamrt-container-host-compat
  - steamrt-libs

add_packages:
  - steamrt-container

post_script: |
  set -eux
  ln -s /usr/libexec/flatpak-xdg-utils/xdg-email /usr/bin/
  ln -s /usr/libexec/flatpak-xdg-utils/xdg-open /usr/bin/
  install -d -m755 /usr/lib/locale
  install -d -m755 /usr/share/i18n
  if [ -e /usr/share/i18n/locales/en_US ]; then
    echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
    localedef -v -i en_US -c -f UTF-8 en_US.UTF-8 || :
    test -e /usr/lib/locale/locale-archive
  fi
  # Arch Linux 32-bit biarch glibc looks for locales here. We might
  # need to use the host system glibc when pressure-vessel brings in the
  # host graphics drivers.
  install -d -m755 /usr/lib32
  ln -fnsv ../lib/locale /usr/lib32/locale
  # Biarch OSs that are the other way round might conceivably look here
  install -d -m755 /usr/lib64
  ln -fnsv ../lib/locale /usr/lib64/locale
  # Ensure that the libdrm folder is present
  install -d -m755 /usr/share/libdrm
  # Arch Linux uses a non-standard ELF interpreter for some binaries in the
  # glibc package. We create two symlinks as a workaround.
  ln -fnsv /lib64/ld-linux-x86-64.so.2 /usr/lib/
  # Few lines above we already ensured that /usr/lib32 exists.
  if [ -e /lib32/ld-linux.so.2 ]; then
      # Create a symlink that the /usr merge will be able to merge
      ln -fnsv /lib32/ld-linux.so.2 /usr/lib32/
  else
      ln -fnsv /lib/ld-linux.so.2 /usr/lib32/
  fi
  # Create symlinks to support the non-standard Exherbo library paths
  install -d -m755 /usr/i686-pc-linux-gnu
  install -d -m755 /usr/x86_64-pc-linux-gnu
  ln -fnsv /usr/lib/i386-linux-gnu /usr/i686-pc-linux-gnu/lib
  ln -fnsv /usr/lib/x86_64-linux-gnu /usr/x86_64-pc-linux-gnu/lib
  # Ensure gconv directories. Previously we already ensured to have both
  # /usr/lib32 and /usr/lib64. "/usr/(i686|x86_64)-pc-linux-gnu/lib" are
  # symlinked to "/usr/lib/(i386|x86_64)-linux-gnu", so there is no need to
  # create a "gconv" folder for them.
  install -d -m755 /usr/lib32/gconv
  install -d -m755 /usr/lib/gconv
  install -d -m755 /usr/lib64/gconv
  install -d -m755 /usr/lib/i386-linux-gnu/gconv
  install -d -m755 /usr/lib/x86_64-linux-gnu/gconv

platform:
  post_script: |
    set -eux
    find /usr -type d -empty -print0 | xargs -0 -t -I '{}' -- touch '{}/.exists'

sdk:
  add_packages_multiarch:
    - steamrt-libdebug:
        debug_symbols: true
    - steamrt-libdevel

  add_packages:
    - steamrt-dev
    - steamrt-libdebug-non-multiarch:
        debug_symbols: true

  post_script: |
    set -eux
    ln -sv busybox /bin/dos2unix
    ln -sv busybox /bin/ifconfig
    ln -sv busybox /bin/ip
    ln -sv busybox /bin/nc
    ln -sv busybox /bin/ping
    ln -sv busybox /bin/ping6
    ln -sv busybox /bin/route
    ln -sv busybox /bin/telnet
    ln -sv busybox /bin/traceroute
    ln -sv busybox /bin/traceroute6
    ln -sv busybox /bin/unix2dos
    ln -sv busybox /bin/vi
    ln -sv busybox /bin/xxd

...