forked from Mirrors/flatpak-builder
Merge pull request #37 from matthiasclasen/user-option
Add a --system option to go with --usertingping/wmclass
commit
97747a3e53
|
@ -17,15 +17,17 @@ _xdg-app() {
|
|||
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'
|
||||
[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'
|
||||
)
|
||||
|
||||
local -A OPTS=(
|
||||
[GENERAL]='--help --verbose --version'
|
||||
[MODE]='--user'
|
||||
[MODE]='--user --system'
|
||||
[ARCH]='--arch'
|
||||
[LIST_REMOTES]='--show-urls'
|
||||
[REPO_CONTENTS]='--show-details --runtimes --apps --update'
|
||||
[UNINSTALL]='--keep-ref'
|
||||
[RUN]='--command --branch --devel'
|
||||
[BUILD_INIT]='--arch --var'
|
||||
[BUILD]='--runtime --network --x11'
|
||||
|
@ -36,6 +38,8 @@ _xdg-app() {
|
|||
|
||||
if __contains_word "--user" ${COMP_WORDS[*]}; then
|
||||
mode=--user
|
||||
else
|
||||
mode=--system
|
||||
fi
|
||||
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
|
@ -123,6 +127,9 @@ _xdg-app() {
|
|||
if __contains_word "$verb" ${VERBS[ARCH]}; then
|
||||
comps="$comps ${OPTS[ARCH]}"
|
||||
fi
|
||||
if __contains_word "$verb" ${VERBS[UNINSTALL]}; then
|
||||
comps="$comps ${OPTS[UNINSTALL]}"
|
||||
fi
|
||||
if [ "$verb" = "run" ]; then
|
||||
comps="$comps ${OPTS[RUN]}"
|
||||
fi
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
<arg choice="plain">NAME</arg> is the name for the new remote, and
|
||||
<arg choice="plain">URL</arg> is the location for the repository.
|
||||
</para>
|
||||
<para>
|
||||
Unless overridden with the --user option, this command changes
|
||||
the system-wide configuration.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
@ -67,8 +71,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Modify the per-user configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Modify the system-wide configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -43,6 +43,10 @@
|
|||
Removes a remote repository from the xdg-app repository configuration.
|
||||
<arg choice="plain">NAME</arg> is the name of an existing remote.
|
||||
</para>
|
||||
<para>
|
||||
Unless overridden with the --user option, this command changes
|
||||
the system-wide configuration.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
@ -65,8 +69,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Modify the per-user configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Modify the system-wide configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -42,13 +42,18 @@
|
|||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
Installs an application. <arg choice="plain">REPOSITORY</arg> must
|
||||
name an existing remote. <arg choice="plain">APP</arg> is the
|
||||
name of the application to install. Optionally,
|
||||
<arg choice="plain">BRANCH</arg> can be specified to install a branch
|
||||
other than the default "master" branch. Note that xdg-app allows to
|
||||
have multiple branches of an application installed and used at the
|
||||
same time.
|
||||
Installs an application. <arg choice="plain">REPOSITORY</arg> must name
|
||||
an existing remote and <arg choice="plain">APP</arg> is the name of the
|
||||
application to install. Optionally, <arg choice="plain">BRANCH</arg> can
|
||||
be specified to install a branch other than the default "master" branch.
|
||||
</para>
|
||||
<para>
|
||||
Note that xdg-app allows to have multiple branches of an application
|
||||
installed and used at the same time.
|
||||
</para>
|
||||
<para>
|
||||
Unless overridden with the --user option, this command creates a
|
||||
system-wide installation.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
@ -72,8 +77,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Create a per-user installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Create a system-wide installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -42,12 +42,19 @@
|
|||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
Installs a runtime. <arg choice="plain">REPOSITORY</arg> must
|
||||
name an existing remote. <arg choice="plain">RUNTIME</arg> is the
|
||||
name of the runtime to install. Optionally,
|
||||
<arg choice="plain">BRANCH</arg> can be specified to install a branch
|
||||
other than the default "master" branch. Note that xdg-app allows having
|
||||
multiple branches of a runtime installed and used at the same time.
|
||||
Installs a runtime. <arg choice="plain">REPOSITORY</arg> must name an
|
||||
existing remote and <arg choice="plain">RUNTIME</arg> is the name of
|
||||
the runtime to install. Optionally, <arg choice="plain">BRANCH</arg>
|
||||
can be specified to install a branch other than the default "master"
|
||||
branch.
|
||||
</para>
|
||||
<para>
|
||||
Note that xdg-app allows having multiple branches of a runtime
|
||||
installed and used at the same time.
|
||||
</para>
|
||||
<para>
|
||||
Unless overridden with the --user option, this command creates a
|
||||
system-wide installation.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
@ -71,8 +78,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Create a per-user installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Create a system-wide installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -41,6 +41,11 @@
|
|||
<para>
|
||||
Lists the names of the installed applications.
|
||||
</para>
|
||||
<para>
|
||||
By default, both per-user and system-wide installations
|
||||
are shown. Use the --user or --system options to change
|
||||
this.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
@ -63,8 +68,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
List per-user installations.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
List system-wide installations.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
<para>
|
||||
Lists the known remote repositories.
|
||||
</para>
|
||||
<para>
|
||||
Unless overridden with the --user option, this command
|
||||
shows the system-wide configuration.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
@ -63,8 +67,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Show the per-user configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Show the system-wide configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
<para>
|
||||
Lists the names of the installed runtimes.
|
||||
</para>
|
||||
<para>
|
||||
By default, both per-user and system-wide installations are shown.
|
||||
Use the --user or --system options to change this.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
@ -63,8 +67,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Show per-user installations.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Show system-wide installations.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -45,12 +45,8 @@
|
|||
You can find all configured remote repositories with xdg-app list-repos.
|
||||
</para>
|
||||
<para>
|
||||
xdg-app can operate in system-wide or per-user mode. The system-wide
|
||||
applications are located in <filename>$prefix/share/xdg-app/app</filename>,
|
||||
and the per-user runtimes are in <filename>$HOME/.local/share/xdg-app/app</filename>.
|
||||
</para>
|
||||
<para>
|
||||
xdg-app uses OSTree, and installed appications are OSTree checkouts.
|
||||
Unless overridden with the --user option, this command uses
|
||||
the system-wide configuration.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
@ -74,8 +70,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Use the per-user configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Use the system-wide configuration.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -89,8 +89,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Remove a per-user installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Remove a system-wide installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -85,8 +85,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Remove a per-user installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Remove a system-wide installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -46,17 +46,21 @@
|
|||
<arg choice="plain">BRANCH</arg> can be specified to update a
|
||||
branch other than the default "master" branch.
|
||||
</para>
|
||||
<para>
|
||||
Normally, this command updates the application to the tip
|
||||
of its branch. But it is possible to check out another commit,
|
||||
with the --commit option.
|
||||
</para>
|
||||
<para>
|
||||
Note that updating a runtime is different from installing
|
||||
a newer branch, and application updates are expected to keep
|
||||
strict compatibility. If an application update does cause
|
||||
strict compatibility. If an application update does cause
|
||||
a problem, it is possible to go back to the previous
|
||||
version, with the --commit option.
|
||||
</para>
|
||||
<para>
|
||||
Normally, this command updates the application to the tip
|
||||
of its branch. But it is possible to check out another commit,
|
||||
with the --commit option.
|
||||
Unless overridden with the --user option, this command updates
|
||||
a system-wide installation.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
@ -80,8 +84,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Update a per-user installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Update a system-wide installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -46,6 +46,11 @@
|
|||
<arg choice="plain">BRANCH</arg> can be specified to update a
|
||||
branch other than the default "master" branch.
|
||||
</para>
|
||||
<para>
|
||||
Normally, this command updates the runtime to the tip
|
||||
of its branch. But it is possible to check out another commit,
|
||||
with the --commit option.
|
||||
</para>
|
||||
<para>
|
||||
Note that updating a runtime is different from installing
|
||||
a newer branch, and runtime updates are expected to keep
|
||||
|
@ -56,9 +61,8 @@
|
|||
version, with the --commit option.
|
||||
</para>
|
||||
<para>
|
||||
Normally, this command updates the runtime to the tip
|
||||
of its branch. But it is possible to check out another commit,
|
||||
with the --commit option.
|
||||
Unless overridden with the --user option, this command updates
|
||||
a system-wide installation.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
@ -82,8 +86,15 @@
|
|||
<term><option>--user</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Work on the per-user configuration instead of the system-wide
|
||||
configuration.
|
||||
Update a per-user installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--system</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Update a system-wide installation.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -11,22 +11,31 @@
|
|||
#include "xdg-app-utils.h"
|
||||
|
||||
static gboolean opt_show_details;
|
||||
static gboolean opt_user;
|
||||
static gboolean opt_system;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "user", 0, 0, G_OPTION_ARG_NONE, &opt_user, "Show user installations", NULL },
|
||||
{ "system", 0, 0, G_OPTION_ARG_NONE, &opt_system, "Show system-wide installations", NULL },
|
||||
{ "show-details", 0, 0, G_OPTION_ARG_NONE, &opt_show_details, "Show arches and branches", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static gboolean
|
||||
print_installed_refs (GFile *base, GCancellable *cancellable, GError **error)
|
||||
print_installed_refs (XdgAppDir *dir, const char *kind, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFile *base;
|
||||
gs_unref_object GFileEnumerator *dir_enum = NULL;
|
||||
gs_unref_object GFileInfo *child_info = NULL;
|
||||
GError *temp_error = NULL;
|
||||
gs_unref_ptrarray GPtrArray *refs = NULL;
|
||||
int i;
|
||||
|
||||
base = g_file_get_child (xdg_app_dir_get_path (dir), kind);
|
||||
if (!g_file_query_exists (base, cancellable))
|
||||
return TRUE;
|
||||
|
||||
refs = g_ptr_array_new ();
|
||||
|
||||
dir_enum = g_file_enumerate_children (base, G_FILE_ATTRIBUTE_STANDARD_NAME,
|
||||
|
@ -134,23 +143,29 @@ xdg_app_builtin_list_runtimes (int argc, char **argv, GCancellable *cancellable,
|
|||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
gs_unref_object XdgAppDir *dir = NULL;
|
||||
gs_unref_object GFile *base = NULL;
|
||||
|
||||
context = g_option_context_new (" - List installed runtimes");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
|
||||
base = g_file_get_child (xdg_app_dir_get_path (dir), "runtime");
|
||||
if (!g_file_query_exists (base, cancellable))
|
||||
if (opt_user || (!opt_user && !opt_system))
|
||||
{
|
||||
ret = TRUE;
|
||||
goto out;
|
||||
gs_unref_object XdgAppDir *dir = NULL;
|
||||
|
||||
dir = xdg_app_dir_get (TRUE);
|
||||
if (!print_installed_refs (dir, "runtime", cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!print_installed_refs (base, cancellable, error))
|
||||
goto out;
|
||||
if (opt_system || (!opt_user && !opt_system))
|
||||
{
|
||||
gs_unref_object XdgAppDir *dir = NULL;
|
||||
|
||||
dir = xdg_app_dir_get (FALSE);
|
||||
if (!print_installed_refs (dir, "runtime", cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
|
@ -167,23 +182,29 @@ xdg_app_builtin_list_apps (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
gs_unref_object XdgAppDir *dir = NULL;
|
||||
gs_unref_object GFile *base = NULL;
|
||||
|
||||
context = g_option_context_new (" - List installed applications");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
|
||||
base = g_file_get_child (xdg_app_dir_get_path (dir), "app");
|
||||
if (!g_file_query_exists (base, cancellable))
|
||||
if (opt_user || (!opt_user && !opt_system))
|
||||
{
|
||||
ret = TRUE;
|
||||
goto out;
|
||||
gs_unref_object XdgAppDir *dir = NULL;
|
||||
|
||||
dir = xdg_app_dir_get (TRUE);
|
||||
if (!print_installed_refs (dir, "app", cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!print_installed_refs (base, cancellable, error))
|
||||
goto out;
|
||||
if (opt_system || (!opt_user && !opt_system))
|
||||
{
|
||||
gs_unref_object XdgAppDir *dir = NULL;
|
||||
|
||||
dir = xdg_app_dir_get (FALSE);
|
||||
if (!print_installed_refs (dir, "app", cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ static GOptionEntry global_entries[] = {
|
|||
};
|
||||
|
||||
static GOptionEntry user_entries[] = {
|
||||
{ "user", 0, 0, G_OPTION_ARG_NONE, &opt_user, "Work on user installed apps", NULL },
|
||||
{ "user", 0, 0, G_OPTION_ARG_NONE, &opt_user, "Work on user installations", NULL },
|
||||
{ "system", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt_user, "Work on system-wide installations", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue