summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2019-09-10 15:57:04 +0200
committerAlexander Larsson <alexl@redhat.com>2019-09-10 15:59:09 +0200
commit41abcdf99d0a5d5f93fbef0f8781b8b6fbb7ab6c (patch)
tree16489c772197bfe5420da5abd01c6d918117bea1
parentd73ce0c508eaae6652c5d49c49fa9a0c70f120a7 (diff)
downloadflatpak-fix-uninstall-unused-versions.tar.gz
Handle 'versions' key when finding local related reffix-uninstall-unused-versions
We were only handling the old single-value 'version' key, even though we handled the 'versions' key when finding remote related refs. The result of this was that some extensions, such as the 19.08 opengl default one was installed by default (as it was found as remote related) yet still removed with --unused (as it was not locally related). Fixes https://github.com/flatpak/flatpak/issues/3004
-rw-r--r--common/flatpak-dir.c138
1 files changed, 77 insertions, 61 deletions
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
index 92f5e0e7..27d9a91b 100644
--- a/common/flatpak-dir.c
+++ b/common/flatpak-dir.c
@@ -13795,6 +13795,9 @@ flatpak_dir_find_local_related_for_metadata (FlatpakDir *self,
g_autofree char *extension = NULL;
g_autofree char *version = g_key_file_get_string (metakey, groups[i],
FLATPAK_METADATA_KEY_VERSION, NULL);
+ g_auto(GStrv) versions = g_key_file_get_string_list (metakey, groups[i],
+ FLATPAK_METADATA_KEY_VERSIONS,
+ NULL, NULL);
gboolean subdirectories = g_key_file_get_boolean (metakey, groups[i],
FLATPAK_METADATA_KEY_SUBDIRECTORIES, NULL);
gboolean no_autodownload = g_key_file_get_boolean (metakey, groups[i],
@@ -13807,19 +13810,24 @@ flatpak_dir_find_local_related_for_metadata (FlatpakDir *self,
FLATPAK_METADATA_KEY_AUTODELETE, NULL);
gboolean locale_subset = g_key_file_get_boolean (metakey, groups[i],
FLATPAK_METADATA_KEY_LOCALE_SUBSET, NULL);
- const char *branch;
- g_autofree char *extension_ref = NULL;
- g_autofree char *checksum = NULL;
g_autofree char *extension_collection_id = NULL;
- g_autoptr(GVariant) deploy_data = NULL;
+ const char *default_branches[] = { NULL, NULL};
+ const char **branches;
+ int branch_i;
/* Parse actual extension name */
flatpak_parse_extension_with_tag (tagged_extension, &extension, NULL);
- if (version)
- branch = version;
+ if (versions)
+ branches = (const char **) versions;
else
- branch = parts[3];
+ {
+ if (version)
+ default_branches[0] = version;
+ else
+ default_branches[0] = parts[3];
+ branches = default_branches;
+ }
extension_collection_id = g_key_file_get_string (metakey, groups[i],
FLATPAK_METADATA_KEY_COLLECTION_ID, NULL);
@@ -13839,63 +13847,71 @@ flatpak_dir_find_local_related_for_metadata (FlatpakDir *self,
g_clear_pointer (&extension_collection_id, g_free);
extension_collection_id = g_strdup (collection_id);
- extension_ref = g_build_filename ("runtime", extension, parts[2], branch, NULL);
- if (flatpak_repo_resolve_rev (self->repo,
- collection_id,
- remote_name,
- extension_ref,
- FALSE,
- &checksum,
- NULL,
- NULL))
- {
- add_related (self, related, extension, extension_collection_id, extension_ref,
- checksum, no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
- }
- else if ((deploy_data = flatpak_dir_get_deploy_data (self, extension_ref,
- FLATPAK_DEPLOY_VERSION_ANY,
- NULL, NULL)) != NULL)
- {
- /* Here we're including extensions that are deployed but might
- * not have a ref in the repo, as happens with remote-delete
- * --force
- */
- checksum = g_strdup (flatpak_deploy_data_get_commit (deploy_data));
- add_related (self, related, extension, extension_collection_id, extension_ref,
- checksum, no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
- }
- else if (subdirectories)
+ for (branch_i = 0; branches[branch_i] != NULL; branch_i++)
{
- g_autoptr(GHashTable) matches = local_match_prefix (self, extension_ref, remote_name);
- GLNX_HASH_TABLE_FOREACH (matches, const char *, match)
+ g_autofree char *extension_ref = NULL;
+ g_autofree char *checksum = NULL;
+ g_autoptr(GVariant) deploy_data = NULL;
+ const char *branch = branches[branch_i];
+
+ extension_ref = g_build_filename ("runtime", extension, parts[2], branch, NULL);
+ if (flatpak_repo_resolve_rev (self->repo,
+ collection_id,
+ remote_name,
+ extension_ref,
+ FALSE,
+ &checksum,
+ NULL,
+ NULL))
{
- g_autofree char *match_checksum = NULL;
- g_autoptr(GVariant) match_deploy_data = NULL;
-
- if (flatpak_repo_resolve_rev (self->repo,
- collection_id,
- remote_name,
- match,
- FALSE,
- &match_checksum,
- NULL,
- NULL))
- {
- add_related (self, related, extension,
- extension_collection_id, match, match_checksum,
- no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
- }
- else if ((match_deploy_data = flatpak_dir_get_deploy_data (self, match,
- FLATPAK_DEPLOY_VERSION_ANY,
- NULL, NULL)) != NULL)
+ add_related (self, related, extension, extension_collection_id, extension_ref,
+ checksum, no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
+ }
+ else if ((deploy_data = flatpak_dir_get_deploy_data (self, extension_ref,
+ FLATPAK_DEPLOY_VERSION_ANY,
+ NULL, NULL)) != NULL)
+ {
+ /* Here we're including extensions that are deployed but might
+ * not have a ref in the repo, as happens with remote-delete
+ * --force
+ */
+ checksum = g_strdup (flatpak_deploy_data_get_commit (deploy_data));
+ add_related (self, related, extension, extension_collection_id, extension_ref,
+ checksum, no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
+ }
+ else if (subdirectories)
+ {
+ g_autoptr(GHashTable) matches = local_match_prefix (self, extension_ref, remote_name);
+ GLNX_HASH_TABLE_FOREACH (matches, const char *, match)
{
- /* Here again we're including extensions that are deployed but might
- * not have a ref in the repo
- */
- match_checksum = g_strdup (flatpak_deploy_data_get_commit (match_deploy_data));
- add_related (self, related, extension,
- extension_collection_id, match, match_checksum,
- no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
+ g_autofree char *match_checksum = NULL;
+ g_autoptr(GVariant) match_deploy_data = NULL;
+
+ if (flatpak_repo_resolve_rev (self->repo,
+ collection_id,
+ remote_name,
+ match,
+ FALSE,
+ &match_checksum,
+ NULL,
+ NULL))
+ {
+ add_related (self, related, extension,
+ extension_collection_id, match, match_checksum,
+ no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
+ }
+ else if ((match_deploy_data = flatpak_dir_get_deploy_data (self, match,
+ FLATPAK_DEPLOY_VERSION_ANY,
+ NULL, NULL)) != NULL)
+ {
+ /* Here again we're including extensions that are deployed but might
+ * not have a ref in the repo
+ */
+ match_checksum = g_strdup (flatpak_deploy_data_get_commit (match_deploy_data));
+ add_related (self, related, extension,
+ extension_collection_id, match, match_checksum,
+ no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
+ }
}
}
}