Commit Graph

62 Commits

Author SHA1 Message Date
Phaedrus Leeds
d764202ce7 transaction: Add new API for getting an op by ref
This will be useful in gnome-software's flatpak plugin, which currently
iterates over the operations a few times, and it will be useful
internally as well.
2022-06-15 16:44:17 -07:00
Ryan Gonzalez
12305b2cae Add --include-sdk/debug to install SDK/debuginfo along with a ref
This makes it a lot easier to give guidance on using `flatpak run -d` or
`flatpak-coredumpctl`, because there's an easy way to install the
relevant refs.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2022-05-06 17:35:30 -07:00
Philip Withnall
733835d818 flatpak-transaction: Add get_no_interaction() method
This complements `flatpak_transaction_set_no_interaction()` and allows
calling code to see if a given transaction is interactive.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-01-25 10:03:41 +01:00
Kalev Lember
426284759c Add G_BEGIN_DECLS/G_END_DECLS to public headers
This ensures that we correctly specify C linkage when including flatpak
headers from C++ code.

This should fix fallout from glib's change to include C++ code in its
headers, see https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1935
for discussion.

Fixes https://github.com/flatpak/flatpak/issues/4117
2021-02-12 15:58:09 +01:00
Alexander Larsson
48b11b3d3d lib: Add flatpak_transaction_operation_get_subpaths()
This returns the actual subpath that will be fetched during the operation,
not just what was passed in.

NOTE: We were previously doing the final resolve of this in the update
case during the pull operation, but this commit changes that to do it
up-front in order to be able to return the right value for this.
2020-11-10 14:32:13 +01:00
Alexander Larsson
bf8ac3cc1c Transaction: Add ready-pre-auth signal
This is similar to the ready signal, except it is called before
per-ref authentication. Apps can use this if they want to be able
to ask for user input on progress before asking for authentication.

This is nice to be able to do in general, but it is also required for
the implementation of
flatpak_installation_list_installed_refs_for_update(), as it doesn't
install any authentication handler, so it will never report updates
for protected refs if using the ready signal.

Note: In special cases we will require authentication even earlier
if authenticating is needed during the resolve operation. This happens
for instance if you are doing a update to a particular commit (rather
than the lastest commit) where we need to get the commit object directly.
2020-10-09 16:57:57 +02:00
Alexander Larsson
84da902443 transaction: Add flatpak_transaction_set_disable_auto_pin()
This disables the automatic pinning of explicitly installed runtimes.
2020-10-08 09:14:51 +02:00
Phaedrus Leeds
7691fc77eb app: Remove EOL unused runtimes in update command
In case a runtime becomes unused and then later becomes End-Of-Life, it
is currently not removed. So this commit removes such runtimes in the
update command, as discussed in #2639. A unit test is included.

I am planning to propose to use the FlatpakTransaction API added here in
gnome-software, so that users don't have to use the CLI at all for
runtimes to be cleaned up. KDE Discover already removes unused runtimes
periodically.
2020-10-08 09:14:51 +02:00
Alexander Larsson
f1f2c4844c transaction: Add install-authenticator signal
If a transaction requires to install an authenticator before it can
continue this signal will be emitted, allowing you to create a new
transaction to install the required authenticator.
2020-06-22 10:51:36 +02:00
Alexander Larsson
0978826c2e Add and use per-transaction no-interaction option
This is useful if to avoid changing the no-interaction of the whole
FlatpakInstallation. Also, having this per transaction lets us
clean up the code in FlatpakQuietTransaction a bit.
2020-06-09 10:38:25 +02:00
Philip Withnall
82d0a3f50a flatpak-transaction: Change related_to_op to related_to_ops
Since a single runtime (for example) can be related-to several apps,
that needs to be representable in the data format.

This is an API break, but only of API which has not been released yet.

