summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-04-27 13:34:14 +0200
committerAlexander Larsson <alexl@redhat.com>2016-04-27 13:39:34 +0200
commitf37b3261d6154680f0ad91ee548fd8fa18ccbdae (patch)
tree5bda1e2899b0b11751a550594037ee8ffd7b8a0b /app
parent7fd926f07e17a3da8fbb14aada40145bf0d0b3cc (diff)
downloadxdg-app-f37b3261d6154680f0ad91ee548fd8fa18ccbdae.tar.gz
Add support for disabled remotes
If this is set we don't list them by default, and we don't automatically update apps from them.
Diffstat (limited to 'app')
-rw-r--r--app/xdg-app-builtins-add-remote.c14
-rw-r--r--app/xdg-app-builtins-list-remotes.c9
-rw-r--r--app/xdg-app-builtins-update.c3
3 files changed, 26 insertions, 0 deletions
diff --git a/app/xdg-app-builtins-add-remote.c b/app/xdg-app-builtins-add-remote.c
index dc39dfd..27d990f 100644
--- a/app/xdg-app-builtins-add-remote.c
+++ b/app/xdg-app-builtins-add-remote.c
@@ -39,6 +39,8 @@ static gboolean opt_do_gpg_verify;
static gboolean opt_do_enumerate;
static gboolean opt_no_enumerate;
static gboolean opt_if_not_exists;
+static gboolean opt_enable;
+static gboolean opt_disable;
static int opt_prio = -1;
static char *opt_title;
static char *opt_url;
@@ -54,6 +56,7 @@ static GOptionEntry modify_options[] = {
{ "gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_do_gpg_verify, "Enable GPG verification", NULL },
{ "enumerate", 0, 0, G_OPTION_ARG_NONE, &opt_do_enumerate, "Mark the remote as enumerate", NULL },
{ "url", 0, 0, G_OPTION_ARG_STRING, &opt_url, "Set a new url", NULL },
+ { "enable", 0, 0, G_OPTION_ARG_NONE, &opt_enable, "Enable the remote", },
{ NULL }
};
@@ -64,6 +67,7 @@ static GOptionEntry common_options[] = {
{ "title", 0, 0, G_OPTION_ARG_STRING, &opt_title, "A nice name to use for this remote", "TITLE" },
{ "gpg-import", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_gpg_import, "Import GPG key from FILE (- for stdin)", "FILE" },
{ "gpg-key", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_import, "Optionally only import the named key(s) from the keyring files", "KEY" },
+ { "disable", 0, 0, G_OPTION_ARG_NONE, &opt_disable, "Disable the remote", },
{ NULL }
};
@@ -200,6 +204,11 @@ xdg_app_builtin_add_remote (int argc, char **argv,
"xa.noenumerate",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
+ if (opt_disable)
+ g_variant_builder_add (optbuilder, "{s@v}",
+ "xa.disable",
+ g_variant_new_variant (g_variant_new_boolean (TRUE)));
+
if (opt_prio != -1)
{
prio_as_string = g_strdup_printf ("%d", opt_prio);
@@ -310,6 +319,11 @@ xdg_app_builtin_modify_remote (int argc, char **argv, GCancellable *cancellable,
if (opt_do_enumerate)
g_key_file_set_boolean (config, group, "xa.noenumerate", FALSE);
+ if (opt_disable)
+ g_key_file_set_boolean (config, group, "xa.disable", TRUE);
+ else if (opt_enable)
+ g_key_file_set_boolean (config, group, "xa.disable", FALSE);
+
if (opt_prio != -1)
{
g_autofree char *prio_as_string = g_strdup_printf ("%d", opt_prio);
diff --git a/app/xdg-app-builtins-list-remotes.c b/app/xdg-app-builtins-list-remotes.c
index 6ddf1fe..a294e00 100644
--- a/app/xdg-app-builtins-list-remotes.c
+++ b/app/xdg-app-builtins-list-remotes.c
@@ -34,11 +34,13 @@
static gboolean opt_show_details;
static gboolean opt_user;
static gboolean opt_system;
+static gboolean opt_show_disabled;
static GOptionEntry options[] = {
{ "user", 0, 0, G_OPTION_ARG_NONE, &opt_user, "Show user installations", NULL },
{ "system", 0, 0, G_OPTION_ARG_NONE, &opt_system, "Show system-wide installations", NULL },
{ "show-details", 'd', 0, G_OPTION_ARG_NONE, &opt_show_details, "Show remote details", NULL },
+ { "show-disabled", 0, 0, G_OPTION_ARG_NONE, &opt_show_disabled, "Show disabled remotes", NULL },
{ NULL }
};
@@ -88,6 +90,11 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
for (i = 0; remotes[i] != NULL; i++)
{
char *remote_name = remotes[i];
+ gboolean disabled;
+
+ disabled = xdg_app_dir_get_remote_disabled (dir, remote_name);
+ if (disabled && !opt_show_disabled)
+ continue;
if (opt_show_details)
{
@@ -119,6 +126,8 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
&gpg_verify, NULL);
if (!gpg_verify)
xdg_app_table_printer_append_with_comma (printer, "no-gpg-verify");
+ if (disabled)
+ xdg_app_table_printer_append_with_comma (printer, "disabled");
if (xdg_app_dir_get_remote_noenumerate (dir, remote_name))
xdg_app_table_printer_append_with_comma (printer, "no-enumerate");
diff --git a/app/xdg-app-builtins-update.c b/app/xdg-app-builtins-update.c
index 70364cd..3d899e5 100644
--- a/app/xdg-app-builtins-update.c
+++ b/app/xdg-app-builtins-update.c
@@ -93,6 +93,9 @@ do_update (XdgAppDir* dir,
if (repository == NULL)
return FALSE;
+ if (xdg_app_dir_get_remote_disabled (dir, repository))
+ g_print ("Not updating %s due to disabled remote %s\n", ref, repository);
+
subpaths = xdg_app_dir_get_subpaths (dir, ref, cancellable, error);
if (subpaths == NULL)
return FALSE;