From f02230ec2177804bffdf9730a0c1c9a28e983081 Mon Sep 17 00:00:00 2001
From: Ludovico de Nittis <ludovico.denittis@collabora.com>
Date: Tue, 6 Apr 2021 14:06:08 +0200
Subject: [PATCH] wrap: Send a more clear warning when attempting to bind
 /usr/* dirs

pressure-vessel doesn't support having the Steam Library under `/usr`.

When this happens, pressure-vessel fails without a clear indication of
what went wrong. For this reason we add a warning message to point out
that pressure-vessel was asked to bind a directory that will not appear
in the resulting container.

Helps: https://github.com/ValveSoftware/steam-runtime/issues/288
Helps: #30

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
---
 pressure-vessel/wrap.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c
index 0f6be0e66..bff5bf4b6 100644
--- a/pressure-vessel/wrap.c
+++ b/pressure-vessel/wrap.c
@@ -381,6 +381,9 @@ bind_and_propagate_from_environ (FlatpakExports *exports,
       canon = g_canonicalize_filename (values[i], NULL);
       value_host = pv_current_namespace_path_to_host_path (canon);
 
+      if (flatpak_has_path_prefix (canon, "/usr"))
+        g_warning_once ("Binding directories that are located under \"/usr/\" is not supported!");
+
       g_info ("Bind-mounting %s=\"%s%s%s\" from the current env as %s=\"%s%s%s\" in the host",
               variable, before, values[i], after,
               variable, before, value_host, after);
@@ -2374,6 +2377,9 @@ main (int argc,
               g_assert (g_path_is_absolute (opt_filesystems[i]));
 
               g_info ("Bind-mounting \"%s\"", opt_filesystems[i]);
+              if (flatpak_has_path_prefix (opt_filesystems[i], "/usr"))
+                g_warning_once ("Binding directories that are located under \"/usr/\" "
+                                "is not supported!");
               flatpak_exports_add_path_expose (exports,
                                                FLATPAK_FILESYSTEM_MODE_READ_WRITE,
                                                opt_filesystems[i]);
-- 
GitLab