forked from Mirrors/flatpak-builder
93 lines
2.4 KiB
C
93 lines
2.4 KiB
C
/*
|
|
* Copyright © 2014 Red Hat, Inc
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* Authors:
|
|
* Alexander Larsson <alexl@redhat.com>
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <locale.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
#include "libgsystem.h"
|
|
#include "libglnx/libglnx.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;
|
|
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");
|
|
|
|
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;
|
|
}
|