Add a --title option to repo-update

This stores a human-readable title in the additional metadata
of the repo summary. We use xa.title as the key.
tingping/wmclass
Matthias Clasen 2015-02-09 15:50:29 +01:00
parent 2054f0e6f5
commit 34dda64b95
3 changed files with 34 additions and 4 deletions

View File

@ -33,7 +33,8 @@ _xdg-app() {
[BUILD]='--runtime --network --x11'
[BUILD_FINISH]='--command --allow'
[BUILD_EXPORT]='--subject --body'
[ARG]='--arch --command --branch --var --allow --forbid --subject --body --runtime'
[REPO_UPDATE]='--title'
[ARG]='--arch --command --branch --var --allow --forbid --subject --body --title --runtime'
)
if __contains_word "--user" ${COMP_WORDS[*]}; then
@ -56,7 +57,7 @@ _xdg-app() {
--allow|--forbid)
comps='x11 wayland ipc pulseaudio system-dbus session-dbus network host-fs homedir'
;;
--branch|--subject|--body)
--branch|--subject|--body|--title)
comps=''
;;
esac
@ -152,6 +153,9 @@ _xdg-app() {
if [ "$verb" = "build-export" ]; then
comps="$comps ${OPTS[BUILD_EXPORT]}"
fi
if [ "$verb" = "repo-update" ]; then
comps="$comps ${OPTS[REPO_UPDATE]}"
fi
else
case "$verb" in

View File

@ -68,6 +68,15 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--title=TITLE</option></term>
<listitem><para>
A title for the repository, e.g. for display in a UI.
The title is stored in the repository summary.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>

View File

@ -10,6 +10,13 @@
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
static char *opt_title;
static GOptionEntry options[] = {
{ "title", 0, 0, G_OPTION_ARG_STRING, &opt_title, "A nice name to use for this repository", "TITLE" },
{ NULL }
};
gboolean
xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, GError **error)
@ -19,10 +26,11 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
gs_unref_object GFile *repofile = NULL;
gs_unref_object OstreeRepo *repo = NULL;
const char *location;
GVariant *extra = NULL;
context = g_option_context_new ("LOCATION - Update repository metadata");
if (!xdg_app_option_context_parse (context, NULL, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
goto out;
if (argc < 2)
@ -39,7 +47,16 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
if (!ostree_repo_open (repo, cancellable, error))
goto out;
if (!ostree_repo_regenerate_summary (repo, NULL, cancellable, error))
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))
goto out;
/* TODO: appstream data */