forked from alexlarsson/xdg-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxdg-app-builtins-repo-update.c
71 lines (51 loc) · 1.61 KB
/
xdg-app-builtins-repo-update.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "config.h"
#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "libgsystem.h"
#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)
{
gboolean ret = FALSE;
GOptionContext *context;
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, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
goto out;
if (argc < 2)
{
usage_error (context, "LOCATION must be specified", error);
goto out;
}
location = argv[1];
repofile = g_file_new_for_commandline_arg (location);
repo = ostree_repo_new (repofile);
if (!ostree_repo_open (repo, cancellable, error))
goto out;
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 */
ret = TRUE;
out:
if (context)
g_option_context_free (context);
return ret;
}