See https://github.com/flatpak/flatpak/pull/3568#issuecomment-618251958

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-30 13:14:45 +01:00
Philip Withnall
5824668418 flatpak-transaction: Add flatpak_transaction_operation_get_is_skipped()
This exposes the `skip` member of `FlatpakTransactionOperation`, as it’s
needed for callers to usefully traverse the operation graph (which is
now accessible using
`flatpak_transaction_operation_get_related_to_op()`).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-23 10:13:19 +02:00
Matthew Leeds
e6b906f842 transaction: Add transaction_operation_get_related_to_op()
This will be used in the following commit, so we can track what
installed thing needs an update when there's a transaction operation to
e.g. install its missing runtime or extension.
2020-04-16 09:22:11 +02:00
Alexander Larsson
a843d2d594 sideload: Add api and CLI support to specify sideload repos dynamically 2020-03-24 14:01:20 +01:00
Alexander Larsson
38c86bdf0f Authenticator: Add extra a{sv} args for future use
These are not used atm, but make the APIs future proof.
2019-12-12 14:27:59 +01:00
Alexander Larsson
6e6c122cb2 Authenticators: Add BasicAuth operation and handle it in transaction
This adds a new way for authenticators to trigger interactive authentication
in the client for simple user/password dialogs. These are not recommended
to use as a webflow is often better. However, for OCI remotes that
use http basic auth this is useful and allows the CLI experience to work
with that.
2019-12-12 12:16:53 +01:00
Philip Chimento
923beec024 Change "update-frequency" to "update-interval"
An event happens more often as its frequency gets higher, so these
values were confusing me.

Rename the constants to include their unit (ms) as well, to avoid
confusion.

Anything that affects public API (such as
flatpak_transaction_progress_set_update_frequency()) or libostree's
options passed to ostree_repo_pull_with_options(), is left as is.
2019-12-06 13:26:49 -08:00
Alexander Larsson
3f6245d41b authenticator: Add a parent_window handle to request_tokens
This allows the authenticator to directly do UI and parent it to the
relevant window. The actual parent string is specified just like
the xdg-desktop-portal one.

There is a new flatpak_transaction_set_parent_window() function that
clients can use to signal the what window they want to be parented to.
2019-11-26 16:37:01 +01:00
Alexander Larsson
0ca1a1624f FlatpakTransaction: Add webflow-start/done signals and abort_webflow()
These signals are emitted when the authenticator needs some kind of
web-based authentication. If the caller implements webflow-start and
returns TRUE, then it needs to show the user the URL and allow the user
to interact with it.

Typically this ends with the web-page being redirected to a url to
localhost or similar which tells the authenticator the result of the
operations. This will cause the webflow-done signal to be emitted and
the transaction operation to continue. If something goes wrong (or the
signal is not handled) it will also report webflow-done, but then the
transaction will fail in a normal way.

Generally all users of FlatpakTransaction need to do is:

 On webflow-start, show a browser window with the url and return TRUE.

 On webflow-done, close the browser window if its still visible.

 If the user closes the browser window early, call
 flatpak_transaction_abort_webflow().
2019-11-26 16:37:01 +01:00
Umang Jain
11631f9514 transaction: Add getter for querying no-pull
As this is a required to deploy autoupdates downloaded in the
background, for clients like gnome-software.
2019-10-08 15:21:09 +05:30
Umang Jain
c7670e87d7 transaction: Add getter for querying no-deploy
FlatpakTransaction inherently doesn't differentiate between a
autoupdate and a regular update; both are
FLATPAK_TRANSACTION_OPERATION_UPDATE.

This getter can help differentiate between a regular update
and autoupdate in clients like gnome-software. Autoupdates
work in two separate transaction passes; first that runs with
"no-deploy" and the second pass that deploys all the downloaded
update (i.e. with "no-pull").
2019-10-08 15:21:03 +05:30
Richard Hughes
4f327649fd Do not break ABI and cause gnome-software to crash
This restores the ABI to the pre-1.4.0 version. This moves the new signal to
the *end* of the struct and also correctly decrements the padding.

Fixes https://github.com/flatpak/flatpak/issues/2957, although we probably need
a 1.4.1 release with this included pretty quickly to avoid chaos.

Closes: #2958
Approved by: alexlarsson
2019-06-13 06:59:41 +00:00
Ryan Gonzalez
7185a00c85 transaction: Add end-of-lifed-with-rebase signal and add_rebase()
end-of-lifed-with-rebase runs earlier in the transaction system than end-of-lifed, meaning it can modify the transaction for rebasing.
The new flatpak_transaction_add_rebase() function can then be used to apply the rebase if wanted.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Matthew Leeds
8d962a686f Run uncrustify
I had to make a few manual edits but other than those the changes look
reasonable.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthew Leeds
9aae124ca3 transaction: Fix gtk-doc warning
Closes: #2574
Approved by: matthiasclasen
2019-01-11 22:57:15 +00:00
Matthias Clasen
45860c56f2 transaction: Add a run vfunc
This lets us avoid extra api FlatpakCliTransaction.

Closes: #2556
Approved by: alexlarsson
2019-01-11 11:42:13 +00:00
Matthias Clasen
3a3ec26ebf transaction: Add api to get the start time of progress
This lets us calculate the download speed, and estimated
time remaining.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
030eb4de3f transaction: Add api to get transferred size
Add a function to FlatpakTransactionProgress to get the
number of transferred bytes. This is useful information
to show during a long-running download.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
19368bd00b transaction: Add api for sizes
Add api to get the download and installed size
of resolved operations. This is useful information
to present to the user before running the transaction.

