forked from Mirrors/flatpak-builder
extensions: Support subdirectory-suffix=foo
If directory is "foo" and the extension id ends with ".ext" and subdirectory-suffix is "sub" then the extension point will be "/usr/foo/ext/sub" rather than just "/usr/foo/ext". This is very useful when the extension point naming scheme is "reversed". For instance, this happens for the /usr/share/themes directory. An extension point for a gtk3 theme would be in /usr/share/themes/$NAME/gtk-3.0, which could be achived by using subdirectory-suffix=gtk-3.0.tingping/wmclass
parent
a3da0b3da8
commit
5e1d456b8b
|
@ -194,7 +194,9 @@ flatpak_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
|
|||
g_autoptr(GKeyFile) x_metakey = NULL;
|
||||
g_autofree char *x_group = NULL;
|
||||
g_autofree char *x_dir = NULL;
|
||||
g_autofree char *x_subdir_suffix = NULL;
|
||||
char *x_subdir = NULL;
|
||||
g_autofree char *bare_extension_point = NULL;
|
||||
|
||||
extensionof_deploy = flatpak_find_deploy_for_ref (extensionof_ref, cancellable, error);
|
||||
if (extensionof_deploy == NULL)
|
||||
|
@ -225,20 +227,25 @@ flatpak_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
|
|||
if (x_dir == NULL)
|
||||
return FALSE;
|
||||
|
||||
x_subdir_suffix = g_key_file_get_string (x_metakey, x_group,
|
||||
"subdirectory-suffix", NULL);
|
||||
|
||||
if (is_app_extension)
|
||||
{
|
||||
app_files = flatpak_deploy_get_files (extensionof_deploy);
|
||||
app_files_ro = TRUE;
|
||||
if (x_subdir != NULL)
|
||||
extension_tmpfs_point = g_build_filename ("/app", x_dir, NULL);
|
||||
extension_point = g_build_filename ("/app", x_dir, x_subdir, NULL);
|
||||
bare_extension_point = g_build_filename ("/app", x_dir, x_subdir, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x_subdir != NULL)
|
||||
extension_tmpfs_point = g_build_filename ("/usr", x_dir, NULL);
|
||||
extension_point = g_build_filename ("/usr", x_dir, x_subdir, NULL);
|
||||
bare_extension_point = g_build_filename ("/usr", x_dir, x_subdir, NULL);
|
||||
}
|
||||
|
||||
extension_point = g_build_filename (bare_extension_point, x_subdir_suffix, NULL);
|
||||
}
|
||||
|
||||
argv_array = g_ptr_array_new_with_free_func (g_free);
|
||||
|
|
|
@ -2187,13 +2187,14 @@ flatpak_run_add_extension_args (GPtrArray *argv_array,
|
|||
for (l = extensions; l != NULL; l = l->next)
|
||||
{
|
||||
FlatpakExtension *ext = l->data;
|
||||
g_autofree char *full_directory = g_build_filename (is_app ? "/app" : "/usr", ext->directory, NULL);
|
||||
g_autofree char *directory = g_build_filename (is_app ? "/app" : "/usr", ext->directory, NULL);
|
||||
g_autofree char *full_directory = g_build_filename (directory, ext->subdir_suffix, NULL);
|
||||
g_autofree char *ref = g_build_filename (full_directory, ".ref", NULL);
|
||||
g_autofree char *real_ref = g_build_filename (ext->files_path, ext->directory, ".ref", NULL);
|
||||
|
||||
if (ext->needs_tmpfs)
|
||||
{
|
||||
g_autofree char *parent = g_path_get_dirname (full_directory);
|
||||
g_autofree char *parent = g_path_get_dirname (directory);
|
||||
if (g_hash_table_lookup (mounted_tmpfs, parent) == NULL)
|
||||
{
|
||||
add_args (argv_array,
|
||||
|
|
|
@ -3451,6 +3451,7 @@ flatpak_extension_free (FlatpakExtension *extension)
|
|||
g_free (extension->directory);
|
||||
g_free (extension->files_path);
|
||||
g_free (extension->add_ld_path);
|
||||
g_free (extension->subdir_suffix);
|
||||
g_free (extension);
|
||||
}
|
||||
|
||||
|
@ -3470,6 +3471,7 @@ flatpak_extension_new (const char *id,
|
|||
const char *ref,
|
||||
const char *directory,
|
||||
const char *add_ld_path,
|
||||
const char *subdir_suffix,
|
||||
GFile *files,
|
||||
gboolean is_unmaintained)
|
||||
{
|
||||
|
@ -3481,6 +3483,7 @@ flatpak_extension_new (const char *id,
|
|||
ext->directory = g_strdup (directory);
|
||||
ext->files_path = g_file_get_path (files);
|
||||
ext->add_ld_path = g_strdup (add_ld_path);
|
||||
ext->subdir_suffix = g_strdup (subdir_suffix);
|
||||
ext->is_unmaintained = is_unmaintained;
|
||||
|
||||
if (is_unmaintained)
|
||||
|
@ -3523,6 +3526,7 @@ flatpak_list_extensions (GKeyFile *metakey,
|
|||
g_autofree char *directory = g_key_file_get_string (metakey, groups[i], "directory", NULL);
|
||||
g_autofree char *version = g_key_file_get_string (metakey, groups[i], "version", NULL);
|
||||
g_autofree char *add_ld_path = g_key_file_get_string (metakey, groups[i], "add-ld-path", NULL);
|
||||
g_autofree char *subdir_suffix = g_key_file_get_string (metakey, groups[i], "subdirectory-suffix", NULL);
|
||||
g_autofree char *ref = NULL;
|
||||
const char *branch;
|
||||
gboolean is_unmaintained = FALSE;
|
||||
|
@ -3548,7 +3552,7 @@ flatpak_list_extensions (GKeyFile *metakey,
|
|||
/* Prefer a full extension (org.freedesktop.Locale) over subdirectory ones (org.freedesktop.Locale.sv) */
|
||||
if (files != NULL)
|
||||
{
|
||||
ext = flatpak_extension_new (extension, extension, ref, directory, add_ld_path, files, is_unmaintained);
|
||||
ext = flatpak_extension_new (extension, extension, ref, directory, add_ld_path, subdir_suffix, files, is_unmaintained);
|
||||
res = g_list_prepend (res, ext);
|
||||
}
|
||||
else if (g_key_file_get_boolean (metakey, groups[i],
|
||||
|
@ -3569,7 +3573,7 @@ flatpak_list_extensions (GKeyFile *metakey,
|
|||
|
||||
if (subdir_files)
|
||||
{
|
||||
ext = flatpak_extension_new (extension, refs[j], dir_ref, extended_dir, add_ld_path, subdir_files, FALSE);
|
||||
ext = flatpak_extension_new (extension, refs[j], dir_ref, extended_dir, add_ld_path, subdir_suffix, subdir_files, FALSE);
|
||||
ext->needs_tmpfs = TRUE;
|
||||
res = g_list_prepend (res, ext);
|
||||
}
|
||||
|
@ -3585,7 +3589,7 @@ flatpak_list_extensions (GKeyFile *metakey,
|
|||
|
||||
if (subdir_files)
|
||||
{
|
||||
ext = flatpak_extension_new (extension, unmaintained_refs[j], dir_ref, extended_dir, add_ld_path, subdir_files, TRUE);
|
||||
ext = flatpak_extension_new (extension, unmaintained_refs[j], dir_ref, extended_dir, add_ld_path, subdir_suffix, subdir_files, TRUE);
|
||||
ext->needs_tmpfs = TRUE;
|
||||
res = g_list_prepend (res, ext);
|
||||
}
|
||||
|
|
|
@ -324,6 +324,7 @@ typedef struct
|
|||
char *ref;
|
||||
char *directory;
|
||||
char *files_path;
|
||||
char *subdir_suffix;
|
||||
char *add_ld_path;
|
||||
int priority;
|
||||
gboolean needs_tmpfs;
|
||||
|
|
Loading…
Reference in New Issue