builder: Unbreak hardlinks when eu-stripping

Otherwise this breaks with rofiles-fuse if the build produces
hardlinked installed files. For instance, as done by mesa.
tingping/wmclass
Alexander Larsson 2017-02-15 19:22:14 +01:00
parent ee83364a8e
commit 5a3c7feb15
3 changed files with 37 additions and 0 deletions

View File

@ -997,6 +997,12 @@ builder_module_handle_debuginfo (BuilderModule *self,
}
g_print ("stripping %s to %s\n", path, debug_path);
/* Some files are hardlinked and eu-strip modifies in-place,
which breaks rofiles-fuse. Unlink them */
if (!flatpak_unbreak_hardlink (file, error))
return FALSE;
if (!eu_strip (error, "--remove-comment", "--reloc-debug-sections",
"-f", debug_path,
"-F", real_debug_path,

View File

@ -498,6 +498,36 @@ flatpak_get_bwrap (void)
return HELPER;
}
gboolean
flatpak_unbreak_hardlink (GFile *file, GError **error)
{
g_autofree char *path = g_file_get_path (file);
struct stat st_buf;
if (stat (path, &st_buf) == 0 && st_buf.st_nlink > 1)
{
g_autoptr(GFile) dir = g_file_get_parent (file);
g_autoptr(GFile) tmp = NULL;
tmp = flatpak_file_new_tmp_in (dir, ".eustripXXXXXX", error);
if (tmp == NULL)
return FALSE;
if (!g_file_copy (file, tmp,
G_FILE_COPY_OVERWRITE,
NULL, NULL, NULL, error))
return FALSE;
if (rename (flatpak_file_get_path_cached (tmp), path) != 0)
{
glnx_set_error_from_errno (error);
return FALSE;
}
}
return TRUE;
}
/* We only migrate the user dir, because thats what most people used with xdg-app,
* and its where all per-user state/config are stored.
*/

View File

@ -78,6 +78,7 @@ void flatpak_migrate_from_xdg_app (void);
GFile *flatpak_file_new_tmp_in (GFile *dir,
const char *templatename,
GError **error);
gboolean flatpak_unbreak_hardlink (GFile *file, GError **error);
gboolean flatpak_write_update_checksum (GOutputStream *out,
gconstpointer data,