Steam Runtime 2 'soldier'
=========================

Steam Runtime 2 'soldier' is a new runtime environment for Steam. Instead
of forming a `LD_LIBRARY_PATH` that merges the host OS's shared libraries
with the shared libraries provided by Valve, it uses Linux namespace
(container) technology to build a more predictable environment.

At the time of writing, it is used as a runtime environment for Proton 5.13
or later, which are compiled against the newer library stack and are
incompatible with the older Steam Runtime 1 'scout'.

See <https://github.com/ValveSoftware/steam-runtime> for more information
about the Steam Runtime.

How this fits into the overall Steam Runtime project
----------------------------------------------------

1. Build .deb packages for the content of the Steam Runtime.
    `steamrt` is one of these packages.

2. Put together the .deb packages into a Flatpak-style container runtime.
    This step is done by
    [flatdeb-steam](https://gitlab.steamos.cloud/steamrt/flatdeb-steam),
    but the choice of the actual packages to include is mostly delegated to
    `steamrt`.

3. Turn the container runtime into a Steampipe depot.  This is controlled by
    [steamlinuxruntime](https://gitlab.steamos.cloud/steamrt/steamlinuxruntime).

Why is this Steam Runtime 2 when heavy was released first?
----------------------------------------------------------

Steam Runtime 2 is older than heavy, but heavy has an older base OS
and was released to the public first. By the time heavy started, Steam
Runtime 2 was already under development, so heavy is considered to be
Steam Runtime 1½.

Steam Runtime 2 is also only the second runtime (after scout) that is
complete enough to run games, which was the Steam Runtime's original
purpose. Steam Runtime 1½ consists of enough to compile and run
`steamwebhelper` and no more, so we consider it to only be half a runtime.

Why does soldier require container technology?
----------------------------------------------

The traditional `LD_LIBRARY_PATH` runtime only works because we're lucky,
and because modern host OSs are strictly newer than it.
Making a `LD_LIBRARY_PATH`-based runtime reliable is difficult, especially
if you want it to be runnable on host OSs that have some packages that
are older than the runtime.

Some libraries cannot be bundled in a `LD_LIBRARY_PATH` for technical
reasons (mainly glibc and graphics drivers). A `LD_LIBRARY_PATH` runtime
needs to get these from the host system, and they need to be at least the
version it was compiled against. This is fine for scout, which is very
old, but would not be OK for a Debian 10-based runtime, which wouldn't work
on (for example) Ubuntu 18.04.

Some libraries *can* be bundled, but need to be patched to search for
plugins in different places (either inside the runtime itself, or in
multiple distro-dependent places), which is not really sustainable.

Using namespace (container) technology to replace `/usr` with the
runtime's libraries sidesteps both these problems.

Where can I get it?
-------------------

The "Steam Linux Runtime - soldier" compatibility tool (app ID 1391110).
is automatically downloaded to your Steam library as
`common/SteamLinuxRuntime_soldier` when you select a version of Proton
that requires it.

If you need more,
<https://repo.steampowered.com/steamrt-images-soldier/snapshots/> contains
several versions of soldier. Each version's subdirectory contains:

* source code in the `sources` subdirectory
* container images that can run games
  (`*.Platform-*-runtime.tar.gz`, which can also be converted into Flatpak
  runtimes)
* container images that can run games with debugging tools available
  (`*.Sdk-*-runtime.tar.gz` and `*.Sdk-*-debug.tar.gz`,
  which can also be converted into Flatpak runtimes)
* container images for compiling your own software
  (`*.Sdk-*-sysroot.tar.gz`, and `*.Sdk-*-sysroot.Dockerfile`, which can
  also be converted into a Docker image)

What's in this repository?
--------------------------

This repository mostly provides "metapackages". This is Debian jargon for
a package that is (almost) empty, and pulls in desired packages by having
dependencies on them.

Developing software that runs in soldier
----------------------------------------

Games that require soldier cannot yet be released on Steam. This
will hopefully become possible in future, when the container runtime
infrastructure is more robust.

A SDK environment is available as a Docker image.
Please see <https://gitlab.steamos.cloud/steamrt/soldier/sdk> and
<https://github.com/ValveSoftware/steam-runtime>.

Backporting policy
------------------

### What we can backport into soldier

This is a bit more liberal than scout, because we're using a container
runtime.

In general, we can backport application-level libraries like Pipewire
and SDL, subject to some conditions:

  * The library needs to have a proper SONAME with a stable ABI,
    for example `libpipewire-0.3.so.0`.
  * If the new library has runtime dependencies which aren't satisfied
    by the Steam Runtime, we need to backport those first, or patch the
    library to avoid the dependencies.
  * If the new library has build-time dependencies which aren't satisfied
    by the Steam Runtime, we need to backport those first, or patch the
    build system to avoid the dependencies.

If the library is, or might become, part of the dependency stack for
user-space graphics drivers like Mesa, then there are some more
requirements, which in practice usually cannot be met for graphics drivers:

  * There needs to be a minor ABI version number in the library's
    physical filename, which goes up with each release.
    For example, `libpipewire-0.3.so.0 -> libpipewire-0.3.so.0.339.0`
    is suitable: each new release increases the minor ABI version.
    However, `libdrm.so.2 -> libdrm.so.2.4.0` is not suitable (see below).

If the library is not part of the dependency stack for graphics drivers
(for example GTK, GNUTLS, Pipewire, SDL), then we can backport invididual
bug-fixes and features without backporting an entire new upstream version.

If the library might become part of the dependency stack for graphics
drivers (for example glibc, zlib, libelf, libgcc, libstdc++), then we can
still can backport invididual bug-fixes and features without backporting
an entire new upstream version, but Steam and games cannot rely on having
those bug-fixes and features at runtime, because our library might have
been overridden by a newer upstream version from the host system.

### Preferred versions to backport

If we can, we prefer to backport the version that was included in a
stable release of Debian or an LTS release of Ubuntu, in preference to
using an intermediate version. This gives us a source for security and
bugfix updates.

The most likely version to be able to backport is the version from the
*next* stable release of Debian, for example backporting from Debian 11
into soldier - this matches official Debian backports. We can use a
version from buster-backports as-is, if it exists.

If we need a version newer than what's in the current Debian stable release,
we prefer to use the version from Debian testing or unstable, but in this
case we should plan to track its updates until the next stable release.

If we need a version newer than what's in Debian unstable, we can go to
experimental or the latest upstream version, but we need to be careful to
track newer releases in this case.

### What we can't backport

We cannot backport libraries that are closely related to the graphics
stack, notably the libraries built by Mesa, including `libgbm.so.1`. The
Steam Runtime is designed to use the version of Mesa from the host
system, to maximize the probability that it will work with the user's
kernel and hardware. For details of the specific libraries involved,
see the implementation of the `gl:` match expression in libcapsule.

We cannot safely backport libraries where the minor ABI version in
the physical filename does not increase, if they are or might become
part of the dependency stack of a graphics driver. For example,
`libdrm.so.2 -> libdrm.so.2.4.0` stays the same across multiple releases,
even while adding new ABI. This means we cannot tell whether our bundled
version is older or newer than the host version, which means we cannot
guarantee that games will be using a version that is the same as or
newer than our backport.

In general, we cannot safely backport libraries that have undergone
non-backwards-compatible changes while keeping the same SONAME.

We generally should not backport bug-fixes and new features that have
not been included in upstream's version control system, and preferably
included in a formal release as well.
