Separate out repo-updating command

Take the summary update out of build-export, and add it to
a new repo-update command instead.
tingping/wmclass
Matthias Clasen 2015-01-24 21:43:18 -05:00
parent 97747a3e53
commit dfde6c46b8
5 changed files with 57 additions and 3 deletions

View File

@ -41,6 +41,7 @@ xdg_app_SOURCES = \
xdg-app-builtins-build.c \
xdg-app-builtins-build-finish.c \
xdg-app-builtins-build-export.c \
xdg-app-builtins-repo-update.c \
xdg-app-dir.c \
xdg-app-dir.h \
xdg-app-utils.h \

View File

@ -219,9 +219,6 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable,
g_print ("Content Written: %u\n", stats.content_objects_written);
g_print ("Content Bytes Written: %" G_GUINT64_FORMAT "\n", stats.content_bytes_written);
if (!ostree_repo_regenerate_summary (repo, NULL, cancellable, error))
goto out;
ret = TRUE;
out:

View File

@ -0,0 +1,54 @@
#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"
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;
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))
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 (!ostree_repo_regenerate_summary (repo, NULL, cancellable, error))
goto out;
/* TODO: appstream data */
ret = TRUE;
out:
if (context)
g_option_context_free (context);
return ret;
}

View File

@ -45,6 +45,7 @@ BUILTINPROTO(build_init);
BUILTINPROTO(build);
BUILTINPROTO(build_finish);
BUILTINPROTO(build_export);
BUILTINPROTO(repo_update);
#undef BUILTINPROTO

View File

@ -36,6 +36,7 @@ static XdgAppCommand commands[] = {
{ "build", xdg_app_builtin_build },
{ "build-finish", xdg_app_builtin_build_finish },
{ "build-export", xdg_app_builtin_build_export },
{ "repo-update", xdg_app_builtin_repo_update },
{ NULL }
};