diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-10-02 19:55:26 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-10-05 13:36:33 +0000 |
commit | f3a3ea9c67cabc8d2d22c110a1d23ca6e7647dfc (patch) | |
tree | d8930286ddec008a9dff8a68e281d7e26f0f5ab8 /app/flatpak-builtins-list.c | |
parent | a0744f1f8047d2db127a5568f417d117212b27bc (diff) | |
download | flatpak-f3a3ea9c67cabc8d2d22c110a1d23ca6e7647dfc.tar.gz |
list: Add an option to filter by runtime
This lets you use list --app --app-runtime=org.gnome.Platform//3.24
to see which apps on your system still depend on this old runtime.
Closes: #2175
Approved by: alexlarsson
Diffstat (limited to 'app/flatpak-builtins-list.c')
-rw-r--r-- | app/flatpak-builtins-list.c | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/app/flatpak-builtins-list.c b/app/flatpak-builtins-list.c index bfb6c6cf..019106cd 100644 --- a/app/flatpak-builtins-list.c +++ b/app/flatpak-builtins-list.c @@ -38,6 +38,7 @@ static gboolean opt_runtime; static gboolean opt_app; static gboolean opt_all; static char *opt_arch; +static char *opt_app_runtime; static GOptionEntry options[] = { { "show-details", 'd', 0, G_OPTION_ARG_NONE, &opt_show_details, N_("Show extra information"), NULL }, @@ -45,6 +46,7 @@ static GOptionEntry options[] = { { "app", 0, 0, G_OPTION_ARG_NONE, &opt_app, N_("List installed applications"), NULL }, { "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, N_("Arch to show"), N_("ARCH") }, { "all", 'a', 0, G_OPTION_ARG_NONE, &opt_all, N_("List all refs (including locale/debug)"), NULL }, + { "app-runtime", 'a', 0, G_OPTION_ARG_STRING, &opt_app_runtime, N_("List all applications using RUNTIME"), N_("RUNTIME") }, { NULL } }; @@ -103,7 +105,11 @@ join_strv (char **a, char **b) } static gboolean -find_refs_for_dir (FlatpakDir *dir, GStrv *apps, GStrv *runtimes, GCancellable *cancellable, GError **error) +find_refs_for_dir (FlatpakDir *dir, + GStrv *apps, + GStrv *runtimes, + GCancellable *cancellable, + GError **error) { if (flatpak_dir_ensure_repo (dir, cancellable, NULL)) { @@ -117,10 +123,19 @@ find_refs_for_dir (FlatpakDir *dir, GStrv *apps, GStrv *runtimes, GCancellable * } static gboolean -print_table_for_refs (gboolean print_apps, GPtrArray * refs_array, const char *arch, GCancellable *cancellable, GError **error) +print_table_for_refs (gboolean print_apps, + GPtrArray * refs_array, + const char *arch, + const char *app_runtime, + GCancellable *cancellable, + GError **error) { FlatpakTablePrinter *printer = flatpak_table_printer_new (); int i; + FlatpakKinds match_kinds; + g_autofree char *match_id = NULL; + g_autofree char *match_arch = NULL; + g_autofree char *match_branch = NULL; i = 0; flatpak_table_printer_set_column_title (printer, i++, _("Ref")); @@ -133,6 +148,13 @@ print_table_for_refs (gboolean print_apps, GPtrArray * refs_array, const char *a } flatpak_table_printer_set_column_title (printer, i++, _("Options")); + if (app_runtime) + { + if (!flatpak_split_partial_ref_arg (app_runtime, FLATPAK_KINDS_RUNTIME, NULL, NULL, + &match_kinds, &match_id, &match_arch, &match_branch, error)) + return FALSE; + } + for (i = 0; i < refs_array->len; i++) { RefsData *refs_data = NULL; @@ -179,6 +201,19 @@ print_table_for_refs (gboolean print_apps, GPtrArray * refs_array, const char *a if (deploy_data == NULL) continue; + if (app_runtime) + { + const char *runtime = flatpak_deploy_data_get_runtime (deploy_data); + if (runtime) + { + g_auto(GStrv) pref = g_strsplit (runtime, "/", 3); + if ((match_id && pref[0] && strcmp (pref[0], match_id) != 0) || + (match_arch && pref[1] && strcmp (pref[1], match_arch) != 0) || + (match_branch && pref[2] && strcmp (pref[2], match_branch) != 0)) + continue; + } + } + if (!opt_all && strcmp (parts[0], "runtime") == 0 && flatpak_id_has_subref_suffix (parts[1])) { @@ -280,7 +315,13 @@ print_table_for_refs (gboolean print_apps, GPtrArray * refs_array, const char *a } static gboolean -print_installed_refs (gboolean app, gboolean runtime, GPtrArray *dirs, const char *arch, GCancellable *cancellable, GError **error) +print_installed_refs (gboolean app, + gboolean runtime, + GPtrArray *dirs, + const char *arch, + const char *app_runtime, + GCancellable *cancellable, + GError **error) { g_autoptr(GPtrArray) refs_array = NULL; int i; @@ -298,7 +339,7 @@ print_installed_refs (gboolean app, gboolean runtime, GPtrArray *dirs, const cha g_ptr_array_add (refs_array, refs_data_new (dir, apps, runtimes)); } - if (!print_table_for_refs (app, refs_array, arch, cancellable, error)) + if (!print_table_for_refs (app, refs_array, arch, app_runtime, cancellable, error)) return FALSE; return TRUE; @@ -330,6 +371,7 @@ flatpak_builtin_list (int argc, char **argv, GCancellable *cancellable, GError * if (!print_installed_refs (opt_app, opt_runtime, dirs, opt_arch, + opt_app_runtime, cancellable, error)) return FALSE; |