Merge pull request #38 from matthiasclasen/repo-update

Separate out repo-updating command
tingping/wmclass
Alexander Larsson 2015-01-26 13:16:17 +01:00
commit 654ab3405e
10 changed files with 182 additions and 7 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

@ -15,7 +15,7 @@ _xdg-app() {
local dir cmd sdk loc
local -A VERBS=(
[ALL]='add-remote delete-remote list-remotes repo-contents install-runtime update-runtime uninstall-runtime list-runtimes install-app update-app uninstall-app list-apps run build-init build build-finish build-export'
[ALL]='add-remote delete-remote list-remotes repo-contents install-runtime update-runtime uninstall-runtime list-runtimes install-app update-app uninstall-app list-apps run build-init build build-finish build-export repo-update'
[MODE]='add-remote delete-remote list-remotes repo-contents install-runtime update-runtime uninstall-runtime list-runtimes install-app update-app uninstall-app list-apps'
[UNINSTALL]='uninstall-runtime uninstall-app'
[ARCH]='build-init install-runtime install-app run uninstall-runtime uninstall-app update-runtime update-app'
@ -110,6 +110,10 @@ _xdg-app() {
elif [[ -z $name ]]; then
name=${COMP_WORDS[i]}
fi
elif [[ $verb = repo-update ]]; then
if [[ -z $loc ]]; then
loc=${COMP_WORDS[i]}
fi
fi
done
@ -241,6 +245,13 @@ _xdg-app() {
fi
;;
repo-update)
if [[ -z $loc ]]; then
comps=''
compopt -o dirnames
fi
;;
esac
fi

View File

@ -31,6 +31,7 @@ man_MANS = \
xdg-app-build.1 \
xdg-app-build-finish.1 \
xdg-app-build-export.1 \
xdg-app-repo-contents.1 \
$(NULL)
xml_files = $(man_MANS:.1=.xml)

View File

@ -66,9 +66,8 @@
in the commit, anything else is ignored.
</para>
<para>
After this command, <arg choice="plain">LOCATION</arg> can be
used as the repository location for xdg-app add-repo, either by
exporting it over http, or directly with a file: url.
The repo-update command should be used to update repository
metadata whenever application builds are added to a repository.
</para>
</refsect1>
@ -150,6 +149,7 @@ Content Bytes Written: 305
<citerefentry><refentrytitle>xdg-app-build-init</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-build</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-build-finish</refentrytitle><manvolnum>1</manvolnum></citerefentry>
<citerefentry><refentrytitle>xdg-app-repo-update</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -0,0 +1,102 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<refentry id="xdg-app-repo-update">
<refentryinfo>
<title>xdg-app repo-update</title>
<productname>xdg-app</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Alexander</firstname>
<surname>Larsson</surname>
<email>alexl@redhat.com</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>xdg-app repo-update</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>xdg-app-repo-update</refname>
<refpurpose>Create a repository from a build directory</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>xdg-app repo-update</command>
<arg choice="opt" rep="repeat">OPTION</arg>
<arg choice="plain">LOCATION</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Updates repository metadata for the repository at
<arg choice="plain">LOCATION</arg>. This command generates
an OSTree summary file that lists the contents of the repository.
The summary is used by xdg-app repo-contents and other commands
to display the contents of remote repositories.
</para>
<para>
After this command, <arg choice="plain">LOCATION</arg> can be
used as the repository location for xdg-app add-repo, either by
exporting it over http, or directly with a file: url.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>The following options are understood:</para>
<variablelist>
<varlistentry>
<term><option>-h</option></term>
<term><option>--help</option></term>
<listitem><para>
Show help options and exit.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>
<listitem><para>
Print debug information during command processing.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--version</option></term>
<listitem><para>
Print version information and exit.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<citerefentry><refentrytitle>ostree</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-repo-contents</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-build-export</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -245,6 +245,13 @@
Create a repository from a build directory.
</para></listitem>
</varlistentry>
<varlistentry>
<term><citerefentry><refentrytitle>xdg-app-repo-contents</refentrytitle><manvolnum>1</manvolnum></citerefentry></term>
<listitem><para>
Update repository metadata.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

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