Add build-import-bundle command

tingping/wmclass
Alexander Larsson 2016-04-19 13:48:49 +02:00
parent 1c1bc4acca
commit cfd3f303b1
8 changed files with 204 additions and 0 deletions

View File

@ -23,6 +23,7 @@ xdg_app_SOURCES = \
app/xdg-app-builtins-build-finish.c \
app/xdg-app-builtins-build-export.c \
app/xdg-app-builtins-build-bundle.c \
app/xdg-app-builtins-build-import-bundle.c \
app/xdg-app-builtins-build-sign.c \
app/xdg-app-builtins-repo-update.c \
app/xdg-app-builtins-document.c \

View File

@ -0,0 +1,94 @@
/*
* Copyright © 2015 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 GOptionEntry options[] = {
{ NULL }
};
gboolean
xdg_app_builtin_build_import (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
g_autoptr(GFile) file = NULL;
g_autoptr(GFile) repofile = NULL;
g_autoptr(OstreeRepo) repo = NULL;
g_autoptr(GBytes) gpg_data = NULL;
const char *location;
const char *filename;
g_autoptr(GVariant) metadata = NULL;
g_autofree char *ref = NULL;
g_autofree char *to_checksum = NULL;
context = g_option_context_new ("LOCATION FILENAME - Import a file bundle into a local repository");
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
return FALSE;
if (argc < 3)
return usage_error (context, "LOCATION and FILENAME must be specified", error);
location = argv[1];
filename = argv[2];
repofile = g_file_new_for_commandline_arg (location);
repo = ostree_repo_new (repofile);
if (!xdg_app_supports_bundles (repo))
return xdg_app_fail (error, "Your version of ostree is too old to support single-file bundles");
if (!g_file_query_exists (repofile, cancellable))
return xdg_app_fail (error, "'%s' is not a valid repository", location);
file = g_file_new_for_commandline_arg (filename);
if (!ostree_repo_open (repo, cancellable, error))
return FALSE;
metadata = xdg_app_bundle_load (file, &to_checksum,
&ref,
NULL,
NULL,
NULL,
error);
if (metadata == NULL)
return FALSE;
g_print ("Importing %s (%s)\n", ref, to_checksum);
if (!xdg_app_pull_from_bundle (repo, file,
NULL, ref, FALSE,
cancellable,
error))
return FALSE;
return TRUE;
}

View File

@ -68,6 +68,7 @@ BUILTINPROTO(build_finish);
BUILTINPROTO(build_sign);
BUILTINPROTO(build_export);
BUILTINPROTO(build_bundle);
BUILTINPROTO(build_import);
BUILTINPROTO(build_update_repo);
BUILTINPROTO(export_file);
BUILTINPROTO(override);

View File

@ -70,6 +70,7 @@ static XdgAppCommand commands[] = {
{ "build-finish", xdg_app_builtin_build_finish, "Finish a build dir for export" },
{ "build-export", xdg_app_builtin_build_export, "Export a build dir to a repository" },
{ "build-bundle", xdg_app_builtin_build_bundle, "Create a bundle file from a build directory" },
{ "build-import-bundle", xdg_app_builtin_build_import, "Import a bundle file" },
{ "build-sign", xdg_app_builtin_build_sign, "Sign an application or runtime" },
{ "build-update-repo", xdg_app_builtin_build_update_repo, "Update the summary file in a repository" },

View File

@ -34,6 +34,7 @@ man_MANS = \
xdg-app-build-init.1 \
xdg-app-build.1 \
xdg-app-build-bundle.1 \
xdg-app-build-import-bundle.1 \
xdg-app-build-finish.1 \
xdg-app-build-export.1 \
xdg-app-build-update-repo.1 \

View File

@ -142,6 +142,7 @@
<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-build-import-bundle</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-repo-update</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>

View File

@ -0,0 +1,98 @@
<?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-build-import-bundle">
<refentryinfo>
<title>xdg-app build-import-bundle</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 build-import-bundle</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>xdg-app-build-import-bundle</refname>
<refpurpose>Import a file bundle into a local repository</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>xdg-app build-import-bundle</command>
<arg choice="opt" rep="repeat">OPTION</arg>
<arg choice="plain">LOCATION</arg>
<arg choice="plain">FILENAME</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Imports a bundle from a file named <arg choice="plain">FILENAME</arg>
into the repository at <arg choice="plain">LOCATION</arg>.
</para>
<para>
The format of the bundle file is that generated by build-bundle.
</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-build-bundle</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-repo-update</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -255,6 +255,13 @@
Create a bundle file from a build directory.
</para></listitem>
</varlistentry>
<varlistentry>
<term><citerefentry><refentrytitle>xdg-app-build-import-bundle</refentrytitle><manvolnum>1</manvolnum></citerefentry></term>
<listitem><para>
Import a file bundle into a local repository.
</para></listitem>
</varlistentry>
<varlistentry>
<term><citerefentry><refentrytitle>xdg-app-build-update-repo</refentrytitle><manvolnum>1</manvolnum></citerefentry></term>