diff options
author | Alexander Larsson <alexander.larsson@gmail.com> | 2015-01-23 15:47:06 +0100 |
---|---|---|
committer | Alexander Larsson <alexander.larsson@gmail.com> | 2015-01-23 15:47:06 +0100 |
commit | 97747a3e530350629ba0f757608185fe67b21184 (patch) | |
tree | 7f2b047f580c5028143e80055db93e50dfae844f | |
parent | 0b19f58a6ff4123741e99573e3414b335d7fd543 (diff) | |
parent | 22f87409516f72a20e4c4ab38a851387d5e2624f (diff) | |
download | xdg-app-97747a3e530350629ba0f757608185fe67b21184.tar.gz |
Merge pull request #37 from matthiasclasen/user-option
Add a --system option to go with --user
-rwxr-xr-x | completion/xdg-app | 9 | ||||
-rw-r--r-- | doc/xdg-app-add-remote.xml | 15 | ||||
-rw-r--r-- | doc/xdg-app-delete-remote.xml | 15 | ||||
-rw-r--r-- | doc/xdg-app-install-app.xml | 30 | ||||
-rw-r--r-- | doc/xdg-app-install-runtime.xml | 30 | ||||
-rw-r--r-- | doc/xdg-app-list-apps.xml | 16 | ||||
-rw-r--r-- | doc/xdg-app-list-remotes.xml | 15 | ||||
-rw-r--r-- | doc/xdg-app-list-runtimes.xml | 15 | ||||
-rw-r--r-- | doc/xdg-app-repo-contents.xml | 19 | ||||
-rw-r--r-- | doc/xdg-app-uninstall-app.xml | 11 | ||||
-rw-r--r-- | doc/xdg-app-uninstall-runtime.xml | 11 | ||||
-rw-r--r-- | doc/xdg-app-update-app.xml | 23 | ||||
-rw-r--r-- | doc/xdg-app-update-runtime.xml | 21 | ||||
-rw-r--r-- | xdg-app-builtins-list.c | 59 | ||||
-rw-r--r-- | xdg-app-main.c | 3 |
15 files changed, 221 insertions, 71 deletions
diff --git a/completion/xdg-app b/completion/xdg-app index d83411f..461ae10 100755 --- a/completion/xdg-app +++ b/completion/xdg-app @@ -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 diff --git a/doc/xdg-app-add-remote.xml b/doc/xdg-app-add-remote.xml index ba46292..87a19ac 100644 --- a/doc/xdg-app-add-remote.xml +++ b/doc/xdg-app-add-remote.xml @@ -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> diff --git a/doc/xdg-app-delete-remote.xml b/doc/xdg-app-delete-remote.xml index eec7852..0d106f1 100644 --- a/doc/xdg-app-delete-remote.xml +++ b/doc/xdg-app-delete-remote.xml @@ -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> diff --git a/doc/xdg-app-install-app.xml b/doc/xdg-app-install-app.xml index c5e6fa6..b8ee4c9 100644 --- a/doc/xdg-app-install-app.xml +++ b/doc/xdg-app-install-app.xml @@ -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> diff --git a/doc/xdg-app-install-runtime.xml b/doc/xdg-app-install-runtime.xml index 692a7ec..13ee30a 100644 --- a/doc/xdg-app-install-runtime.xml +++ b/doc/xdg-app-install-runtime.xml @@ -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> diff --git a/doc/xdg-app-list-apps.xml b/doc/xdg-app-list-apps.xml index fa546e7..071b94a 100644 --- a/doc/xdg-app-list-apps.xml +++ b/doc/xdg-app-list-apps.xml @@ -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> diff --git a/doc/xdg-app-list-remotes.xml b/doc/xdg-app-list-remotes.xml index 8f5bc25..c33dd12 100644 --- a/doc/xdg-app-list-remotes.xml +++ b/doc/xdg-app-list-remotes.xml @@ -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> diff --git a/doc/xdg-app-list-runtimes.xml b/doc/xdg-app-list-runtimes.xml index ebb1bcc..be4c101 100644 --- a/doc/xdg-app-list-runtimes.xml +++ b/doc/xdg-app-list-runtimes.xml @@ -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> diff --git a/doc/xdg-app-repo-contents.xml b/doc/xdg-app-repo-contents.xml index abe301f..02250bb 100644 --- a/doc/xdg-app-repo-contents.xml +++ b/doc/xdg-app-repo-contents.xml @@ -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> diff --git a/doc/xdg-app-uninstall-app.xml b/doc/xdg-app-uninstall-app.xml index b1662c7..95a5014 100644 --- a/doc/xdg-app-uninstall-app.xml +++ b/doc/xdg-app-uninstall-app.xml @@ -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> diff --git a/doc/xdg-app-uninstall-runtime.xml b/doc/xdg-app-uninstall-runtime.xml index 05af178..6a1b6c1 100644 --- a/doc/xdg-app-uninstall-runtime.xml +++ b/doc/xdg-app-uninstall-runtime.xml @@ -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> diff --git a/doc/xdg-app-update-app.xml b/doc/xdg-app-update-app.xml index c3b99fa..c956e8e 100644 --- a/doc/xdg-app-update-app.xml +++ b/doc/xdg-app-update-app.xml @@ -47,16 +47,20 @@ 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> diff --git a/doc/xdg-app-update-runtime.xml b/doc/xdg-app-update-runtime.xml index 520955d..2e56814 100644 --- a/doc/xdg-app-update-runtime.xml +++ b/doc/xdg-app-update-runtime.xml @@ -47,6 +47,11 @@ 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 strict compatibility, so that applications can be guaranteed @@ -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> diff --git a/xdg-app-builtins-list.c b/xdg-app-builtins-list.c index 42b15fb..b9bf3d5 100644 --- a/xdg-app-builtins-list.c +++ b/xdg-app-builtins-list.c @@ -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; diff --git a/xdg-app-main.c b/xdg-app-main.c index 6fca4ca..5d47ed6 100644 --- a/xdg-app-main.c +++ b/xdg-app-main.c @@ -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 } }; |