New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transaction: Add new flatpak_transaction_add_rebase_and_uninstall() API #5332
transaction: Add new flatpak_transaction_add_rebase_and_uninstall() API #5332
Conversation
This will be used in the next commit to simplify some new code. Currently, this introduces no functional changes. Signed-off-by: Philip Withnall <[email protected]> Helps: flatpak#3991
I’ve tested this using the reproducer instructions in #3991 and it fixes the issue. With the hack applied to cause the installation of the rebased app to fail with
Because the rebase op fails, the uninstall op for |
If this is accepted and lands, gnome-software’s flatpak plugin will need to be updated to use it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good to me, but I think it should be possible to add a test for the reproducer. I didn't run this, but I think it should work:
diff --git a/tests/test-repo.sh b/tests/test-repo.sh
index 55403259..c9f0996f 100644
--- a/tests/test-repo.sh
+++ b/tests/test-repo.sh
@@ -439,6 +439,26 @@ ${FLATPAK} build-commit-from --no-update-summary --end-of-life-rebase=org.test.H
GPGARGS="${FL_GPGARGS}" $(dirname $0)/make-test-app.sh repos/test-rebase org.test.NewHello master "${REBASE_COLLECTION_ID}" "NEW" > /dev/null
update_repo test-rebase
+# Temporarily set the minimum free space to 1 to make the install of the
+# rebased app fail.
+orig_min_free_space=$(ostree --repo=$FL_DIR/repo config get core.min-free-space-size || :)
+ostree --repo=$FL_DIR/repo config set core.min-free-space-size 1
+
+if ${FLATPAK} ${U} update -y org.test.Hello >&2; then
+ assert_not_reached "flatpak update should fail with insufficient free space"
+fi
+
+# Check that the old app is still installed and the new app is not installed.
+assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/files
+assert_not_has_dir $FL_DIR/app/org.test.NewHello/$ARCH/master/active/files
+
+# Restore the original minimum free space.
+if [ -n "$orig_min_free_space" ]; then
+ ostree --repo=$FL_DIR/repo config set core.min-free-space-size "$orig_min_free_space"
+else
+ ostree --repo=$FL_DIR/repo config unset core.min-free-space-size
+fi
+
${FLATPAK} ${U} update -y org.test.Hello >&2
# Make sure we got the new version installed
You were right. I had to change But now the test works and it fails if I revert the atomicity fixes, so that’s all good. Since the test is 99% your code, I’ve put your name on the commit to add it. No changes made to the other commits. |
🙄 double whoops. I even wrote the previous 👍 from me. I think the code makes sense and the test proves it works correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewed the implementation in detail: I'm more familiar with the sandboxing part of Flatpak than the "package management" layer. This could benefit from review from @mwleeds or @alexlarsson when finished.
This mostly replaces `flatpak_transaction_add_rebase()`. It’s necessary because the uninstall op for an eol-rebased app needs to be linked to the install/update op for the rebased app, otherwise one op can proceed after the other has failed (or they can be run in the wrong order) and result in the old app being uninstalled but the new one not installed. The following commit will port the internal flatpak `FlatpakTransaction` subclasses to use it. Other consumers of `FlatpakTransaction` (such as gnome-software) will have to be ported as well. Signed-off-by: Philip Withnall <[email protected]> Fixes: flatpak#3991
This fixes the possible situation where an eol-rebase app can be uninstalled and the new version not correctly installed (due to, for example, the install op failing due to a lack of disk space). Signed-off-by: Philip Withnall <[email protected]> Fixes: flatpak#3991
This adds a test to cover the changes in the previous commit. Helps: flatpak#3991
8d41d99
to
c96119f
Compare
Just in case it’s not clear: as far as I’m concerned, this is finished and ready to be merged whenever the right people have reviewed it. |
Actually, are either of them actively reviewing things at the moment? If not, this could block indefinitely, which would be a bit of a shame. Is the combination of your review and Dan’s review not sufficient? |
This looks fine to me. And yes, I'm currently very lame at following flatpak stuff. If I'm not seeing something important, please seek me out and I can help. |
This mostly replaces
flatpak_transaction_add_rebase()
. It’s necessarybecause the uninstall op for an eol-rebased app needs to be linked to
the install/update op for the rebased app, otherwise one op can proceed
after the other has failed (or they can be run in the wrong order) and
result in the old app being uninstalled but the new one not installed.
The following commit will port the internal flatpak
FlatpakTransaction
subclasses to use it. Other consumers of
FlatpakTransaction
(such asgnome-software) will have to be ported as well.
Signed-off-by: Philip Withnall [email protected]
Fixes: #3991