Add more bug fixes cherry-picked from newer libostree releases
authorSimon McVittie <smcv@debian.org>
Mon, 7 Mar 2022 23:37:33 +0000 (23:37 +0000)
committerSimon McVittie <smcv@debian.org>
Mon, 7 Mar 2022 23:37:33 +0000 (23:37 +0000)
Each of these fixes issues that were reported against Flatpak when
using the libostree from Debian 11, either via bullseye or
buster-backports.

debian/patches/Fix-marking-static-delta-commits-as-partial.patch [new file with mode: 0644]
debian/patches/Fix-translation-of-file-URIs-into-paths.patch [new file with mode: 0644]
debian/patches/lib-Fix-a-bad-call-to-g_file_get_child.patch [new file with mode: 0644]
debian/patches/libotutil-Avoid-infinite-recursion-during-error-unwinding.patch
debian/patches/series

diff --git a/debian/patches/Fix-marking-static-delta-commits-as-partial.patch b/debian/patches/Fix-marking-static-delta-commits-as-partial.patch
new file mode 100644 (file)
index 0000000..4fe264e
--- /dev/null
@@ -0,0 +1,60 @@
+From: Phaedrus Leeds <mwleeds@protonmail.com>
+Date: Sat, 19 Feb 2022 07:55:02 -0600
+Subject: Fix marking static delta commits as partial
+
+This patch makes it so that we mark the .commit file from a static delta
+as partial before writing the commit to the staging directory. This
+exactly mirrors what we do in meta_fetch_on_complete() when writing the
+commit on that codepath, which should lend some credibility to the
+correctness of this patch.
+
+I have checked that this fixes an issue Flatpak users have been
+encountering (https://github.com/flatpak/flatpak/issues/3479) which
+results in error messages like "error: Failed to install
+org.freedesktop.Sdk.Extension.texlive: Failed to read commit
+c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No
+such metadata object
+8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree"
+
+Here's the sequence of events that lead to the error:
+1. An install operation is started that fetches static deltas.
+2. The fetch is interrupted for some reason such as network connectivity
+   dropping.
+3. The .commit and .commitmeta files for the commit being pulled are
+   left in the staging dir, e.g.
+   "~/.local/share/flatpak/repo/tmp/staging-dfe862b2-13fc-49a2-ac92-5a59cc0d8e18-RURckd"
+4. There is no `.commitpartial` file for the commit in
+   "~/.local/share/flatpak/repo/state/"
+5. The next time the user attempts the install, libostree reuses the
+   existing staging dir, pulls the commit and commitmeta objects into
+   the repo from the staging dir on the assumption that it's a complete
+   commit.
+6. Flatpak then tries to deploy the commit but fails in
+   ostree_repo_read_commit() in flatpak_dir_deploy(), leading to the
+   error message "Failed to read commit ..."
+7. This happens again any subsequent time the user attempts the install,
+   until the incomplete commit is removed with "flatpak repair --user".
+
+I will try to also add a workaround in Flatpak so this is fixed even
+when Flatpak links against affected versions of libostree.
+
+Bug: https://github.com/flatpak/flatpak/issues/3479
+Origin: upstream, 2022.2, commit:5d3b1ca37a508e9f80702b7ef7383fe95253ec6a
+---
+ src/libostree/ostree-repo-pull.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
+index 758c505..4f44191 100644
+--- a/src/libostree/ostree-repo-pull.c
++++ b/src/libostree/ostree-repo-pull.c
+@@ -2214,6 +2214,9 @@ process_one_static_delta (OtPullData                 *pull_data,
+                                          ref, cancellable, error))
+             return FALSE;
++          if (!ostree_repo_mark_commit_partial (pull_data->repo, to_revision, TRUE, error))
++            return FALSE;
++
+           if (detached_data && !ostree_repo_write_commit_detached_metadata (pull_data->repo,
+                                                                             to_revision,
+                                                                             detached_data,
diff --git a/debian/patches/Fix-translation-of-file-URIs-into-paths.patch b/debian/patches/Fix-translation-of-file-URIs-into-paths.patch
new file mode 100644 (file)
index 0000000..1062281
--- /dev/null
@@ -0,0 +1,57 @@
+From: Phaedrus Leeds <mwleeds@endlessos.org>
+Date: Wed, 10 Mar 2021 10:02:14 -0800
+Subject: Fix translation of file:// URIs into paths
+
+Currently if a file path contains a special character such as '\', and
+that character is encoded into a file:// URI that is passed to
+ostree_repo_pull_with_options(), the percent encoding will remain in the
+path passed to g_file_new() (in the case of backslash %5C) and the pull
+will then fail with a file not found error. This is an important edge
+case to handle because by default on many Linux distributions a
+filesystem with no label is mounted at a path based on its UUID, and
+this is then passed to systemd-escape by Flatpak (when
+--enable-auto-sideloading was used at compile time) to create a symbolic
+link such as this which contains backslashes:
+
+$ ls -l /run/flatpak/sideload-repos/
+total 0
+lrwxrwxrwx 1 mwleeds mwleeds 55 Mar  9 14:21
+'automount-run-media-mwleeds-29419e8f\x2dc680\x2d4e95\x2d9a31\x2d2cc907d421cb'
+-> /run/media/mwleeds/29419e8f-c680-4e95-9a31-2cc907d421cb
+
+And Flatpak then passes libostree a file:// URI containing that path, to
+implement sideloading (pulling content from the USB drive).
+
+This results in an error like:
+
+Error: While pulling app/org.videolan.VLC/x86_64/stable from remote
+flathub:
+/run/flatpak/sideload-repos/automount-run-media-mwleeds-29419e8f%5Cx2dc680%5Cx2d4e95%5Cx2d9a31%5Cx2d2cc907d421cb/.ostree/repo:
+opendir(/run/flatpak/sideload-repos/automount-run-media-mwleeds-29419e8f%5Cx2dc680%5Cx2d4e95%5Cx2d9a31%5Cx2d2cc907d421cb/.ostree/repo):
+No such file or directory
+
+This patch avoids such errors by using g_file_new_for_uri() instead of
+g_file_new_for_path(), so that GLib handles the %-decoding for us.
+
+Bug: https://community.endlessos.com/t/can-not-install-vlc-from-usb-drive-3-9-3/16353
+Bug: https://github.com/flatpak/flatpak/issues/4378
+Origin: upstream, 2021.1, commit:19577522f8eacd868cf25d53e1ac0e7f424e952b
+---
+ src/libostree/ostree-repo-pull.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
+index 4f44191..ac9e7a7 100644
+--- a/src/libostree/ostree-repo-pull.c
++++ b/src/libostree/ostree-repo-pull.c
+@@ -4084,8 +4084,8 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
+    */
+   if (g_str_equal (first_scheme, "file") && !pull_data->require_static_deltas)
+     {
+-      g_autofree char *path = _ostree_fetcher_uri_get_path (first_uri);
+-      g_autoptr(GFile) remote_repo_path = g_file_new_for_path (path);
++      g_autofree char *uri = _ostree_fetcher_uri_to_string (first_uri);
++      g_autoptr(GFile) remote_repo_path = g_file_new_for_uri (uri);
+       pull_data->remote_repo_local = ostree_repo_new (remote_repo_path);
+       if (!ostree_repo_open (pull_data->remote_repo_local, cancellable, error))
+         goto out;
diff --git a/debian/patches/lib-Fix-a-bad-call-to-g_file_get_child.patch b/debian/patches/lib-Fix-a-bad-call-to-g_file_get_child.patch
new file mode 100644 (file)
index 0000000..be2c10b
--- /dev/null
@@ -0,0 +1,39 @@
+From: Valentin David <me@valentindavid.com>
+Date: Tue, 2 Nov 2021 19:49:04 +0100
+Subject: lib: Fix a bad call to g_file_get_child
+
+In Glib, since commit 3a6e8bc8876e149c36b6b14c6a25a718edb581ed,
+`g_file_get_child` does not accept absolute path as paramater anymore.
+
+The broken assertion was encountered during `ostree admin deploy`
+command for the checkout of subpath `etc`.
+
+Example of error log:
+```
+(ostree admin deploy:1640): GLib-GIO-CRITICAL **: 03:42:00.570: g_file_get_child: assertion '!g_path_is_absolute (name)' failed
+
+(ostree admin deploy:1640): GLib-GIO-CRITICAL **: 03:42:00.570: g_file_query_info: assertion 'G_IS_FILE (file)' failed
+**
+OSTree:ERROR:src/ostree/ot-main.c:232:ostree_run: assertion failed: (success || error)
+Bail out! OSTree:ERROR:src/ostree/ot-main.c:232:ostree_run: assertion failed: (success || error)
+```
+
+Bug: https://github.com/flatpak/flatpak/pull/4707
+Origin: upstream, 2021.6, commit:adc097a2edb1b7aaf5604043b4b1d5bd6ef8a308
+---
+ src/libostree/ostree-repo-checkout.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c
+index 00c6a77..c6645d7 100644
+--- a/src/libostree/ostree-repo-checkout.c
++++ b/src/libostree/ostree-repo-checkout.c
+@@ -1381,7 +1381,7 @@ ostree_repo_checkout_at (OstreeRepo                        *self,
+   g_autoptr(GFile) target_dir = NULL;
+   if (strcmp (options->subpath, "/") != 0)
+-    target_dir = g_file_get_child (commit_root, options->subpath);
++    target_dir = g_file_resolve_relative_path (commit_root, options->subpath);
+   else
+     target_dir = g_object_ref (commit_root);
+   g_autoptr(GFileInfo) target_info =
index 6196301db43525e4a6d1f8f17bfa2fb0c8b66d8f..55665d3788498e2b9b29cadcc2f5dad684b492cc 100644 (file)
@@ -15,6 +15,7 @@ Partially resolves https://github.com/ostreedev/ostree/issues/2525
 libglnx to a version where libglnx#3 has been fixed).
 
 Signed-off-by: Simon McVittie <smcv@collabora.com>
+Bug: https://github.com/ostreedev/ostree/issues/2525
 Applied-upstream: 2022.2, commit:920f85cabc656e4a7c07574aa9af211b6153756d
 ---
  src/libotutil/ot-variant-builder.c | 2 +-
index 6662431a8db4d583af7b559dca9d0a9151c2b074..b2fc9c44efe052ed3de705fff25e8881b79fae51 100644 (file)
@@ -1,4 +1,7 @@
 test-pull-summary-sigs-Set-timestamps-to-serve-expected-f.patch
 Fall-back-if-copy_file_range-fails-with-EINVAL.patch
 libotutil-Avoid-infinite-recursion-during-error-unwinding.patch
+Fix-marking-static-delta-commits-as-partial.patch
+lib-Fix-a-bad-call-to-g_file_get_child.patch
+Fix-translation-of-file-URIs-into-paths.patch
 debian/Skip-test-pull-repeated-during-CI.patch