From 640bf9e69c726b42e8af398fecc1b3190923e4a8 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 23 Jun 2016 13:08:12 +0200 Subject: [PATCH] remote-ls: Better multiarch support By default, only show supported refs. Use --arch to limit it to a specific arch, or --arch=* to list all. --- app/flatpak-builtins-ls-remote.c | 23 ++++++++++++++++------- doc/flatpak-remote-ls.xml | 9 +++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/flatpak-builtins-ls-remote.c b/app/flatpak-builtins-ls-remote.c index d2f549be1..a333f1f85 100644 --- a/app/flatpak-builtins-ls-remote.c +++ b/app/flatpak-builtins-ls-remote.c @@ -35,12 +35,14 @@ static gboolean opt_show_details; static gboolean opt_runtime; static gboolean opt_app; static gboolean opt_only_updates; +static char *opt_arch; static GOptionEntry options[] = { { "show-details", 'd', 0, G_OPTION_ARG_NONE, &opt_show_details, "Show arches and branches", NULL }, { "runtime", 0, 0, G_OPTION_ARG_NONE, &opt_runtime, "Show only runtimes", NULL }, { "app", 0, 0, G_OPTION_ARG_NONE, &opt_app, "Show only apps", NULL }, { "updates", 0, 0, G_OPTION_ARG_NONE, &opt_only_updates, "Show only those where updates are available", NULL }, + { "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Limit to this arch (* for all)", "ARCH" }, { NULL } }; @@ -58,7 +60,8 @@ flatpak_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr g_autofree const char **keys = NULL; int i; const char *repository; - const char *arch; + const char **arches = flatpak_get_arches (); + const char *opt_arches[] = {NULL, NULL}; context = g_option_context_new (" REMOTE - Show available runtimes and applications"); @@ -82,7 +85,16 @@ flatpak_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - arch = flatpak_get_arch (); + if (opt_arch != NULL) + { + if (strcmp (opt_arch, "*") == 0) + arches = NULL; + else + { + opt_arches[0] = opt_arch; + arches = opt_arches; + } + } g_hash_table_iter_init (&iter, refs); while (g_hash_table_iter_next (&iter, &key, &value)) @@ -111,11 +123,8 @@ flatpak_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr continue; } - if (!opt_show_details) - { - if (strcmp (arch, parts[2]) != 0) - continue; - } + if (arches != NULL && !g_strv_contains (arches, parts[2])) + continue; if (strcmp (parts[0], "runtime") == 0 && !opt_runtime) continue; diff --git a/doc/flatpak-remote-ls.xml b/doc/flatpak-remote-ls.xml index 1df98d2da..c3aa9f515 100644 --- a/doc/flatpak-remote-ls.xml +++ b/doc/flatpak-remote-ls.xml @@ -115,6 +115,15 @@ + + + + + Show only those matching the specied architecture. By default, only + supported architectures are shown. Use --arch=* to show all archtectures. + + +