From a7741724c507e82ee941b02bb506fb6319dd4cd4 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 20 May 2020 12:36:44 +0100
Subject: [PATCH] runtime: Don't use bwrap to run locale-gen when not required

If we're running locale-gen on the host system, we might as well just
run it, without wrapping bwrap around it. This requires the new
--output-dir option in p-v-locale-gen.

To stay consistent, also move from bwrap --chdir DIR to
p-v-locale-gen --output-dir DIR in the case where we still need to
use bwrap.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 src/runtime.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/runtime.c b/src/runtime.c
index c98cc017f..71a62fc7b 100644
--- a/src/runtime.c
+++ b/src/runtime.c
@@ -731,16 +731,11 @@ ensure_locales (PvRuntime *self,
       locale_gen = g_build_filename (self->tools_dir,
                                      "pressure-vessel-locale-gen",
                                      NULL);
-
-      flatpak_bwrap_add_args (run_locale_gen,
-                              self->bubblewrap,
-                              "--ro-bind", "/", "/",
-                              NULL);
-      pv_bwrap_add_api_filesystems (run_locale_gen);
+      /* We don't actually need to use bwrap when we're just running on
+       * the host system. */
       flatpak_bwrap_add_args (run_locale_gen,
-                              "--bind", locales, locales,
-                              "--chdir", locales,
                               locale_gen,
+                              "--output-dir", locales,
                               "--verbose",
                               NULL);
     }
@@ -764,8 +759,8 @@ ensure_locales (PvRuntime *self,
       flatpak_bwrap_add_args (run_locale_gen,
                               "--ro-bind", self->tools_dir, "/run/host/tools",
                               "--bind", locales, "/overrides/locales",
-                              "--chdir", "/overrides/locales",
                               locale_gen,
+                              "--output-dir", "/overrides/locales",
                               "--verbose",
                               NULL);
     }
-- 
GitLab