builder: Handle the case where the source directory is in a symlink

It can happen, like in https://github.com/flatpak/flatpak/issues/353
that there are references in the source to the absolute source path.
We need to ensure that is visible in the build. We mostly do this,
but for technical reasons it didn't get the same pathname when
the source was inside a symlinked directory. We fix this with an
extra bind-mount to the symlinked directory name too.

This fixes https://github.com/flatpak/flatpak/issues/353
tingping/wmclass
Alexander Larsson 2016-10-18 11:03:54 +02:00
parent 6345f0bae7
commit 0f05143227
1 changed files with 6 additions and 0 deletions

View File

@ -760,8 +760,14 @@ build (GFile *app_dir,
builddir = "/run/build/";
g_ptr_array_add (args, g_strdup ("--nofilesystem=host"));
/* We mount the canonical location, because bind-mounts of symlinks don't really work */
g_ptr_array_add (args, g_strdup_printf ("--filesystem=%s", source_dir_path_canonical));
/* Also make sure the original path is available (if it was not canonical, in case something references that. */
if (strcmp (source_dir_path_canonical, source_dir_path) != 0)
g_ptr_array_add (args, g_strdup_printf ("--bind-mount=%s=%s", source_dir_path, source_dir_path_canonical));
g_ptr_array_add (args, g_strdup_printf ("--bind-mount=%s%s=%s", builddir, module_name, source_dir_path_canonical));
if (cwd_subdir)
g_ptr_array_add (args, g_strdup_printf ("--build-dir=%s%s/%s", builddir, module_name, cwd_subdir));