diff --git a/app/xdg-app-builtins-build-export.c b/app/xdg-app-builtins-build-export.c index 296b5910..940e9e96 100644 --- a/app/xdg-app-builtins-build-export.c +++ b/app/xdg-app-builtins-build-export.c @@ -407,10 +407,9 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, if (!ostree_repo_commit_transaction (repo, &stats, cancellable, error)) goto out; - if (!ostree_repo_regenerate_summary (repo, - NULL, - cancellable, - error)) + if (!xdg_app_repo_update (repo, + cancellable, + error)) goto out; format_size = g_format_size (stats.content_bytes_written); diff --git a/app/xdg-app-builtins-repo-update.c b/app/xdg-app-builtins-repo-update.c index e6a74fdb..5b693c3b 100644 --- a/app/xdg-app-builtins-repo-update.c +++ b/app/xdg-app-builtins-repo-update.c @@ -46,7 +46,6 @@ xdg_app_builtin_build_update_repo (int argc, char **argv, GCancellable *cancella g_autoptr(GFile) repofile = NULL; g_autoptr(OstreeRepo) repo = NULL; const char *location; - GVariant *extra = NULL; context = g_option_context_new ("LOCATION - Update repository metadata"); @@ -64,19 +63,12 @@ xdg_app_builtin_build_update_repo (int argc, char **argv, GCancellable *cancella if (!ostree_repo_open (repo, cancellable, error)) return FALSE; - if (opt_title) - { - GVariantBuilder builder; - - g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); - g_variant_builder_add (&builder, "{sv}", "xa.title", g_variant_new_string (opt_title)); - extra = g_variant_builder_end (&builder); - } - - if (!ostree_repo_regenerate_summary (repo, extra, cancellable, error)) + if (opt_title && + !xdg_app_repo_set_title (repo, opt_title, error)) return FALSE; - /* TODO: appstream data */ + if (!xdg_app_repo_update (repo, cancellable, error)) + return FALSE; return TRUE; } diff --git a/common/xdg-app-utils.c b/common/xdg-app-utils.c index 7c590758..08ed0d4c 100644 --- a/common/xdg-app-utils.c +++ b/common/xdg-app-utils.c @@ -1293,3 +1293,54 @@ xdg_app_variant_bsearch_str (GVariant *array, *out_pos = imid; return FALSE; } + +gboolean +xdg_app_repo_set_title (OstreeRepo *repo, + const char *title, + GError **error) +{ + g_autoptr(GKeyFile) config = NULL; + + config = ostree_repo_copy_config (repo); + + if (title) + g_key_file_set_string (config, "xdg-app", "title", title); + else + g_key_file_remove_key (config, "xdg-app", "title", NULL); + + if (!ostree_repo_write_config (repo, config, error)) + return FALSE; + + return TRUE; +} + +gboolean +xdg_app_repo_update (OstreeRepo *repo, + GCancellable *cancellable, + GError **error) +{ + GVariantBuilder builder; + GKeyFile *config; + g_autofree char *title = NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + + config = ostree_repo_get_config (repo); + + if (config) + { + title = g_key_file_get_string (config, "xdg-app", "title", NULL); + } + + if (title) + g_variant_builder_add (&builder, "{sv}", "xa.title", + g_variant_new_string (title)); + + if (!ostree_repo_regenerate_summary (repo, g_variant_builder_end (&builder), + cancellable, error)) + return FALSE; + + /* TODO: appstream data */ + + return TRUE; +} diff --git a/common/xdg-app-utils.h b/common/xdg-app-utils.h index 17b464cf..2a08f0f6 100644 --- a/common/xdg-app-utils.h +++ b/common/xdg-app-utils.h @@ -169,6 +169,13 @@ void xdg_app_table_printer_append_with_comma (XdgAppTablePrinter void xdg_app_table_printer_finish_row (XdgAppTablePrinter *printer); void xdg_app_table_printer_print (XdgAppTablePrinter *printer); +gboolean xdg_app_repo_set_title (OstreeRepo *repo, + const char *title, + GError **error); +gboolean xdg_app_repo_update (OstreeRepo *repo, + GCancellable *cancellable, + GError **error); + gboolean xdg_app_spawn (GFile *dir, char **output, GError **error,