summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhaedrus Leeds <mwleeds@protonmail.com>2021-10-25 14:44:11 -0700
committerAlexander Larsson <alexander.larsson@gmail.com>2022-01-11 11:51:02 +0100
commitbd4fff12f64bc5f5461972fdf659fdb2b3422c16 (patch)
tree25e305d07bc08c1abe4b5166b4e30e14284e590a
parent512b693dbf110fd6d22ee463137c9b9f0bcce91b (diff)
downloadflatpak-bd4fff12f64bc5f5461972fdf659fdb2b3422c16.tar.gz
Don't use app title from flatpakref as remote title
On two different code paths we were using the "Title" field in flatpakref files as the title of a remote, which is incorrect. In most cases, the remote added via the RuntimeRepo key will be the same as the remote the app is from, so when the remote is added for the runtime, its title will be correctly set using the Title value from the flatpakrepo file and the app will therefore have an origin remote with a title set. This is not currently true for flatpakref files that use SuggestRemoteName=, see https://github.com/flatpak/flatpak/pull/4513 For flatpakref files that use a different remote than the RuntimeRepo, we don't currently have a way for the title to be set automatically; perhaps we should (https://github.com/flatpak/flatpak/issues/4512). Fixes https://github.com/flatpak/flatpak/issues/4499 (cherry picked from commit 9dbd265cdd68099b62119e06f94bab43cf1f5ea9)
-rw-r--r--common/flatpak-dir.c13
-rw-r--r--common/flatpak-utils.c6
-rw-r--r--tests/testlibrary.c9
3 files changed, 16 insertions, 12 deletions
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
index db784c3d..8af97531 100644
--- a/common/flatpak-dir.c
+++ b/common/flatpak-dir.c
@@ -13738,14 +13738,12 @@ parse_ref_file (GKeyFile *keyfile,
char **name_out,
char **branch_out,
char **url_out,
- char **title_out,
GBytes **gpg_data_out,
gboolean *is_runtime_out,
char **collection_id_out,
GError **error)
{
g_autofree char *url = NULL;
- g_autofree char *title = NULL;
g_autofree char *name = NULL;
g_autofree char *branch = NULL;
g_autofree char *version = NULL;
@@ -13757,7 +13755,6 @@ parse_ref_file (GKeyFile *keyfile,
*name_out = NULL;
*branch_out = NULL;
*url_out = NULL;
- *title_out = NULL;
*gpg_data_out = NULL;
*is_runtime_out = FALSE;
@@ -13784,9 +13781,6 @@ parse_ref_file (GKeyFile *keyfile,
if (branch == NULL)
branch = g_strdup ("master");
- title = g_key_file_get_string (keyfile, FLATPAK_REF_GROUP,
- FLATPAK_REF_TITLE_KEY, NULL);
-
is_runtime = g_key_file_get_boolean (keyfile, FLATPAK_REF_GROUP,
FLATPAK_REF_IS_RUNTIME_KEY, NULL);
@@ -13824,7 +13818,6 @@ parse_ref_file (GKeyFile *keyfile,
*name_out = g_steal_pointer (&name);
*branch_out = g_steal_pointer (&branch);
*url_out = g_steal_pointer (&url);
- *title_out = g_steal_pointer (&title);
*gpg_data_out = g_steal_pointer (&gpg_data);
*is_runtime_out = is_runtime;
*collection_id_out = g_steal_pointer (&collection_id);
@@ -13845,14 +13838,13 @@ flatpak_dir_create_remote_for_ref_file (FlatpakDir *self,
g_autofree char *name = NULL;
g_autofree char *branch = NULL;
g_autofree char *url = NULL;
- g_autofree char *title = NULL;
g_autofree char *remote = NULL;
gboolean is_runtime = FALSE;
g_autofree char *collection_id = NULL;
g_autoptr(GFile) deploy_dir = NULL;
g_autoptr(FlatpakDecomposed) ref = NULL;
- if (!parse_ref_file (keyfile, &name, &branch, &url, &title, &gpg_data, &is_runtime, &collection_id, error))
+ if (!parse_ref_file (keyfile, &name, &branch, &url, &gpg_data, &is_runtime, &collection_id, error))
return FALSE;
ref = flatpak_decomposed_new_from_parts (is_runtime ? FLATPAK_KINDS_RUNTIME : FLATPAK_KINDS_APP,
@@ -13875,7 +13867,8 @@ flatpak_dir_create_remote_for_ref_file (FlatpakDir *self,
if (remote == NULL)
{
- remote = flatpak_dir_create_origin_remote (self, url, name, title, flatpak_decomposed_get_ref (ref),
+ /* title is NULL because the title from the ref file is the title of the app not the remote */
+ remote = flatpak_dir_create_origin_remote (self, url, name, NULL, flatpak_decomposed_get_ref (ref),
gpg_data, collection_id, NULL, NULL, error);
if (remote == NULL)
return FALSE;
diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c
index 3824139a..a08b6f91 100644
--- a/common/flatpak-utils.c
+++ b/common/flatpak-utils.c
@@ -2260,8 +2260,10 @@ flatpak_parse_repofile (const char *remote_name,
if (subset != NULL)
g_key_file_set_string (config, group, "xa.subset", subset);
- title = g_key_file_get_locale_string (keyfile, source_group,
- FLATPAK_REPO_TITLE_KEY, NULL, NULL);
+ /* Don't use the title from flatpakref files; that's the title of the app */
+ if (!from_ref)
+ title = g_key_file_get_locale_string (keyfile, FLATPAK_REPO_GROUP,
+ FLATPAK_REPO_TITLE_KEY, NULL, NULL);
if (title != NULL)
g_key_file_set_string (config, group, "xa.title", title);
diff --git a/tests/testlibrary.c b/tests/testlibrary.c
index c428ceb6..dbe3a4e5 100644
--- a/tests/testlibrary.c
+++ b/tests/testlibrary.c
@@ -3561,8 +3561,10 @@ test_transaction_flatpakref_remote_creation (void)
g_autoptr(FlatpakInstallation) user_inst = NULL;
g_autoptr(FlatpakInstallation) system_inst = NULL;
g_autoptr(FlatpakTransaction) transaction = NULL;
+ g_autoptr(FlatpakRemote) remote = NULL;
g_autoptr(GError) error = NULL;
g_autofree char *s = NULL;
+ g_autofree char *remote_title = NULL;
g_autoptr(GBytes) data = NULL;
gboolean res;
@@ -3612,6 +3614,13 @@ test_transaction_flatpakref_remote_creation (void)
assert_remote_in_installation (user_inst, "test-without-runtime-repo");
assert_remote_in_installation (user_inst, "test-runtime-only-repo");
+ /* The remote should not use the title of the app as its title */
+ remote = flatpak_installation_get_remote_by_name (user_inst, "test-without-runtime-repo", NULL, &error);
+ g_assert_no_error (error);
+ g_assert_nonnull (remote);
+ remote_title = flatpak_remote_get_title (remote);
+ g_assert_null (remote_title);
+
empty_installation (user_inst);
remove_remote_user ("test-without-runtime-repo");
remove_remote_user ("test-runtime-only-repo");