flatpak/0001-transaction-Add-back-support-for-file-uris-in-Runtim.patch

69 lines
2.4 KiB
Diff

From 1029f2b1d05bf96eb6083b5879c31997fd1d53be Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Wed, 12 Jun 2019 08:15:37 +0200
Subject: [PATCH] transaction: Add back support for file: uris in RuntimeRepo
keys
This used to work, and the gnome-software test suite relies on it,
so add it back. I believe it regressed in
https://github.com/flatpak/flatpak/pull/2740
This fixes https://github.com/flatpak/flatpak/issues/2955
Closes: #2956
Approved by: alexlarsson
---
common/flatpak-transaction.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/common/flatpak-transaction.c b/common/flatpak-transaction.c
index 849455ca..e4a42dfc 100644
--- a/common/flatpak-transaction.c
+++ b/common/flatpak-transaction.c
@@ -2618,15 +2618,35 @@ handle_runtime_repo_deps (FlatpakTransaction *self,
if (priv->disable_deps)
return TRUE;
- if (!g_str_has_prefix (dep_url, "http:") && !g_str_has_prefix (dep_url, "https:"))
- return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Flatpakrepo URL %s not HTTP or HTTPS"), dep_url);
- soup_session = flatpak_create_soup_session (PACKAGE_STRING);
- dep_data = flatpak_load_http_uri (soup_session, dep_url, 0, NULL, NULL, cancellable, error);
- if (dep_data == NULL)
+ if (g_str_has_prefix (dep_url, "file:"))
{
- g_prefix_error (error, "Can't load dependent file %s", dep_url);
- return FALSE;
+ g_autoptr(GFile) file = NULL;
+ g_autofree char *data = NULL;
+ gsize data_len;
+
+ file = g_file_new_for_uri (dep_url);
+
+ if (!g_file_load_contents (file, cancellable, &data, &data_len, NULL, error))
+ {
+ g_prefix_error (error, "Can't load dependent file %s", dep_url);
+ return FALSE;
+ }
+
+ dep_data = g_bytes_new_take (g_steal_pointer (&data), data_len);
+ }
+ else
+ {
+ if (!g_str_has_prefix (dep_url, "http:") && !g_str_has_prefix (dep_url, "https:"))
+ return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Flatpakrepo URL %s not HTTP or HTTPS"), dep_url);
+
+ soup_session = flatpak_create_soup_session (PACKAGE_STRING);
+ dep_data = flatpak_load_http_uri (soup_session, dep_url, 0, NULL, NULL, cancellable, error);
+ if (dep_data == NULL)
+ {
+ g_prefix_error (error, "Can't load dependent file %s", dep_url);
+ return FALSE;
+ }
}
if (!g_key_file_load_from_data (dep_keyfile,
--
2.21.0