summaryrefslogtreecommitdiff
path: root/app/flatpak-builtins-update.c
diff options
context:
space:
mode:
authorPhaedrus Leeds <matthew.leeds@endlessm.com>2020-08-24 07:49:26 -0700
committerAlexander Larsson <alexander.larsson@gmail.com>2020-10-08 09:14:51 +0200
commit7691fc77eb0d47eaeb6d62217447f68af5bd425d (patch)
tree8c7955ffe487cf360081a7f9597d1811568f2611 /app/flatpak-builtins-update.c
parent617f614d50958c8d8355efc540ec5cb75d0b357b (diff)
downloadflatpak-7691fc77eb0d47eaeb6d62217447f68af5bd425d.tar.gz
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.
Diffstat (limited to 'app/flatpak-builtins-update.c')
-rw-r--r--app/flatpak-builtins-update.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/flatpak-builtins-update.c b/app/flatpak-builtins-update.c
index 3904ec8e..be372f85 100644
--- a/app/flatpak-builtins-update.c
+++ b/app/flatpak-builtins-update.c
@@ -147,6 +147,8 @@ flatpak_builtin_update (int argc,
flatpak_transaction_set_disable_static_deltas (transaction, opt_no_static_deltas);
flatpak_transaction_set_disable_dependencies (transaction, opt_no_deps);
flatpak_transaction_set_disable_related (transaction, opt_no_related);
+ if (opt_arch)
+ flatpak_transaction_set_default_arch (transaction, opt_arch);
for (i = 0; opt_sideload_repos != NULL && opt_sideload_repos[i] != NULL; i++)
flatpak_transaction_add_sideload_repo (transaction, opt_sideload_repos[i]);
@@ -275,6 +277,23 @@ flatpak_builtin_update (int argc,
}
}
+ /* Add uninstall operations for any runtimes that are unused and EOL.
+ * Strictly speaking these are not updates but "update" is the command people
+ * run to keep their system maintained. It would be possible to do this in
+ * the transaction that updates them to being EOL, but doing it here seems
+ * more future-proof since we may want to use additional conditions to
+ * determine if something is unused. See
+ * https://github.com/flatpak/flatpak/issues/3799
+ */
+ if ((kinds & FLATPAK_KINDS_RUNTIME) && n_prefs == 0 && !opt_no_deps)
+ {
+ for (k = 0; k < dirs->len; k++)
+ {
+ FlatpakTransaction *transaction = g_ptr_array_index (transactions, k);
+ flatpak_transaction_set_include_unused_uninstall_ops (transaction, TRUE);
+ }
+ }
+
has_updates = FALSE;
for (k = 0; k < dirs->len; k++)