summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhaedrus Leeds <mwleeds@protonmail.com>2021-11-17 14:01:53 -0800
committerAlexander Larsson <alexander.larsson@gmail.com>2021-11-18 15:20:05 +0100
commit470b321c63a3a20b43b7d4142ce3038edc87f808 (patch)
tree914d3c5fa30c2aa0f2740a5564f8264e11868830
parent2c4c84ffee1a7b0c73f5af9dec02f63e6e1ef2ca (diff)
downloadflatpak-470b321c63a3a20b43b7d4142ce3038edc87f808.tar.gz
list: Tweak logic for excluding Locale/Debug extensions
The man page states that the --all option for the list command includes runtime extensions (e.g. that end in .Locale or .Debug) and this is the case. When --all is omitted, we only show such extensions when the thing they extend is not already in the list. However when you run a command like "flatpak list --runtime --columns=application,branch", you get a list that excludes runtime locale extensions but includes app locale extensions, since the corresponding apps are not in the list despite presumably being installed. This doesn't seem like the right behavior, so tweak the logic so that app locale extensions are excluded when --all is omitted and --runtime is used. Strictly speaking the "extension-of" information is not guaranteed to be present in the deploy data (which acquires it from the metadata), but in practice it seems to be present for all but Sources extensions, and I think it should be considered required since we are already using it to implement functionality elsewhere in Flatpak: https://github.com/flatpak/flatpak/issues/4585
-rw-r--r--app/flatpak-builtins-list.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/app/flatpak-builtins-list.c b/app/flatpak-builtins-list.c
index 82049cbb..273c5649 100644
--- a/app/flatpak-builtins-list.c
+++ b/app/flatpak-builtins-list.c
@@ -97,20 +97,6 @@ refs_data_free (RefsData *refs_data)
g_free (refs_data);
}
-static char *
-strip_last_element (const char *id)
-{
- gsize id_len = strlen (id);
- while (id_len > 0 &&
- id[id_len - 1] != '.')
- id_len--;
-
- if (id_len > 0)
- id_len--; /* Remove the dot too */
-
- return g_strndup (id, id_len);
-}
-
static gboolean
print_table_for_refs (gboolean print_apps,
GPtrArray * refs_array,
@@ -148,7 +134,7 @@ print_table_for_refs (gboolean print_apps,
RefsData *refs_data = NULL;
FlatpakDir *dir = NULL;
GPtrArray *dir_refs = NULL;
- g_autoptr(GHashTable) pref_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ g_autoptr(GHashTable) ref_hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
int j;
refs_data = (RefsData *) g_ptr_array_index (refs_array, i);
@@ -158,8 +144,7 @@ print_table_for_refs (gboolean print_apps,
for (j = 0; j < dir_refs->len; j++)
{
FlatpakDecomposed *ref = g_ptr_array_index (dir_refs, j);
- char *partial_ref = flatpak_make_valid_id_prefix (flatpak_decomposed_get_pref (ref));
- g_hash_table_insert (pref_hash, partial_ref, ref);
+ g_hash_table_add (ref_hash, (char *)flatpak_decomposed_get_ref (ref));
}
for (j = 0; j < dir_refs->len; j++)
@@ -213,11 +198,18 @@ print_table_for_refs (gboolean print_apps,
flatpak_decomposed_is_runtime (ref) &&
flatpak_decomposed_id_is_subref (ref))
{
- g_autofree char *parent_id = strip_last_element (ref_id);
- g_autofree char *prefix_partial_ref = g_strconcat (parent_id, "/", ref_arch, "/", ref_branch, NULL);
+ g_autoptr(FlatpakDecomposed) extensionof_decomposed = NULL;
+ const char *extension_of = flatpak_deploy_data_get_extension_of (deploy_data);
+ if (extension_of != NULL)
+ extensionof_decomposed = flatpak_decomposed_new_from_ref (extension_of, NULL);
+ if (extensionof_decomposed != NULL)
+ {
+ if (!opt_app && flatpak_decomposed_is_app (extensionof_decomposed))
+ continue;
- if (g_hash_table_lookup (pref_hash, prefix_partial_ref))
- continue;
+ if (g_hash_table_lookup (ref_hash, extension_of))
+ continue;
+ }
}
repo = flatpak_deploy_data_get_origin (deploy_data);