summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Leeds <matthew.leeds@endlessm.com>2018-10-19 18:20:02 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-10-24 16:38:16 +0000
commita4683a4328d1c4622f7314e8581397e1c24edf9e (patch)
tree166a1c5bc018f58d5710ee66920063e3871adf54
parent070e07c6f223bc4cb6bbcaebf6b814293b20c1a1 (diff)
downloadflatpak-a4683a4328d1c4622f7314e8581397e1c24edf9e.tar.gz
installation: Respect configured set of repo finders
OSTree now has a repo config option to set which repo finders (that is, sources for refs) will be used, and API which exposes the default set (which was either configured by the user or decided by libostree). So this commit changes flatpak_installation_list_remotes_by_type() to respect that configuration, since that's the only place flatpak passes a set of OstreeRepoFinder instances to libostree. See also https://github.com/ostreedev/ostree/pull/1758/ Closes: #2264 Approved by: pwithnall
-rw-r--r--common/flatpak-installation.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c
index e9e03777..a3650d66 100644
--- a/common/flatpak-installation.c
+++ b/common/flatpak-installation.c
@@ -1269,6 +1269,9 @@ flatpak_installation_list_remotes_by_type (FlatpakInstallation *self,
const guint NUM_FLATPAK_REMOTE_TYPES = 3;
gboolean types_filter[NUM_FLATPAK_REMOTE_TYPES];
gsize i;
+#if OSTREE_CHECK_VERSION (2018, 9)
+ const char * const *default_repo_finders = NULL;
+#endif
remote_names = flatpak_dir_list_remotes (dir, cancellable, error);
if (remote_names == NULL)
@@ -1280,11 +1283,50 @@ flatpak_installation_list_remotes_by_type (FlatpakInstallation *self,
if (!flatpak_dir_maybe_ensure_repo (dir_clone, cancellable, error))
return NULL;
+#if OSTREE_CHECK_VERSION (2018, 9)
+ OstreeRepo *repo = flatpak_dir_get_repo (dir_clone);
+ if (repo != NULL)
+ default_repo_finders = ostree_repo_get_default_repo_finders (repo);
+#endif
+
+ /* If NULL or an empty array of types is passed then we use the default set
+ * provided by ostree, or fall back to using all */
for (i = 0; i < NUM_FLATPAK_REMOTE_TYPES; ++i)
{
- /* If NULL or an empty array of types is passed then we include all types */
- types_filter[i] = (num_types == 0) ? TRUE : FALSE;
+ if (num_types != 0)
+ types_filter[i] = FALSE;
+#if OSTREE_CHECK_VERSION (2018, 9)
+ else if (default_repo_finders == NULL)
+ types_filter[i] = TRUE;
+#else
+ else
+ types_filter[i] = TRUE;
+#endif
+ }
+
+#if OSTREE_CHECK_VERSION (2018, 9)
+ if (default_repo_finders != NULL && num_types == 0)
+ {
+ g_autofree char *default_repo_finders_str = g_strjoinv (" ", (gchar **)default_repo_finders);
+ g_debug ("Using default repo finder list: %s", default_repo_finders_str);
+
+ for (const char * const *iter = default_repo_finders; iter && *iter; iter++)
+ {
+ const char *default_repo_finder = *iter;
+
+ if (strcmp (default_repo_finder, "config") == 0)
+ types_filter[FLATPAK_REMOTE_TYPE_STATIC] = TRUE;
+ else if (strcmp (default_repo_finder, "lan") == 0)
+ types_filter[FLATPAK_REMOTE_TYPE_LAN] = TRUE;
+ else if (strcmp (default_repo_finder, "mount") == 0)
+ types_filter[FLATPAK_REMOTE_TYPE_USB] = TRUE;
+ else
+ g_debug ("Unknown value in list returned by "
+ "ostree_repo_get_default_repo_finders(): %s",
+ default_repo_finder);
+ }
}
+#endif
for (i = 0; i < num_types; ++i)
{