From 545a6996983870107c22f24ca51923692e2b3d9a Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 7 Apr 2016 13:00:01 +0200 Subject: builder: Only create one locale extension Given that each app can have 100 locates, ostree just doesn't scale to having a branch per app/locale combo. For 100 apps and 100 locales that would be 10000 branches. Also, things like xdg-app remote-list doesn't properly handle that either. We need to handle this by e.g. supporting subsetting the pull of the locale extension. --- builder/builder-manifest.c | 119 ++++++++--------------------------------- builder/xdg-app-builder-main.c | 19 +------ 2 files changed, 24 insertions(+), 114 deletions(-) (limited to 'builder') diff --git a/builder/builder-manifest.c b/builder/builder-manifest.c index 5882b20..8778d90 100644 --- a/builder/builder-manifest.c +++ b/builder/builder-manifest.c @@ -1634,10 +1634,9 @@ builder_manifest_finish (BuilderManifest *self, { g_autoptr(GFile) metadata_file = NULL; g_autofree char *extension_contents = NULL; - g_autoptr(GFileEnumerator) dir_enum = NULL; g_autoptr(GFileOutputStream) output = NULL; - gboolean found_locale = FALSE; - GFileInfo *next; + g_autoptr(GFile) metadata_locale_file = NULL; + g_autofree char *metadata_contents = NULL; metadata_file = g_file_get_child (app_dir, "metadata"); @@ -1656,51 +1655,16 @@ builder_manifest_finish (BuilderManifest *self, NULL, NULL, error)) return FALSE; - 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.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, 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; - found_locale = TRUE; - } - } - if (found_locale) - { - g_autoptr(GFile) metadata_locale_file = NULL; - g_autofree char *metadata_contents = NULL; - - metadata_locale_file = g_file_get_child (app_dir, "metadata.locale"); - metadata_contents = g_strdup_printf("[Runtime]\n" - "name=%s.Locale\n", self->id); - 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; - } + metadata_locale_file = g_file_get_child (app_dir, "metadata.locale"); + metadata_contents = g_strdup_printf("[Runtime]\n" + "name=%s.Locale\n", self->id); + 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; } @@ -1920,11 +1884,10 @@ builder_manifest_create_platform (BuilderManifest *self, { 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; - gboolean found_locale = FALSE; + g_autoptr(GFile) metadata_locale_file = NULL; + g_autofree char *metadata_contents = NULL; metadata_file = g_file_get_child (app_dir, "metadata.platform"); @@ -1943,54 +1906,16 @@ builder_manifest_create_platform (BuilderManifest *self, 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; - - found_locale = TRUE; - } - } - if (found_locale) - { - g_autoptr(GFile) metadata_locale_file = NULL; - g_autofree char *metadata_contents = NULL; - - metadata_locale_file = g_file_get_child (app_dir, "metadata.platform.locale"); - metadata_contents = g_strdup_printf("[Runtime]\n" - "name=%s.Locale\n", self->id_platform); - 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; - - } + metadata_locale_file = g_file_get_child (app_dir, "metadata.platform.locale"); + metadata_contents = g_strdup_printf("[Runtime]\n" + "name=%s.Locale\n", self->id_platform); + 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)) diff --git a/builder/xdg-app-builder-main.c b/builder/xdg-app-builder-main.c index d284370..f4fce5f 100644 --- a/builder/xdg-app-builder-main.c +++ b/builder/xdg-app-builder-main.c @@ -369,27 +369,19 @@ main (int argc, { g_autoptr(GFileInfo) child_info = next; const char *name = g_file_info_get_name (child_info); - const char *language = NULL; g_autofree char *metadata_arg = NULL; g_autofree char *files_arg = NULL; if (strcmp (name, "metadata.locale") == 0) { g_print ("exporting %s.Locale to repo\n", builder_manifest_get_id (manifest)); - language = NULL; - } - else if (g_str_has_prefix (name, "metadata.locale.")) - { - language = name + strlen ("metadata.locale."); - - g_print ("exporting %s.Locale.%s to repo\n", builder_manifest_get_id (manifest), language); } else continue; metadata_arg = g_strdup_printf ("--metadata=%s", name); files_arg = g_strconcat (builder_context_get_build_runtime (build_context) ? "--files=usr" : "--files=files", - "/share/runtime/locale/", language, NULL); + "/share/runtime/locale/", NULL); if (!do_export (&error, TRUE, metadata_arg, files_arg, @@ -443,25 +435,18 @@ main (int argc, { 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 (strcmp (name, "metadata.platform.locale") == 0) { g_print ("exporting %s.Locale to repo\n", platform_id); - language = NULL; - } - else if (g_str_has_prefix (name, "metadata.platform.locale.")) - { - language = name + strlen ("metadata.platform.locale."); - g_print ("exporting %s.Locale.%s to repo\n", platform_id, language); } else continue; metadata_arg = g_strdup_printf ("--metadata=%s", name); - files_arg = g_strconcat ("--files=platform/share/runtime/locale/", language, NULL); + files_arg = g_strconcat ("--files=platform/share/runtime/locale/", NULL); if (!do_export (&error, TRUE, metadata_arg, files_arg, -- cgit v1.2.1