Support runtime-less extra-data

This is going to be needed for the nvidia driver to solve
https://github.com/flatpak/flatpak/issues/595

(cherry picked from commit 62286cf779)
This commit is contained in:
Alexander Larsson
2017-02-28 18:10:06 +01:00
parent c216d989a8
commit 8bd07ca2a0
2 changed files with 18 additions and 9 deletions

View File

@@ -3637,24 +3637,31 @@ apply_extra_data (FlatpakDir *self,
if (runtime_ref_parts == NULL)
return FALSE;
runtime_deploy = flatpak_find_deploy_for_ref (runtime_ref, cancellable, error);
if (runtime_deploy == NULL)
return FALSE;
if (!g_key_file_get_boolean (metakey, "Extra Data", "NoRuntime", NULL))
{
runtime_deploy = flatpak_find_deploy_for_ref (runtime_ref, cancellable, error);
if (runtime_deploy == NULL)
return FALSE;
runtime_files = flatpak_deploy_get_files (runtime_deploy);
}
app_files = g_file_get_child (checkoutdir, "files");
app_export_file = g_file_get_child (checkoutdir, "export");
extra_files = g_file_get_child (app_files, "extra");
extra_export_file = g_file_get_child (extra_files, "export");
runtime_files = flatpak_deploy_get_files (runtime_deploy);
argv_array = g_ptr_array_new_with_free_func (g_free);
fd_array = g_array_new (FALSE, TRUE, sizeof (int));
g_array_set_clear_func (fd_array, clear_fd);
g_ptr_array_add (argv_array, g_strdup (flatpak_get_bwrap ()));
add_args (argv_array,
"--ro-bind", flatpak_file_get_path_cached (runtime_files), "/usr",
if (runtime_files)
add_args (argv_array,
"--ro-bind", flatpak_file_get_path_cached (runtime_files), "/usr",
"--lock-file", "/usr/.ref",
NULL);
add_args (argv_array,
"--ro-bind", flatpak_file_get_path_cached (app_files), "/app",
"--bind", flatpak_file_get_path_cached (extra_files), "/app/extra",
"--chdir", "/app/extra",

View File

@@ -3960,8 +3960,10 @@ flatpak_run_setup_base_argv (GPtrArray *argv_array,
else if (g_file_test ("/var/lib/dbus/machine-id", G_FILE_TEST_EXISTS))
add_args (argv_array, "--ro-bind", "/var/lib/dbus/machine-id", "/etc/machine-id", NULL);
etc = g_file_get_child (runtime_files, "etc");
if ((flags & FLATPAK_RUN_FLAG_WRITABLE_ETC) == 0 &&
if (runtime_files)
etc = g_file_get_child (runtime_files, "etc");
if (etc != NULL &&
(flags & FLATPAK_RUN_FLAG_WRITABLE_ETC) == 0 &&
g_file_query_exists (etc, NULL))
{
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
@@ -4023,7 +4025,7 @@ flatpak_run_setup_base_argv (GPtrArray *argv_array,
NULL);
}
for (i = 0; i < G_N_ELEMENTS (usr_links); i++)
for (i = 0; runtime_files != NULL && i < G_N_ELEMENTS (usr_links); i++)
{
const char *subdir = usr_links[i];
g_autoptr(GFile) runtime_subdir = g_file_get_child (runtime_files, subdir);