forked from Mirrors/flatpak-builder
Add support for separated locales when creating platforms
parent
f1d401e6cd
commit
f98f565df0
|
@ -1766,6 +1766,16 @@ builder_manifest_create_platform (BuilderManifest *self,
|
|||
!g_subprocess_wait_check (subp, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (self->separate_locales)
|
||||
{
|
||||
g_autoptr(GFile) root_dir = NULL;
|
||||
|
||||
root_dir = g_file_get_child (app_dir, "platform");
|
||||
|
||||
if (!builder_migrate_locale_dirs (root_dir, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->metadata_platform)
|
||||
{
|
||||
GFile *base_dir = builder_context_get_base_dir (context);
|
||||
|
@ -1868,6 +1878,63 @@ builder_manifest_create_platform (BuilderManifest *self,
|
|||
}
|
||||
}
|
||||
|
||||
if (self->separate_locales)
|
||||
{
|
||||
g_autoptr(GFile) metadata_file = NULL;
|
||||
g_autofree char *extension_contents = NULL;
|
||||
g_autoptr(GFileEnumerator) dir_enum = NULL;
|
||||
g_autoptr(GFileOutputStream) output = NULL;
|
||||
g_autoptr(GFile) locale_parent_dir = NULL;
|
||||
GFileInfo *next;
|
||||
|
||||
metadata_file = g_file_get_child (app_dir, "metadata.platform");
|
||||
|
||||
extension_contents = g_strdup_printf("\n"
|
||||
"[Extension %s.Locale]\n"
|
||||
"directory=share/runtime/locale\n"
|
||||
"subdirectories=true\n",
|
||||
self->id_platform);
|
||||
|
||||
output = g_file_append_to (metadata_file, G_FILE_CREATE_NONE, NULL, error);
|
||||
if (output == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!g_output_stream_write_all (G_OUTPUT_STREAM (output),
|
||||
extension_contents, strlen (extension_contents),
|
||||
NULL, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
locale_parent_dir = g_file_resolve_relative_path (platform_dir, "share/runtime/locale");
|
||||
dir_enum = g_file_enumerate_children (locale_parent_dir, "standard::name,standard::type",
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, NULL);
|
||||
|
||||
while (dir_enum != NULL &&
|
||||
(next = g_file_enumerator_next_file (dir_enum, NULL, NULL)))
|
||||
{
|
||||
g_autoptr(GFileInfo) child_info = next;
|
||||
const char *name = g_file_info_get_name (child_info);
|
||||
|
||||
if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
g_autoptr(GFile) metadata_locale_file = NULL;
|
||||
g_autofree char *metadata_contents = NULL;
|
||||
g_autofree char *filename = g_strdup_printf ("metadata.platform.locale.%s", name);
|
||||
|
||||
metadata_locale_file = g_file_get_child (app_dir, filename);
|
||||
|
||||
metadata_contents = g_strdup_printf("[Runtime]\n"
|
||||
"name=%s.Locale.%s\n", self->id_platform, name);
|
||||
if (!g_file_replace_contents (metadata_locale_file,
|
||||
metadata_contents, strlen (metadata_contents),
|
||||
NULL, FALSE,
|
||||
G_FILE_CREATE_REPLACE_DESTINATION,
|
||||
NULL, NULL, error))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!builder_cache_commit (cache, "Created platform", error))
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,7 @@ main (int argc,
|
|||
g_autoptr(BuilderCache) cache = NULL;
|
||||
g_autofree char *cache_branch = NULL;
|
||||
g_autoptr(GFileEnumerator) dir_enum = NULL;
|
||||
g_autoptr(GFileEnumerator) dir_enum2 = NULL;
|
||||
GFileInfo *next = NULL;
|
||||
const char *platform_id = NULL;
|
||||
|
||||
|
@ -359,22 +360,7 @@ main (int argc,
|
|||
return 1;
|
||||
}
|
||||
|
||||
platform_id = builder_manifest_get_id_platform (manifest);
|
||||
if (builder_context_get_build_runtime (build_context) &&
|
||||
platform_id != NULL)
|
||||
{
|
||||
g_print ("exporting %s to repo\n", platform_id);
|
||||
|
||||
if (!do_export (&error, TRUE,
|
||||
"--metadata=metadata.platform",
|
||||
"--files=platform",
|
||||
opt_repo, app_dir_path, NULL))
|
||||
{
|
||||
g_print ("Export failed: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Export regular locale extensions */
|
||||
dir_enum = g_file_enumerate_children (app_dir, "standard::name,standard::type",
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, NULL);
|
||||
|
@ -407,6 +393,7 @@ main (int argc,
|
|||
}
|
||||
}
|
||||
|
||||
/* Export debug extensions */
|
||||
debuginfo_metadata = g_file_get_child (app_dir, "metadata.debuginfo");
|
||||
if (g_file_query_exists (debuginfo_metadata, NULL))
|
||||
{
|
||||
|
@ -421,6 +408,55 @@ main (int argc,
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Export platform */
|
||||
platform_id = builder_manifest_get_id_platform (manifest);
|
||||
if (builder_context_get_build_runtime (build_context) &&
|
||||
platform_id != NULL)
|
||||
{
|
||||
g_print ("exporting %s to repo\n", platform_id);
|
||||
|
||||
if (!do_export (&error, TRUE,
|
||||
"--metadata=metadata.platform",
|
||||
"--files=platform",
|
||||
builder_context_get_separate_locales (build_context) ? "--exclude=/share/runtime/locale/*/*" : skip_arg,
|
||||
opt_repo, app_dir_path, NULL))
|
||||
{
|
||||
g_print ("Export failed: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Export platform locales */
|
||||
dir_enum2 = g_file_enumerate_children (app_dir, "standard::name,standard::type",
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, NULL);
|
||||
while (dir_enum2 != NULL &&
|
||||
(next = g_file_enumerator_next_file (dir_enum2, NULL, NULL)))
|
||||
{
|
||||
g_autoptr(GFileInfo) child_info = next;
|
||||
const char *name = g_file_info_get_name (child_info);
|
||||
const char *language;
|
||||
g_autofree char *metadata_arg = NULL;
|
||||
g_autofree char *files_arg = NULL;
|
||||
|
||||
if (!g_str_has_prefix (name, "metadata.platform.locale."))
|
||||
continue;
|
||||
language = name + strlen ("metadata.platform.locale.");
|
||||
|
||||
g_print ("exporting %s.Locale.%s to repo\n", platform_id, language);
|
||||
|
||||
metadata_arg = g_strdup_printf ("--metadata=%s", name);
|
||||
files_arg = g_strconcat ("--files=platform/share/runtime/locale/", language, NULL);
|
||||
if (!do_export (&error, TRUE,
|
||||
metadata_arg,
|
||||
files_arg,
|
||||
opt_repo, app_dir_path, NULL))
|
||||
{
|
||||
g_print ("Export failed: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!builder_gc (cache, &error))
|
||||
|
|
Loading…
Reference in New Issue