Use ostree's BARE_USER_ONLY flag (#674)

* Use ostree's BARE_USER_ONLY flag

Now that Ostree has a 'bare user only' mode for repositories, we should
use it.

This allows installing Flatpak run times inside different Docker layers.

Original patch by: Alexander Larsson <alexl@redhat.com>
Tested-by: Emmanuele Bassi <ebassi@gmail.com>

* Use the parent mode when creating a child repo

Instead of hard coding the repository mode, query the parent's mode.

* Gate bare-user-only repo creation behind an environment variable

We keep the default of bare-user repositories, but with an environment
variable we change new repositories to bare-user-only.
This commit is contained in:
Emmanuele Bassi
2017-04-03 15:31:18 +01:00
committed by Alexander Larsson
parent 31364707d5
commit 8bbcf0b23b

View File

@@ -1398,9 +1398,18 @@ flatpak_dir_ensure_repo (FlatpakDir *self,
if (!g_file_query_exists (repodir, cancellable))
{
if (!ostree_repo_create (repo,
OSTREE_REPO_MODE_BARE_USER,
cancellable, error))
OstreeRepoMode mode = OSTREE_REPO_MODE_BARE_USER;
#if OSTREE_CHECK_VERSION(2017, 3)
{
const char *mode_env = g_getenv ("FLATPAK_OSTREE_REPO_MODE");
if (g_strcmp0 (mode_env, "user-only") == 0)
mode = OSTREE_REPO_MODE_BARE_USER_ONLY;
}
#endif
if (!ostree_repo_create (repo, mode, cancellable, error))
{
flatpak_rm_rf (repodir, cancellable, NULL);
goto out;
@@ -4529,9 +4538,9 @@ flatpak_dir_create_system_child_repo (FlatpakDir *self,
repo_dir_config = g_file_get_child (repo_dir, "config");
if (!g_file_query_exists (repo_dir_config, NULL))
{
if (!ostree_repo_create (new_repo,
OSTREE_REPO_MODE_BARE_USER,
NULL, error))
OstreeRepoMode parent_mode = ostree_repo_get_mode (self->repo);
if (!ostree_repo_create (new_repo, parent_mode, NULL, error))
return NULL;
}
else