mirror of
https://github.com/flatpak/flatpak.git
synced 2026-04-02 06:13:13 -04:00
Handle 'versions' key when finding local related ref
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
This commit is contained in:
@@ -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))
|
||||
for (branch_i = 0; branches[branch_i] != NULL; branch_i++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
g_autofree char *match_checksum = NULL;
|
||||
g_autoptr(GVariant) match_deploy_data = NULL;
|
||||
g_autofree char *extension_ref = NULL;
|
||||
g_autofree char *checksum = NULL;
|
||||
g_autoptr(GVariant) deploy_data = NULL;
|
||||
const char *branch = branches[branch_i];
|
||||
|
||||
if (flatpak_repo_resolve_rev (self->repo,
|
||||
collection_id,
|
||||
remote_name,
|
||||
match,
|
||||
FALSE,
|
||||
&match_checksum,
|
||||
NULL,
|
||||
NULL))
|
||||
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)
|
||||
{
|
||||
g_autoptr(GHashTable) matches = local_match_prefix (self, extension_ref, remote_name);
|
||||
GLNX_HASH_TABLE_FOREACH (matches, const char *, match)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user