From 3f144d1e02fa060680eba18a9dd81969682a3170 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Feb 2022 14:47:24 +0000 Subject: [PATCH] app: Make ALL_DIRS and STANDARD_DIRS imply OPTIONAL_REPO It is already the case that when we are using ALL_DIRS, we always combine it with OPTIONAL_REPO, meaning no need to populate empty installations. ALL_DIRS is used for commands that iterate through all known installations to enumerate apps/runtimes, such as `flatpak run` and `flatpak list`; for these commands, it's reasonable to say that if the installation does not have a libostree repository, then that's equivalent to it having a libostree repository with no apps and no runtimes. Make this happen automatically if forgotten. For STANDARD_DIRS, we were inconsistent about this: `flatpak remote-list` had OPTIONAL_REPO, but the other commands did not. STANDARD_DIRS is used for `flatpak create-usb`, and for all the commands that manipulate remotes. For the commands that manipulate remotes, it seems reasonable to say that if an installation has no libostree repository and we are unable to create one, then that's equivalent to an installation with a libostree repository but no remotes. Similarly, for create-usb, an installation where we are unable to create a libostree repository seems like it should be equivalent to an installation whose libostree repository does not contain any of the refs we are interested in. Resolves: https://github.com/flatpak/flatpak/issues/4111 Signed-off-by: Simon McVittie --- app/flatpak-builtins.h | 6 ++++-- app/flatpak-main.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/flatpak-builtins.h b/app/flatpak-builtins.h index ec1ac4a4..d925c8cd 100644 --- a/app/flatpak-builtins.h +++ b/app/flatpak-builtins.h @@ -39,10 +39,12 @@ G_BEGIN_DECLS * @FLATPAK_BUILTIN_FLAG_ONE_DIR: Allow a single --user/--system/--installation option * and return a single dir. If no option is specified, default to --system * @FLATPAK_BUILTIN_FLAG_STANDARD_DIRS: Allow repeated use of --user/--system/--installation - * and return multiple dirs. If no option is specified return system(default)+user + * and return multiple dirs. If no option is specified return system(default)+user. + * Implies %FLATPAK_BUILTIN_FLAG_OPTIONAL_REPO. * @FLATPAK_BUILTIN_FLAG_ALL_DIRS: Allow repeated use of --user/--system/--installation * and return multiple dirs. If no option is specified, return all installations, - * starting with system(default)+user + * starting with system(default)+user. + * Implies %FLATPAK_BUILTIN_FLAG_OPTIONAL_REPO. * * Flags affecting the behavior of flatpak_option_context_parse(). * diff --git a/app/flatpak-main.c b/app/flatpak-main.c index 88e9d5af..dfdd45b3 100644 --- a/app/flatpak-main.c +++ b/app/flatpak-main.c @@ -470,7 +470,9 @@ flatpak_option_context_parse (GOptionContext *context, { FlatpakDir *dir = g_ptr_array_index (dirs, i); - if (flags & FLATPAK_BUILTIN_FLAG_OPTIONAL_REPO) + if (flags & (FLATPAK_BUILTIN_FLAG_OPTIONAL_REPO | + FLATPAK_BUILTIN_FLAG_ALL_DIRS | + FLATPAK_BUILTIN_FLAG_STANDARD_DIRS)) { if (!flatpak_dir_maybe_ensure_repo (dir, cancellable, error)) return FALSE;