From 47906593b86ad9dd34044bbe9c2dbc39f7f247fc Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 26 Oct 2016 20:39:03 +0200 Subject: [PATCH] When installing to the system dir, don't consider --user dependencies It makes no sense to allow you to install an application systemwide if it only works for your user. However, its generally fine if to install a per-user app that relies on a system-installed runtime. In particular, this fixes installing system-wide extra-data apps where we need the runtime to be system-installed to run the unpack script. --- app/flatpak-transaction.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/flatpak-transaction.c b/app/flatpak-transaction.c index f8660ece..609c787d 100644 --- a/app/flatpak-transaction.c +++ b/app/flatpak-transaction.c @@ -51,12 +51,29 @@ struct FlatpakTransaction { }; +/* Check if the ref is in the dir, or in the system dir, in case its a + * user-dir. We want to avoid depending on user-installed things when + * installing to the system dir. + */ static gboolean -ref_is_installed (const char *ref) +ref_is_installed (FlatpakDir *dir, const char *ref) { - g_autoptr(FlatpakDeploy) deploy = NULL; - deploy = flatpak_find_deploy_for_ref (ref, NULL, NULL); - return deploy != NULL; + g_autoptr(GFile) deploy_dir = NULL; + + deploy_dir = flatpak_dir_get_if_deployed (dir, ref, NULL, NULL); + if (deploy_dir != NULL) + return TRUE; + + if (flatpak_dir_is_user (dir)) + { + g_autoptr(FlatpakDir) system_dir = flatpak_dir_get_system (); + + deploy_dir = flatpak_dir_get_if_deployed (dir, ref, NULL, NULL); + if (deploy_dir != NULL) + return TRUE; + } + + return FALSE; } static gboolean @@ -331,7 +348,7 @@ add_deps (FlatpakTransaction *self, if (!flatpak_transaction_contains_ref (self, full_runtime_ref)) { - if (!ref_is_installed (full_runtime_ref)) + if (!ref_is_installed (self->dir, full_runtime_ref)) { g_auto(GStrv) remotes = NULL;