Better handling of the title in the summary

Now we store the title in the repo config and re-apply it every time
we regenerate the summary.
tingping/wmclass
Alexander Larsson 2016-01-14 21:26:51 +01:00
parent 93e8d8bd78
commit cb971722fe
4 changed files with 65 additions and 16 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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,