Closes: #2371
Approved by: alexlarsson
2018-12-18 14:50:26 +00:00
Matthias Clasen
3f0eb7e481 transaction: Fix up a signal signature
We were emitting the ::operation-done signal with
different arguments than declared for the signal.
This showed up as test failure when comparing
the result argument.

Closes: #2187
Approved by: alexlarsson
2018-10-05 13:34:49 +00:00
Will Thompson
9cc72ed08f transaction: improve cross-refs for signal parameter docs
Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:16 +00:00
Alexander Larsson
adffe7d15f fixup! Add flatpak_transaction_operation_type_to_string() 2018-07-10 19:25:44 +02:00
Richard Hughes
53d3a741da Add flatpak_transaction_operation_type_to_string()
This seemed like a useful thing to have, and is what I used in gnome-software.
2018-07-10 19:25:44 +02:00
Alexander Larsson
3f4518b15c Run uncrustify
Closes: #1870
Approved by: alexlarsson
2018-07-08 10:05:37 +00:00
Alexander Larsson
c0ebd3a121 transaction: Move flatpakref installation to transaction code
This adds the flatpak_transaction_add_install_flatpakref method
to easily install from flatpakref files. It additionally
adds a new signal called add-new-remote which is called in two
cases:

 To ask if the user wants to add a "normal" remote for the url
 specified by a flatpakref file.

 When a new remote is required for the runtimes the application
 depends on.

Closes: #1868
Approved by: alexlarsson
2018-07-07 15:38:46 +00:00
Alexander Larsson
1ecca029a8 transaction: Add flatpak_transaction_set_default_arch
This will be used as the default when installing something that
doesn't specify a ref, such as a flatpakref file.

Closes: #1868
Approved by: alexlarsson
2018-07-07 15:38:46 +00:00
Alexander Larsson
93ca5cdf45 transaction: Add get_installation()
Closes: #1841
Approved by: alexlarsson
2018-06-29 12:56:15 +00:00
Alexander Larsson
f504656890 transaction: Mark error const in operation-error signal
Closes: #1841
Approved by: alexlarsson
2018-06-29 12:56:15 +00:00
Alexander Larsson
23f1df8a5b Transaction: Add operation getters for metadata and old_metadata
Closes: #1799
Approved by: alexlarsson
2018-06-19 14:54:22 +00:00
Alexander Larsson
0515e49140 transaction: Add APIs to set dependency sources
Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
5e8b5e5319 Transaction: Use flatpakTransactionOperation in signals
This changes the signals to use a FlatpakTransactionOperation
argument instead of a bunch of arguments in the signal, making
this easier to extend in the future.

This is an API break, but nobody is using this API yet, and it
was only available in one unstable release.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
462204462e Transaction: Add flatpak_transaction_operation_get_bundle_path
This is to match what you can get from the new_operation arguments.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
f9ad4e3eee transaction: Add ready signal
This signal is emitted after all the added operations and their dependencies
are resolved and we have the full list of things that will be
done as part of the transaction. At this point you can call
flatpak_transaction_get_operations() and decide if you want to
continue with the operation.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
4c8f788ecd transaction: Make FlatpakTransactionOperation a (public) GObject
Only the type itself is exposed atm, not members, etc.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
79d43a3c1a transaction: Drop the internal FlatpakTransactionOpKind type
Instead use FlatpakTransactionOperationType internally too,
but extend it with a INSTALL_OR_UPDATE value which is not public.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
715cc173ef Transactions: Add uninstall operation and handle no-pull correctly
In the no-pull case and when uninstalling, we never want to do any network
i/o for e.g. detecting depenedencies.

Closes: #1744
Approved by: alexlarsson
2018-06-01 10:59:14 +00:00
Alexander Larsson
91957b5c61 transaction: strdup progress status in getter
This way we're safe from reentrant use of the progress
2018-05-29 16:37:21 +02:00
Alexander Larsson
9fe81aaf90 Transaction: Add (and use) vfuncs for signals 2018-05-29 16:37:21 +02:00
Alexander Larsson
d2e419418b transaction: Change from installation_create_transaction() to transaction_new_for_installation()
This way is nicer because then the user can derive from FlatpakTransaction
2018-05-29 16:37:21 +02:00
Alexander Larsson
143e24f3bd Transaction: Convert to derivable type 2018-05-29 16:37:21 +02:00