Skip to content
Snippets Groups Projects
Commit 9bd42167 authored by Simon McVittie's avatar Simon McVittie
Browse files

runtime: Create EGL, Vulkan ICD JSON as symlinks into /run/host


Because that isn't going to work if you have EGL/Vulkan ICDs installed
in your home directory or something, and the JSON file is small, we
fall back to copying in this case.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent ad9ee411
No related branches found
No related tags found
No related merge requests found
...@@ -1639,6 +1639,7 @@ typedef enum ...@@ -1639,6 +1639,7 @@ typedef enum
TAKE_FROM_HOST_FLAGS_IF_DIR = (1 << 0), TAKE_FROM_HOST_FLAGS_IF_DIR = (1 << 0),
TAKE_FROM_HOST_FLAGS_IF_EXISTS = (1 << 1), TAKE_FROM_HOST_FLAGS_IF_EXISTS = (1 << 1),
TAKE_FROM_HOST_FLAGS_IF_CONTAINER_COMPATIBLE = (1 << 2), TAKE_FROM_HOST_FLAGS_IF_CONTAINER_COMPATIBLE = (1 << 2),
TAKE_FROM_HOST_FLAGS_COPY_FALLBACK = (1 << 3),
TAKE_FROM_HOST_FLAGS_NONE = 0 TAKE_FROM_HOST_FLAGS_NONE = 0
} TakeFromHostFlags; } TakeFromHostFlags;
...@@ -1675,12 +1676,6 @@ pv_runtime_take_from_host (PvRuntime *self, ...@@ -1675,12 +1676,6 @@ pv_runtime_take_from_host (PvRuntime *self,
const char *base; const char *base;
glnx_autofd int parent_dirfd = -1; glnx_autofd int parent_dirfd = -1;
/* If it isn't in /usr, /lib, etc., then the symlink will be
* dangling and this probably isn't going to work. */
if (!path_visible_in_run_host (source_in_host))
g_warning ("\"%s\" is unlikely to appear in /run/host",
source_in_host);
parent_in_container = g_path_get_dirname (dest_in_container); parent_in_container = g_path_get_dirname (dest_in_container);
parent_dirfd = pv_resolve_in_sysroot (self->mutable_sysroot_fd, parent_dirfd = pv_resolve_in_sysroot (self->mutable_sysroot_fd,
parent_in_container, parent_in_container,
...@@ -1695,6 +1690,25 @@ pv_runtime_take_from_host (PvRuntime *self, ...@@ -1695,6 +1690,25 @@ pv_runtime_take_from_host (PvRuntime *self,
if (!glnx_shutil_rm_rf_at (parent_dirfd, base, NULL, error)) if (!glnx_shutil_rm_rf_at (parent_dirfd, base, NULL, error))
return FALSE; return FALSE;
/* If it isn't in /usr, /lib, etc., then the symlink will be
* dangling and this probably isn't going to work. */
if (!path_visible_in_run_host (source_in_host))
{
if (flags & TAKE_FROM_HOST_FLAGS_COPY_FALLBACK)
{
return glnx_file_copy_at (AT_FDCWD, source_in_host, NULL,
parent_dirfd, base,
GLNX_FILE_COPY_OVERWRITE,
NULL, error);
}
else
{
g_warning ("\"%s\" is unlikely to appear in /run/host",
source_in_host);
/* ... but try it anyway, it can't hurt */
}
}
target = g_build_filename ("/run/host", source_in_host, NULL); target = g_build_filename ("/run/host", source_in_host, NULL);
if (TEMP_FAILURE_RETRY (symlinkat (target, parent_dirfd, base)) != 0) if (TEMP_FAILURE_RETRY (symlinkat (target, parent_dirfd, base)) != 0)
...@@ -2467,9 +2481,13 @@ pv_runtime_use_host_graphics_stack (PvRuntime *self, ...@@ -2467,9 +2481,13 @@ pv_runtime_use_host_graphics_stack (PvRuntime *self,
"glvnd", "egl_vendor.d", "glvnd", "egl_vendor.d",
json_base, NULL); json_base, NULL);
flatpak_bwrap_add_args (bwrap, if (!pv_runtime_take_from_host (self, bwrap,
"--ro-bind", json_on_host, json_in_container, json_on_host,
NULL); json_in_container,
TAKE_FROM_HOST_FLAGS_COPY_FALLBACK,
error))
return FALSE;
pv_search_path_append (egl_path, json_in_container); pv_search_path_append (egl_path, json_in_container);
} }
} }
...@@ -2541,9 +2559,13 @@ pv_runtime_use_host_graphics_stack (PvRuntime *self, ...@@ -2541,9 +2559,13 @@ pv_runtime_use_host_graphics_stack (PvRuntime *self,
"vulkan", "icd.d", "vulkan", "icd.d",
json_base, NULL); json_base, NULL);
flatpak_bwrap_add_args (bwrap, if (!pv_runtime_take_from_host (self, bwrap,
"--ro-bind", json_on_host, json_in_container, json_on_host,
NULL); json_in_container,
TAKE_FROM_HOST_FLAGS_COPY_FALLBACK,
error))
return FALSE;
pv_search_path_append (vulkan_path, json_in_container); pv_search_path_append (vulkan_path, json_in_container);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment