diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-04-19 13:48:49 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-04-19 13:53:26 +0200 |
commit | cfd3f303b18b009a6eed5bb1d3eaf8980cdf7b64 (patch) | |
tree | 00ebf4da91fa6b2fd0db8681ae60e0c80635d7ac | |
parent | 1c1bc4acca467bdb15e8c75f3ef3f802d9cafea0 (diff) | |
download | xdg-app-cfd3f303b18b009a6eed5bb1d3eaf8980cdf7b64.tar.gz |
Add build-import-bundle command
-rw-r--r-- | app/Makefile.am.inc | 1 | ||||
-rw-r--r-- | app/xdg-app-builtins-build-import-bundle.c | 94 | ||||
-rw-r--r-- | app/xdg-app-builtins.h | 1 | ||||
-rw-r--r-- | app/xdg-app-main.c | 1 | ||||
-rw-r--r-- | doc/Makefile.am | 1 | ||||
-rw-r--r-- | doc/xdg-app-build-bundle.xml | 1 | ||||
-rw-r--r-- | doc/xdg-app-build-import-bundle.xml | 98 | ||||
-rw-r--r-- | doc/xdg-app.xml | 7 |
8 files changed, 204 insertions, 0 deletions
diff --git a/app/Makefile.am.inc b/app/Makefile.am.inc index 146ef18..853a8da 100644 --- a/app/Makefile.am.inc +++ b/app/Makefile.am.inc @@ -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 \ diff --git a/app/xdg-app-builtins-build-import-bundle.c b/app/xdg-app-builtins-build-import-bundle.c new file mode 100644 index 0000000..d6d80a3 --- /dev/null +++ b/app/xdg-app-builtins-build-import-bundle.c @@ -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; +} diff --git a/app/xdg-app-builtins.h b/app/xdg-app-builtins.h index c71253e..f0dbde9 100644 --- a/app/xdg-app-builtins.h +++ b/app/xdg-app-builtins.h @@ -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); diff --git a/app/xdg-app-main.c b/app/xdg-app-main.c index 87edbfb..504a7fb 100644 --- a/app/xdg-app-main.c +++ b/app/xdg-app-main.c @@ -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" }, diff --git a/doc/Makefile.am b/doc/Makefile.am index fa641ea..6d70e23 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -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 \ diff --git a/doc/xdg-app-build-bundle.xml b/doc/xdg-app-build-bundle.xml index 435d293..bac719f 100644 --- a/doc/xdg-app-build-bundle.xml +++ b/doc/xdg-app-build-bundle.xml @@ -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> diff --git a/doc/xdg-app-build-import-bundle.xml b/doc/xdg-app-build-import-bundle.xml new file mode 100644 index 0000000..ebc9dd9 --- /dev/null +++ b/doc/xdg-app-build-import-bundle.xml @@ -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> diff --git a/doc/xdg-app.xml b/doc/xdg-app.xml index 033b8b9..f5a1d0c 100644 --- a/doc/xdg-app.xml +++ b/doc/xdg-app.xml @@ -256,6 +256,13 @@ </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> <listitem><para> |