mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-31 02:51:22 -05:00
extensions: Respect versions (as well as version) when finding related refs
This allows one extension point to match multiple versions of an extension. In particular, this is useful for OpenGL so that we can match the version matching the current runtime, as well as the "magic" 1.4 version for nvidia. Closes: #1722 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
11908f4fa3
commit
45c9fb967a
@@ -10928,6 +10928,9 @@ flatpak_dir_find_remote_related (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],
|
||||
@@ -10939,17 +10942,25 @@ flatpak_dir_find_remote_related (FlatpakDir *self,
|
||||
gboolean locale_subset = g_key_file_get_boolean (metakey, groups[i],
|
||||
FLATPAK_METADATA_KEY_LOCALE_SUBSET, NULL);
|
||||
g_autofree char *extension_collection_id = NULL;
|
||||
const char *branch;
|
||||
const char *default_branches[] = { NULL, NULL};
|
||||
const char **branches;
|
||||
g_autofree char *extension_ref = NULL;
|
||||
g_autofree char *checksum = NULL;
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef FLATPAK_ENABLE_P2P
|
||||
extension_collection_id = g_key_file_get_string (metakey, groups[i],
|
||||
@@ -10970,24 +10981,29 @@ flatpak_dir_find_remote_related (FlatpakDir *self,
|
||||
g_clear_pointer (&extension_collection_id, g_free);
|
||||
extension_collection_id = g_strdup (state->collection_id);
|
||||
|
||||
extension_ref = g_build_filename ("runtime", extension, parts[2], branch, NULL);
|
||||
for (branch_i = 0; branches[branch_i] != NULL; branch_i++)
|
||||
{
|
||||
const char *branch = branches[branch_i];
|
||||
|
||||
if (flatpak_remote_state_lookup_ref (state, extension_ref, &checksum, NULL, NULL))
|
||||
{
|
||||
add_related (self, related, extension, extension_collection_id, extension_ref, checksum,
|
||||
no_autodownload, download_if, autodelete, locale_subset);
|
||||
}
|
||||
else if (subdirectories)
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_remote_state_match_subrefs (state, extension_ref);
|
||||
int j;
|
||||
for (j = 0; refs[j] != NULL; j++)
|
||||
extension_ref = g_build_filename ("runtime", extension, parts[2], branch, NULL);
|
||||
|
||||
if (flatpak_remote_state_lookup_ref (state, extension_ref, &checksum, NULL, NULL))
|
||||
{
|
||||
g_autofree char *subref_checksum = NULL;
|
||||
add_related (self, related, extension, extension_collection_id, extension_ref, checksum,
|
||||
no_autodownload, download_if, autodelete, locale_subset);
|
||||
}
|
||||
else if (subdirectories)
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_remote_state_match_subrefs (state, extension_ref);
|
||||
int j;
|
||||
for (j = 0; refs[j] != NULL; j++)
|
||||
{
|
||||
g_autofree char *subref_checksum = NULL;
|
||||
|
||||
if (flatpak_remote_state_lookup_ref (state, refs[j], &subref_checksum, NULL, NULL))
|
||||
add_related (self, related, extension, extension_collection_id, refs[j], subref_checksum,
|
||||
no_autodownload, download_if, autodelete, locale_subset);
|
||||
if (flatpak_remote_state_lookup_ref (state, refs[j], &subref_checksum, NULL, NULL))
|
||||
add_related (self, related, extension, extension_collection_id, refs[j], subref_checksum,
|
||||
no_autodownload, download_if, autodelete, locale_subset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ add_extensions () {
|
||||
mkdir -p $DIR/files/foo/none
|
||||
mkdir -p $DIR/files/foo/dir
|
||||
mkdir -p $DIR/files/foo/dir2
|
||||
mkdir -p $DIR/files/foo/multiversion
|
||||
|
||||
cat >> $DIR/metadata <<EOF
|
||||
[Extension org.test.Extension1]
|
||||
@@ -85,6 +86,11 @@ subdirectories=true
|
||||
directory=foo/dir2
|
||||
subdirectories=true
|
||||
|
||||
[Extension org.test.Multiversion]
|
||||
directory=foo/multiversion
|
||||
versions=not-master;master
|
||||
subdirectories=true
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -112,6 +118,8 @@ make_extension org.test.Extension3 not-master
|
||||
make_extension org.test.Extension4 master
|
||||
make_extension org.test.Dir.foo master
|
||||
make_extension org.test.Dir.bar master
|
||||
make_extension org.test.Multiversion.master master
|
||||
make_extension org.test.Multiversion.notmaster not-master
|
||||
|
||||
assert_has_extension_file () {
|
||||
local prefix=$1
|
||||
@@ -139,6 +147,9 @@ assert_has_extension_file /usr dir/foo/exists
|
||||
assert_has_extension_file /usr dir/foo/extension-org.test.Dir.foo:master
|
||||
assert_has_extension_file /usr dir/bar/extension-org.test.Dir.bar:master
|
||||
assert_not_has_extension_file /usr dir2/foo/exists
|
||||
run_sh "ls -lR /usr/foo/multiversion"
|
||||
assert_has_extension_file /usr multiversion/master/extension-org.test.Multiversion.master:master
|
||||
assert_has_extension_file /usr multiversion/notmaster/extension-org.test.Multiversion.notmaster:not-master
|
||||
|
||||
echo "ok runtime extensions"
|
||||
|
||||
@@ -161,5 +172,7 @@ assert_has_extension_file /app dir/foo/exists
|
||||
assert_has_extension_file /app dir/foo/extension-org.test.Dir.foo:master
|
||||
assert_has_extension_file /app dir/bar/extension-org.test.Dir.bar:master
|
||||
assert_not_has_extension_file /app dir2/foo/exists
|
||||
assert_has_extension_file /app multiversion/master/extension-org.test.Multiversion.master:master
|
||||
assert_has_extension_file /app multiversion/notmaster/extension-org.test.Multiversion.notmaster:not-master
|
||||
|
||||
echo "ok app extensions"
|
||||
|
||||
Reference in New Issue
Block a user