From 754e1fb5d4082b87116cc1c2da0bd7b5290f8371 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 12 Nov 2020 12:44:29 +0100 Subject: [PATCH] Allow configuring the subset This adds support to remote-add, remote-modify and the flatpakrepo file parser. --- app/flatpak-builtins-remote-add.c | 8 ++++++++ app/flatpak-builtins-remote-modify.c | 9 +++++++++ common/flatpak-dir-private.h | 1 + common/flatpak-utils.c | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/app/flatpak-builtins-remote-add.c b/app/flatpak-builtins-remote-add.c index 42863518..c3d1e3cd 100644 --- a/app/flatpak-builtins-remote-add.c +++ b/app/flatpak-builtins-remote-add.c @@ -48,6 +48,7 @@ static char *opt_comment; static char *opt_description; static char *opt_homepage; static char *opt_icon; +static char *opt_subset; static char *opt_default_branch; static char *opt_url; static char *opt_collection_id = NULL; @@ -69,6 +70,7 @@ static GOptionEntry common_options[] = { { "no-enumerate", 0, 0, G_OPTION_ARG_NONE, &opt_no_enumerate, N_("Mark the remote as don't enumerate"), NULL }, { "no-use-for-deps", 0, 0, G_OPTION_ARG_NONE, &opt_no_deps, N_("Mark the remote as don't use for deps"), NULL }, { "prio", 0, 0, G_OPTION_ARG_INT, &opt_prio, N_("Set priority (default 1, higher is more prioritized)"), N_("PRIORITY") }, + { "subset", 0, 0, G_OPTION_ARG_STRING, &opt_subset, N_("The named subset to use for this remote"), N_("SUBSET") }, { "title", 0, 0, G_OPTION_ARG_STRING, &opt_title, N_("A nice name to use for this remote"), N_("TITLE") }, { "comment", 0, 0, G_OPTION_ARG_STRING, &opt_comment, N_("A one-line comment for this remote"), N_("COMMENT") }, { "description", 0, 0, G_OPTION_ARG_STRING, &opt_description, N_("A full-paragraph description for this remote"), N_("DESCRIPTION") }, @@ -119,6 +121,12 @@ get_config_from_opts (GKeyFile *config, if (opt_collection_id) g_key_file_set_string (config, group, "collection-id", opt_collection_id); + if (opt_subset) + { + g_key_file_set_string (config, group, "xa.subset", opt_subset); + g_key_file_set_boolean (config, group, "xa.subset-is-set", TRUE); + } + if (opt_title) { g_key_file_set_string (config, group, "xa.title", opt_title); diff --git a/app/flatpak-builtins-remote-modify.c b/app/flatpak-builtins-remote-modify.c index df9210f8..fb9a9a25 100644 --- a/app/flatpak-builtins-remote-modify.c +++ b/app/flatpak-builtins-remote-modify.c @@ -52,6 +52,7 @@ static char *opt_comment; static char *opt_description; static char *opt_homepage; static char *opt_icon; +static char *opt_subset; static char *opt_default_branch; static char *opt_url; static char *opt_collection_id = NULL; @@ -66,6 +67,7 @@ static GOptionEntry modify_options[] = { { "enumerate", 0, 0, G_OPTION_ARG_NONE, &opt_do_enumerate, N_("Mark the remote as enumerate"), NULL }, { "use-for-deps", 0, 0, G_OPTION_ARG_NONE, &opt_do_deps, N_("Mark the remote as used for dependencies"), NULL }, { "url", 0, 0, G_OPTION_ARG_STRING, &opt_url, N_("Set a new url"), N_("URL") }, + { "subset", 0, 0, G_OPTION_ARG_STRING, &opt_subset, N_("Set a new subset to use"), N_("SUBSET") }, { "enable", 0, 0, G_OPTION_ARG_NONE, &opt_enable, N_("Enable the remote"), NULL }, { "update-metadata", 0, 0, G_OPTION_ARG_NONE, &opt_update_metadata, N_("Update extra metadata from the summary file"), NULL }, { NULL } @@ -141,6 +143,13 @@ get_config_from_opts (FlatpakDir *dir, const char *remote_name, gboolean *change *changed = TRUE; } + if (opt_subset) + { + g_key_file_set_string (config, group, "xa.subset", opt_subset); + g_key_file_set_boolean (config, group, "xa.subset-is-set", TRUE); + *changed = TRUE; + } + if (opt_title) { g_key_file_set_string (config, group, "xa.title", opt_title); diff --git a/common/flatpak-dir-private.h b/common/flatpak-dir-private.h index f4ebb8c7..4efad92f 100644 --- a/common/flatpak-dir-private.h +++ b/common/flatpak-dir-private.h @@ -72,6 +72,7 @@ GType flatpak_deploy_get_type (void); #define FLATPAK_REPO_GROUP "Flatpak Repo" #define FLATPAK_REPO_VERSION_KEY "Version" #define FLATPAK_REPO_URL_KEY "Url" +#define FLATPAK_REPO_SUBSET_KEY "Subset" #define FLATPAK_REPO_TITLE_KEY "Title" #define FLATPAK_REPO_DEFAULT_BRANCH_KEY "DefaultBranch" #define FLATPAK_REPO_GPGKEY_KEY "GPGKey" diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index 7f58e2a5..235ee008 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -2192,6 +2192,7 @@ flatpak_parse_repofile (const char *remote_name, g_autofree char *icon = NULL; g_autofree char *homepage = NULL; g_autofree char *filter = NULL; + g_autofree char *subset = NULL; g_autofree char *authenticator_name = NULL; gboolean nodeps; const char *source_group; @@ -2232,6 +2233,11 @@ flatpak_parse_repofile (const char *remote_name, g_key_file_set_string (config, group, "url", uri); + subset = g_key_file_get_locale_string (keyfile, source_group, + FLATPAK_REPO_SUBSET_KEY, NULL, NULL); + if (subset != NULL) + g_key_file_set_string (config, group, "xa.subset", subset); + title = g_key_file_get_locale_string (keyfile, source_group, FLATPAK_REPO_TITLE_KEY, NULL, NULL); if (title != NULL)