Support the --installation parameter for most flatpak commands

Other commands (e.g. remote-list) need explicit support for this parameter.
This commit is contained in:
Mario Sanchez Prada
2016-12-16 19:17:33 +00:00
parent 53a81e3f1c
commit a3961b4875

View File

@@ -39,6 +39,7 @@ static gboolean opt_version;
static gboolean opt_default_arch;
static gboolean opt_supported_arches;
static gboolean opt_user;
static char *opt_installation;
typedef struct
{
@@ -115,6 +116,7 @@ static GOptionEntry empty_entries[] = {
GOptionEntry user_entries[] = {
{ "user", 0, 0, G_OPTION_ARG_NONE, &opt_user, N_("Work on user installations"), NULL },
{ "system", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt_user, N_("Work on system-wide installations (default)"), NULL },
{ "installation", 0, 0, G_OPTION_ARG_STRING, &opt_installation, N_("Work on a specific system-wide installation"), NULL },
{ NULL }
};
@@ -236,7 +238,16 @@ flatpak_option_context_parse (GOptionContext *context,
if (!(flags & FLATPAK_BUILTIN_FLAG_NO_DIR))
{
dir = opt_user ? flatpak_dir_get_user () : flatpak_dir_get_system_default ();
if (opt_user)
dir = flatpak_dir_get_user ();
else if (opt_installation == NULL)
dir = flatpak_dir_get_system_default ();
else
{
dir = flatpak_dir_get_system_by_id (opt_installation, cancellable, error);
if (dir == NULL)
return FALSE;
}
if (!flatpak_dir_ensure_path (dir, cancellable, error))
return FALSE;