Common tasks
============

Adding a library to the SDK
---------------------------

Suppose you want to add `libfoo-dev` to the SDK.

Install `libfoo-dev` in a `sniper` container/chroot, and check what other
packages it pulls in, and where they came from (`sniper` or `bullseye`).
Check that those packages have acceptable licensing terms.

Check whether you can install `libfoo-dev:amd64` and `libfoo-dev:i386`
in a `sniper` container/chroot without needing to remove anything else.

Edit `debian/control` and add `libfoo-dev` to an appropriate `Depends`
list. If you can co-install the amd64 and i386 versions of it, add it
to `steamrt-libdevel`. If not, add it to `steamrt-libdevel-non-multiarch`.

If you want to be able to ship games that use this library unconditionally,
you'll need to provide the library in the runtime (see below).

Adding a library to the Platform
--------------------------------

Suppose you want to add `libFoo.so.1` to the runtime.

Install `libfoo1` (or whatever is the right package name) in a `sniper`
container/chroot, and check what other packages it pulls in, and where
they came from (`sniper` or `bullseye`).  Check that those packages have
acceptable licensing terms.

Check whether you can install `libfoo1:amd64` and `libfoo1:i386`
in a `sniper` container/chroot without needing to remove anything else.
If you can't, improve the packaging until you can (install to Multi-Arch
directories and set `Multi-Arch: same`). We don't support libraries that
are not multi-arch co-installable.

Edit `abi/steam-runtime-abi.yaml` and add the new library and each of its
(recursive) dependencies. If the name of the package matches the SONAME,
you can just add it to the list as a string, similar to `libX11.so.6`. If
not, you'll have to add it as a dict that contains a `deb:` key, similar
to `libz.so.1` containing `deb: zlib1g`.

After editing `abi/steam-runtime-abi.yaml`, regenerate
the `abi/expectations` directory by running
`abi/maintainer-generate-expectations.py` in a `sniper` chroot or container.

If you want to be able to compile against this library without downloading
extra packages, you'll need to provide the library in the SDK (see above).

Testing a new sniper runtime
----------------------------

### Within Steam

The sniper runtime is not yet supported by Steam.

### Outside Steam

Build the runtime using CI or `flatdeb-steam`, as before.
Various artifacts are produced, but the only one we need here is
`com.valvesoftware.SteamRuntime.Platform-amd64,i386-sniper-runtime.tar.gz`.

Unpack it into an empty directory, for example `~/tmp/sniper`, so that
you have `~/tmp/sniper/metadata` and `~/tmp/sniper/files/bin/env`.
Create a directory on the same filesystem that can be used for temporary
copies and logs, for example `~/tmp/pressure-vessel-var`.

Download a pressure-vessel relocatable release from
<https://repo.steampowered.com/pressure-vessel/snapshots/> and unpack it
into a directory, or use the one included in `SteamLinuxRuntime_sniper`,
or build your own.

Then run a command like:

```
$ .../pressure-vessel/bin/pressure-vessel-wrap \
    --variable-dir ~/tmp/pressure-vessel-var \
    --copy-runtime \
    --runtime ~/tmp/sniper \
    -- \
    xterm
```

Testing a new sniper SDK
------------------------

Build the runtime using CI or `flatdeb-steam`. Various artifacts are
produced, but the ones we'll need here are
`com.valvesoftware.SteamRuntime.Sdk-amd64,i386-sniper-sysroot.tar.gz`
and `com.valvesoftware.SteamRuntime.Sdk-amd64,i386-sniper-sysroot.Dockerfile`.
Download them into a new, empty directory and `cd` into that directory.

For Docker users:

    $ sudo docker build -t steamrt_sniper_amd64:latest -f *.Dockerfile .

Then you can use the `steamrt_sniper_amd64` Docker image for builds.

For Podman users: it's the same as Docker, but use `podman build` instead
of `sudo docker build`.

For `schroot` users:

    $ /path/to/steam-runtime/setup_chroot.sh --suite=sniper --amd64 --tarball *-sysroot.tar.gz
