Add make-app-current

tingping/wmclass
Alexander Larsson 2015-03-10 16:33:56 +01:00
parent e2fdfc531c
commit e0e23ee181
8 changed files with 224 additions and 4 deletions

View File

@ -87,6 +87,7 @@ xdg_app_SOURCES = \
xdg-app-builtins-list-remotes.c \
xdg-app-builtins-repo-contents.c \
xdg-app-builtins-install.c \
xdg-app-builtins-make-current.c \
xdg-app-builtins-update.c \
xdg-app-builtins-uninstall.c \
xdg-app-builtins-list.c \

View File

@ -15,10 +15,10 @@ _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 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'
[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 make-app-current'
[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 make-app-current'
[UNINSTALL]='uninstall-runtime uninstall-app'
[ARCH]='build-init install-runtime install-app run uninstall-runtime uninstall-app update-runtime update-app'
[ARCH]='build-init install-runtime install-app run uninstall-runtime uninstall-app update-runtime update-app make-app-current'
)
local -A OPTS=(

View File

@ -24,6 +24,7 @@ man_MANS = \
xdg-app-list-runtimes.1 \
xdg-app-install-app.1 \
xdg-app-update-app.1 \
xdg-app-make-app-current.1 \
xdg-app-uninstall-app.1 \
xdg-app-list-apps.1 \
xdg-app-run.1 \

View File

@ -49,7 +49,10 @@
</para>
<para>
Note that xdg-app allows to have multiple branches of an application
installed and used at the same time.
installed and used at the same time. However, only one can be current,
meaning its exported files (for instance desktop files and icons) are
visible to the host. The last installed version is made current by
default, but you can manually change with make-app-current.
</para>
<para>
Unless overridden with the --user option, this command creates a

View File

@ -0,0 +1,137 @@
<?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-make-app-current">
<refentryinfo>
<title>xdg-app make-app-current</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 make-app-current</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>xdg-app-make-app-current</refname>
<refpurpose>Make a specific version of an app current</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>xdg-app make-app-current</command>
<arg choice="opt" rep="repeat">OPTION</arg>
<arg choice="plain">APP</arg>
<arg choice="plain">BRANCH</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Makes a particular branch of an application current. Only the current branch
of an app has its exported files (such as desktop files and icons) made visible
to the host.
</para>
<para>
When a new branch is installed it will automatically be made current, so this
command is often not needed.
</para>
<para>
Unless overridden with the --user option, this command creates a
system-wide installation.
</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>--user</option></term>
<listitem><para>
Create a per-user installation.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--system</option></term>
<listitem><para>
Create a system-wide installation.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--arch=ARCH</option></term>
<listitem><para>
The architecture to install for.
</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>Examples</title>
<para>
<command>$ xdg-app --user make-app-current org.gnome.GEdit 3.14</command>
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<citerefentry><refentrytitle>xdg-app</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-install-app</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>xdg-app-list-apps</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -0,0 +1,76 @@
#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"
static char *opt_arch;
static GOptionEntry options[] = {
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Arch to make current for", "ARCH" },
{ NULL }
};
gboolean
xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *origin = NULL;
const char *app;
const char *branch = "master";
gs_free char *ref = NULL;
context = g_option_context_new ("APP BRANCH - Make branch of application current");
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
goto out;
if (argc < 3)
{
usage_error (context, "APP and BRANCH must be specified", error);
goto out;
}
app = argv[1];
branch = argv[2];
if (!xdg_app_is_valid_name (app))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid application name", app);
goto out;
}
if (!xdg_app_is_valid_branch (branch))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
goto out;
}
ref = xdg_app_build_app_ref (app, branch, opt_arch);
deploy_base = xdg_app_dir_get_deploy_dir (dir, ref);
if (!g_file_query_exists (deploy_base, cancellable))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "App %s branch %s is not installed", app, branch);
goto out;
}
if (!xdg_app_dir_make_current_ref (dir, ref, cancellable, error))
goto out;
ret = TRUE;
out:
if (context)
g_option_context_free (context);
return ret;
}

View File

@ -37,6 +37,7 @@ BUILTINPROTO(update_runtime);
BUILTINPROTO(uninstall_runtime);
BUILTINPROTO(list_runtimes);
BUILTINPROTO(install_app);
BUILTINPROTO(make_current_app);
BUILTINPROTO(update_app);
BUILTINPROTO(uninstall_app);
BUILTINPROTO(list_apps);

View File

@ -29,6 +29,7 @@ static XdgAppCommand commands[] = {
{ "list-runtimes", xdg_app_builtin_list_runtimes },
{ "install-app", xdg_app_builtin_install_app },
{ "update-app", xdg_app_builtin_update_app },
{ "make-app-current", xdg_app_builtin_make_current_app },
{ "uninstall-app", xdg_app_builtin_uninstall_app },
{ "list-apps", xdg_app_builtin_list_apps },
{ "run", xdg_app_builtin_run },